|
2 | 2 | TaskCard, |
3 | 3 | ) |
4 | 4 | from unitxt.catalog import add_to_catalog |
5 | | -from unitxt.loaders import LoadFromHFSpace |
| 5 | +from unitxt.loaders import LoadCSV |
6 | 6 | from unitxt.operators import ( |
7 | 7 | Apply, |
8 | 8 | Copy, |
|
13 | 13 | from unitxt.stream_operators import DeleteSplits, JoinStreams |
14 | 14 | from unitxt.test_utils.card import test_card |
15 | 15 |
|
| 16 | +# 'lmsys/arena-hard-browser' (https://huggingface.co/spaces/lmarena-ai/arena-hard-browser) was gone from HF. |
| 17 | +# https://paperswithcode.com/dataset/arena-hard points at git repository https://github.com/lmarena/arena-hard-auto |
| 18 | +# from which the dataset is now fetched: |
| 19 | + |
| 20 | +question_git_repo_file_path = "https://raw.githubusercontent.com/lmarena/arena-hard-auto/57451f35d2be7fef9f05d5567f36e4c959bb6630/data/arena-hard-v0.1/question.jsonl" |
| 21 | +model_answer_git_repo_file_path = "https://raw.githubusercontent.com/lmarena/arena-hard-auto/57451f35d2be7fef9f05d5567f36e4c959bb6630/data/arena-hard-v0.1/model_answer/gpt-4-0314.jsonl" |
| 22 | + |
16 | 23 | card = TaskCard( |
17 | | - loader=LoadFromHFSpace( |
18 | | - space_name="lmsys/arena-hard-browser", |
19 | | - revision="03b91ca", # May 26, 2024 |
20 | | - data_files={ |
21 | | - "questions": "data/arena-hard-v0.1/question.jsonl", |
22 | | - "model_answer": "data/arena-hard-v0.1/model_answer/gpt-4-0314.jsonl", |
23 | | - }, |
24 | | - data_classification_policy = ["public"], |
25 | | - ), |
| 24 | + loader=LoadCSV( |
| 25 | + files={"questions": question_git_repo_file_path, "model_answer": model_answer_git_repo_file_path}, |
| 26 | + file_type="json", |
| 27 | + lines=True, |
| 28 | + data_classification_policy=["public"], |
| 29 | + ), |
26 | 30 | preprocess_steps=[ |
27 | 31 | # region Question file |
28 | 32 | Rename(field_to_field={"cluster": "group"}, apply_to_streams=["questions"]), |
29 | 33 | Copy( |
30 | | - field_to_field={"turns/0/content": "model_input"}, |
| 34 | + field_to_field={"prompt": "model_input"}, |
31 | 35 | apply_to_streams=["questions"], |
32 | 36 | ), |
33 | 37 | Set(fields={"reference_model": "gpt-4-0314"}, apply_to_streams=["questions"]), |
34 | 38 | # endregion |
35 | 39 | # region Answers file processing |
36 | 40 | Copy( |
37 | 41 | field_to_field={ |
38 | | - "choices/0/turns/0/content": "reference_model_output", |
39 | | - "choices/0/turns/0/token_len": "reference_model_output_token_len", |
| 42 | + "messages/1/content/answer": "reference_model_output" |
| 43 | + # "choices/0/turns/0/token_len": "reference_model_output_token_len", |
40 | 44 | }, |
41 | 45 | apply_to_streams=["model_answer"], |
42 | 46 | ), |
43 | 47 | Rename( |
44 | | - field_to_field={"model_id": "reference_model"}, |
| 48 | + field_to_field={"model": "reference_model"}, |
45 | 49 | apply_to_streams=["model_answer"], |
46 | 50 | ), |
47 | 51 | Apply( |
|
56 | 60 | left_stream="questions", |
57 | 61 | right_stream="model_answer", |
58 | 62 | how="inner", |
59 | | - on=["question_id", "reference_model"], |
| 63 | + on=["uid", "reference_model"], |
60 | 64 | new_stream_name="test", |
61 | 65 | ), |
62 | 66 | DeleteSplits(splits=["questions", "model_answer"]), |
63 | 67 | SelectFields( |
64 | 68 | fields=[ |
65 | | - "question_id", |
| 69 | + "uid", |
66 | 70 | "category", |
67 | 71 | "model_input", |
68 | 72 | "reference_model", |
|
71 | 75 | ), |
72 | 76 | Rename( |
73 | 77 | field_to_field={ |
| 78 | + "uid": "question_id", |
74 | 79 | "model_input": "input", |
75 | 80 | "category": "group", |
76 | 81 | "reference_model_output": "output", |
|
0 commit comments