chat-completion-input has to be string format
Browse files- hf2llamastack.py +9 -6
hf2llamastack.py
CHANGED
|
@@ -2,6 +2,7 @@ from datasets import load_dataset, DatasetDict, Dataset
|
|
| 2 |
import os
|
| 3 |
import textwrap
|
| 4 |
import random
|
|
|
|
| 5 |
|
| 6 |
OUTPUT_DATASET_NAME = "teddyyyy123/gpqa_0shot_cot"
|
| 7 |
|
|
@@ -60,12 +61,14 @@ def convert_to_llamastack_format(ds):
|
|
| 60 |
|
| 61 |
# must use the df.loc syntax, directly assigning to row['key'] won't keep it
|
| 62 |
df.loc[idx, 'input_query'] = row['Question']
|
| 63 |
-
df.loc[idx, 'chat_completion_input'] =
|
| 64 |
-
|
| 65 |
-
'
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
df.loc[idx, 'expected_answer'] = shuffled_target_letter
|
| 70 |
return Dataset.from_pandas(df)
|
| 71 |
|
|
|
|
| 2 |
import os
|
| 3 |
import textwrap
|
| 4 |
import random
|
| 5 |
+
import json
|
| 6 |
|
| 7 |
OUTPUT_DATASET_NAME = "teddyyyy123/gpqa_0shot_cot"
|
| 8 |
|
|
|
|
| 61 |
|
| 62 |
# must use the df.loc syntax, directly assigning to row['key'] won't keep it
|
| 63 |
df.loc[idx, 'input_query'] = row['Question']
|
| 64 |
+
df.loc[idx, 'chat_completion_input'] = json.dumps(
|
| 65 |
+
[{
|
| 66 |
+
'role':'user', 'content':[{
|
| 67 |
+
'type':'text',
|
| 68 |
+
'text': COT_PROMPT_TEMPATE.format(row['Question'], *shuffled_choices)
|
| 69 |
+
}]
|
| 70 |
+
}]
|
| 71 |
+
)
|
| 72 |
df.loc[idx, 'expected_answer'] = shuffled_target_letter
|
| 73 |
return Dataset.from_pandas(df)
|
| 74 |
|