Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -70,3 +70,48 @@ from datasets import load_dataset
|
|
| 70 |
ds = load_dataset("Misraj/MathVision_testmini", split="testmini")
|
| 71 |
print(ds[0]["prompt"])
|
| 72 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
ds = load_dataset("Misraj/MathVision_testmini", split="testmini")
|
| 71 |
print(ds[0]["prompt"])
|
| 72 |
```
|
| 73 |
+
|
| 74 |
+
<!-- scoring:start -->
|
| 75 |
+
## Scoring
|
| 76 |
+
|
| 77 |
+
Two files in this repo score model outputs locally (no LLM judge):
|
| 78 |
+
|
| 79 |
+
| File | Purpose |
|
| 80 |
+
|---|---|
|
| 81 |
+
| `mm_scoring.py` | `extract_answer(response, row)` pulls the final answer out of a model response (reads `\boxed{}`, "answer is ...", option letters or option text); `is_correct(pred, row)` compares it with the gold answer |
|
| 82 |
+
| `mathvision_adapt.py` | `prepare_mathvision(row)` adds the fields the scorer needs, which this dataset does not store; `final_prompt(row)` appends an answer-format instruction |
|
| 83 |
+
|
| 84 |
+
`prepare_mathvision` derives: `question_type` (`multi_choice` if `options` is non-empty, else `free_form`),
|
| 85 |
+
`answer_type` (`integer` / `float` / `text`, from the gold answer), `choices`, `answer_is_letter` and `precision`.
|
| 86 |
+
When the options are only letters (`A`-`E`), the option values are inside the image, so `choices` are blank and
|
| 87 |
+
the answer is matched by letter.
|
| 88 |
+
|
| 89 |
+
### Example
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
from datasets import load_dataset
|
| 93 |
+
from huggingface_hub import hf_hub_download
|
| 94 |
+
import sys
|
| 95 |
+
|
| 96 |
+
for f in ["mm_scoring.py", "mathvision_adapt.py"]:
|
| 97 |
+
hf_hub_download("Misraj/MathVision_testmini", f, repo_type="dataset", local_dir=".")
|
| 98 |
+
sys.path.insert(0, ".")
|
| 99 |
+
from mm_scoring import extract_answer, is_correct
|
| 100 |
+
from mathvision_adapt import prepare_mathvision, final_prompt
|
| 101 |
+
|
| 102 |
+
ds = load_dataset("Misraj/MathVision_testmini", split="testmini")
|
| 103 |
+
row = ds[0]
|
| 104 |
+
ex = {**row, **prepare_mathvision(row)}
|
| 105 |
+
|
| 106 |
+
model_input = final_prompt(ex) # text prompt to send together with row["image"]
|
| 107 |
+
response = "... so the answer is \\boxed{A}" # your model's output
|
| 108 |
+
print(is_correct(extract_answer(response, ex), ex))
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
### Notes
|
| 112 |
+
|
| 113 |
+
- Use the same `final_prompt` for every model you compare; without an explicit format instruction, extraction is less reliable.
|
| 114 |
+
- Multiple choice is scored by letter, integers exactly, floats rounded to the gold precision. Other free-form answers
|
| 115 |
+
(fractions, expressions, text) are compared as normalized strings, so equivalent forms (`0.5` vs `1/2`) can count as wrong.
|
| 116 |
+
- Responses cut off at the generation limit have no real final answer. Report how many were cut off next to accuracy.
|
| 117 |
+
<!-- scoring:end -->
|