Text Generation
Transformers
Safetensors
qwen3
weight-space-programming
in-weight-os
model-merging
continual-learning
tool-calling
safety-alignment
vllm
conversational
text-generation-inference
Instructions to use masstensor/Qwen3-8B-InWeight-OS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use masstensor/Qwen3-8B-InWeight-OS with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="masstensor/Qwen3-8B-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/Qwen3-8B-InWeight-OS") model = AutoModelForCausalLM.from_pretrained("masstensor/Qwen3-8B-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/Qwen3-8B-InWeight-OS with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "masstensor/Qwen3-8B-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/Qwen3-8B-InWeight-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/masstensor/Qwen3-8B-InWeight-OS
- SGLang
How to use masstensor/Qwen3-8B-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/Qwen3-8B-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/Qwen3-8B-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/Qwen3-8B-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/Qwen3-8B-InWeight-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use masstensor/Qwen3-8B-InWeight-OS with Docker Model Runner:
docker model run hf.co/masstensor/Qwen3-8B-InWeight-OS
Upgrade to Trajectory-Safe Universal In-Weight OS v2 (0% GSM8K/MATH-500/Dolly contamination, dual thinking/non-thinking support)
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:e181a412a5535fa28afaf47f0e2ed3b803f51b10d37c3dca30709e73a8f279c3
|
| 3 |
+
size 396083
|
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:a169a087a663fcc94d9c574f87dec62e9b12b08611e3396e009b7d83235cf59c
|
| 3 |
+
size 764787
|
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:c955401b606dfabd660fa347868bd04c523cef28f0181149cb79a30eefb15f13
|
| 3 |
+
size 248509
|
install_skills.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Hot-swappable Skill Cartridge Loader for In-Weight OS.
|
| 3 |
Allows installing or uninstalling any subset of {safety, tools, fast_router}
|
| 4 |
into the terminal MLP layer of Qwen3-8B or Llama-3.1-8B-Instruct in ~20ms.
|
| 5 |
"""
|
|
@@ -10,7 +10,7 @@ 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
|
| 14 |
mlp = model.model.layers[layer_idx].mlp
|
| 15 |
cols = payload["cols"].long()
|
| 16 |
dev = mlp.gate_proj.weight.device
|
|
@@ -18,5 +18,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
|
| 22 |
return model
|
|
|
|
| 1 |
"""
|
| 2 |
+
Hot-swappable Skill Cartridge Loader for In-Weight OS v2 (Trajectory-Safe Universal Guard).
|
| 3 |
Allows installing or uninstalling any subset of {safety, tools, fast_router}
|
| 4 |
into the terminal MLP layer of Qwen3-8B or Llama-3.1-8B-Instruct in ~20ms.
|
| 5 |
"""
|
|
|
|
| 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()
|
| 16 |
dev = mlp.gate_proj.weight.device
|
|
|
|
| 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)}' ({len(cols)} dormant neurons at Layer {layer_idx})")
|
| 22 |
return model
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 16381517208
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1666a231120b8ad69ae200971eba729ac07a800c65a778de365c4f540220c1b7
|
| 3 |
size 16381517208
|