Text Generation
Transformers
Safetensors
chipformer
chip-8
emulator
mechanistic-interpretability
compiled-transformer
custom_code
Instructions to use divagr1925/chipformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use divagr1925/chipformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="divagr1925/chipformer", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("divagr1925/chipformer", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use divagr1925/chipformer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "divagr1925/chipformer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "divagr1925/chipformer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/divagr1925/chipformer
- SGLang
How to use divagr1925/chipformer 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 "divagr1925/chipformer" \ --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": "divagr1925/chipformer", "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 "divagr1925/chipformer" \ --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": "divagr1925/chipformer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use divagr1925/chipformer with Docker Model Runner:
docker model run hf.co/divagr1925/chipformer
Model card: lead with the game running inside the transformer
Browse files
README.md
CHANGED
|
@@ -5,7 +5,6 @@ pipeline_tag: text-generation
|
|
| 5 |
tags:
|
| 6 |
- chip-8
|
| 7 |
- emulator
|
| 8 |
-
- hand-crafted-weights
|
| 9 |
- mechanistic-interpretability
|
| 10 |
- compiled-transformer
|
| 11 |
- custom_code
|
|
@@ -13,17 +12,21 @@ tags:
|
|
| 13 |
|
| 14 |
# chipformer
|
| 15 |
|
| 16 |
-
|
| 17 |
-
predicting the next token *is* executing the program.
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
**Play it in your browser:** [divagr.com/chipformer](https://divagr.com/chipformer) 路
|
| 29 |
[Hugging Face Space](https://huggingface.co/spaces/divagr1925/chipformer) 路 Source: [GitHub](https://github.com/divagr18/chipformer)
|
|
@@ -51,6 +54,10 @@ The architecture is ordinary:
|
|
| 51 |
`modeling_chipformer.py` contains nothing CHIP-8 specific apart from the host loop, which only feeds
|
| 52 |
tokens in and reads the screen back.
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
## Usage
|
| 55 |
|
| 56 |
```python
|
|
|
|
| 5 |
tags:
|
| 6 |
- chip-8
|
| 7 |
- emulator
|
|
|
|
| 8 |
- mechanistic-interpretability
|
| 9 |
- compiled-transformer
|
| 10 |
- custom_code
|
|
|
|
| 12 |
|
| 13 |
# chipformer
|
| 14 |
|
| 15 |
+
**Tetris, running entirely inside a transformer.**
|
|
|
|
| 16 |
|
| 17 |
+
This model *is* a CHIP-8 computer. Give it a game as the prompt and greedy decoding runs the game:
|
| 18 |
+
every token it predicts is one write to the machine's memory (a register, the program counter, a
|
| 19 |
+
row of pixels). Paint those writes onto a 64脳32 screen and you are playing Tetris. Your keypresses
|
| 20 |
+
and the 60 Hz clock go into the context window. Everything else, every frame, every collision,
|
| 21 |
+
every point on the scoreboard, comes out of the model.
|
| 22 |
+
|
| 23 |
+
There is no emulator behind it. It is the same loop every language model runs: read the context,
|
| 24 |
+
predict the next token, append it, repeat.
|
| 25 |
+
|
| 26 |
+
- One set of weights plays Tetris, Space Invaders, Brix, Pong and 100+ other games. Switching games
|
| 27 |
+
means switching the prompt.
|
| 28 |
+
- An ordinary decoder-only architecture: 18 layers, d_model 382,
|
| 29 |
+
42 attention heads, 22,276 ReGLU units, vocabulary 8,708, float64.
|
| 30 |
|
| 31 |
**Play it in your browser:** [divagr.com/chipformer](https://divagr.com/chipformer) 路
|
| 32 |
[Hugging Face Space](https://huggingface.co/spaces/divagr1925/chipformer) 路 Source: [GitHub](https://github.com/divagr18/chipformer)
|
|
|
|
| 54 |
`modeling_chipformer.py` contains nothing CHIP-8 specific apart from the host loop, which only feeds
|
| 55 |
tokens in and reads the screen back.
|
| 56 |
|
| 57 |
+
**Where the weights come from.** They are compiled from a description of the CHIP-8 circuit
|
| 58 |
+
(written in a small DSL in the GitHub repo) rather than learned, which is what makes every
|
| 59 |
+
instruction exact. 139,229 of the 32,328,660 parameters are nonzero.
|
| 60 |
+
|
| 61 |
## Usage
|
| 62 |
|
| 63 |
```python
|