Evaluates the readability of the given Question or Hint using the specified method [17].
Parameters:
sentences (List[Union[Question, Hint]]) – List of sentences to evaluate.
**kwargs – Additional keyword arguments.
Returns:
List of readability scores for each sentence.
Return type:
List[float]
Notes
This function stores the scores as Metric objects within the metrics attribute of the Question or Hint, with names based on the method, such as “readability-flesch_kincaid_reading_ease-sm”.
Examples
>>> fromhinteval.coresimportQuestion,Hint>>> fromhinteval.evaluation.readabilityimportTraditionalIndexes>>>>>> traditional_indexes=TraditionalIndexes(method='flesch_kincaid_reading_ease')>>> sentence_1=Question('What is the capital of Austria?')>>> sentence_2=Hint('This city, once home to Mozart and Beethoven, is the capital of Austria.')>>> sentences=[sentence_1,sentence_2]>>> results=traditional_indexes.evaluate(sentences)>>> print(results)# [87.945, 69.994]>>> metrics=[f'{metric_key}: {metric_value.value}'forsentinsentencesformetric_key,metric_valuein... sent.metrics.items()]>>> print(metrics)# ['readability-flesch_kincaid_reading_ease-sm: 87.945', 'readability-flesch_kincaid_reading_ease-sm: 69.994']
Evaluates the readability of the given Question or Hint using the specified machine learning method [20].
Parameters:
sentences (List[Union[Question, Hint]]) – List of sentences to evaluate.
**kwargs – Additional keyword arguments.
Returns:
List of readability scores for each sentence.
Return type:
List[float]
Notes
This function stores the scores as Metric objects within the metrics attribute of the Question or Hint, with names based on the method, such as “readability-ml-xgboost-sm”.
Examples
>>> fromhinteval.coresimportQuestion,Hint>>> fromhinteval.evaluation.readabilityimportMachineLearningBased>>>>>> machine_learning=MachineLearningBased(method='xgboost')>>> sentence_1=Question('What is the capital of Austria?')>>> sentence_2=Hint('This city, once home to Mozart and Beethoven, is the capital of Austria.')>>> sentences=[sentence_1,sentence_2]>>> results=machine_learning.evaluate(sentences)>>> print(results)# [0, 0]>>> classes=[sent.metrics['readability-ml-xgboost-sm'].metadata['description']forsentinsentences]>>> print(classes)# ['beginner', 'beginner']>>> metrics=[f'{metric_key}: {metric_value.value}'forsentinsentencesformetric_key,metric_valuein... sent.metrics.items()]>>> print(metrics)# ['readability-ml-xgboost-sm: 0', 'readability-ml-xgboost-sm: 0']
Evaluates the readability of the given Question or Hint using the specified neural network model [23].
Parameters:
sentences (List[Union[Question, Hint]]) – List of sentences to evaluate.
**kwargs – Additional keyword arguments.
Returns:
List of readability scores for each sentence.
Return type:
List[float]
Notes
This function stores the scores as Metric objects within the metrics attribute of the Question or Hint, with names based on the model, such as “readability-nn-bert-base”.
Examples
>>> fromhinteval.coresimportQuestion,Hint>>> fromhinteval.evaluation.readabilityimportNeuralNetworkBased>>>>>> neural_network=NeuralNetworkBased(model_name='bert-base')>>> sentence_1=Question('What is the capital of Austria?')>>> sentence_2=Hint('This city, once home to Mozart and Beethoven, is the capital of Austria.')>>> sentences=[sentence_1,sentence_2]>>> results=neural_network.evaluate(sentences)>>> print(results)# [0, 0]>>> classes=[sent.metrics['readability-nn-bert-base'].metadata['description']forsentinsentences]>>> print(classes)# ['beginner', 'beginner']>>> metrics=[f'{metric_key}: {metric_value.value}'forsentinsentencesformetric_key,metric_valuein... sent.metrics.items()]>>> print(metrics)# ['readability-nn-bert-base: 0', 'readability-nn-bert-base: 0']
Evaluates the readability of the question and hints of the given instances using large language models [26].
Parameters:
sentences (List[Union[Question, Hint]]) – List of sentences to evaluate.
**kwargs – Additional keyword arguments.
Returns:
List of readability scores for each sentence.
Return type:
List[float]
Notes
This function stores the scores as Metric objects within the metrics attribute of the Question or Hint, with names based on the model, such as “readability-llm-meta-llama_Meta-Llama-3.1-70B-Instruct-Turbo”.
Examples
>>> fromhinteval.coresimportQuestion,Hint>>> fromhinteval.evaluation.readabilityimportLlmBased>>>>>> llm=LlmBased(model_name='meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',... api_key='your_api_key',base_url='base_url',batch_size=2,... enable_tqdm=True)>>> sentence_1=Question('What is the capital of Austria?')>>> sentence_2=Hint('This city, once home to Mozart and Beethoven, is the capital of Austria.')>>> sentences=[sentence_1,sentence_2]>>> results=llm.evaluate(sentences)>>> print(results)# [0, 0]>>> classes=[sent.metrics['readability-llm-meta-llama_Meta-Llama-3.1-70B-Instruct-Turbo'].metadata['description']forsentinsentences]>>> print(classes)# ['beginner', 'beginner']>>> metrics=[f'{metric_key}: {metric_value.value}'forsentinsentencesformetric_key,metric_valuein... sent.metrics.items()]>>> print(metrics)# ['readability-llm-meta-llama_Meta-Llama-3.1-70B-Instruct-Turbo: 0', 'readability-llm-meta-llama_Meta-Llama-3.1-70B-Instruct-Turbo: 0']