Downloads · 30 days
0
leninangelov/alpaca_capitals_27m
alpaca_capitals_27m is a text generation model from leninangelov. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
alpacacapitals27m is a small decoder-only language model trained from scratch in Spanish as an educational experiment. It studies how a compact Transformer learns general instruction-following patterns together with a…
Downloads · 30 days
0
Access
Public
Updated Sep 23, 2026
Parameters
32.3M
131 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors129 MB · 98%
From the Hugging Face model README
alpaca_capitals_27m is a small decoder-only language model trained from scratch in Spanish as an educational experiment. It studies how a compact Transformer learns general instruction-following patterns together with a narrow factual domain: country-capital associations.
This release corresponds to the alpaca_capitals experiment and contains approximately 27M parameters. The export script records the exact parameter count detected from the selected checkpoint in export_manifest.json.

d_model): 512step_0018000.pt)NOTE: This repository uses a custom architecture. It is not currently presented as a drop-in transformers.AutoModelForCausalLM.from_pretrained() model. The repository includes the original architecture/training source and the tokenizer/configuration artifacts required to reconstruct the model.
The model was trained with a mixed Spanish instruction corpus:
bertin-project/alpaca-spanish — the general Spanish instruction-following dataset.capitals_clean.jsonl — a local dataset designed to reinforce country-capital knowledge in Spanish.The capital dataset covers the 195-country/state scope used in this experiment and contains multiple Spanish formulations for each country. During training, the local data were oversampled with local_weight=5.
The upstream bertin-project/alpaca-spanish dataset is published on Hugging Face under CC BY 4.0. Users should review the upstream dataset terms and the terms applicable to any additional local data before redistribution or commercial use.
| Parameter | Value |
|---|---|
| Maximum Alpaca samples | 52,000 |
| Vocabulary size | 10,000 |
| Sequence length | 256 |
| Batch size | 16 |
d_model | 512 |
| Layers | 8 |
| Attention heads | 8 |
| KV heads | 2 |
| Training steps | 30,000 |
| Learning rate | 3e-4 |
| Weight decay | 0.1 |
| Warmup steps | 500 |
| Gradient clipping | 1.0 |
| Local-data weight | 5 |
| Checkpoint interval | 2,000 steps |
The selected checkpoint is recorded in export_manifest.json, together with its SHA-256 hash.
This repository releases the step 18,000 checkpoint, corresponding to:
step_0018000.pt
The full training run continued to 30,000 steps and produced checkpoints every 2,000 steps. General validation loss and task-specific factual behavior were not perfectly aligned during the experiment.
Among the initially inspected checkpoints, the lowest general validation loss occurred around step 14,000. However, qualitative testing on country-capital questions showed stronger factual behavior from the step 18,000 checkpoint. For that reason, step 18,000 was selected as the model released in this repository.
This checkpoint choice is based on qualitative task-specific testing rather than a complete 195-country benchmark. The exact released checkpoint step and the SHA-256 hash of the exported model.safetensors file are also recorded in export_manifest.json.
Usuario: ¿Cuál es la capital de China?
Modelo: La capital de China es Pekín. La respuesta es Pekín.
Usuario: Dime la capital de Marruecos
Modelo: La capital de Marruecos es Rabat. La respuesta es Rabat.
Usuario: ¿Cuál es la capital de Argentina?
Modelo: La capital de Argentina es Buenos Aires. La respuesta es Buenos Aires.
For factual testing, greedy decoding was more stable than stochastic sampling:
temperature = 0.1
top_k = 1
max_new_tokens = 80
With top_k=1, generation is effectively greedy.
The following charts summarize the behavior of the full 30K-step training run.

The training loss decreases steadily throughout the run, showing that the model continues fitting the training distribution. The validation-loss checkpoints, however, improve strongly at first and then stop improving at the same pace. This is a useful sign that the model keeps learning patterns from the training data while the general validation objective begins to saturate.

Perplexity drops rapidly during the early stages of training and then stabilizes. Validation perplexity improves substantially at first, reaching its lowest region around the middle part of the run, and then becomes less favorable in later checkpoints. This is consistent with the checkpoint table and indicates that the checkpoint with the lowest global validation loss is not necessarily the best checkpoint for the specific geography task evaluated qualitatively.

The checkpoint summary shows that the automatic recommendation based on lowest validation loss was:
val_loss = 2.5358val_ppl = 12.63However, the model released in this repository is:
step_0018000.pt)The training monitor selected step 14,000 because it had the best general validation loss among the saved checkpoints. That metric is useful, but this project had a narrower target objective as well: answering country-capital questions in Spanish.
During qualitative testing of the released task, the step 18,000 checkpoint showed better practical behavior on country-capital prompts than the automatic 14K recommendation. In particular, it produced stronger answers under the factual decoding configuration used for this experiment:
temperature = 0.1
top_k = 1
max_new_tokens = 80
This means the final release decision was based on task-specific qualitative performance, not only on the generic validation metric shown by the training dashboard. That choice is pedagogically useful because it illustrates an important lesson in machine learning:
the checkpoint with the best global validation loss is not always the checkpoint that performs best on the final task you care about.
In other words, step 14,000 was the best checkpoint according to the monitor’s automatic validation-loss criterion, while step 18,000 was selected for publication because it was more convincing for the intended capital-city inference demonstrations.
This is an educational tiny language model, not a production knowledge system.
Observed limitations include:
A useful result from this experiment is that learning a canonical factual mapping does not automatically imply robustness to surface-form variation.
This model is intended for:
It is not intended as an authoritative geography reference or as a production conversational assistant.
The public model weights are stored as:
model.safetensors
The original experimental checkpoints were PyTorch .pt files. They were converted to Safetensors for safer public distribution. The Safetensors release contains model weights only; optimizer and scheduler states are intentionally excluded.
Typical repository contents:
README.md
model.safetensors
model_config.json
tokenizer.json
tokenizer_stats.json
inference_settings.json
export_manifest.json
checkpoint_index.csv
training_metrics.csv
tiny_spanish_transformer_v2.py
safetensors_loader.py
requirements.txt
The weights can be read with:
from safetensors.torch import load_file
state_dict = load_file("model.safetensors", device="cpu")
Because this is a custom Transformer implementation, instantiate the architecture using the included model source/configuration and then load the state dictionary:
model.load_state_dict(state_dict)
See tiny_spanish_transformer_v2.py and model_config.json for the architecture used by the experiment.
export_manifest.json records the selected source checkpoint, checkpoint step, detected parameter count, SHA-256 of model.safetensors, and serialization format.
The model has been manually evaluated with several country-capital prompts and prompt variations. A formal benchmark across all 195 countries and multiple surface forms is a recommended next step.
Useful future metrics include canonical capital accuracy, lowercase/no-accent accuracy, terse-prompt accuracy, paraphrase robustness, and accuracy by checkpoint.
The general instruction data are based on bertin-project/alpaca-spanish.
This model was developed as a small-scale Spanish Transformer training experiment for educational and research purposes.