| from typing import List, Tuple | |
| from .cot import generate_answer | |
| from .utils import get_answer | |
| def sample_cot( | |
| question: str, | |
| model_id: str="llama3-8b-8192", | |
| temperature: float=0.5, | |
| max_tokens: int=200, | |
| exampler: List[Tuple[str, str]]=None | |
| ): | |
| """ | |
| to be written | |
| """ | |
| reasoning, last_line = generate_answer(question, model_id, temperature, max_tokens, "cot",exampler) | |
| return reasoning, last_line | |
| def self_consistent_answer( | |
| question:str, | |
| model_id:str="llama3-8b-8192", | |
| temperature:float=0.5, | |
| max_tokens:int=200, | |
| exampler:List[Tuple[str, str]]=None, | |
| num_samples:int=3 | |
| ): | |
| """ | |
| to be written | |
| """ | |
| reasoning_paths = [] | |
| results = [] | |
| for _ in range(num_samples): | |
| reasoning, last_line = sample_cot(question, model_id, temperature, max_tokens ,exampler) | |
| reasoning_paths.append(reasoning) | |
| results.append(last_line) | |
| return reasoning_paths, results | |