Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -79,19 +79,31 @@ We have two subsets: Common-O (3 - 8 objects) and Common-O Complex (8 - 16 objec
|
|
| 79 |
```python
|
| 80 |
import datasets
|
| 81 |
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
|
| 85 |
-
instructions = ""
|
| 86 |
|
| 87 |
-
|
| 88 |
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
```
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
-
|
|
|
|
| 79 |
```python
|
| 80 |
import datasets
|
| 81 |
|
| 82 |
+
common_o = datasets.load("facebook/Common-O")["main"]
|
| 83 |
|
| 84 |
+
x = common_o[3]
|
| 85 |
|
|
|
|
| 86 |
|
| 87 |
+
output: str = model(x["image_1"], x["image_2"], x["question"])
|
| 88 |
|
| 89 |
+
check_answer(output, x["answer"])
|
| 90 |
+
```
|
| 91 |
|
| 92 |
+
To check the answer, we use an exact match criteria:
|
| 93 |
|
| 94 |
+
```python
|
| 95 |
+
def check_answer(
|
| 96 |
+
generation: str,
|
| 97 |
+
ground_truth: List[str]
|
| 98 |
+
):
|
| 99 |
+
preds = generation.split("\n")[-1]
|
| 100 |
+
preds = re.sub("Answer:", "", preds)
|
| 101 |
+
preds = preds.split(",")
|
| 102 |
+
preds = sorted(preds, key=lambda x: x[0])
|
| 103 |
+
|
| 104 |
+
ground_truth = sorted(ground_truth)
|
| 105 |
+
return preds == ground_truth
|
| 106 |
```
|
| 107 |
|
| 108 |
|
| 109 |
|
|
|