Instructions to use thealper2/nanochat-turkish with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thealper2/nanochat-turkish with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thealper2/nanochat-turkish", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("thealper2/nanochat-turkish", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thealper2/nanochat-turkish with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thealper2/nanochat-turkish" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thealper2/nanochat-turkish", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thealper2/nanochat-turkish
- SGLang
How to use thealper2/nanochat-turkish 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 "thealper2/nanochat-turkish" \ --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": "thealper2/nanochat-turkish", "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 "thealper2/nanochat-turkish" \ --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": "thealper2/nanochat-turkish", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thealper2/nanochat-turkish with Docker Model Runner:
docker model run hf.co/thealper2/nanochat-turkish
nanochat-turkish
A decoder-only GPT language model for Turkish, trained entirely from scratch (random initialization, no pretrained weights) using the NanoChat training stack and exported to a self-contained 🤗 Transformers model.
⚠️ This is a small research/education model trained on a single instruction dataset. It is not a production assistant. See Limitations.
Overview
- Objective: causal (next-token) language modeling, supervised on the assistant turns of Turkish instruction–response pairs.
- Language: Turkish (
tr). - Architecture: NanoChat GPT — a modern decoder-only transformer (rotary embeddings, QK-norm, ReLU² MLP, value/residual embeddings, logit soft-capping).
- Training data:
merve/turkish_instructions. - Total parameters: 75.5M (75,497,706).
- Loads with:
AutoModelForCausalLM.from_pretrained(..., trust_remote_code=True)— no NanoChat dependency at inference time.
Architecture
This is a decoder-only transformer following the NanoChat design:
| Component | Choice |
|---|---|
Layers (n_layer) |
8 |
Model dim (n_embd) |
512 |
| Attention heads | 4 (head dim 128) |
| KV heads | 4 |
| Context length | 1024 |
| Vocab size | 16,384 |
| Positional encoding | Rotary (RoPE), base 100000, no learned position embeddings |
| Normalization | Parameter-free RMSNorm (pre-norm blocks + QK-norm) |
| MLP | ReLU² (squared ReLU), 4× expansion |
| Embeddings | Untied token embedding / LM head |
| Value embeddings | Residual value embeddings on layers [1, 3, 5, 7] (input-gated) |
| Extra mixing | Per-layer residual & x0 gates, embedding "smear", mid-network "backout" |
| Logits | Soft-capped to ±15 via tanh |
| Attention impl. | PyTorch SDPA (portable), sliding-window pattern "L" |
| Bias terms | None |
Embedding layer. Token ids are embedded, RMS-normalized, and an embedding "smear" mixes a gated fraction of the previous token's embedding into each position (cheap bigram-like signal).
Attention. Queries/keys/values are projected without bias; rotary embeddings
encode relative position; queries and keys are RMS-normalized ("QK-norm") and
scaled by 1.2 for sharper attention. On value-embedding layers, an input-gated
residual value embedding is added to V.
Feed-forward network. A two-layer MLP with a squared-ReLU activation and 4× inner expansion.
Head. After a final RMSNorm, an untied linear LM head produces logits that
are soft-capped with 15 · tanh(logits / 15).
Tokenizer. A byte-level BPE tokenizer trained from scratch on the Turkish corpus (see Tokenizer).
Training Dataset
merve/turkish_instructions is an
Alpaca-style Turkish instruction dataset with talimat (instruction), giriş
(optional input) and çıktı (output) fields.
Preprocessing pipeline (see turkish_gpt/data.py):
- NFC Unicode normalization and control-character stripping (UTF-8 validated)
- horizontal-whitespace collapsing and blank-line trimming
- removal of rows with empty instruction/output
- length filtering (instruction ≤ 8000 chars, output ≤ 8000 chars)
- exact- and near-duplicate removal
- formatting into two-turn
user→assistantchat conversations
Resulting counts:
| Stat | Value |
|---|---|
| Source rows | 51563 |
| Exact duplicates removed | 0 |
| Near-duplicates removed | 0 |
| Empty output removed | 0 |
| Kept conversations | 51563 |
| Train / Val split | 50532 / 1031 |
Training Configuration
| Setting | Value |
|---|---|
| Objective | Causal LM, loss on assistant tokens only |
| Epochs | 4.0 |
| Optimizer | Muon (matrices) + AdamW (embeddings/scalars) — NanoChat MuonAdamW |
| Matrix LR (Muon) | 0.02 |
| Embedding / Unembedding LR (AdamW) | 0.2 / 0.004 |
| Scalar LR | 0.5 |
| Weight decay | 0.0 |
| LR schedule | Linear warmup → constant → linear warmdown |
| Warmup / warmdown ratio | 0.03 / 0.4 |
| Gradient clipping | 1.0 |
| Device batch size | 16 sequences |
| Effective batch | 16,384 tokens (grad-accum 1) |
| Max sequence length | 1024 |
| Optimizer steps | 988 |
| Precision | torch.bfloat16 |
| Seed | 42 |
Tokenizer
- Type: byte-level BPE (Hugging Face
tokenizers), fully Unicode-safe and reversible for any byte sequence (no out-of-vocabulary tokens). - Vocab size: 16,384 (including special tokens).
- Trained on: the Turkish training corpus described above.
- Special tokens:
<|bos|>,<|user_start|>,<|user_end|>,<|assistant_start|>,<|assistant_end|>(EOS),<|pad|>,<|unk|>(plus tool-call markers for schema compatibility). - Chat template: bundled, so
tokenizer.apply_chat_template(...)works.
Evaluation
Metrics on the held-out validation split (loss and perplexity are computed over supervised assistant tokens only):
| Metric | Value |
|---|---|
| Validation loss | 3.7131 |
| Validation perplexity | 40.98 |
| Best validation loss | 3.5664 |
Generation examples
1. Prompt: Merhaba, nasılsın?
Merhaba, nasılsın? Bloglarınız ve ilgi alanlardan bazılarını nasıl değerlendirirsiniz? Edin: Bana nasıl bakalım? C. Ne tür bir egzersiz yaparsınız? Cevap: Edin: Edin ve ne dedi? A. Bana nasıl yardım edebileceğimi düşünüyorsunuz? C. Tüyünüz ve dostlarınız nelerdi? A. B. Ne tür bir şey oldu? A. Bir gününüze ne tür bir şey var? B. Bir gün doğumuna ne kadar? C. Doğum günü? A. Bir gün ne tür bir egzersiz yaptı? B. Bu egzersizlerinizden en iyi şekilde yararlanabiliriz C. İyi bir rutin oluşturmak için ne tür bir egzersiz yapardınız?
2. Prompt: Türkiye'nin başkenti neresidir?
Beniks, Bots ve Chire olmak üzere iki yüzünde yüksek zirvesidir.
3. Prompt: Yapay zeka nedir? Kısaca açıkla.
Yapay zeka, insanların sorunları çözmeye ve sorunları çözmeye yardımcı olmak için tıbbi geçmişli bir AI asistanı olarak kullanılabilir. Bir yapay zeka asistanı, görüntü tanıma, doğal dil işleme ve karar verme için kullanılabilir. Örneğin, bir yapay zeka asistanı, tıbbi verileri analiz etmek veya tıbbi görüntüleme için kullanılabilir. AI asistanı, otonom olarak karar verme, görevleri gerçekleştiren sanal asistanları veya sanal asistanları gibi yapay zeka asistanları gibi sıradan görevleri otomatikleştirmek için kullanılabilir. Yapay zeka asistanları, tıbbi görüntüleme, hastalıkları tespit etmek ve maliyetleri azaltmak için kullanılabilir ve maliyetleri azaltmak için kullanılabilir. Yapay zeka asistanı, insan müdahalesi olmadan müşterilere kişiselleştirilmiş yanıtlar sağlamak için müşteri geri bildirimlerinden ve insan müdahalesi olmadan kişiselleştirilmiş bir asistan oluşturmak için kullanılabilir. AI asistanları, ilaç etkileşimleri ve tıbbi kayıtlardaki kalıpları belirleme ve maliyetleri düşürme için de kullanılabilir. Ek olarak yapay zeka asistanı, doğruluğu artırmak için kullanılabilir ve hatta maliyet ve maliyet tasarrufu sağlamak için kullanılabilir. Yapay zeka asistanları, büyük miktarda veriyi hızlı ve doğru bir şekilde işleyebilir ve bu asistanları ve hastalar gibi kişisel verileri analiz edebilir ve bu müşteri ihtiyaçları için daha fazla bilgi birikmesine olanak tanır. AI asistanları, tıbbi prosedürlerin daha iyi tanıyacakları ve daha fazlası için kullanılabilir, bu da bir müşteri ihtiyaçlarını daha iyi anlamaları için daha etkili bir yol sağlar.
4. Prompt: Aşağıdaki cümleyi İngilizceye çevir: Bugün hava çok güzel.
"Yarınki" cümlesi.
5. Prompt: Sağlıklı yaşam için üç öneri ver.
- Sağlıklı yaşam için üç öneri, daha iyi yaşam için bir hedef ve sağlıklı seçimler yapın. 2. Dengeli beslenmek, artan enerji seviyelerini kontrol altında tutmak veya stres ve kaygıları azaltmaya yardımcı olabilir. 3. Çeşitli diyetleri ve diğer kronik hastalık riskini azaltmaya yardımcı olabilir.
6. Prompt: Bir kediyle bir köpek arasındaki farkları özetle.
Bir kedi kedisi, bir memeli ve bir köpek yüzmeye çalışırken kedilere uymak üzere bir kediyle bakışmıştır. kedinin köpek kedlarına sahip köpek ve kediydi,Kediler köpek olarak köpektir. Kediler köpeklerin köpeklerdir, kediyi evcilleştirerek kediye bak alır ve kedinin kedinin çok çeşitli boyut ve kedilere sahip olabileceği kediye kedinin ile evcil hayvan bir kediye götürüyordu. kedinin kedi kedinden daha az keder ve kedinin, kedi kedinin bu çok köpek kedinin köpek evcil hayvanlarının her zaman, kedinin harikalarına ve kedilere kadar evcil hayvan sahibi olduğunu düşünüyorum. Kedi kediyle kedinin genellikle köpek kedileri köpek yavrusu ve kediyi evcil hayvanlardır. Köpek kedisi ve kedilerin evcil hayvanına evcil hayvanlar köpek köpekleri bir köpek yavrusu varım. Kediler evcil hayvanı köpekten kedilere kadar Köpekler çok daha küçük kürklere ve köpekler kedilerle köpek yavrusu tutarken Kediler köpekler ve köpekler evcil hayvan olarak yiyecek ve ve evcil hayvanlardır. Köpekler evcil köpekler ve evcil evcil hayvanı evcil hayvan olarak yetiştirilen dört kediye aile ve köpekler evcil hayvanlardır. Köpekler kedilerinden daha memnundur ve köpekler ve evcil hayvanın olma eğilimindedirler. Köpekler bir köpek yavrusu olmalı ve evcil hayvanlar bir köpek yavrusu için çok daha büyüktür. Köpekler tüylü köpeklerle daha bağımsız ve
7. Prompt: 5 ile 8'in toplamı kaçtır?
5 ile 8'in toplamı 14'tür, çünkü 8'in toplamı 55'tir.
8. Prompt: Kısa bir motivasyon sözü yaz.
Bir motive kalmanın ve motive kalmanıza yardımcı olması çok önemlidir. Örneğin, bir kişi bir isim veya bir elemeyecek veya bir fiilin edatma veya bir fiilin neden olabilir.
Intended Uses
- Research and education on small-scale, from-scratch LLM training for Turkish.
- A reproducible baseline / starting point for Turkish instruction tuning.
- Experiments with the NanoChat architecture and Hugging Face export tooling.
Limitations
This is a small model trained on a single, modest instruction dataset from random initialization. Expect:
- Hallucinations and factually incorrect statements — it has no grounding.
- Weak factual accuracy and limited world knowledge.
- Incomplete instruction following, especially for multi-step or long tasks.
- Bias inherited from the training data.
- Turkish-only competence; other languages are unsupported and degenerate.
- Short effective context and no retrieval/tools.
Do not use this model for high-stakes decisions, factual lookups, or as a production assistant.
Ethical Considerations
The model reflects the content, style and biases of its training data
(merve/turkish_instructions). It may produce inaccurate, stereotyped, or otherwise
undesirable text. Outputs should be reviewed by a human before any downstream
use. No personal data was intentionally used beyond what is present in the
public source dataset. Because the model can fabricate confident-sounding but
false statements, it must not be relied upon for medical, legal, financial, or
safety-critical guidance.
How to use
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("thealper2/nanochat-turkish", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("thealper2/nanochat-turkish", trust_remote_code=True)
messages = [{"role": "user", "content": "Türkiye'nin başkenti neresidir?"}]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
)
output = model.generate(**inputs, max_new_tokens=128, do_sample=True, temperature=0.8, top_k=50)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Pipeline API
from transformers import pipeline
pipe = pipeline("text-generation", model="thealper2/nanochat-turkish", trust_remote_code=True)
messages = [{"role": "user", "content": "Kısa bir motivasyon sözü yaz."}]
print(pipe(messages, max_new_tokens=128, do_sample=True, temperature=0.8)[0]["generated_text"])
Note:
trust_remote_code=Trueis required because the architecture is provided by the bundledmodeling_turkish_gpt.py. The model does not import or require the NanoChat codebase at inference time.
Files
| File | Purpose |
|---|---|
config.json |
Model configuration (with auto_map for remote code) |
configuration_turkish_gpt.py |
PretrainedConfig subclass |
modeling_turkish_gpt.py |
Self-contained model implementation |
model.safetensors |
Model weights (fp32) |
generation_config.json |
Default generation parameters |
tokenizer.json / tokenizer_config.json / special_tokens_map.json |
Tokenizer |
training_args.json |
Full training configuration + run summary |
README.md |
This model card |
LICENSE |
MIT license |
Reproducibility
The full pipeline is reproducible from the project repository:
make install # install dependencies into the environment
make data # download + preprocess merve/turkish_instructions
make tokenizer # train the byte-level BPE tokenizer
make train # train the model from scratch
make evaluate # validation loss / perplexity / samples
make export # export the self-contained Hugging Face model
# or simply:
make all
Training used a fixed seed (42) for Python/NumPy/PyTorch RNGs.
All hyperparameters are stored in training_args.json and configs/default.json.
Hardware
| Component | Value |
|---|---|
| GPU | CPU-only |
| VRAM | n/a GB |
| Compute capability | None |
| Driver | None |
| CPU | AMD Ryzen 7 260 w/ Radeon 780M Graphics (16 threads) |
| RAM | 14.9 GB |
| PyTorch | 2.11.0+cu128 |
| CUDA | 12.8 |
| Python | 3.12.3 |
Training Statistics
| Statistic | Value |
|---|---|
| Total parameters | 75,497,706 |
| Trainable parameters | 75,497,706 |
| Transformer matrices | 25,166,016 |
| Embedding params | 8,388,608 |
| Value-embedding params | 33,554,432 |
| LM-head params | 8,388,608 |
| Training duration | 8m 45s |
| Tokens processed | 16,187,392 |
| Supervised train tokens | 2,956,154 |
| Throughput | 33,678 tokens/sec |
| Estimated total FLOPs | 4.074e+15 |
| Peak VRAM | 7.11 GB |
| Best checkpoint | best.pt |
| Final val loss / ppl | 3.7131 / 40.98 |
Citation
@misc{nanogpt_turkish_2026,
title = {Turkish NanoGPT: a Turkish causal language model trained from scratch with NanoChat},
author = {Turkish NanoGPT contributors},
year = {2026},
note = {Trained from scratch on merve/turkish_instructions},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/thealper2/nanochat-turkish}}
}
@misc{nanochat,
author = {Andrej Karpathy},
title = {nanochat: The best ChatGPT that \$100 can buy},
year = {2025},
publisher = {GitHub},
url = {https://github.com/karpathy/nanochat}
}
License
Released under the MIT license (see LICENSE). The training data
merve/turkish_instructions is subject to its own dataset license/terms on the Hugging
Face Hub; please review them before redistribution.
- Downloads last month
- -