Instructions to use CanisAI/teach-math-qwen3-4b-2507-r1-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use CanisAI/teach-math-qwen3-4b-2507-r1-merged with PEFT:
Task type is invalid.
- Transformers
How to use CanisAI/teach-math-qwen3-4b-2507-r1-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CanisAI/teach-math-qwen3-4b-2507-r1-merged") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("CanisAI/teach-math-qwen3-4b-2507-r1-merged") model = AutoModelForCausalLM.from_pretrained("CanisAI/teach-math-qwen3-4b-2507-r1-merged") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use CanisAI/teach-math-qwen3-4b-2507-r1-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CanisAI/teach-math-qwen3-4b-2507-r1-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CanisAI/teach-math-qwen3-4b-2507-r1-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CanisAI/teach-math-qwen3-4b-2507-r1-merged
- SGLang
How to use CanisAI/teach-math-qwen3-4b-2507-r1-merged 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 "CanisAI/teach-math-qwen3-4b-2507-r1-merged" \ --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": "CanisAI/teach-math-qwen3-4b-2507-r1-merged", "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 "CanisAI/teach-math-qwen3-4b-2507-r1-merged" \ --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": "CanisAI/teach-math-qwen3-4b-2507-r1-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CanisAI/teach-math-qwen3-4b-2507-r1-merged with Docker Model Runner:
docker model run hf.co/CanisAI/teach-math-qwen3-4b-2507-r1-merged
Canis.teach — Qwen3‑4B Instruct (Math) — Merged
Merged full model (LoRA adapters applied to the base), ready for direct use with Transformers.
- Base: Qwen/Qwen3-4B-Instruct-2507
- Release: CanisAI/teach-math-qwen3-4b-2507-r1-merged
- Project: Canis.teach, Learning that fits.
- Tags: canis-teach, qwen3, education, lora-merged, transformers
What is this?
This repository contains a merged checkpoint: the LoRA adapters fine‑tuned on Math tutoring dialogues have been merged into the base model (Qwen/Qwen3‑4B‑Instruct‑2507). This allows you to load and run the model directly with Transformers (no PEFT merge step at runtime).
For lightweight adapters or Ollama-friendly quantized builds, see the “Related” section.
Quick usage (Transformers)
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "CanisAI/teach-math-qwen3-4b-2507-r1-merged"
tok = AutoTokenizer.from_pretrained(repo, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(
repo,
device_map="auto",
torch_dtype="auto"
)
prompt = "Explain how to solve 2x + 1 = 5 step by step."
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=256, temperature=0.7, top_p=0.8, top_k=20)
print(tok.decode(out[0], skip_special_tokens=True))
Recommended decoding (for instruct-style usage):
- temperature ≈ 0.7
- top_p ≈ 0.8
- top_k ≈ 20 Adjust to your needs.
Intended use
- Subject‑aware tutoring for Math with didactic, step‑by‑step responses.
- Suitable for educational prototypes, demonstrations, and research.
- Built to “teach, not just answer”: stepwise hints, clarity, and rubric‑aligned structure.
Safety and limitations
- Human oversight is required. The model may hallucinate or oversimplify.
- For fact‑heavy tasks, consider Retrieval‑Augmented Generation (RAG) with curriculum sources.
- Follow data privacy and compliance rules in your environment (e.g., school policies).
Training summary
- Base model: Qwen/Qwen3-4B-Instruct-2507
- Method: Supervised fine‑tuning with LoRA (Unsloth + TRL/PEFT), then merged to full weights
- Data: Subject‑specific tutoring dialogues generated/curated via Canis.lab
- Goal: Improve clarity, hints, and step-by-step pedagogy for Math
Note: Exact hyperparameters and logs are provided in the LoRA training pipeline (if published) or available on request.
Related
- LoRA adapters (lightweight):
- CanisAI/teach-math-qwen3-4b-2507-r1
- Quantized GGUF for Ollama/llama.cpp:
- CanisAI/teach-math-qwen3-4b-2507-r1-gguf
- Base model:
- Qwen/Qwen3-4B-Instruct-2507
License
- Inherits the base model’s license. Review the base model terms before use.
- Dataset licensing and any third‑party assets should be respected accordingly.
Acknowledgments
- Qwen3 by Qwen team
- Unsloth, TRL, PEFT, and Transformers for training/serving
- Educators and contributors supporting Canis.teach
Learning that fits.
- Downloads last month
- -