Qwen3 - Socratic
Using Large Language Models (LLMs) in education presents unique challenges. Typically, LLMs are designed to provide direct answers to questions, which can hinder students' critical thinking and self-discovery skills. To address this, we focus on fine-tuning LLMs to facilitate Socratic interactions. Instead of giving straightforward answers, these models guide students to explore and find the answers themselves. We achieve this through Supervised Fine-Tuning (SFT) Qwen3:4b with a LoRA adapter over 754 successiful socratic conversations (or 7384 conversation turns) generated with socratic-bench.
SFT traces available at socratic-bench/datasets/positive-traces.
Usage
You need to install unsloth (see Docs).
import torch
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="eurecom-ds/qwen3-4b-socratic",
dtype=torch.bfloat16,
max_seq_length=1024,
load_in_4bit=False,
load_in_8bit=False,
)
model = FastLanguageModel.for_inference(model)
# โ
Patch apply_chat_template to default enable_thinking=False
if hasattr(tokenizer, "apply_chat_template"):
original_fn = tokenizer.apply_chat_template
def patched_apply_chat_template(conversation, **kwargs):
kwargs.setdefault("enable_thinking", False)
return original_fn(conversation, **kwargs)
tokenizer.apply_chat_template = patched_apply_chat_template
messages = [
{"role": "user", "content": "why is the sky blue?"},
]
raw_prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
inputs = tokenizer([raw_prompt], return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs, max_new_tokens=128, do_sample=True, temperature=0.3
)
generation = outputs[0, len(inputs['input_ids'][0]):]
decoded = tokenizer.decode(generation, skip_special_tokens=True)
print(decoded)
# Have you ever looked at the sky on a clear day and wondered why it appears blue? What do you think might be happening with the light from the sun that makes the sky look that way?
- Downloads last month
- 39
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
๐
Ask for provider support