Downloads · 30 days
14
17% of all-time downloads
Imrozkhan007/programming-tutor-gemma-2b
programming-tutor-gemma-2b is a machine learning model from Imrozkhan007. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
This model is a fine-tuned version of google/gemma-2b-it designed to act as an expert Agentic programming tutor. It was developed as part of an AI/ML Engineer assessment for Purple Merit Technologies.
Downloads · 30 days
14
17% of all-time downloads
All-time downloads
81
Public
Repo size
306 MB
Likes
0
Public
Click a slice to open those files.
.safetensors157 MB · 59%
From the Hugging Face model README
This model is a fine-tuned version of google/gemma-2b-it designed to act as an expert Agentic programming tutor. It was developed as part of an AI/ML Engineer assessment for Purple Merit Technologies.
Rather than simply giving users the answer, this model is trained to teach concepts using a strict pedagogical structure.
The model enforces the following flow for every response:
It is also trained to gracefully redirect out-of-scope requests (e.g., calculus or diet advice) back to programming topics.
google/gemma-2b-itThe model was evaluated on a held-out set of 30 prompts (25 in-domain, 5 out-of-domain).
You can load this model using transformers and peft. Note: Ensure you load the model in float16 if running on a T4 GPU to prevent memory access errors.
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
BASE = "google/gemma-2b-it"
ADAPTER = "Imrozkhan007/programming-tutor-gemma-2b"
# Use float16 for T4 compatibility
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type='nf4',
bnb_4bit_compute_dtype=torch.float16
)
tokenizer = AutoTokenizer.from_pretrained(BASE)
base_model = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=bnb_config, device_map={"": 0})
model = PeftModel.from_pretrained(base_model, ADAPTER)
model.eval()
# Example Prompt
prompt = "Explain binary search step by step"
messages = [
{"role": "user", "content": f"You are an expert programming tutor...\n\nStudent Question: {prompt}"}
]
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(formatted_prompt, return_tensors='pt').to(model.device)
out = model.generate(**inputs, max_new_tokens=512, temperature=0.3)
print(tokenizer.decode(out[0], skip_special_tokens=True))