I have documents from which I am attempting to use gpt-4o-mini to extract attribute-value pairs. Below is an example of such a document
1
2 TAG No. 306FV - 10002
3 SERVICE HOT OIL
4 Document No. D - 30-100-1225-103
5 LINE No. 306-HM
6. Line Size 6 in.
7. Line Class A006F
... etc.
I have finetuned gpt-4o-mini for this task. Combined with structured outputs, the expected output for the above sample would be something like this
{
"attributes": [
{"AttributeName": "TAG No.", "Value": "36FV - 27374"},
{"AttributeName": "SERVICE", "Value": "HOT OIL"},
{"AttributeName": "Document No.", "Value": "D - 40-870-198-345"},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line Class", "Value": "A-006F"},
...
etc.
]
}
However, my finetuned model will sometimes get stuck in an infinite loop where it repeats detections of the same attributes over and over until the token limit is reached. For example,
{
"attributes": [
{"AttributeName": "TAG No.", "Value": "36FV - 27374"},
{"AttributeName": "SERVICE", "Value": "HOT OIL"},
{"AttributeName": "Document No.", "Value": "D - 40-870-198-345"},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
{"AttributeName": "Line No.", "Value": "306-HM"},
{"AttributeName": "Line Size", "Value": "6 in."},
...
etc.
]
}
This behaviour only occurs sometimes. Some runs will extract the information as desired, while other runs will exhibit this oscillating behaviour and terminate after the token limit is reached. I have not noticed this behaviour in the base model, it seems to only occur in my fine-tuned model.
Model parameters:
temperature=0
top_p = 1
freqency_penalty=0
presence_penalty=0
I have tried playing around with the frequency and presence penalty but to no avail.
I have looked on the fine-tuning discussion thread but couldn’t find any similar posts to this. Anybody experienced anything similar and/or have any advice on how to fix this?