I need a python script to do the following to a json with camel-ai format data: This…
- User
I need a python script to do the following to a json with camel-ai format data:
This script will convert a camel-ai format dataset into alpaca format.
Example of Camel-AI format dataset:
''' [ { "role_1": "Biologist_RoleType.ASSISTANT", "topic;": "Taxonomy", "sub_topic": "Identification of new species", "message_1": "What are the specific characteristics...", "message_2": "To differentiate and identify a new species..." }, ] '''
Example of an Alpaca format dataset:
''' [ { "instruction": "What are the three primary colors?", "input": "", "output": "The three primary colors are red, blue, and yellow." }, ] '''
Given that there is no role, topic, subtopic in alpaca, and no input in camel-ai, we will not fill the input field, and will take the message_1 as the instruction, and message_2 as the output to convert the data to alpaca format.
You should be sure to open the json files with encode='utf-8' and save the json with indent2
- Assistant
Certainly! Below is a Python script that will read the Camel-AI format JSON file and convert it into the Alpaca format, as described in your instructions. It will save the output to a new file with an indentation of 2.
python - User
Now, I need a script to do the following:
This script will convert an alpaca format dataset into sharegpt format.
Example of an alpaca format dataset:
''' [ { "instruction": "Name the following organic compound: C6H5CH2CH2CH(CH3)2.", "input": "", "output": "The given organic compound is 4-ethyl-2-methylhexane." }, ] '''
Example of an Alpaca format dataset:
''' [ { "id": f47ac10b-58cc-4372-a567-0e02b2c3d479, "conversations": [ { "from": "human", "value": "How does the regulation of glycolysis..." }, { "from": "gpt", "value": "The regulation of glycolysis..." } ] }, ] '''
Given that there is no direct correlation for the fields, we want to convert the instruction text + "\n{input}" to a "from": "human" value field, and the output to the "from": "gpt" value field, with a UUID generated for the ID field.
indent 2, load json file with utf-8 encoding
- Assistant
Certainly! Below is the Python script to convert an Alpaca format dataset into the ShareGPT format. It takes into consideration the instruction and the output as specified, and also generates a UUID for each conversation's ID.
python