Text Generation
Transformers
Safetensors
English
3-digit-basic-calc
arithmetic
process-supervision
scratchpad
chain-of-thought
from-scratch
interpretability
small-language-model
looped-transformer
custom_code
Instructions to use vmal/3-digit-basic-calc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vmal/3-digit-basic-calc with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vmal/3-digit-basic-calc", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("vmal/3-digit-basic-calc", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vmal/3-digit-basic-calc with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vmal/3-digit-basic-calc" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vmal/3-digit-basic-calc", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vmal/3-digit-basic-calc
- SGLang
How to use vmal/3-digit-basic-calc 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 "vmal/3-digit-basic-calc" \ --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": "vmal/3-digit-basic-calc", "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 "vmal/3-digit-basic-calc" \ --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": "vmal/3-digit-basic-calc", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vmal/3-digit-basic-calc with Docker Model Runner:
docker model run hf.co/vmal/3-digit-basic-calc
| # Copyright 2026. Released under the MIT license. | |
| """Configuration for the 3-digit-basic-calc looped arithmetic transformer.""" | |
| from transformers import PretrainedConfig | |
| class ThreeDigitBasicCalcConfig(PretrainedConfig): | |
| """Config for a looped ("universal") decoder-only calculator transformer. | |
| A small stack of ``num_hidden_layers`` decoder blocks is applied ``n_loops`` | |
| times with shared weights, giving an effective depth of | |
| ``num_hidden_layers * n_loops`` at the parameter cost of the stack alone. | |
| """ | |
| model_type = "3-digit-basic-calc" | |
| def __init__( | |
| self, | |
| vocab_size: int = 34, | |
| max_position_embeddings: int = 176, | |
| hidden_size: int = 256, | |
| num_attention_heads: int = 8, | |
| num_hidden_layers: int = 2, | |
| n_loops: int = 8, | |
| dropout: float = 0.05, | |
| rms_eps: float = 1e-6, | |
| rope_base: float = 10000.0, | |
| pad_token_id: int = 0, | |
| bos_token_id: int = 1, | |
| eos_token_id: int = 2, | |
| unk_token_id: int = 3, | |
| **kwargs, | |
| ): | |
| self.vocab_size = vocab_size | |
| self.max_position_embeddings = max_position_embeddings | |
| self.hidden_size = hidden_size | |
| self.num_attention_heads = num_attention_heads | |
| self.num_hidden_layers = num_hidden_layers | |
| self.n_loops = n_loops | |
| self.dropout = dropout | |
| self.rms_eps = rms_eps | |
| self.rope_base = rope_base | |
| self.unk_token_id = unk_token_id | |
| kwargs.setdefault("tie_word_embeddings", False) | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| **kwargs, | |
| ) | |