This requires 2 requests (I mean of course the model has to tell you about the reasoning else it did not happen - and I mean you also want to know if it happened).
- send the prompt for the analysis
- receive the answer
- add the messages for a second prompt where you do this:
Create a json schema and give it with the prompt.
This one is probably overkill af:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"problem_uuid": {
"type": "string",
"pattern": "^[a-f0-9]{32}$"
},
"student_id": {
"type": "string",
"pattern": "^[a-z0-9]+$"
},
"comparison_result": {
"type": "object",
"properties": {
"is_correct": {
"type": "boolean"
},
"correctness_percentage": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"summary": {
"type": "string",
"minLength": 1
}
},
"required": ["is_correct", "correctness_percentage", "summary"]
}
},
"required": ["problem_uuid", "student_id", "comparison_result"]
}
Also add as last sentence to the prompt:
Start the output with { and end the output with }
And I would also add some rule based evaluation e.g. with a regular expression get all problem_uuid from the document(s) and then count that and compare it to the output of the LLM.
Here is some pseudo code:
messages = []
messages = [{'role': 'system', 'message': 'you are a helpful intern - find the problem uuid and the student number and stuff and show me your reasoning in chain of thought style'}
{'role': 'user', 'message': 'here is some data to analyse: {some data}'}]
answer = model.chat($messages)
messages = [{'role': 'system', 'message': 'you are a helpful intern - find the problem uuid and the student number and stuff and show me your reasoning in chain of thought style'}
{'role': 'user', 'message': 'here is some data to analyse: {some data}'}
{'role': 'assistent', 'message': '{answer}' }
{'role': 'user', 'message' : 'follow up with the json schema and the last sentence where we ask for response start with { and end with }'}
]
json = model.chat($messages)