The job failed due to an invalid training file. 'str' object has no attribute 'get'

Hello everyone! I’m trying to finetune the model by providing JSONL file.
Sample data:
{“messages”: [{“role”: “user”, “content”: “SIMLA FROZEN FOOD LOCKER LLC CO”}, {“role”: “assistant”, “content”: [“Foodservice / Wholesale”, “retail”]}]}
{“messages”: [{“role”: “user”, “content”: “PIGGLY WIGGLY NC”}, {“role”: “assistant”, “content”: “retail”}]}
But I get this error: ‘The job failed due to an invalid training file. ‘str’ object has no attribute ‘get’’.
Is it because of a list of categories? in some cases, I need them to have multiple categories, so I put them in list. How can I fix this?
Thank You!!

Welcome to the dev forum @kmehta1

The content of an assistant message object needs to adhere to the specs on the chat completions API.

Thus Instead of returning an array, it should be retuning a string.

2 Likes

Hi!!
Thank You for the insight! so my entry should look like this?
{“messages”: [{“role”: “user”, “content”: “SIMLA FROZEN FOOD LOCKER LLC CO”}, {“role”: “assistant”, “content”: “Foodservice / Wholesale, retail”}]}

There is no way I can separate retail and wholesale/Foodservice at all? I do not want them to go as a single string, but I guess there is no other way to do it?? I want the model to be able to put multiple categories where its appropriate.

You can absolutely split the string you receive at commas to create a list at your end.
e.g.

# Example string with spaces
input_string = "apple, banana, cherry, orange"

# Split the string and remove whitespace from each item
result_list = [item.strip() for item in input_string.split(',')]

# Display the result
print(result_list)
1 Like

But then I get the list that I cannot input to open ai to train the model. I have tried using list but as You have mentioned, I need string. So, my only choice is to combine my categories in one string? I am trying to build a model that will categorize companies, sometimes the company needs 2 categories to describe its business. Thats why I am trying to put 2 different categories as 2 strings in a list because for the next company I might only use one category.