elroy-350m-chat
elroy-350m-chat is a 361M-parameter Llama-style decoder trained from scratch on about 20B tokens of educational Python and English by Strife Technologies, as a fully documented teaching project. Every line of the tokenizer, model, training loop and fine-tuning code is in the repository, with a chapter explaining it:
https://github.com/strifero/elroy
This is the chat variant: fine-tuned on coding instructions with the template <|system|>...<|end|><|user|>...<|end|><|assistant|>. Use elroy_min.chat_prompt(question) to build prompts and stop on <|end|>.
Use
No transformers needed. elroy_min.py in this repo holds the model, the tokenizer and a sampler in one file:
import torch
from elroy_min import load, generate
model, tok = load(".") # this folder
ids = tok.encode(chat_prompt("Write a function that checks whether a number is prime."))
out = generate(model, ids, max_new_tokens=128, temperature=0.2, top_p=0.95, stop_ids={tok.eot})
print(tok.decode(out))
Training
| Parameters | 361M (24 layers, width 1024, 16 heads, context 2048) |
| Tokens | about 20B: 45% Stack-Edu Python, 20% StarCoderData Python, 25% FineWeb-Edu, 10% Cosmopedia-v2 |
| Objective | next token, plus fill-in-the-middle on half of the code |
| Hardware | two NVIDIA RTX A4500 (20GB), about 6 days |
| Tokenizer | own byte-level BPE, 32,768 entries, code-aware pre-tokenization |
Evaluation
| Benchmark | pass@1 |
|---|---|
| HumanEval | 26.8% |
| HumanEval+ | 25.6% |
| MBPP (sanitized) | 38.9% |
Data and licenses
Stack-Edu (HuggingFaceTB, Python subset; files with a permissive or no detected license, as in The Stack v2), StarCoderData (bigcode, permissive), FineWeb-Edu (ODC-By), Cosmopedia-v2 (ODC-By). Fine-tuning data: Magicoder OSS-Instruct (MIT), evol-codealpaca-v1 (Apache-2.0), and a handwritten set in the repository.
Limitations
This is a small model. It writes short, mostly correct Python functions and explains beginner concepts. It makes confident mistakes, knows little outside Python, has no knowledge of recent libraries, and has not been trained to refuse anything. Run what it writes before you rely on it.
- Downloads last month
- -