Add comment for each criteria in speaking grading.
This commit is contained in:
96
app.py
96
app.py
@@ -435,15 +435,35 @@ def grade_speaking_task_1():
|
|||||||
answer = speech_to_text(sound_file_name)
|
answer = speech_to_text(sound_file_name)
|
||||||
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Transcripted answer: " + answer)
|
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Transcripted answer: " + answer)
|
||||||
|
|
||||||
|
json_format = {
|
||||||
|
"comment": "extensive comment about answer quality",
|
||||||
|
"overall": 0.0,
|
||||||
|
"task_response": {
|
||||||
|
"Fluency and Coherence": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about fluency and coherence"
|
||||||
|
},
|
||||||
|
"Lexical Resource": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about lexical resource"
|
||||||
|
},
|
||||||
|
"Grammatical Range and Accuracy": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about grammatical range and accuracy"
|
||||||
|
},
|
||||||
|
"Pronunciation": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about pronunciation on the transcribed answer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if has_x_words(answer, 20):
|
if has_x_words(answer, 20):
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": (
|
"content": (
|
||||||
'You are a helpful assistant designed to output JSON on this format: '
|
'You are a helpful assistant designed to output JSON on this format: ' + str(json_format))
|
||||||
'{"comment": "comment about answer quality", "overall": 0.0, '
|
|
||||||
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
|
|
||||||
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
@@ -453,6 +473,10 @@ def grade_speaking_task_1():
|
|||||||
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
||||||
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
||||||
'\n Question: "' + question + '" \n Answer: "' + answer + '"')
|
'\n Question: "' + question + '" \n Answer: "' + answer + '"')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": 'Address the student as "you"'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
token_count = count_total_tokens(messages)
|
token_count = count_total_tokens(messages)
|
||||||
@@ -579,15 +603,35 @@ def grade_speaking_task_2():
|
|||||||
answer = speech_to_text(sound_file_name)
|
answer = speech_to_text(sound_file_name)
|
||||||
logging.info("POST - speaking_task_2 - " + str(request_id) + " - Transcripted answer: " + answer)
|
logging.info("POST - speaking_task_2 - " + str(request_id) + " - Transcripted answer: " + answer)
|
||||||
|
|
||||||
|
json_format = {
|
||||||
|
"comment": "extensive comment about answer quality",
|
||||||
|
"overall": 0.0,
|
||||||
|
"task_response": {
|
||||||
|
"Fluency and Coherence": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about fluency and coherence"
|
||||||
|
},
|
||||||
|
"Lexical Resource": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about lexical resource"
|
||||||
|
},
|
||||||
|
"Grammatical Range and Accuracy": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about grammatical range and accuracy"
|
||||||
|
},
|
||||||
|
"Pronunciation": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about pronunciation on the transcribed answer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if has_x_words(answer, 20):
|
if has_x_words(answer, 20):
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": (
|
"content": (
|
||||||
'You are a helpful assistant designed to output JSON on this format: '
|
'You are a helpful assistant designed to output JSON on this format: ' + str(json_format))
|
||||||
'{"comment": "comment about answer quality", "overall": 0.0, '
|
|
||||||
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
|
|
||||||
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
@@ -597,6 +641,10 @@ def grade_speaking_task_2():
|
|||||||
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
||||||
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
||||||
'\n Question: "' + question + '" \n Answer: "' + answer + '"')
|
'\n Question: "' + question + '" \n Answer: "' + answer + '"')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": 'Address the student as "you"'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
token_count = count_total_tokens(messages)
|
token_count = count_total_tokens(messages)
|
||||||
@@ -800,15 +848,34 @@ def grade_speaking_task_3():
|
|||||||
token_count,
|
token_count,
|
||||||
["answer"],
|
["answer"],
|
||||||
GEN_QUESTION_TEMPERATURE))
|
GEN_QUESTION_TEMPERATURE))
|
||||||
|
json_format = {
|
||||||
|
"comment": "extensive comment about answer quality",
|
||||||
|
"overall": 0.0,
|
||||||
|
"task_response": {
|
||||||
|
"Fluency and Coherence": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about fluency and coherence"
|
||||||
|
},
|
||||||
|
"Lexical Resource": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about lexical resource"
|
||||||
|
},
|
||||||
|
"Grammatical Range and Accuracy": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about grammatical range and accuracy"
|
||||||
|
},
|
||||||
|
"Pronunciation": {
|
||||||
|
"grade": 0.0,
|
||||||
|
"comment": "extensive comment about pronunciation on the transcribed answer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": (
|
"content": (
|
||||||
'You are a helpful assistant designed to output JSON on this format: '
|
'You are a helpful assistant designed to output JSON on this format: ' + str(json_format))
|
||||||
'{"comment": "comment about answer quality", "overall": 0.0, '
|
|
||||||
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
|
|
||||||
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
message = (
|
message = (
|
||||||
@@ -833,6 +900,11 @@ def grade_speaking_task_3():
|
|||||||
"content": message
|
"content": message
|
||||||
})
|
})
|
||||||
|
|
||||||
|
messages.append({
|
||||||
|
"role": "user",
|
||||||
|
"content": 'Address the student as "you"'
|
||||||
|
})
|
||||||
|
|
||||||
token_count = count_total_tokens(messages)
|
token_count = count_total_tokens(messages)
|
||||||
|
|
||||||
logging.info("POST - speaking_task_3 - " + str(request_id) + " - Requesting grading of the answers.")
|
logging.info("POST - speaking_task_3 - " + str(request_id) + " - Requesting grading of the answers.")
|
||||||
|
|||||||
Reference in New Issue
Block a user