ALX-1
ALX-1 is a small GPT-style language model (17.7M parameters) trained from scratch to generate Python code from a short natural-language task description. It was built for learning and experimentation, and is a compact example of an end-to-end decoder-only transformer pipeline: tokenization, training, and inference.
Note: ALX-1 is a tiny model trained on a small dataset. Expect frequent mistakes and incomplete output. It is not suitable for production use.
Model Details
| Architecture | Decoder-only Transformer (GPT-style) |
| Parameters | 17.7M |
| Layers | 6 |
| Attention heads | 4 |
| Embedding dimension | 256 |
| Context length | 256 tokens |
| Tokenizer | GPT-2 BPE (via tiktoken) |
| Weights format | model.safetensors (F32) |
| Best validation loss | 2.1852 |
| Language | English (prompts), Python (output) |
| License | MIT |
Training Data
Trained on iamtarun/python_code_instructions_18k_alpaca, a dataset of roughly 18k Python instruction/code pairs in Alpaca format.
Intended Use
Intended for:
- Learning how small language models are trained and used
- Experimenting with code-generation fine-tuning, sampling strategies, and evaluation
- A lightweight baseline for comparison with larger models
Not intended for:
- Production code generation
- Any task where correctness or security of the generated code matters
- Generating code that will be executed without careful review
Installation
pip install torch safetensors tiktoken huggingface_hub
Usage
from huggingface_hub import snapshot_download
import sys
path = snapshot_download("alexjmt1/ALX-1")
sys.path.insert(0, path)
from model import load_alx1, ask
model = load_alx1(path, device="cpu")
print(ask(model, "Write a Python function to check if a number is prime."))
Prompt format
The model expects prompts in the following format:
Task:
<instruction>
Code:
The ask helper applies this template for you. If you call the model directly, make sure to follow it, since the model was trained on this structure.
Context limit
The context window is 256 tokens, shared between the prompt and the generated code. Keep instructions short and expect long outputs to be truncated.
Limitations and Risks
- Small scale: 17.7M parameters and a ~18k-example dataset limit the model's coding ability considerably.
- Correctness: Generated code is often wrong, incomplete, or does not run. Always review and test it.
- Narrow coverage: It handles simple, single-function style tasks best. Complex multi-step programs, large codebases, and other languages are out of scope.
- Short context: 256 tokens restricts both prompt and output length.
- Security: Output may contain insecure or unsafe patterns. Do not run generated code in sensitive environments without review.
- Biases: The model inherits any biases and quirks present in its training data.
Repository Files
| File | Description |
|---|---|
model.safetensors |
Model weights |
model.py |
Model definition plus the load_alx1 and ask helpers |
README.md |
This model card |
License
Released under the MIT License.
Acknowledgements
- iamtarun/python_code_instructions_18k_alpaca for the training data
- tiktoken for the GPT-2 BPE tokenizer
- The GPT-2 architecture and the wider open-source community for the ideas this model builds on
Citation
If you use ALX-1 in your work, you can cite it as:
@misc{alx1,
author = {alexjmt1},
title = {ALX-1: A Small GPT-style Model for Python Code Generation},
year = {2026},
url = {https://huggingface.co/alexjmt1/ALX-1}
}
- Downloads last month
- 37