Downloads · 30 days
25
20% of all-time downloads
AndreiSobo/pact-qwen-tutor
pact-qwen-tutor is a text generation model from AndreiSobo. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
This model is a fine-tuned version of Qwen 2.5 7B Instruct, designed to act as a Socratic coding tutor for Python programming.
Downloads · 30 days
25
20% of all-time downloads
All-time downloads
124
Public
Parameters
7.6B
15.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors15.2 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of Qwen 2.5 7B Instruct, designed to act as a Socratic coding tutor for Python programming.
PACT (Personalised AI Coding Tutor) is trained to:
The training dataset was generated through:
Dataset Error types include:
The model will be evaluated on:
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 (matching training format)
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.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [2,1]
Constraints:
- 2 <= nums.length <= 104
- -109 <= nums[i] <= 109
- Only one valid answer exists.
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]
```
It runs but gives wrong output for some test cases.
Can you give me a hint?"""
}
]
# 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)
Alternatively, using notebooks can separate setup and inference
Setup:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
quant_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True
)
model = AutoModelForCausalLM.from_pretrained(
"AndreiSobo/pact-qwen-tutor",
quantization_config=quant_config,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("AndreiSobo/pact-qwen-tutor")
Inference:
# Importantly, messages must have the same structure as the JSONL object the model was trained on
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.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [2,1]
Constraints:
- 2 <= nums.length <= 104
- -109 <= nums[i] <= 109
- Only one valid answer exists.
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]
```
It runs but gives wrong output for some test cases.
Can you give me a hint?"""
}
]
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)
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print(response)
The model will respond with Socratic hints like:
For best results, user queries must have the same structure as its training data:
Problem: [Name]This model is designed for educational purposes, specifically to:
Not intended for:
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}
}
This model inherits the Apache 2.0 license from Qwen 2.5 7B Instruct.
For questions, issues, or feedback: