Text Generation
Transformers
Safetensors
llama
weight-space-programming
in-weight-os
model-merging
continual-learning
tool-calling
safety-alignment
vllm
conversational
text-generation-inference
Instructions to use masstensor/Llama-3.1-8B-Instruct-InWeight-OS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use masstensor/Llama-3.1-8B-Instruct-InWeight-OS with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="masstensor/Llama-3.1-8B-Instruct-InWeight-OS") 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("masstensor/Llama-3.1-8B-Instruct-InWeight-OS") model = AutoModelForCausalLM.from_pretrained("masstensor/Llama-3.1-8B-Instruct-InWeight-OS", 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 masstensor/Llama-3.1-8B-Instruct-InWeight-OS with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "masstensor/Llama-3.1-8B-Instruct-InWeight-OS" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "masstensor/Llama-3.1-8B-Instruct-InWeight-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/masstensor/Llama-3.1-8B-Instruct-InWeight-OS
- SGLang
How to use masstensor/Llama-3.1-8B-Instruct-InWeight-OS 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 "masstensor/Llama-3.1-8B-Instruct-InWeight-OS" \ --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": "masstensor/Llama-3.1-8B-Instruct-InWeight-OS", "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 "masstensor/Llama-3.1-8B-Instruct-InWeight-OS" \ --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": "masstensor/Llama-3.1-8B-Instruct-InWeight-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use masstensor/Llama-3.1-8B-Instruct-InWeight-OS with Docker Model Runner:
docker model run hf.co/masstensor/Llama-3.1-8B-Instruct-InWeight-OS
Release Llama-3.1-8B-Instruct-InWeight-OS full weights + modular skill cartridges + paper PDF
1949354 verified Download install_skills.py from masstensor/Llama-3.1-8B-Instruct-InWeight-OS: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/masstensor/Llama-3.1-8B-Instruct-InWeight-OS/resolve/main/install_skills.py
- Command line
-
hf download hf://masstensor/Llama-3.1-8B-Instruct-InWeight-OS/install_skills.py
-
curl -L -o install_skills.py https://huggingface.co/masstensor/Llama-3.1-8B-Instruct-InWeight-OS/resolve/main/install_skills.py
1.13 kB
| """ | |
| Hot-swappable Skill Cartridge Loader for In-Weight OS. | |
| Allows installing or uninstalling any subset of {safety, tools, fast_router} | |
| into the terminal MLP layer of Qwen3-8B or Llama-3.1-8B-Instruct in ~20ms. | |
| """ | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| def install_cartridges(model, cartridge_paths): | |
| with torch.no_grad(): | |
| for pt_path in cartridge_paths: | |
| payload = torch.load(pt_path, map_location="cpu", weights_only=True) | |
| layer_idx = int(payload["terminal_fsm_layer"]) | |
| mlp = model.model.layers[layer_idx].mlp | |
| cols = payload["cols"].long() | |
| dev = mlp.gate_proj.weight.device | |
| dt = mlp.gate_proj.weight.dtype | |
| mlp.gate_proj.weight[cols, :] = payload["gate"].to(device=dev, dtype=dt) | |
| mlp.up_proj.weight[cols, :] = payload["up"].to(device=dev, dtype=dt) | |
| mlp.down_proj.weight[:, cols] = payload["down"].to(device=dev, dtype=dt) | |
| print(f"[In-Weight OS] Installed cartridge '{payload['skill_name']}' ({len(cols)} dormant neurons at Layer {layer_idx})") | |
| return model | |