Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,8 @@ def generate_lesson(grade, topic, level):
|
|
| 18 |
device=device
|
| 19 |
)
|
| 20 |
|
| 21 |
-
prompt = f"""
|
|
|
|
| 22 |
|
| 23 |
Lesson Title:
|
| 24 |
Objective:
|
|
@@ -26,11 +27,22 @@ Activity:
|
|
| 26 |
Instruction (Khmer):
|
| 27 |
Materials:
|
| 28 |
|
|
|
|
|
|
|
| 29 |
Grade: {grade}
|
| 30 |
Topic: {topic}
|
| 31 |
-
TaRL Level: {level}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
output = pipe(prompt, max_new_tokens=300, temperature=0.7, do_sample=True)
|
| 34 |
return output[0]['generated_text']
|
| 35 |
|
| 36 |
@spaces.GPU
|
|
|
|
| 18 |
device=device
|
| 19 |
)
|
| 20 |
|
| 21 |
+
prompt = f"""
|
| 22 |
+
You are a lesson planning assistant. Return only one structured Khmer math lesson plan with these fields:
|
| 23 |
|
| 24 |
Lesson Title:
|
| 25 |
Objective:
|
|
|
|
| 27 |
Instruction (Khmer):
|
| 28 |
Materials:
|
| 29 |
|
| 30 |
+
Please follow the structure exactly.
|
| 31 |
+
|
| 32 |
Grade: {grade}
|
| 33 |
Topic: {topic}
|
| 34 |
+
TaRL Level: {level}
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
output = pipe(
|
| 39 |
+
prompt,
|
| 40 |
+
max_new_tokens=300,
|
| 41 |
+
temperature=0.7,
|
| 42 |
+
do_sample=True,
|
| 43 |
+
eos_token_id=tokenizer.eos_token_id # helps terminate early
|
| 44 |
+
)
|
| 45 |
|
|
|
|
| 46 |
return output[0]['generated_text']
|
| 47 |
|
| 48 |
@spaces.GPU
|