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
Upgrade to WSP v3.0 2-Layer Sensor-Beacon-Actuator Architecture (Layer 26/22 Semantic Sensors + Nullspace Beacon + Layer 35/31 Actuators)
Browse files
cartridges/skill1_surgical_safety.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79ff8b7560a28b36ee83130ee5aac7ba5e78a99b56e0e4bf092bffb154e9fb0a
|
| 3 |
+
size 397151
|
cartridges/skill2_multi_tool_json.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31c42714156bffbcc76d98730f091d3300c487366a167117839b7a02765063f8
|
| 3 |
+
size 765855
|
cartridges/skill3_sys1_fast_router.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf86194777ed9af696c01f705c68731ccf2ae176c2282f36003aee8259b9bd13
|
| 3 |
+
size 200493
|
install_skills.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
-
Hot-swappable Skill Cartridge Loader for In-Weight OS v3.0 (
|
| 3 |
-
|
| 4 |
-
into
|
| 5 |
"""
|
| 6 |
import torch
|
| 7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -10,6 +10,15 @@ def install_cartridges(model, cartridge_paths):
|
|
| 10 |
with torch.no_grad():
|
| 11 |
for pt_path in cartridge_paths:
|
| 12 |
payload = torch.load(pt_path, map_location="cpu", weights_only=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
layer_idx = int(payload.get("terminal_fsm_layer", payload.get("layer")))
|
| 14 |
mlp = model.model.layers[layer_idx].mlp
|
| 15 |
cols = payload["cols"].long()
|
|
@@ -18,5 +27,5 @@ def install_cartridges(model, cartridge_paths):
|
|
| 18 |
mlp.gate_proj.weight[cols, :] = payload["gate"].to(device=dev, dtype=dt)
|
| 19 |
mlp.up_proj.weight[cols, :] = payload["up"].to(device=dev, dtype=dt)
|
| 20 |
mlp.down_proj.weight[:, cols] = payload["down"].to(device=dev, dtype=dt)
|
| 21 |
-
print(f"[In-Weight OS] Installed cartridge '{payload.get('skill_name', pt_path)}'
|
| 22 |
return model
|
|
|
|
| 1 |
"""
|
| 2 |
+
Hot-swappable 2-Layer Skill Cartridge Loader for In-Weight OS v3.0 (Sensor-Beacon-Actuator Architecture).
|
| 3 |
+
Installs both the Mid-Layer Semantic Sensor () and Terminal Actuator ()
|
| 4 |
+
into Qwen3-8B or Llama-3.1-8B-Instruct in ~20ms.
|
| 5 |
"""
|
| 6 |
import torch
|
| 7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 10 |
with torch.no_grad():
|
| 11 |
for pt_path in cartridge_paths:
|
| 12 |
payload = torch.load(pt_path, map_location="cpu", weights_only=True)
|
| 13 |
+
if "sensor_layer_patch" in payload:
|
| 14 |
+
sp = payload["sensor_layer_patch"]
|
| 15 |
+
s_idx = int(sp["layer"])
|
| 16 |
+
s_mlp = model.model.layers[s_idx].mlp
|
| 17 |
+
s_cols = sp["cols"].long()
|
| 18 |
+
dev, dt = s_mlp.gate_proj.weight.device, s_mlp.gate_proj.weight.dtype
|
| 19 |
+
s_mlp.gate_proj.weight[s_cols, :] = sp["gate"].to(device=dev, dtype=dt)
|
| 20 |
+
s_mlp.up_proj.weight[s_cols, :] = sp["up"].to(device=dev, dtype=dt)
|
| 21 |
+
s_mlp.down_proj.weight[:, s_cols] = sp["down"].to(device=dev, dtype=dt)
|
| 22 |
layer_idx = int(payload.get("terminal_fsm_layer", payload.get("layer")))
|
| 23 |
mlp = model.model.layers[layer_idx].mlp
|
| 24 |
cols = payload["cols"].long()
|
|
|
|
| 27 |
mlp.gate_proj.weight[cols, :] = payload["gate"].to(device=dev, dtype=dt)
|
| 28 |
mlp.up_proj.weight[cols, :] = payload["up"].to(device=dev, dtype=dt)
|
| 29 |
mlp.down_proj.weight[:, cols] = payload["down"].to(device=dev, dtype=dt)
|
| 30 |
+
print(f"[In-Weight OS v3.0] Installed 2-Layer Sensor-Beacon-Actuator cartridge '{payload.get('skill_name', pt_path)}'")
|
| 31 |
return model
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 16060556616
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2258a0606bc5a04420988809a029e0b804b58e4af41ba1be2bac33cfaf5857cc
|
| 3 |
size 16060556616
|