Views
No views yet
mjpsm/activity-generation-model-v1.1 is a fine-tuned activity-generation model designed for the MyVillage learning workflow. It generates one small next learning activity from a learner's current context.1{
2 "title": "string",
3 "description": "string",
4 "instructions": "string"
5}| Property | Value |
|---|---|
| Model | mjpsm/activity-generation-model-v1.1 |
| Base model | Qwen/Qwen2.5-0.5B-Instruct |
| Previous version | mjpsm/activity-generation-model-v1 |
| Task | Conditional educational activity generation |
| Output | JSON containing title, description, and instructions |
| Fine-tuning approach | Supervised fine-tuning with LoRA |
| Language | English |
1Village goal
2 +
3Previous activity title
4 +
5Knowledge submission
6 ↓
7activity-generation-model-v1.1
8 ↓
9Next micro-activitymjpsm/activity-generation-model-v1 using the same fixed set of 20 benchmark cases, identical prompts, and deterministic decoding.| Metric | V1 | V1.1 | Change |
|---|---|---|---|
| Valid JSON | 100% | 100% | Maintained |
| Exact output schema | 100% | 100% | Maintained |
| Single-sentence instructions | 40% | 95% | +55 pp |
| Micro-activity heuristic pass | 65% | 90% | +25 pp |
| Expected-focus hit | 80% | 95% | +15 pp |
| Sequencing-marker rate | 20% | 5% | -15 pp |
| Unnecessary-setup marker rate | 5% | 0% | -5 pp |
| Large-scope marker rate | 0% | 0% | Maintained |
| Instructions over 30 words | 25% | 5% | -20 pp |
| Forbidden-pattern hit rate | 0% | 0% | Maintained |
| Average instruction length | 25.1 words | 16.2 words | -35.5% |
| Average description length | 18.05 words | 12.15 words | -32.7% |
| Average generated tokens | 70.8 | 49.35 | -30.3% |
| Average benchmark latency | 2.18 s | 1.56 s | -28.6% |
1Village goal:
2Understand how to train, evaluate, and improve machine learning models.
3
4Previous activity title:
5Train a Linear Regression Model
6
7Knowledge submission:
8I trained a linear regression model and got an R-squared value of 0.7, but I am not sure what that score means for the quality of my model.1{
2 "title": "Interpret Your R-Squared Score",
3 "description": "Learn what your R-squared score says about your model.",
4 "instructions": "Research what R-squared measures and write one sentence explaining what your score means."
5}pip install torch transformers acceleratetorchao is not required.1import json
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5MODEL_ID = "mjpsm/activity-generation-model-v1.1"
6
7SYSTEM_PROMPT = """You are an educational activity generator for MyVillage.
8
9Given:
101. the Village goal,
112. the previous activity title, and
123. the student's knowledge submission,
13
14generate exactly one small, realistic next learning activity.
15
16The activity must:
17- directly build on what the student demonstrated,
18- move the student toward the Village goal,
19- represent the smallest meaningful next step,
20- stay short and focused,
21- avoid unnecessary setup,
22- avoid large or multi-step projects,
23- avoid unsupported named tools, datasets, APIs, people, files, platforms, or requirements,
24- allow the same activity title to appear for different students when the same next activity is appropriate.
25
26Return valid JSON only with exactly these fields:
27- title
28- description
29- instructions
30
31Do not include markdown, commentary, activityType, estimatedMinutes, or extra fields.
32"""
33
34tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
35
36dtype = torch.float16 if torch.cuda.is_available() else torch.float32
37
38model = AutoModelForCausalLM.from_pretrained(
39 MODEL_ID,
40 torch_dtype=dtype,
41 device_map="auto" if torch.cuda.is_available() else None,
42)
43
44if not torch.cuda.is_available():
45 model = model.to("cpu")
46
47model.eval()
48
49village_goal = (
50 "Develop foundational 3D modeling skills and learn how to create "
51 "detailed objects and environments using professional 3D software."
52)
53
54previous_activity_title = "Introduction to Basic 3D Modeling"
55
56knowledge_submission = (
57 "I learned how to create basic 3D objects using cubes, spheres, and "
58 "cylinders. I still need practice combining shapes into more complex models."
59)
60
61user_prompt = f"""Village goal:
62{village_goal}
63
64Previous activity title:
65{previous_activity_title}
66
67Knowledge submission:
68{knowledge_submission}
69
70Generate the next activity."""
71
72messages = [
73 {"role": "system", "content": SYSTEM_PROMPT},
74 {"role": "user", "content": user_prompt},
75]
76
77prompt = tokenizer.apply_chat_template(
78 messages,
79 tokenize=False,
80 add_generation_prompt=True,
81)
82
83inputs = tokenizer(
84 prompt,
85 return_tensors="pt",
86).to(model.device)
87
88with torch.inference_mode():
89 output = model.generate(
90 **inputs,
91 max_new_tokens=180,
92 do_sample=False,
93 repetition_penalty=1.05,
94 pad_token_id=tokenizer.eos_token_id,
95 eos_token_id=tokenizer.eos_token_id,
96 )
97
98generated_tokens = output[0, inputs["input_ids"].shape[1]:]
99
100response = tokenizer.decode(
101 generated_tokens,
102 skip_special_tokens=True,
103).strip()
104
105try:
106 activity = json.loads(response)
107 print(json.dumps(activity, indent=2))
108except json.JSONDecodeError:
109 print("Model returned non-JSON output:")
110 print(response)title, description, and instructions,do_sample=False), and