Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple API to run load and evaluate datasets based on tasks and input data #1327

Open
yoavkatz opened this issue Nov 4, 2024 · 4 comments
Open
Assignees

Comments

@yoavkatz
Copy link
Member

yoavkatz commented Nov 4, 2024

We need a simple way for a user to load a Unitxt dataset based on existing files or data structures.
This is required for ilab (@Roni-Friedman ) and also for other use cases.

I thought that maybe a dataframe is a common interface that everyone knows.

load_dataset(task="tasks.classification.multi_class", test_set = pd.from_csv("test.csv"))
load_dataset(task="tasks.classification.multi_class", test_set = pd.from_csv("test.csv"), train_set=pd.from_csv("train.csv" )

And

evaluate(predications, task="tasks.classification.multi_class", test_set = pd.from_csv("test.csv"))

The assumption is that the fields of input dataframe are the same as the task, and a clear error message will be presented if not.

@elronbandel
Copy link
Member

elronbandel commented Nov 4, 2024

Is unitxt.api.produce not enough? you could use it with produce(pd.from_csv("test.csv").to_list(), task="your_task")

unitxt/src/unitxt/api.py

Lines 132 to 139 in 582d96f

def produce(instance_or_instances, dataset_query: Optional[str] = None, **kwargs):
is_list = isinstance(instance_or_instances, list)
if not is_list:
instance_or_instances = [instance_or_instances]
result = _get_produce_with_cache(dataset_query, **kwargs)(instance_or_instances)
if not is_list:
result = result[0]
return result

@yoavkatz
Copy link
Member Author

yoavkatz commented Nov 4, 2024

I did not even think about produce. I'll check. It has to be more prominently documented (Currently it's under "Production and Inference").

@yoavkatz
Copy link
Member Author

yoavkatz commented Nov 4, 2024

I tried:

Set up question answer pairs in a dictionary

data = [
{"question": "What is the capital of Texas?", "answers": ["Austin"]},
{"question": "What is the color of the sky?", "answers": ["Blue"]},
]

test_dataset = produce(data,task="tasks.qa.open", template="templates.qa.open.title")

But the output dataset does not contain references field, so it can not be evaluated.

@elronbandel
Copy link
Member

You are right. I forgot it was meant for inference. We should document it properly.

@yoavkatz yoavkatz changed the title Simple API to run load datasets based on tasks and input data Simple API to run load and evaluate datasets based on tasks and input data Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants