Generates hints for a list of instances using the configured large language model [42].
Parameters:
instances (List[Instance]) – A list of instances, where each instance contains a question and its corresponding answer.
**kwargs – Additional keyword arguments.
Returns:
A list of lists containing generated hints for each instance.
Return type:
List[List[str]]
Notes
This function stores the generated hints as Hint objects within the instances attribute of the Subset.
Examples
>>> fromhinteval.coresimportInstance,Question,Answer>>> fromhinteval.modelimportAnswerAware>>>>>> answer_aware=AnswerAware(model_name='meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',... api_key='your_api_key',... base_url='base_url',... num_of_hints=2)>>> instance_1=Instance(question=Question('What is the capital of Austria?'),... answers=[Answer('Vienna')],hints=[])>>> instance_2=Instance(question=Question('Who was the president of USA in 2009?'),... answers=[Answer('Barack Obama')],hints=[])>>> instances=[instance_1,instance_2]>>> results=answer_aware.generate(instances)>>> print(results)# [# ['The city is celebrated for its cultural landmarks like palaces and museums.',# 'It is historically significant, located near the Danube River.'],# ['The president Obama, inaugurated in 2009, was the first African American to hold the office.',# 'He won the Nobel Peace Prize in 2009 for enhancing international diplomacy.']# ]
Raises:
RuntimeError – If hint generation fails due to model or API issues.
Generates hints for a list of instances using the configured large language model [46].
Parameters:
instances (List[Instance]) – A list of instances, where each instance contains a question.
**kwargs – Additional keyword arguments.
Returns:
A list of lists containing generated hints for each instance.
Return type:
List[List[str]]
Notes
This function stores the generated hints as Hint objects within the instances attribute of the Subset.
Examples
>>> fromhinteval.coresimportInstance,Question>>> fromhinteval.modelimportAnswerAgnostic>>>>>> answer_agnostic=AnswerAgnostic(model_name='meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',... api_key='your_api_key',... num_of_hints=2)>>> instance_1=Instance(question=Question('What is the capital of Austria?'),answers=[],hints=[])>>> instance_2=Instance(question=Question('Who was the president of USA in 2009?'),answers=[],hints=[])>>> instances=[instance_1,instance_2]>>> results=answer_agnostic.generate(instances)>>> print(results)# [# ["The city you're looking for is located along the Danube River.",# "It's a city famous for its grand palaces, opera houses, and classical music heritage."],# ['The person who held the office in 2009 was the first African American to hold the position.',# 'The president who took office in 2009 was a member of the Democratic Party and served two consecutive terms from 2009 to 2017.']# ]
Raises:
RuntimeError – If hint generation fails due to model or API issues.