PACT - Personalised AI Coding Tutor
This model is a fine-tuned version of Qwen 2.5 7B Instruct, designed to act as a Socratic coding tutor for Python programming.
Model Description
PACT (Personalised AI Coding Tutor) is trained to:
- Provide guiding hints rather than direct solutions
- Ask Socratic questions to help students discover answers themselves
- Identify errors without revealing the fix
- Be encouraging and supportive in tone
Training Details
- Base model: Qwen/Qwen2.5-7B-Instruct
- Method: QLoRA (4-bit quantization with LoRA rank-16 adapters)
- Dataset: 227 synthetic examples of coding errors with Socratic hints
- Training: 3 epochs, batch size 16, learning rate 2e-4
- Hardware: NVIDIA RTX 4090 (24GB VRAM)
- Framework: HuggingFace Transformers + PEFT + TRL
Dataset Creation Process
The training dataset was generated through:
- Sampling LeetCode problems (Easy/Medium/Hard)
- Using Claude Sonnet 4.5 to generate realistic student errors
- Validating with GPT-5.2 to ensure quality (79.1% pass rate)
- Formatting for Qwen 2.5 Instruct chat template
Dataset Error types include:
- Logic errors (48.5%)
- Edge case failures (19.4%)
- Off-by-one errors (18.5%)
- Missing base cases (7.5%)
- Wrong algorithms (3.5%)
The model will be evaluated on:
- Code Leakage Rate (CLR): Percentage of responses containing executable code (target: <5%)
- Guiding Question Rate (GQR): Percentage using Socratic questions (target: >70%)
- Direct Answer Rate (DAR): Percentage revealing solutions directly (target: <10%)
- Error Identification Accuracy (EIA): Correctly identifying the actual bug (target: >85%)
- Factual Correctness Rate (FCR): Technical accuracy of hints (target: >95%)
Usage
Basic Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"AndreiSobo/pact-qwen-tutor",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("AndreiSobo/pact-qwen-tutor")
# Example conversation
messages = [
{
"role": "system",
"content": "You are PACT, a Socratic Python coding tutor. Help students learn through guided questions and hints, not direct answers."
},
{
"role": "user",
"content": """Problem: Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers that add up to target.
My code:
```python
def twoSum(nums, target):
for i in range(len(nums)):
for j in range(len(nums)):
if nums[i] + nums[j] == target:
return [i, j]
```
I'm getting wrong answers for some test cases. Can you help me understand what's wrong?"""
}
]
# Generate response
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=200,
temperature=0.7,
do_sample=True,
top_p=0.9
)
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print(response)
Expected Response Style
The model will provide Socratic guidance like:
"Let's think about what happens when your loops run. When
i=0andj=0, what values are you comparing? Is it valid for an element to be paired with itself in this problem? Consider what the problem statement says about using the same element twice."
Rather than directly stating:
❌ "Change
range(len(nums))torange(i+1, len(nums))in the inner loop."
Intended Use
This model is designed for educational purposes, specifically to:
- Help students learn Python programming through guided discovery
- Assist in debugging common coding errors
- Encourage critical thinking and problem-solving skills
- Provide formative feedback on coding assignments
Not intended for:
- Production code generation
- Automated grading systems
- Replacing human instruction entirely
Limitations
- Language: Focused on Python; other languages not tested
- Problem domains: Optimized for algorithmic/LeetCode-style problems
- Error types: Trained on common student mistakes; may not handle edge cases well
- Context length: Limited to 2048 tokens per conversation
- Socratic quality: May occasionally be too direct or too vague
Ethical Considerations
- Students should be encouraged to attempt problems independently before seeking hints
- Educators should review model responses for accuracy before sharing with students
- This tool supplements, not replaces, traditional learning resources
Citation
If you use this model in your research or educational materials, please cite:
@misc{pact2026,
author = {Sobo, Andrei},
title = {PACT: Personalised AI Coding Tutor - A Socratic Fine-Tuned Qwen 2.5 Model},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/AndreiSobo/pact-qwen-tutor}
}
Acknowledgements
- Base Model: Qwen Team at Alibaba Cloud
- Synthetic Data Generation: Anthropic Claude Sonnet 4.5, OpenAI GPT-5.2
- Source Dataset: LeetCode problems (newfacade/LeetCodeDataset)
- Framework: HuggingFace Transformers, PEFT, TRL, bitsandbytes
License
This model inherits the Apache 2.0 license from Qwen 2.5 7B Instruct.
Contact
For questions, issues, or feedback:
- GitHub: [https://github.com/AndreiSobo/Personal-Coding-Tutor]
- Email: [soboandrei@gmail.com]
- HuggingFace: @AndreiSobo
- Downloads last month
- 11