Instructions to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3.5-mini-instruct") model = PeftModel.from_pretrained(base_model, "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor") - Transformers
How to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor
- SGLang
How to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor with Docker Model Runner:
docker model run hf.co/Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor
Model Card for Phi-3.5-mini-Socratic-Coding-Tutor
Phi-3.5-mini-Socratic-Coding-Tutor is a fine-tuned LoRA adapter built on top of microsoft/Phi-3.5-mini-instruct using 8-bit QLoRA. It is designed to act as an expert Socratic programming tutor following the PACT (Pedagogical Alignment for Coding Tutors) methodology.
Rather than outputting complete copy-paste solutions immediately, the model engages developers interactively—probing conceptual understanding, asking targeted debugging questions, highlighting edge cases, and guiding learners to discover and resolve bugs on their own.
Model Details
Model Description
- Developed by: Kami0867
- Model type: 8-bit QLoRA PEFT Adapter for Causal Language Modeling
- Base Model:
microsoft/Phi-3.5-mini-instruct - Language(s) (NLP): English
- License: MIT
- Finetuned from model:
microsoft/Phi-3.5-mini-instruct - Training Dataset:
AndreiSobo/PACT-Socratic-Coding-Tutor - Target Hardware: Consumer GPUs with 8GB VRAM (e.g., RTX 5060 Ti / RTX 4060)
Model Sources
- Hugging Face Hub Repository: Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor
- Base Architecture Paper: Phi-3 Technical Report
Uses
Direct Use
- Interactive Coding Pedagogy: Guiding students and software engineers through algorithmic challenges (data structures, edge-case analysis, LeetCode style problems).
- Interactive Debugging: Guiding developers to reason through logic bugs, off-by-one errors, and boundary condition failures via targeted questions.
- Codebase Exploration: Providing guided hints and architectural breakdowns when exploring repositories.
Socratic Tutoring Behavioral Guardrails (PACT)
- Never provide complete code solutions directly unless explicitly requested after multiple repeated failed attempts.
- Probe boundary conditions and edge cases (e.g., empty arrays, single-item collections, integer overflow, pointer nullability).
- Decompose complex problems into smaller, manageable milestones.
- Encourage independent reasoning by acknowledging partial progress before pointing out flaws.
Out-of-Scope Use
- Zero-shot complete script generation or unguided code dump generation.
- Generating malicious exploit payloads, bypassing security constraints, or unverified safety-critical code deployment.
How to Get Started with the Model
GitHub: https://github.com/ChiragPrasad2006/Assist-stu
You can load and query the model directly using Hugging Face transformers and peft in 8-bit quantization:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
adapter_id = "Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor"
base_model_id = "microsoft/Phi-3.5-mini-instruct"
# 1. Load Tokenizer
tokenizer = AutoTokenizer.from_pretrained(adapter_id, trust_remote_code=True)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
# 2. Configure 8-bit Quantization (fits in ~3.8 GB VRAM)
bnb_config = BitsAndBytesConfig(
load_in_8bit=True,
)
# 3. Load Quantized Base Model
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map={"": 0},
torch_dtype=torch.float16,
trust_remote_code=True,
attn_implementation="eager",
)
# 4. Attach Socratic LoRA Adapter
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
# 5. Format Socratic Chat Prompt
messages = [
{
"role": "system",
"content": (
"You are an expert Socratic Coding Tutor. Your goal is to help developers discover "
"bugs, design architectures, and reason through code independently. Never generate the "
"complete solution directly unless explicitly requested after multiple failed attempts. "
"Provide precise hints, highlight conceptual pitfalls, and ask targeted guiding questions."
),
},
{
"role": "user",
"content": "Why is my binary search getting stuck in an infinite loop when the target is not in the array?",
},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda:0")
# 6. Generate Response
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.7,
top_p=0.9,
do_sample=True,
use_cache=False,
)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(response)
Training Details
Training Data
- Dataset:
AndreiSobo/PACT-Socratic-Coding-Tutor - Format: Multi-turn conversational dialogues demonstrating Socratic interaction patterns, progressive hints, and guided queries.
- Max Sequence Length: 1024 tokens
Training Procedure
Fine-tuned using Supervised Fine-Tuning (SFT) with QLoRA via Hugging Face peft and trl.
LoRA Hyperparameters
- LoRA Rank ($r$): 16
- LoRA Alpha ($\alpha$): 32
- LoRA Dropout: 0.05
- Target Modules:
["qkv_proj", "o_proj", "gate_up_proj", "down_proj"] - Bias:
"none" - Task Type:
CAUSAL_LM
Training Hyperparameters
- Epochs: 4.0
- Per-Device Batch Size: 1
- Gradient Accumulation Steps: 8
- Effective Batch Size: 8
- Learning Rate: $2 \times 10^{-4}$
- Learning Rate Schedule: Cosine decay with warmup
- Warmup Ratio: 0.05
- Weight Decay: 0.01
- Optimizer:
paged_adamw_8bit - Quantization: 8-bit normal float via
bitsandbytes - Precision: FP16 mixed precision
Evaluation
Evaluation Metrics
Evaluated on a held-out test split of the PACT Socratic Coding dataset:
| Metric | Result |
|---|---|
| Evaluation Loss | 0.564 |
| Token Accuracy | 85.48% |
| Perplexity | 1.758 |
Qualitative Findings
- Consistent avoidance of raw copy-paste code dumps.
- High accuracy in pinpointing algorithmic pitfalls (recursion base cases, index off-by-one, null references).
- Concise and interactive conversational style.
Technical Specifications & Environmental Impact
- Hardware Used: Single NVIDIA GeForce RTX 5060 Ti (8GB VRAM)
- Peak VRAM During Training: ~6.2 GB
- Peak VRAM During Inference: ~3.84 GB
- Compute Provider: Local workstation
- Estimated Carbon: < 0.15 kg CO2eq for 4 epochs
- Downloads last month
- 24
Model tree for Kami0867/Phi-3.5-mini-Socratic-Coding-Tutor
Base model
microsoft/Phi-3.5-mini-instruct