This is a LoRA fine-tuned version of Meta's LLaMA 3.2 3B base model, trained to rewrite confusing educational content into clearer, more accessible alternatives. The model supports six targeted rewrite modes, each designed to address a specific clarity need in educational writing.
This model was developed as part of a structured NLP/LLM learning journey, serving as the core engine for the Teaching Quality Analyzer capstone project.
Model Details
Property
Value
Base model
meta-llama/Llama-3.2-3B
Model type
Causal Language Model (Decoder-only)
Fine-tuning method
QLoRA (4-bit quantisation + LoRA)
LoRA rank
16
LoRA alpha
32
Target modules
q_proj, v_proj, k_proj, o_proj
Trainable parameters
3,407,872 (0.45% of total)
Training precision
BFloat16
License
Apache 2.0
Intended Use
Primary Use Cases
Rewriting dense, jargon-heavy educational text into clearer alternatives
Helping educators improve the accessibility of their content before publishing or recording
Assisting content creators in adapting technical material for different audience levels
Powering educational content quality tools and dashboards
Out-of-Scope Use Cases
General-purpose text generation
Creative writing or fiction
Medical, legal, or financial advice
Any application requiring factual accuracy guarantees (the model may hallucinate or alter facts)
Rewrite Modes
The model supports six distinct rewrite modes, specified via the system prompt at inference time.
Mode
Description
Default
General clarity improvement — improves readability and flow while preserving meaning
Adds one concrete, domain-relevant example to illustrate the concept
Concise
Reduces word count while preserving all key information
Step by Step
Breaks the explanation into clearly numbered steps
Add Analogy
Adds a real-world comparison that makes abstract concepts concrete
Training Data
The model was fine-tuned on a custom synthetic dataset of 846 educational rewrite pairs generated using the Anthropic Claude API, following the methodology established in the Alpaca data generation paper (Taori et al., 2023).
Property
Value
Total examples
846
Source passages
141 (66 Wikipedia + 75 arXiv abstracts)
Modes per passage
6
Domain scope
All domains (computer science, biology, physics, mathematics, economics, chemistry, medicine)
Claude API (claude-sonnet-4-5) with manual seed examples
Prompt style
Dynamic — 49% short system prompts, 51% detailed system prompts
Train split
612 examples (70%)
Validation split
138 examples (17%)
Test split
96 examples (13%)
Split strategy
Stratified at passage level (all 6 modes for a passage go to the same split)
Data Generation Methodology
Source passages were collected from Wikipedia technical articles and arXiv paper abstracts across diverse academic domains. Each passage was then fed to the Claude API with mode-specific prompts to generate six targeted rewrites. A small set of manually written seed examples was included to anchor the generation quality. This approach mirrors the synthetic data generation methodology used in Stanford Alpaca and Microsoft Orca.
Training Configuration
Hyperparameter
Value
Epochs
3
Learning rate
2e-4
LR scheduler
Cosine
Warmup steps
50
Batch size
2
Gradient accumulation steps
8
Effective batch size
16
Weight decay
0.01
Max gradient norm
1.0
Max sequence length
512
Quantisation
4-bit NF4 (QLoRA)
Training framework
TRL SFTTrainer
Hardware
NVIDIA Tesla T4 (16GB)
Training time
150 minutes
Evaluation Results
Training Curves
Epoch
Training Loss
Validation Loss
1
1.737
1.183
2
1.149
1.086
3
1.044
1.065
The gap between training and validation loss at epoch 3 is 0.021, indicating minimal overfitting despite the relatively small dataset size.
Mode-Specific Qualitative Evaluation
Qualitative evaluation was conducted on a held-out test passage across all six modes.
Produces structured numbered steps following the source mechanism
Add Analogy
Good
Generates relevant real-world comparisons with clear mappings
Known Limitations
Simpler mode occasionally retains jargon from the source text. Root cause: training data generated by a large language model (Claude) that itself uses technical vocabulary. Recommended fix: regenerate Simpler mode training pairs with stricter jargon constraints.
Add Example mode sometimes adds examples from unrelated domains. Root cause: insufficient domain-specificity constraints in the generation prompts. Recommended fix: regenerate Add Example pairs with explicit domain-matching requirements.
Model size: At 3B parameters, the model shows strong instruction-following on most modes but may struggle with highly complex or ambiguous inputs. Upgrading to a 7B model is expected to improve consistency across all modes.
Factual accuracy: The model may alter facts or introduce inaccuracies in rewrites. All outputs should be reviewed before publication.
Language: English only. Not tested on multilingual inputs.
1defgenerate_rewrite(model, tokenizer, text, mode, max_new_tokens=256):23 mode_instructions ={4"Default":"""You are an expert educational content rewriter.
5Rewrite the text to be clearer and easier to understand.
6Improve readability while preserving the original meaning exactly.
7Output ONLY the rewrite, nothing else.""",89"Simpler":"""You are an expert educational content rewriter.
10Rewrite the text so a 16-year-old with no technical background can understand it.
11Replace ALL technical terms with everyday words.
12Use short sentences. Maximum 15 words per sentence.
13Never use acronyms or jargon.
14If a technical term is unavoidable, explain it in brackets.
15Output ONLY the rewrite, nothing else.""",1617"Add Example":"""You are an expert educational content rewriter.
18Rewrite the text and add ONE concrete example that directly illustrates the concept.
19The example MUST be about the exact same topic as the input text.
20Do not use unrelated examples from different domains.
21Format: original explanation + "For example, ..."
22Output ONLY the rewrite with example, nothing else.""",2324"Concise":"""You are an expert educational content rewriter.
25Rewrite the text using fewer words while keeping the same meaning.
26Remove redundancy and filler phrases.
27Do not remove important information.
28Output ONLY the shorter rewrite, nothing else.""",2930"Step by Step":"""You are an expert educational content rewriter.
31Break down HOW THIS CONCEPT WORKS into clear numbered steps.
32Each step must explain part of the mechanism described in the original text.
33Do NOT explain history. Do NOT add information not in the original text.
34Format strictly as:
351. [first part of the mechanism]
362. [second part]
373. [third part]
38Output ONLY the numbered steps, nothing else.""",3940"Add Analogy":"""You are an expert educational content rewriter.
41Rewrite the text and add a real-world analogy that makes the concept concrete.
42The analogy must map clearly to the concept in the original text.
43Explain why the analogy applies.
44Output ONLY the rewrite with analogy, nothing else.""",45}4647 system = mode_instructions.get(mode, mode_instructions["Default"])48 prompt =f"<|system|>\n{system}\n<|user|>\nText: {text}\n<|assistant|>\n"4950 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)5152with torch.no_grad():53 outputs = model.generate(54**inputs,55 max_new_tokens=max_new_tokens,56 temperature=0.7,57 top_p=0.95,58 top_k=50,59 do_sample=True,60 repetition_penalty=1.3,61 pad_token_id=tokenizer.eos_token_id,62 eos_token_id=tokenizer.eos_token_id,63)6465 new_tokens = outputs[0][inputs['input_ids'].shape[1]:]66return tokenizer.decode(new_tokens, skip_special_tokens=True).strip()676869# Example usage70text ="""Backpropagation computes the gradient of the loss function
71with respect to the weights of the network by applying the chain rule
72of calculus iteratively through each layer."""7374for mode in["Default","Simpler","Concise","Step by Step","Add Analogy"]:75 rewrite = generate_rewrite(model, tokenizer, text, mode)76print(f"\n[{mode}]\n{rewrite}")
Each mode has a dedicated system prompt that specifies the rewriting objective, constraints, and output format. Using the correct system prompt is essential for good results.
Future Work
The following improvements are planned for subsequent iterations:
Regenerate Simpler and Add Example training pairs with stricter domain-specificity and jargon constraints, then retrain
Upgrade base model to 7B for improved instruction following across all modes
Expand training dataset to 2,000+ examples for better generalisation
Add audience suitability scoring — a formula-based 1-10 score indicating the accessibility level of any rewrite
Mode-specific LoRA adapters — separate adapter per mode for higher per-mode quality at the cost of additional training time
Citation
If you use this model in your research or projects, please cite: