Datasets:
Update dataset card
Browse files806 unmodified lines8078088098108118128138148158168176 unmodified lines82482582682782882947 unmodified lines8778788798808818828838848858868878888898908918928938948955 unmodified lines9019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659668 unmodified lines975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023806 unmodified lineshf download SciKnowOrg/HighSchoolBench-MCQ --repo-type dataset --include "subsets/*" --local-dir HighSchoolBench-MCQ```## Benchmarking our dataset on LLMs using the OpenAI APIThe following examples demonstrate how to benchmark language and vision-language models on individual HighSchoolBench-MCQ configurations using the OpenAI API. Text, image, and table configurations are illustrated below. Each example evaluates the full test split of the selected configuration and calculates exact-match accuracy against the reference option labels.**Image-based questions require a multimodal model that supports image inputs.** The example model, `gpt-4.1-mini`, supports text and images. Tables are supplied as Markdown-formatted text.```bashpip install datasets openai scikit-learn pillow6 unmodified linesThis example evaluates text-based multiple-choice questions using exact-match accuracy.```pythonimport osfrom datasets import load_dataset47 unmodified linesprint(f"Accuracy: {accuracy_score(references, predictions):.2%}")```</details><details><summary><strong>Example: Image-based MCQs</strong></summary>Configuration: `context_text_images__text_options`This example evaluates image-supported multiple-choice questions using a multimodal model and exact-match accuracy.```pythonimport osimport ioimport base64from datasets import load_datasetfrom openai import OpenAIfrom sklearn.metrics import accuracy_score5 unmodified lines)MODEL = "gpt-4.1-mini"# 2. Load the full test split of one configurationquestions = load_dataset("SciKnowOrg/HighSchoolBench-MCQ", "context_text_images__text_options", split="test")# 3. Encode PIL images for the multimodal APIdef image_to_url(image):buffer = io.BytesIO()image.convert("RGB").save(buffer, format="PNG")return "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode("utf-8")# 4. Generate predictions and collect reference labelspredictions = []references = []for item in questions:# Pair each option label with its textoptions = "\n".join(f"{label}. {text}" for label, text in zip(item["answer_option_labels"], item["answer_options"]))# Build the question promptprompt = ("Using the information provided below, answer the multiple-choice question.\n\n"f"Subject: {item['subject']}\n"f"Domain: {item['domain']}\n\n"f"Context:\n{item['context'] or 'None'}\n"f"{item.get('image_context') or ''}\n""The accompanying images are part of the context.\n\n"f"Question:\n{item['question']}\n\n"f"Options:\n{options}\n\n"f"Select exactly {item['num_correct_answer_options']} correct option(s).\n""Return only the selected option label(s), separated by commas if necessary.\n""Do not include explanations, option text, or additional information.")# Attach images in the order stored in the datasetcontent = [{"type": "text", "text": prompt}]for i, image in enumerate(item["images"], start=1):content.append({"type": "text", "text": f"Context image {i}:"})content.append({"type": "image_url", "image_url": {"url": image_to_url(image)}})response = client.chat.completions.create(model=MODEL, messages=[{"role": "user", "content": content}])reply = response.choices[0].message.content or ""# Normalize label order for exact-match scoringpredicted = ",".join(sorted(label.strip().upper() for label in reply.strip().strip(".").split(",")))expected = ",".join(sorted(label.strip().upper() for label in item["correct_answer"]))predictions.append(predicted)references.append(expected)print(f"Question {item['instance']}: model {predicted}, correct {expected}")# 5. Report exact-match accuracyprint(f"Accuracy: {accuracy_score(references, predictions):.2%}")```</details><details><summary><strong>Example: Table-based MCQs</strong></summary>Configuration: `context_text_table__text_options`This example evaluates multiple-choice questions with Markdown-formatted tables using exact-match accuracy.```pythonimport os8 unmodified lines)MODEL = "gpt-4.1-mini"# 2. Load the full test split of one configurationquestions = load_dataset("SciKnowOrg/HighSchoolBench-MCQ", "context_text_table__text_options", split="test")# 4. Generate predictions and collect reference labelspredictions = []references = []for item in questions:# Pair each option label with its textoptions = "\n".join(f"{label}. {text}" for label, text in zip(item["answer_option_labels"], item["answer_options"]))# Build the question promptprompt = ("Using the information provided below, answer the multiple-choice question.\n\n"f"Subject: {item['subject']}\n"f"Domain: {item['domain']}\n\n"f"Context:\n{item['context'] or 'None'}\n"f"{item.get('table_context') or ''}\n\n"f"Tables:\n{item['tables']}\n\n"f"Question:\n{item['question']}\n\n"f"Options:\n{options}\n\n"f"Select exactly {item['num_correct_answer_options']} correct option(s).\n""Return only the selected option label(s), separated by commas if necessary.\n""Do not include explanations, option text, or additional information.")# Query the modelresponse = client.chat.completions.create(model=MODEL, messages=[{"role": "user", "content": prompt}])reply = response.choices[0].message.content or ""# Normalize label order for exact-match scoringpredicted = ",".join(sorted(label.strip().upper() for label in reply.strip().strip(".").split(",")))expected = ",".join(sorted(label.strip().upper() for label in item["correct_answer"]))predictions.append(predicted)references.append(expected)print(f"Question {item['instance']}: model {predicted}, correct {expected}")# 5. Report exact-match accuracyprint(f"Accuracy: {accuracy_score(references, predictions):.2%}")```</details>**Note:** Each dataset configuration must be loaded and evaluated separately for benchmarking.806 unmodified lines8078088098108118128138148158168178188198206 unmodified lines82782882983083183283383447 unmodified lines8828838848858868878888898908918928938948958968978988999009019029039049055 unmodified lines9119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110028 unmodified lines10111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063806 unmodified lineshf download SciKnowOrg/HighSchoolBench-MCQ --repo-type dataset --include "subsets/*" --local-dir HighSchoolBench-MCQ```## Benchmarking Data Using LLMs or VLMs via OpenAI-Compatible APIsThe following examples demonstrate how to benchmark language and vision-language models on individual HighSchoolBench-MCQ configurations using the OpenAI API. Text, image, and table configurations are illustrated below. Each example evaluates the full test split of the selected configuration and calculates exact-match accuracy against the reference option labels.Examples of models that can be used include Llama 3.3 70B, Qwen3, and DeepSeek-V3 for text-based inputs, and GPT-4.1-mini, GPT-4o, Qwen2.5-VL, and Llama 3.2 Vision for image-based inputs.> **Note:** Image-based questions require a multimodal model that supports image inputs. The example model, `gpt-4.1-mini`, supports text and images. Tables are supplied as Markdown-formatted text.```bashpip install datasets openai scikit-learn pillow6 unmodified linesThis example evaluates text-based multiple-choice questions using exact-match accuracy.In the example below, we use the OpenAI model `gpt-4.1-mini`. The code can be adapted to other OpenAI-compatible APIs, such as GWDG and OpenRouter, by changing the API key, base URL, and model name.```pythonimport osfrom datasets import load_dataset47 unmodified linesprint(f"Accuracy: {accuracy_score(references, predictions):.2%}")```**Smoke test (five question IDs):** IDs: `[insert IDs]`. Exact-match accuracy: **[X/5 (XX%)]**.</details><details><summary><strong>Example: MCQs with image answer options</strong></summary>Configuration: `context_text_only__image_options`This example evaluates multiple-choice questions where the answer options are images using a multimodal model and exact-match accuracy.In the example below, we use the OpenAI model `gpt-4.1-mini`. The code can be adapted to other OpenAI-compatible APIs, such as GWDG and OpenRouter, by changing the API key, base URL, and model name.```pythonimport osimport ioimport base64from PIL import Imagefrom datasets import load_datasetfrom openai import OpenAIfrom sklearn.metrics import accuracy_score5 unmodified lines)MODEL = "gpt-4.1-mini"# 2. Load the full test split of the image-option configurationquestions = load_dataset("SciKnowOrg/HighSchoolBench-MCQ","context_text_only__image_options",split="test",)def image_to_url(image):buffer = io.BytesIO()image.convert("RGB").save(buffer, format="PNG")return "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode("utf-8")# 3. Generate predictions and collect reference labelspredictions = []references = []for item in questions:labels = item["answer_option_labels"]option_values = item["answer_options"]option_groups = item.get("option_image_label_groups") or []prompt = ("Using the information provided below, answer the multiple-choice question.\n\n"f"Subject: {item['subject']}\n"f"Domain: {item['domain']}\n\n"f"Context:\n{item['context'] or 'None'}\n\n"f"Question:\n{item['question']}\n\n"f"Available option labels: {', '.join(labels)}\n"f"Select exactly {item['num_correct_answer_options']} correct option(s).\n""The labeled answer options are shown in the accompanying image(s).\n""Return only the selected option label(s), separated by commas if necessary.\n""Do not include explanations or additional information.")content = [{"type": "text", "text": prompt}]# Image answer options may be stored as PIL objects in answer_options,# or as image entries accompanied by option_image_label_groups.option_images = [value for value in option_values if isinstance(value, Image.Image)]if not option_images:option_images = [image for image in (item.get("images") or []) if isinstance(image, Image.Image)]if not option_images:raise ValueError(f"No decoded option images found for instance {item['instance']}; inspect its dataset fields.")for index, image in enumerate(option_images):if index < len(option_groups) and option_groups[index]:group_labels = option_groups[index]elif len(option_images) == len(labels):group_labels = [labels[index]]else:group_labels = [] # Image may already show multiple labeled optionsdescription = (f"Answer option image {index + 1} (labels: {', '.join(group_labels)}):"if group_labels else f"Answer option image {index + 1}:")content.append({"type": "text", "text": description})content.append({"type": "image_url", "image_url": {"url": image_to_url(image)}})response = client.chat.completions.create(model=MODEL, messages=[{"role": "user", "content": content}])reply = response.choices[0].message.content or ""predicted = ",".join(sorted(label.strip().upper() for label in reply.strip().strip(".").split(",")))expected = ",".join(sorted(label.strip().upper() for label in item["correct_answer"]))predictions.append(predicted)references.append(expected)print(f"Question {item['instance']}: model {predicted}, correct {expected}")print(f"Accuracy: {accuracy_score(references, predictions):.2%}")```**Smoke test (five question IDs):** IDs: `[insert IDs]`. Exact-match accuracy: **[X/5 (XX%)]**.</details><details><summary><strong>Example: MCQs with table answer options</strong></summary>Configuration: `context_text_only__table_options`This example evaluates multiple-choice questions where the answer options are Markdown-formatted tables using exact-match accuracy.In the example below, we use the OpenAI model `gpt-4.1-mini`. The code can be adapted to other OpenAI-compatible APIs, such as GWDG and OpenRouter, by changing the API key, base URL, and model name.```pythonimport os8 unmodified lines)MODEL = "gpt-4.1-mini"# 2. Load the full test split of the table-option configurationquestions = load_dataset("SciKnowOrg/HighSchoolBench-MCQ","context_text_only__table_options",split="test",)# 3. Generate predictions and collect reference labelspredictions = []references = []for item in questions:# Each answer option is a Markdown-formatted tableoptions = "\n\n".join(f"Option {label}:\n{table}"for label, table in zip(item["answer_option_labels"], item["answer_options"]))prompt = ("Using the information provided below, answer the multiple-choice question.\n\n"f"Subject: {item['subject']}\n"f"Domain: {item['domain']}\n\n"f"Context:\n{item['context'] or 'None'}\n\n"f"Question:\n{item['question']}\n\n"f"Options (Markdown tables):\n{options}\n\n"f"Select exactly {item['num_correct_answer_options']} correct option(s).\n""Return only the selected option label(s), separated by commas if necessary.\n""Do not include explanations, option text, or additional information.")response = client.chat.completions.create(model=MODEL, messages=[{"role": "user", "content": prompt}])reply = response.choices[0].message.content or ""predicted = ",".join(sorted(label.strip().upper() for label in reply.strip().strip(".").split(",")))expected = ",".join(sorted(label.strip().upper() for label in item["correct_answer"]))predictions.append(predicted)references.append(expected)print(f"Question {item['instance']}: model {predicted}, correct {expected}")print(f"Accuracy: {accuracy_score(references, predictions):.2%}")```**Smoke test (five question IDs):** IDs: `[insert IDs]`. Exact-match accuracy: **[X/5 (XX%)]**.</details>**Note:** Each dataset configuration must be loaded and evaluated separately for benchmarking.
README.md+81-41