Datasets:
Update dataset card
Browse files731 unmodified lines7327337347357367377381 unmodified line74074174274374474574674774874975075175275375475575675718 unmodified lines7767777787797807817824 unmodified lines7877887897907917927938 unmodified lines80280380480580680780880981081181281381481581613 unmodified lines830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909731 unmodified lines| `context_text_contextualized_tables_images__text_options` | Tables and images with associated passages | Text || `context_text_contextualized_tables_images__image_options` | Tables and images with associated passages | Images |In contextualized configurations, individual images and tables are stored alongside their associated passages. Some configurations contain only a test split.## Data format1 unmodified line| Field | Description ||---|---|| `id` | Question identifier from the source file. || `assessment_program` | Source assessment or competition. || `assessment_stage` | Assessment stage or exam type. || `subject` | Subject assigned to the question. || `domain` | Topic within the subject. || `context` | Supporting passage or shared context, when available. || `question` | Question stem. Mathematical expressions use LaTeX. || `options` | Ordered answer options as strings or images. Table options are represented as Markdown strings. || `option_labels` | Labels corresponding to the answer options. || `answer` | List of correct option labels. || `split` | Original split label: `train`, `val`, or `test`. || `num_answer_options` | Number of correct options, equal to `len(answer)`. |### Context-specific fields18 unmodified lines- **Parquet:** `data/<configuration>/`, with typed columns and embedded images. These files are used by the Hugging Face dataset viewer and `load_dataset`.- **JSON Lines and images:** `subsets/<configuration>/<split>/`, containing a `metadata.jsonl` file and the images referenced by its records.In Parquet, `options` and `option_labels` are separate ordered lists. In the JSON Lines files, options retain their source representation, usually a mapping such as `{"A": "...", "B": "..."}`.## Usage4 unmodified linesdataset = load_dataset("SciKnowOrg/HighSchoolBench-MCQ","context_text_images__text_options",)print(dataset)8 unmodified linesprint("Question:", example["question"])for label, option in zip(example["option_labels"],example["options"],):print(f"{label}. {option}")print("Correct answer:", example["answer"])# Question images are decoded as PIL images.images = example["images"]```List the available configurations:13 unmodified lines--local-dir HighSchoolBench-MCQ```## Evaluating an LLMThe script below tests a model on HighSchoolBench-MCQ through anyOpenAI-compatible chat API (OpenAI, OpenRouter, a local vLLM server, ...) andreports exact-match accuracy: a question counts as correct only when the modelselects exactly the set of correct options.```bashpip install datasets openai pillowexport OPENAI_API_KEY=... # API key of your provider``````pythonimport base64, io, os, refrom datasets import load_datasetfrom openai import OpenAIMODEL = "<model-name>" # any chat model available at your providerclient = OpenAI(base_url=os.getenv("OPENAI_BASE_URL")) # leave OPENAI_BASE_URL unset for OpenAI# Same configuration as in Usage. Its questions include images, so use a vision-capable model.dataset = load_dataset("SciKnowOrg/HighSchoolBench-MCQ", "context_text_images__text_options", split="test")dataset = dataset.select(range(min(20, len(dataset)))) # first 20 questionsdef as_text(value):return "\n\n".join(value) if isinstance(value, list) else str(value)def image_part(image):buffer = io.BytesIO()image.save(buffer, format="PNG")url = "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode()return {"type": "image_url", "image_url": {"url": url}}def build_prompt(example):context = "\n\n".join(as_text(example[key]) for key in ("context", "table_context", "tables", "image_context") if example.get(key)) or "none"options = "\n".join(f"{label}. {option}" for label, option in zip(example["option_labels"], example["options"]))rule = "Exactly one option is correct." if example["num_answer_options"] == 1 else "More than one option is correct."text = (f"Context:\n{context}\n\nQuestion: {example['question']}\n\nOptions:\n{options}\n\n{rule} "+ 'Reply only with JSON, e.g. {"Answer": "B"} or {"Answer": "A,C"}.')images = [image_part(image) for image in example.get("images") or []]return [{"type": "text", "text": text}] + imagescorrect = 0for example in dataset:response = client.chat.completions.create(model=MODEL,temperature=0,messages=[{"role": "user", "content": build_prompt(example)}],)reply = response.choices[0].message.content or ""match = re.search(r'"Answer"\s*:\s*"([^"]*)"', reply)predicted = sorted(label.strip().upper() for label in match.group(1).split(",")) if match else []correct += predicted == sorted(example["answer"])print(f"{example['id']}: answer {example['answer']}, model {predicted}")print(f"Exact-match accuracy: {correct}/{len(dataset)} = {correct / len(dataset):.1%}")```To use another provider, set `OPENAI_BASE_URL`, for example`https://openrouter.ai/api/v1` (OpenRouter) or `http://localhost:8000/v1`(a local vLLM server).The prompts are short zero-shot versions of those used in the HighSchoolBenchevaluation, so scores can differ slightly from the reported results.## CitationIf you use HighSchoolBench, please cite:731 unmodified lines7327337347357367377381 unmodified line74074174274374474574674774874975075175275375475575675775818 unmodified lines7777787797807817827834 unmodified lines7887897907917927937948 unmodified lines80380480580680780880981081181281381481513 unmodified lines829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912731 unmodified lines| `context_text_contextualized_tables_images__text_options` | Tables and images with associated passages | Text || `context_text_contextualized_tables_images__image_options` | Tables and images with associated passages | Images |In contextualized configurations, individual images and tables are stored alongside their associated passages.## Data format1 unmodified line| Field | Description ||---|---|| `instance` | Question identifier from the source file (integer). || `assessment_program` | Source assessment or competition. || `assessment_type` | Assessment type, such as national or state. || `assessment_category` | Assessment category, when provided. || `subject` | Subject assigned to the question. || `domain` | Topic within the subject. || `context` | Supporting passage or shared context, when available. || `question` | Question stem. Mathematical expressions use LaTeX. || `answer_options` | Ordered answer options as strings or images. Table options are represented as Markdown strings. || `answer_option_labels` | Labels corresponding to the answer options. || `correct_answer` | List of correct option labels (including single-answer questions). || `num_correct_answer_options` | Number of correct option labels, equal to `len(correct_answer)`. || `split` | Original split label: `train`, `val`, or `test` (last column). |### Context-specific fields18 unmodified lines- **Parquet:** `data/<configuration>/`, with typed columns and embedded images. These files are used by the Hugging Face dataset viewer and `load_dataset`.- **JSON Lines and images:** `subsets/<configuration>/<split>/`, containing a `metadata.jsonl` file and the images referenced by its records.In Parquet, `answer_options` and `answer_option_labels` are separate ordered lists. In the JSON Lines files, the public column name is `answer_options`; where the source used a mapping, that mapping is retained, such as `{"A": "...", "B": "..."}`.## Usage4 unmodified linesdataset = load_dataset("SciKnowOrg/HighSchoolBench-MCQ","context_text_only__text_options",)print(dataset)8 unmodified linesprint("Question:", example["question"])for label, option in zip(example["answer_option_labels"],example["answer_options"],):print(f"{label}. {option}")print("Correct answer:", example["correct_answer"])```List the available configurations:13 unmodified lines--local-dir HighSchoolBench-MCQ```## Evaluating an LLM via APIThis **zero-shot** example loads questions from the text-only MCQ configuration, requests predictions from an OpenAI-compatible LLM API, and calculates **exact-match accuracy**. For questions with multiple correct answers, the prediction must contain exactly the same set of labels as the reference answer.Install the required packages:```bashpip install datasets openai```Set the API configuration at the top of the following Python example. **Keep your API key private:** do not commit a real key to a public repository or shared notebook. For reusable code, prefer an environment variable.```pythonimport osfrom datasets import load_datasetfrom openai import OpenAI# --- Configure your API and model ---API_KEY = os.getenv("OPENAI_API_KEY", "YOUR_API_KEY")MODEL = "gpt-4.1-mini" # Replace with a model available from your providerBASE_URL = "https://api.openai.com/v1" # E.g. https://openrouter.ai/api/v1client = OpenAI(api_key=API_KEY, base_url=BASE_URL)# --- Load one HighSchoolBench-MCQ configuration ---questions = load_dataset("SciKnowOrg/HighSchoolBench-MCQ","context_text_only__text_options",split="test",)correct = 0for item in questions:options = "\n".join(f"{label}. {value}"for label, value in zip(item["answer_option_labels"], item["answer_options"]))prompt = ("Select all correct options. Reply with option labels only, ""separated by commas (e.g., A or A,C).\n\n"f"Context: {item.get('context') or 'None'}\n"f"Question: {item['question']}\n"f"Options:\n{options}\nAnswer:")response = client.chat.completions.create(model=MODEL,messages=[{"role": "user", "content": prompt}],)reply = (response.choices[0].message.content or "").strip().upper()valid = {str(label).upper() for label in item["answer_option_labels"]}labels = [part.strip() for part in reply.split(",")]predicted = (set(labels)if labels and all(label in valid for label in labels)and len(labels) == len(set(labels))else set())reference = {str(label).upper() for label in item["correct_answer"]}is_correct = bool(predicted) and predicted == referencecorrect += is_correctprint(f"Instance {item['instance']}: "f"prediction={sorted(predicted)}, "f"reference={sorted(reference)}, correct={is_correct}")if len(questions):print(f"Exact-match accuracy: {correct}/{len(questions)} = {correct / len(questions):.1%}")else:print("No questions found in the selected split.")```For another OpenAI-compatible provider, change `BASE_URL`, `MODEL`, and `API_KEY`.## CitationIf you use HighSchoolBench, please cite:
README.md+71-68