CoolFace
Modelpublic

HattoriHanzo1/Qapricorn-4B-GGUF

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes95downloads
Model Card

Qapricorn-4B πŸβš”οΈ

"Nusquam est qui ubique est" β€” Kto jest wszΔ™dzie, nie jest nigdzie. Qapricorn jest tam gdzie trzeba β€” reasoning, nie encyklopedia.

Model Description

Qapricorn-4B is a fine-tuned version of Qwen3-4B with enhanced reasoning capabilities, Polish language support, and coding skills. The model was trained using QLoRA with a carefully curated multilingual dataset combining mathematical reasoning, coding tasks, and Polish language data.

The name Qapricorn comes from:

  • β€”Qa β€” Qapla' (Klingon for "Success")
  • β€”pricorn β€” Capricorn (perseverance, patience)

A model built with persistence, on a free GPU, step by step. πŸ’ͺ


Key Features

  • β€”πŸ§  Native `<think>` reasoning β€” inherited from Qwen3-4B and strengthened through training
  • β€”πŸ‡΅πŸ‡± Polish language support β€” thinks and responds in Polish when prompted in Polish
  • β€”πŸ’» Coding capability β€” Python, algorithms, data structures
  • β€”πŸ”’ Mathematical reasoning β€” step-by-step problem solving
  • β€”πŸŒ Multilingual β€” seamlessly switches between Polish and English based on prompt language

Reasoning Example

Prompt: StaΕ‚a Kaprekara to liczba 6174. Zastosuj algorytm dla liczby 1234.

<think>
Algorytm Kaprekara dziaΕ‚a tak: 
- Iteracja 1: 4321 - 1234 = 3087
- Iteracja 2: 8730 - 0378 = 8352  
- Iteracja 3: 8532 - 2358 = 6174 βœ“

Warto też wspomnieć że dla liczb trzycyfrowych analogiczna stała to 495...
</think>

Algorytm Kaprekara dla 1234:
- Iteracja 1: 4321 - 1234 = 3087
- Iteracja 2: 8730 - 0378 = 8352
- Iteracja 3: 8532 - 2358 = **6174** βœ“

The model correctly solved the Kaprekar constant problem AND independently noted the analogous constant (495) for 3-digit numbers β€” demonstrating genuine reasoning, not pattern matching.


Training Details

Base Model

  • β€”Model: unsloth/Qwen3-4B-unsloth-bnb-4bit
  • β€”Method: QLoRA (4-bit quantization)
  • β€”LoRA rank: r=16, alpha=32
  • β€”Target modules: qproj, kproj, vproj, oproj, gateproj, upproj, down_proj
  • β€”Trainable parameters: 33M / 4B (0.81%)

Training Infrastructure

  • β€”Platform: Kaggle (free tier) β€” 1x Tesla T4 16GB
  • β€”Framework: Unsloth 2026.3.3 + TRL
  • β€”Total steps: 1500
  • β€”Dataset coverage: ~33% of training data

Training Phases

PhaseStepsLRSchedulerNotes
10β†’1002e-4linearInitial learning
2100β†’3005e-5cosineMain training
3300β†’6005e-5cosineStabilization
4600β†’11001e-5cosineFine-tuning
51100β†’15005e-6cosineFinal polish

Loss Progression

Phase 1: ~1.8 β†’ 1.1  (rapid learning)
Phase 2: avg 0.755    (best convergence)
Phase 3: avg 1.114    (new cosine cycle)
Phase 4: avg 1.076    (gradual improvement)
Phase 5: avg 1.046    (final polish, min=0.600)

Dataset

Mixed multilingual dataset (~48k records, 269MB):

SourceRecordsType
Math Reasoning PL25,357Math + <think> CoT
Claude Opus 4.5250Coding + <think>
Polish Language CSV7,799Polish language
Synthia-Coder v1.514,982Coding instructions
Total48,388

All datasets were converted to ChatML format with <think> blocks preserved.


Available Formats

FileSizeRecommended for
qapricorn_f16.gguf~7.5 GBFurther quantization
qapricorn_Q8_0.gguf~4.3 GBBest quality, 6GB+ VRAM
qapricorn_Q6_K.gguf~3.3 GBGreat quality, 4GB+ VRAM
qapricorn_Q4_K_M.gguf~2.5 GBBest speed/quality ratio

Usage

llama.cpp

bash
./llama-cli \
  -m qapricorn_Q4_K_M.gguf \
  -p "Czym jest ciΔ…g geometryczny? WyjaΕ›nij krok po kroku." \
  --temp 0.6 \
  --top-p 0.95 \
  -n 512

llama-server

bash
./llama-server \
  -m qapricorn_Q4_K_M.gguf \
  --port 8080 \
  --ctx-size 4096 \
  --temp 0.6

Python (transformers)

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("HattoriHanzo1/Qapricorn-4B-merged-bf16")
tokenizer = AutoTokenizer.from_pretrained("HattoriHanzo1/Qapricorn-4B-merged-bf16")

messages = [
    {"role": "system", "content": "JesteΕ› pomocnym asystentem AI."},
    {"role": "user", "content": "WyjaΕ›nij algorytm Kaprekara."}
]

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=512, temperature=0.6, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Thinking Mode

Qapricorn inherits Qwen3's thinking toggle:

/think    β€” enable thinking (default)
/no_think β€” disable thinking for faster responses

Benchmarks (Qualitative)

TaskResult
Kaprekar constant (4B model)βœ… Solved + found 3-digit analogy
Polish mathematical reasoningβœ… Step-by-step with verification
Linked list reversal (Python)βœ… With edge cases
Lateral thinking puzzlesβœ… Level 3/4 reasoning
Sentiment analysis (Polish)βœ… With justification
Multilingual switchingβœ… Auto-detects prompt language

Limitations

  • β€”Biology/natural science responses may contain occasional hallucinations (dataset gap)
  • β€”4B parameter limit β€” complex multi-step reasoning may be less reliable than larger models
  • β€”Training covered ~33% of available dataset β€” further training possible

Related Repositories


License

Apache 2.0 β€” same as base model Qwen3-4B.


Built on a free GPU, on a Sunday, step by step. "Heghlu'meH QaQ jajvam" β€” Today is a good day to train. βš”οΈ