Skip to content

Commit 9270239

Browse files
committed
break another prepare file aiming to more than one hf path
Signed-off-by: dafnapension <[email protected]>
1 parent e69439a commit 9270239

File tree

3 files changed

+46
-34
lines changed

3 files changed

+46
-34
lines changed

prepare/cards/doc_vqa.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from unitxt.collections_operators import Explode, Wrap
44
from unitxt.image_operators import ToImage
55
from unitxt.operators import Copy
6-
from unitxt.splitters import RenameSplits
76
from unitxt.templates import MultiReferenceTemplate
87
from unitxt.test_utils.card import test_card
98

@@ -48,35 +47,3 @@
4847

4948
test_card(card)
5049
add_to_catalog(card, f"cards.doc_vqa.{language}", overwrite=True)
51-
52-
53-
card = TaskCard(
54-
loader=LoadHF(
55-
path="lmms-lab/DocVQA",
56-
name="DocVQA",
57-
data_classification_policy=["public"],
58-
splits=["train", "test"],
59-
),
60-
preprocess_steps=[
61-
RenameSplits(mapper={"validation": "test"}),
62-
ToImage(field="image", to_field="context"),
63-
Set(fields={"context_type": "image"}),
64-
],
65-
task="tasks.qa.with_context.abstractive[metrics=[metrics.anls]]",
66-
templates=[template, *templates.items],
67-
default_template=template,
68-
__tags__={
69-
"license": "apache-2.0",
70-
"multilinguality": "monolingual",
71-
"modalities": ["image", "text"],
72-
"size_categories": "10K<n<100K",
73-
"task_categories": "question-answering",
74-
"task_ids": "extractive-qa",
75-
},
76-
__description__=(
77-
"The doc-vqa Dataset integrates images from the Infographic_vqa dataset sourced from HuggingFaceM4 The Cauldron dataset, as well as images from the dataset AFTDB (Arxiv Figure Table Database) curated by cmarkea. This dataset consists of pairs of images and corresponding text, with each image linked to an average of five questions and answers available in both English and French. These questions and answers were generated using Gemini 1.5 Pro, thereby rendering the dataset well-suited for multimodal tasks involving image-text pairing and multilingual question answering."
78-
),
79-
)
80-
81-
test_card(card)
82-
add_to_catalog(card, "cards.doc_vqa.lmms_eval", overwrite=True)

prepare/cards/doc_vqa_lmms.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from unitxt.blocks import LoadHF, Set, TaskCard
2+
from unitxt.catalog import add_to_catalog, get_from_catalog
3+
from unitxt.image_operators import ToImage
4+
from unitxt.splitters import RenameSplits
5+
from unitxt.templates import MultiReferenceTemplate
6+
from unitxt.test_utils.card import test_card
7+
8+
templates = get_from_catalog("templates.qa.with_context.all")
9+
template = MultiReferenceTemplate(
10+
input_format="{context}\n{question}\nAnswer the question using a single word or phrase.",
11+
references_field="answers",
12+
__description__="lmms-evals default template for docvqa.",
13+
)
14+
15+
card = TaskCard(
16+
loader=LoadHF(
17+
path="lmms-lab/DocVQA",
18+
name="DocVQA",
19+
data_classification_policy=["public"],
20+
splits=["train", "test", "validation"],
21+
),
22+
preprocess_steps=[
23+
RenameSplits(mapper={"validation": "test"}),
24+
ToImage(field="image", to_field="context"),
25+
Set(fields={"context_type": "image"}),
26+
],
27+
task="tasks.qa.with_context.abstractive[metrics=[metrics.anls]]",
28+
templates=[template, *templates.items],
29+
default_template=template,
30+
__tags__={
31+
"license": "apache-2.0",
32+
"multilinguality": "monolingual",
33+
"modalities": ["image", "text"],
34+
"size_categories": "10K<n<100K",
35+
"task_categories": "question-answering",
36+
"task_ids": "extractive-qa",
37+
},
38+
__description__=(
39+
"The doc-vqa Dataset integrates images from the Infographic_vqa dataset sourced from HuggingFaceM4 The Cauldron dataset, as well as images from the dataset AFTDB (Arxiv Figure Table Database) curated by cmarkea. This dataset consists of pairs of images and corresponding text, with each image linked to an average of five questions and answers available in both English and French. These questions and answers were generated using Gemini 1.5 Pro, thereby rendering the dataset well-suited for multimodal tasks involving image-text pairing and multilingual question answering."
40+
),
41+
)
42+
43+
test_card(card)
44+
add_to_catalog(card, "cards.doc_vqa.lmms_eval", overwrite=True)

src/unitxt/catalog/cards/doc_vqa/lmms_eval.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
],
1010
"splits": [
1111
"train",
12-
"test"
12+
"test",
13+
"validation"
1314
]
1415
},
1516
"preprocess_steps": [

0 commit comments

Comments
 (0)