jpruzcuen commited on
Commit ·
14e10ce
1
Parent(s): 891e323
added quiz
Browse files
app.py
CHANGED
|
@@ -44,21 +44,59 @@ def chat(message, history):
|
|
| 44 |
|
| 45 |
return response["choices"][0]["message"]["content"]
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
Ask questions about AI and Machine Learning! I can help you better understand the
|
| 52 |
-
theoretical and practical skills to succeed in this field.
|
| 53 |
-
|
| 54 |
This Llama 3.2 1B model was fine-tuned on the FineTome-100k instruction dataset.
|
| 55 |
-
"""
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
demo.launch()
|
|
|
|
| 44 |
|
| 45 |
return response["choices"][0]["message"]["content"]
|
| 46 |
|
| 47 |
+
def quiz():
|
| 48 |
+
'''Generate a multiple choice quiz with 10 questions (created by the llm)'''
|
| 49 |
+
system_prompt = {
|
| 50 |
+
"role": "system",
|
| 51 |
+
"content": (
|
| 52 |
+
"Generate a set of 10 multiple-choice questions about machine learning for a student."
|
| 53 |
+
"Each question should have 4 answer options (A–D) with a single correct answer.\n\n"
|
| 54 |
+
"Format exactly like this:\n\n"
|
| 55 |
+
"1. Question text...\n"
|
| 56 |
+
"A) ...\nB) ...\nC) ...\nD) ...\n**Correct Answer: X**\n\n"
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
response = llm.create_chat_completion(
|
| 61 |
+
messages=[system_prompt],
|
| 62 |
+
max_tokens=512,
|
| 63 |
+
temperature=0.7
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
return response["choices"][0]["message"]["content"]
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
with gr.Blocks(title="TAI: AI Teacher Assistant") as demo:
|
| 72 |
+
gr.Markdown("""
|
| 73 |
+
# TAI: Your AI Teacher Assistant
|
| 74 |
Ask questions about AI and Machine Learning! I can help you better understand the
|
| 75 |
+
theoretical and practical skills to succeed in this field. Test your understanding with a quiz!
|
| 76 |
+
|
| 77 |
This Llama 3.2 1B model was fine-tuned on the FineTome-100k instruction dataset.
|
| 78 |
+
""")
|
| 79 |
+
with gr.Row():
|
| 80 |
+
|
| 81 |
+
# Left column: chat
|
| 82 |
+
with gr.Column(scale=2):
|
| 83 |
+
chatbot = gr.ChatInterface(
|
| 84 |
+
chat,
|
| 85 |
+
examples=[
|
| 86 |
+
"Which tasks can recurrent neural networks address?",
|
| 87 |
+
"Explain backpropagation in simple terms.",
|
| 88 |
+
"What are the benefits of regularization during training?",
|
| 89 |
+
"Write a short summary of advancements that allowed for deep neural networks to work."
|
| 90 |
+
]
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# Right column: quiz
|
| 94 |
+
with gr.Column(scale=1):
|
| 95 |
+
gr.Markdown("## Machine Learning Quiz")
|
| 96 |
+
quiz_btn = gr.Button("Start Quiz", variant="primary")
|
| 97 |
+
quiz_output = gr.Markdown()
|
| 98 |
+
|
| 99 |
+
quiz_btn.click(fn=quiz, outputs=quiz_output)
|
| 100 |
+
|
| 101 |
|
| 102 |
demo.launch()
|