Format a question for the benchmark dataset
(category: str, question: str, answer: str)
| 136 | return " ".join(text.replace("\r", "\n").split()) |
| 137 | |
| 138 | def format_question(category: str, question: str, answer: str) -> Dict[str, Any]: |
| 139 | """Format a question for the benchmark dataset""" |
| 140 | # Basic sanity checks |
| 141 | if not question or not answer: |
| 142 | raise ValueError(f"Empty question or answer in {category}") |
| 143 | |
| 144 | return { |
| 145 | "id": f"{category}_{random.getrandbits(32):08x}", |
| 146 | "category": category, |
| 147 | "question": clean_text(question), |
| 148 | "answer": clean_text(answer), |
| 149 | "metadata": { |
| 150 | "source": SOURCES[category]["name"], |
| 151 | "type": category, |
| 152 | "difficulty": "challenging" # All examples are chosen to be challenging |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | def load_source_dataset(config: Dict[str, Any]) -> datasets.Dataset: |
| 157 | """Load a source dataset with error handling""" |
no test coverage detected