Skip to content

Commit

Permalink
break another prepare file aiming to more than one hf path
Browse files Browse the repository at this point in the history
Signed-off-by: dafnapension <[email protected]>
  • Loading branch information
dafnapension committed Feb 6, 2025
1 parent e69439a commit 9270239
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
33 changes: 0 additions & 33 deletions prepare/cards/doc_vqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from unitxt.collections_operators import Explode, Wrap
from unitxt.image_operators import ToImage
from unitxt.operators import Copy
from unitxt.splitters import RenameSplits
from unitxt.templates import MultiReferenceTemplate
from unitxt.test_utils.card import test_card

Expand Down Expand Up @@ -48,35 +47,3 @@

test_card(card)
add_to_catalog(card, f"cards.doc_vqa.{language}", overwrite=True)


card = TaskCard(
loader=LoadHF(
path="lmms-lab/DocVQA",
name="DocVQA",
data_classification_policy=["public"],
splits=["train", "test"],
),
preprocess_steps=[
RenameSplits(mapper={"validation": "test"}),
ToImage(field="image", to_field="context"),
Set(fields={"context_type": "image"}),
],
task="tasks.qa.with_context.abstractive[metrics=[metrics.anls]]",
templates=[template, *templates.items],
default_template=template,
__tags__={
"license": "apache-2.0",
"multilinguality": "monolingual",
"modalities": ["image", "text"],
"size_categories": "10K<n<100K",
"task_categories": "question-answering",
"task_ids": "extractive-qa",
},
__description__=(
"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."
),
)

test_card(card)
add_to_catalog(card, "cards.doc_vqa.lmms_eval", overwrite=True)
44 changes: 44 additions & 0 deletions prepare/cards/doc_vqa_lmms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from unitxt.blocks import LoadHF, Set, TaskCard
from unitxt.catalog import add_to_catalog, get_from_catalog
from unitxt.image_operators import ToImage
from unitxt.splitters import RenameSplits
from unitxt.templates import MultiReferenceTemplate
from unitxt.test_utils.card import test_card

templates = get_from_catalog("templates.qa.with_context.all")
template = MultiReferenceTemplate(
input_format="{context}\n{question}\nAnswer the question using a single word or phrase.",
references_field="answers",
__description__="lmms-evals default template for docvqa.",
)

card = TaskCard(
loader=LoadHF(
path="lmms-lab/DocVQA",
name="DocVQA",
data_classification_policy=["public"],
splits=["train", "test", "validation"],
),
preprocess_steps=[
RenameSplits(mapper={"validation": "test"}),
ToImage(field="image", to_field="context"),
Set(fields={"context_type": "image"}),
],
task="tasks.qa.with_context.abstractive[metrics=[metrics.anls]]",
templates=[template, *templates.items],
default_template=template,
__tags__={
"license": "apache-2.0",
"multilinguality": "monolingual",
"modalities": ["image", "text"],
"size_categories": "10K<n<100K",
"task_categories": "question-answering",
"task_ids": "extractive-qa",
},
__description__=(
"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."
),
)

test_card(card)
add_to_catalog(card, "cards.doc_vqa.lmms_eval", overwrite=True)
3 changes: 2 additions & 1 deletion src/unitxt/catalog/cards/doc_vqa/lmms_eval.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
],
"splits": [
"train",
"test"
"test",
"validation"
]
},
"preprocess_steps": [
Expand Down

0 comments on commit 9270239

Please sign in to comment.