Skip to content

Commit

Permalink
modified templates and IOFields for structured data task cards
Browse files Browse the repository at this point in the history
  • Loading branch information
csrajmohan committed Feb 22, 2024
1 parent 4b8fd85 commit 87f1d9a
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion prepare/cards/dart.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
field_to_field={"annotations/text/0": "output"},
use_query=True,
),
AddFields(fields={"type_of_input": "Triples"}),
AddFields(fields={"type_of_input": "Triples", "type_of_output": "Text"}),
],
task="tasks.generation",
templates="templates.generation.all",
Expand Down
2 changes: 1 addition & 1 deletion prepare/cards/tablerow_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
MapInstanceValues(mappers={"label": {"0": "Normal", "1": "Heart Disease"}}),
AddFields(
fields={
"text_type": "Person",
"text_type": "Person medical record",
"type_of_class": "Heart Disease Possibility",
}
),
Expand Down
4 changes: 3 additions & 1 deletion prepare/cards/wiki_bio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
),
SerializeKeyValPairs(field_to_field=[["kvpairs", "input"]]),
RenameFields(field_to_field={"target_text": "output"}),
AddFields(fields={"type_of_input": "Key-Value pairs"}),
AddFields(
fields={"type_of_input": "Key-Value pairs", "type_of_output": "Text"}
),
],
task="tasks.generation",
templates="templates.generation.all",
Expand Down
2 changes: 1 addition & 1 deletion prepare/tasks/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

add_to_catalog(
FormTask(
inputs=["input", "type_of_input"],
inputs=["input", "type_of_input", "type_of_output"],
outputs=["output"],
metrics=["metrics.normalized_sacrebleu"],
augmentable_inputs=["input"],
Expand Down
2 changes: 1 addition & 1 deletion prepare/templates/classification/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

add_to_catalog(
InputOutputTemplate(
input_format="Classify the {type_of_class} of following {text_type} to one of these options: {classes}. Text: {text}",
input_format="Classify the {type_of_class} of following {text_type} to one of these options: {classes}. {text_type}: {text}",
output_format="{label}",
postprocessors=[
"processors.take_first_non_empty_line",
Expand Down
2 changes: 1 addition & 1 deletion prepare/templates/generation/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

add_to_catalog(
InputOutputTemplate(
input_format="Given the following {type_of_input}, generate the corresponding text. {type_of_input}: {input}",
input_format="Given the following {type_of_input}, generate the corresponding {type_of_output}. {type_of_input}: {input}",
output_format="{output}",
postprocessors=[
"processors.take_first_non_empty_line",
Expand Down
3 changes: 2 additions & 1 deletion src/unitxt/catalog/cards/dart.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
{
"type": "add_fields",
"fields": {
"type_of_input": "Triples"
"type_of_input": "Triples",
"type_of_output": "Text"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/unitxt/catalog/cards/tablerow_classify.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
"type": "add_fields",
"fields": {
"text_type": "Person",
"text_type": "Person medical record",
"type_of_class": "Heart Disease Possibility"
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/unitxt/catalog/cards/wiki_bio.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
{
"type": "add_fields",
"fields": {
"type_of_input": "Key-Value pairs"
"type_of_input": "Key-Value pairs",
"type_of_output": "Text"
}
}
],
Expand Down
3 changes: 2 additions & 1 deletion src/unitxt/catalog/tasks/generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"type": "form_task",
"inputs": [
"input",
"type_of_input"
"type_of_input",
"type_of_output"
],
"outputs": [
"output"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "input_output_template",
"input_format": "Classify the {type_of_class} of following {text_type} to one of these options: {classes}. Text: {text}",
"input_format": "Classify the {type_of_class} of following {text_type} to one of these options: {classes}. {text_type}: {text}",
"output_format": "{label}",
"postprocessors": [
"processors.take_first_non_empty_line",
Expand Down
2 changes: 1 addition & 1 deletion src/unitxt/catalog/templates/generation/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "input_output_template",
"input_format": "Given the following {type_of_input}, generate the corresponding text. {type_of_input}: {input}",
"input_format": "Given the following {type_of_input}, generate the corresponding {type_of_output}. {type_of_input}: {input}",
"output_format": "{output}",
"postprocessors": [
"processors.take_first_non_empty_line",
Expand Down
5 changes: 2 additions & 3 deletions tests/library/test_struct_data_operators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from unitxt.struct_data_operators import (
from src.unitxt.struct_data_operators import (
ListToKeyValPairs,
SerializeKeyValPairs,
SerializeTableAsIndexedRowMajor,
Expand All @@ -11,13 +11,12 @@
TruncateTableCells,
TruncateTableRows,
)

from src.unitxt.test_utils.operators import (
check_operator,
)


class TestTableOperators(unittest.TestCase):
class TestStructDataOperators(unittest.TestCase):
"""Tests for tabular data processing operators."""

def test_serializetable_markdown(self):
Expand Down

0 comments on commit 87f1d9a

Please sign in to comment.