Text Generation
Transformers
Safetensors
olmo_hybrid
risc-v
compiled-weights
olmo-hybrid
gated-deltanet
tool-use
conversational
Instructions to use jgalego/olmputer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jgalego/olmputer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jgalego/olmputer") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jgalego/olmputer") model = AutoModelForCausalLM.from_pretrained("jgalego/olmputer", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jgalego/olmputer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jgalego/olmputer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jgalego/olmputer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jgalego/olmputer
- SGLang
How to use jgalego/olmputer 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 "jgalego/olmputer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jgalego/olmputer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "jgalego/olmputer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jgalego/olmputer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jgalego/olmputer with Docker Model Runner:
docker model run hf.co/jgalego/olmputer
File size: 2,301 Bytes
318553d fa0f2cf 318553d fa0f2cf 318553d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # /// script
# requires-python = ">=3.12"
# dependencies = [
# "chipformer @ https://github.com/JGalego/olmputer/archive/98639dff4c84a18542e3ca12a286a4df563b3a27.tar.gz#subdirectory=experimental/riscv", # pylint: disable=line-too-long
# "huggingface_hub",
# "torch==2.14.1",
# "transformers==5.19.0",
# ]
# ///
"""Ask Olmputer a question and print the conversation.
OLMo writes a calc call. At </function_calls> the chip layers run the calculator firmware and
write the environment turn with the exact value, and OLMo reads it and answers. The CPU's trace
tokens stay inside the chip layers, so this decodes with chipformer's RvChat rather than
generate(), on its Triton executor when there is a GPU. Every token the computer writes is checked
against a reference RISC-V emulator as it is generated, and the whole conversation is replayed
through the circuit at the end. The question is the first argument.
"""
import sys
import urllib.request
from pathlib import Path
import torch
from chipformer.rv import bridge, elf, ref
from chipformer.rv.chat import RvChat, replay
from huggingface_hub import snapshot_download
QUESTION = sys.argv[1] if len(sys.argv) > 1 else "Use calc: what is 123456789 * 987654321?"
FIRMWARE = Path("calc-olmo.elf")
if not FIRMWARE.exists():
urllib.request.urlretrieve("https://raw.githubusercontent.com/JGalego/olmputer/"
"98639dff4c84a18542e3ca12a286a4df563b3a27/experimental/riscv/"
"tests/data/rv/calc-olmo.elf", FIRMWARE)
BOT = RvChat(snapshot_download("jgalego/olmputer"), fast=False,
executor=torch.cuda.is_available())
IDS = BOT.prompt_ids([{"role": "user", "content": QUESTION}])
MACHINE, REFERENCE = (ref.Machine.from_program(elf.program(FIRMWARE)) for _ in range(2))
bridge.park(MACHINE) # the firmware waits for a call
bridge.park(REFERENCE)
LOCK = bridge.Session(BOT.T, REFERENCE)
LOCK.history(IDS)
RESULT = BOT.generate(IDS, MACHINE, 600, lock=LOCK)
print(BOT.text_of(RESULT["tokens"]))
print(f"\n{RESULT['text_tokens']} text tokens, {RESULT['chip_tokens']} trace tokens, "
f"{RESULT['seconds']:.1f} s; checked against the reference: {RESULT['lock_error'] is None}")
print("replayed through the circuit:", replay(BOT, IDS, RESULT["tokens"], FIRMWARE))
|