Instructions to use melephant/1-layer-addition with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use melephant/1-layer-addition with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="melephant/1-layer-addition", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("melephant/1-layer-addition", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use melephant/1-layer-addition with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "melephant/1-layer-addition" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "melephant/1-layer-addition", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/melephant/1-layer-addition
- SGLang
How to use melephant/1-layer-addition 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 "melephant/1-layer-addition" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "melephant/1-layer-addition", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "melephant/1-layer-addition" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "melephant/1-layer-addition", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use melephant/1-layer-addition with Docker Model Runner:
docker model run hf.co/melephant/1-layer-addition
Fixed-width addition transformer
Run s85nnxtf is a 1-block, bias-free causal transformer trained for
4-digit base-10 addition. Operands are zero-padded and answers use
5 digits, retaining overflow.
Results
| Metric | Value |
|---|---|
| Validation loss | 0.003520 |
| Validation generated-token accuracy | 99.85% |
| Validation exact-answer accuracy | 99.32% |
| No-carry exact-answer accuracy | 97.27% |
| Single-carry exact-answer accuracy | 100.00% |
| Multiple-carry exact-answer accuracy | 98.44% |
| Carry-chain exact-answer accuracy | 97.27% |
Training configuration
- Updates: 10000
- Optimizer: muon
- Muon peak learning rate: 0.02
- AdamW peak learning rate: 0.0003
- Weight decay: 0.01
- Warmup updates: 100
- Minimum learning-rate ratio: 0.1
- Initialization: normal
- Seed: 0
- Source commit:
unavailable
The complete resolved configuration, environment, metrics, source snapshot, and checkpoints are
available in training/. Machine-readable hashes and metrics are in
export_manifest.json.
Loading
This repository contains custom Transformers code. For reproducible or security-sensitive use, pin the commit revision printed by the uploader.
from transformers import AutoModelForCausalLM, AutoTokenizer
revision = "PINNED_COMMIT_HASH"
tokenizer = AutoTokenizer.from_pretrained(
"OWNER/REPO", trust_remote_code=True, revision=revision
)
model = AutoModelForCausalLM.from_pretrained(
"OWNER/REPO", trust_remote_code=True, revision=revision
)
inputs = tokenizer("0000 + 0000 =", return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=model.config.answer_digits, do_sample=False)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Intended use and limitations
This model is intended for mechanistic-interpretability research on its configured fixed-width addition task. It is not a general arithmetic system: inputs outside the configured grammar or width are unsupported, and generated answers must not be treated as reliable calculations.
- Downloads last month
- 88