Downloads · 30 days
267
15% of all-time downloads
jaigouk/qwen3-4b-german-teacher-v1
qwen3-4b-german-teacher-v1 is a text generation model from jaigouk. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
A finetuned Qwen3-4B model specialized for German language teaching at A1-B1 CEFR levels. This model excels at:
Downloads · 30 days
267
15% of all-time downloads
All-time downloads
1.8K
Public
Parameters
4B
10.6 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors8 GB · 76%
From the Hugging Face model README
A finetuned Qwen3-4B model specialized for German language teaching at A1-B1 CEFR levels. This model excels at:
| Property | Value |
|---|---|
| Base Model | Qwen/Qwen3-4B |
| Parameters | 4B |
| Training Method | SFT (Supervised Fine-Tuning) with LoRA |
| LoRA Rank | 32 |
| LoRA Alpha | 64 |
| Training Epochs | 2 |
| Learning Rate | 2e-4 |
| Context Length | 4096 tokens |
Evaluated on a custom German grammar benchmark:
| Metric | Score | Description |
|---|---|---|
| CoLA MCC | 0.721 | Matthews Correlation Coefficient for grammaticality judgment |
| GEC F1 | 0.349 | Macro F1 for grammar error correction |
| Generation Quality | 3.99/5.0 | Human-evaluated response quality |
| Overall Score | 0.633 | Weighted composite score |
Comparison with SmolLM3-German-V6 (3B parameters, Q4 quantized):
| Metric | Qwen3 German Teacher (4B) | SmolLM3-German-V6 (3B) | Improvement |
|---|---|---|---|
| CoLA MCC | 0.721 | 0.624 | +15.5% |
| GEC F1 | 0.349 | 0.145 | +140.7% |
| Generation Quality | 3.99 | 3.19 | +25.1% |
| Overall Score | 0.633 | 0.492 | +28.7% |
Key advantages of this model:
The model was trained on ~9,000 examples with the following composition:
| Category | Percentage | Purpose |
|---|---|---|
| Grammar Correction | 35% | Error correction patterns |
| Grammar Judgment | 25% | CoLA-style "Is this correct?" examples |
| Structured Teaching | 20% | Verb conjugations, grammar explanations |
| General Conversation | 20% | Fluency preservation |
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("jaigouk/qwen3-4b-german-teacher")
tokenizer = AutoTokenizer.from_pretrained("jaigouk/qwen3-4b-german-teacher")
messages = [
{"role": "system", "content": "Du bist ein freundlicher Deutschlehrer für A1-B1 Lernende."},
{"role": "user", "content": "Is this German sentence correct? 'Ich habe nach Berlin gefahren.'"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Download the GGUF file: qwen3-german-teacher-Q4_K_M.gguf
Create a Modelfile:
FROM ./qwen3-german-teacher-Q4_K_M.gguf
TEMPLATE """{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}<|im_start|>user
{{ .Prompt }}<|im_end|>
<|im_start|>assistant
<think>
</think>
{{ .Response }}<|im_end|>
"""
PARAMETER stop "<|im_end|>"
PARAMETER stop "<|endoftext|>"
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER num_ctx 4096
SYSTEM """Du bist ein freundlicher Deutschlehrer für A1-B1 Lernende. Erkläre Grammatikfehler klar und einfach. Beurteile grammatische Korrektheit sorgfältig."""
ollama create qwen3-german-teacher -f Modelfile
ollama run qwen3-german-teacher "Is 'Ich habe nach Berlin gefahren' correct?"
User: Is this German sentence grammatically correct? "Ich habe nach Berlin gefahren."
Model: No, this sentence is incorrect. The verb "fahren" describes movement from one place to another, so it requires "sein" as the auxiliary verb, not "haben".
Correct: "Ich bin nach Berlin gefahren."
User: Explain when to use "sein" vs "haben" in the Perfekt tense.
Model: In German, most verbs use "haben" in the Perfekt tense, but verbs that describe:
These verbs use "sein" instead. For example:
User: Conjugate "sein" in present tense.
Model: Here is the conjugation of "sein" (to be) in present tense:
| Person | Conjugation |
|---|---|
| ich | bin |
| du | bist |
| er/sie/es | ist |
| wir | sind |
| ihr | seid |
| sie/Sie | sind |
This model was developed using insights from recent research on instruction-tuning and continual learning:
Based on the GRAPE paper (Feb 2025):
"Instructions paired with responses sampled from other LLMs are often out of the distribution of the target model, which can lead to diminishing returns and even hurt performance"
Key insight: Rather than using responses generated by larger models (GPT-4, Claude), we curated training examples that align with Qwen3's natural output distribution. This prevents the model from learning patterns it cannot reliably reproduce.
The breakthrough in V4 was adding 25% explicit grammaticality judgment examples. This teaches the model to reason about correctness rather than just generate correct text:
User: Ist der Satz grammatisch korrekt? "Der Frau ist schön."
Assistant: Nein, der Satz ist nicht korrekt.
Fehler: "Der" ist maskulin, aber "Frau" ist feminin.
Korrektur: "Die Frau ist schön."
From arXiv:2502.11756 on Fisher Information computation:
These insights from our earlier SmolLM3 experiments (V5/V6 with Elastic Weight Consolidation) informed our dataset composition decisions for Qwen3-V4.
This project was inspired by the 3-stage finetuning approach described in MiroThinker (arXiv:2511.11793):
Our training script design followed the MiroThinker paper's architecture, including:
However, this model uses only SFT because our experiments with preference optimization showed a fundamental trade-off:
| Model | CoLA MCC | GEC F1 | Generation | Overall | Status |
|---|---|---|---|---|---|
| V6 SFT (Baseline) | 0.624 | 0.191 | 3.29 | 0.516 | Reference |
| V8 (DPO) | 0.583 | 0.063 | 3.63 | 0.473 | -8% overall |
| V9 (SimPO) | 0.567 | 0.073 | 3.72 | 0.479 | -7% overall |
Key findings:
For grammar teaching, accuracy is more important than fluency, so we stayed with pure SFT. The V4 dataset composition (25% CoLA-style judgment examples) proved more effective than preference optimization for our metrics.
Configuration based on MiroThinker recommendations for multi-stage training:
Base Model: Qwen/Qwen3-4B
LoRA Configuration:
- Rank (r): 32
- Alpha: 64
- Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
- Dropout: 0
Training Configuration:
- Epochs: 2
- Learning Rate: 2e-4 (linear decay)
- Batch Size: 2 (effective: 8 with gradient accumulation)
- Warmup: 10%
- Precision: BF16
- Optimizer: AdamW 8-bit
The SFT stage trains on ~9,000 curated examples covering grammar judgment, error correction, and teaching explanations.
After SFT training, the model goes through:
LoRA adapters are merged into the base model:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B")
model = PeftModel.from_pretrained(base_model, "lora_adapters/")
model = model.merge_and_unload()
model.save_pretrained("merged_model/", safe_serialization=True)
For efficient local inference:
python convert_hf_to_gguf.py merged_model/ --outtype bf16 --outfile model-bf16.gguf
llama-quantize model-bf16.gguf model-Q4_K_M.gguf Q4_K_M
The Q4_K_M quantization reduces model size from ~8GB to 2.5GB while maintaining high quality.
If you use this model, please cite:
@misc{qwen3-4b-german-teacher-2025,
author = {Jaigouk Kim},
title = {Qwen3-4B German Teacher: A Finetuned Model for German Grammar Teaching},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/jaigouk/qwen3-4b-german-teacher}
}
This model is released under the Apache 2.0 license, following the base Qwen3 model license.