Bulgarian GPT ~700M

A compact decoder-only language model designed for Bulgarian and English text generation, with a Bulgarian-extended GPT-2 tokenizer and optional gated recurrent depth in the middle transformer blocks.

This repository uses a custom PyTorch architecture. Use the included inference runner rather than AutoModelForCausalLM or a standard GPT-2 tokenizer.

Quickstart

Clone this model repository

git clone https://huggingface.co/clecho52/NikeLLM
cd NikeLLM
pip install -r requirements.txt

Install a CUDA-enabled PyTorch build appropriate for your system if using an NVIDIA GPU. CPU inference is also supported. The first tokenizer initialization may download the standard GPT-2 encoding through tiktoken.

Instruction / chat mode

python inference.py --chat --prompt "Обясни накратко какво е машинно обучение." --max-new-tokens 128

Raw text completion

python inference.py --prompt "България е страна, която" --max-new-tokens 100

Translation

python inference.py --chat --prompt 'Преведи на английски: Днес времето е прекрасно.'

These are example inputs, not verified model outputs.

Python API

from inference import Generator

model = Generator('.', device='auto')
# Or Generator('YOUR_ORG/YOUR_MODEL', revision='COMMIT_SHA')

answer = model.generate(
    'Защо небето е синьо?',
    chat=True,
    max_new_tokens=128,
    temperature=0.7,
    top_k=50,
    top_p=0.95,
    seed=42,
)
print(answer)

Multi-turn conversations can be passed explicitly:

print(model.generate([
    {'role': 'user', 'content': 'Какво е фотосинтеза?'},
    {'role': 'assistant', 'content': 'Процес, при който растенията използват светлина.'},
    {'role': 'user', 'content': 'А защо е важна?'}
], chat=True))

Architecture

The following describes the supplied training script's defaults, not an independently inspected final checkpoint. The exported config.json contains the authoritative release settings.

Property Default
Transformer blocks 22
Hidden dimension 1,536
Attention heads 24
Head dimension 64
SwiGLU intermediate dimension 4,096
Normalization RMSNorm
Position encoding RoPE (theta 10,000)
Training sequence length 4,096
Sliding attention window 2,048
Vocabulary 50,257 + up to 8,192 Bulgarian subwords
EOS token ID 50,256
Input/output embeddings Tied
Recurrent middle blocks 9 (blocks 8–16, one-based)

The middle section shares its weights across repeated passes. For nonzero extra passes, learned sigmoid gates interpolate between the input and output of each middle pass. --middle-loops 0 executes each block once; 1 executes the middle section twice, for 31 total block executions with the default architecture. Values 2 and 3 execute 40 and 49 blocks respectively. These are execution counts, not additional parameters. By default inference reproduces the checkpoint's fixed depth, or the training sampler's evaluation depth for variable-depth checkpoints. Overriding it may affect quality.

The tokenizer preserves GPT-2 IDs, greedily matches Bulgarian subwords, and splits ASCII digits individually. The exact ordered added vocabulary and its fingerprint are stored in tokenizer_info.json. Do not replace it with an ordinary GPT-2 or Llama tokenizer.

Prompt format

The default instruction format is:

### User
Какво е изкуствен интелект?

### Assistant

An optional ### System section can precede the user message. The runner encodes headers and content separately to match the training pipeline, inserts the assistant header automatically, and stops on EOS or a new role header in chat mode. Raw completion does not insert headers.

Generation settings

Argument Default Description
--max-new-tokens 128 Maximum generated tokens
--temperature 0.7 Set to 0 for greedy decoding
--top-k 50 Set to 0 to disable
--top-p 0.95 Set to 1 to disable
--middle-loops Checkpoint-derived Extra middle passes (0–3)
--device auto CUDA if available, otherwise CPU
--dtype auto BF16/FP16 on CUDA, FP32 on CPU
--seed unset Optional sampling seed

The implementation recomputes the context at every step (no KV cache), truncating to the most recent configured context length. It is a reference implementation, not a high-throughput serving engine. A roughly 700M-parameter model requires about 1.4 GB of weight storage in BF16 and 2.8 GB in FP32, excluding runtime memory and loading overhead. Actual requirements vary with context and hardware.

Training approach and data

The training implementation supports a mixture of ordinary causal cross-entropy and assistant-token-supervised examples. The default source configuration includes FineWeb, FineWeb-Edu, Bulgarian Corpus 33B, UltraChat 200K, Bulgarian Aya, FineMath, Python educational code, Bulgarian/English FineWiki and bidirectional subtitle translation. Aya uses balanced shuffled task decks across dialogue, event linking, generation, paraphrase identification, question answering, summarization and simplification. Custom source configurations can override these defaults.

The actual dataset revisions, token count, training duration, checkpoint metrics and final training mixture have not been independently verified for this release. No benchmark or safety evaluation results are claimed here.

Limitations

This model may produce inaccurate, repetitive, biased or unsafe text; translation and instruction following can be inconsistent. It is not designed for high-stakes decisions or factual verification without independent checks. Longer contexts or untrained recurrent depths may degrade performance. Review generated content before use.

Maintainer: export a training checkpoint

Only the original training checkpoint is needed; training dependencies and optimizer states are not needed at inference time.

pip install -r requirements.txt
python export.py /path/to/runs/gpt700m/latest.pt --out . --dtype bfloat16
python inference.py --chat --prompt "Здравей!" --temperature 0 --max-new-tokens 32

Use --dtype float32 (the default) to avoid reducing checkpoint weight precision. The exporter uses restricted PyTorch loading and writes only model tensors in SafeTensors format, plus the actual architecture, loop settings and tokenizer metadata. Older checkpoints missing extended-tokenizer metadata must have the original metadata recovered before export.

Upload these files together: README.md, model.py, inference.py, requirements.txt, config.json, tokenizer_info.json, model.safetensors. export.py and smoke_test.py may also be included. Do not upload the full optimizer checkpoint unless intentionally releasing training state.

Before publishing, replace the example repository identifier, document the actual training data and evaluation results, and choose a license after reviewing model and dataset rights. No license is asserted by this draft.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support