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
Download configuration_chipformer.py from divagr1925/chipformer: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/divagr1925/chipformer/resolve/main/configuration_chipformer.py
- Command line
-
hf download hf://divagr1925/chipformer/configuration_chipformer.py
-
curl -L -o configuration_chipformer.py https://huggingface.co/divagr1925/chipformer/resolve/main/configuration_chipformer.py
1.47 kB
| """Configuration for chipformer: a transformer whose weights were set by hand to execute CHIP-8.""" | |
| from transformers import PretrainedConfig | |
| class ChipformerConfig(PretrainedConfig): | |
| """Shape of the network plus the machine constants a host needs to talk to it. | |
| ``layers`` has one entry per layer: ``{"heads": [[qk_dim, v_dim], ...], "ffn_units": n, | |
| "head_names": [...]}``. Heads have their own (tiny) widths, so they are not one fused | |
| tensor. ``machine`` holds the token layout (ADDR_BASE, STEP, TICK, ...), the font and | |
| the quirk profiles; see docs/trace_format.md in the GitHub repo. | |
| """ | |
| model_type = "chipformer" | |
| def __init__(self, d_model: int = 382, vocab_size: int = 8708, beta: float = 1000.0, | |
| layers: list | None = None, machine: dict | None = None, | |
| max_position: int = 1 << 22, rollover_at: int = 250_000, **kwargs): | |
| self.d_model = d_model | |
| self.hidden_size = d_model | |
| self.vocab_size = vocab_size | |
| self.beta = beta | |
| self.layers = layers or [] | |
| self.n_layers = len(self.layers) | |
| self.num_hidden_layers = len(self.layers) | |
| self.machine = machine or {} | |
| self.max_position = max_position # the circuits assume positions stay below this | |
| self.rollover_at = rollover_at # the host restarts the context from a state dump here | |
| kwargs.setdefault("tie_word_embeddings", False) | |
| super().__init__(**kwargs) | |