Text Generation
Transformers
Safetensors
English
qwen3_5_text
decision-model
typed-decisions
multimodal
classification
calibration
routing
system-one
dual-mode
qwen3.5
tractus
conversational
Eval Results (legacy)
Instructions to use Ethan33X/Tractus-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ethan33X/Tractus-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ethan33X/Tractus-4B") 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("Ethan33X/Tractus-4B") model = AutoModelForCausalLM.from_pretrained("Ethan33X/Tractus-4B", 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 Ethan33X/Tractus-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ethan33X/Tractus-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ethan33X/Tractus-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ethan33X/Tractus-4B
- SGLang
How to use Ethan33X/Tractus-4B 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 "Ethan33X/Tractus-4B" \ --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": "Ethan33X/Tractus-4B", "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 "Ethan33X/Tractus-4B" \ --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": "Ethan33X/Tractus-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Ethan33X/Tractus-4B with Docker Model Runner:
docker model run hf.co/Ethan33X/Tractus-4B
File size: 5,894 Bytes
68037a6 | 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #!/usr/bin/env python3
"""
Tractus-decision Single-Pass Quickstart (~30 seconds)
-----------------------------------------------------
Demonstrates single-pass System 1 inference with Tractus-decision models using:
1. Single causal forward pass (logits_to_keep=1, 0 generated tokens)
2. Optional Binary Prior Shift (asymmetric K = 2 in Decision Index 0.3) -> Logit Softcapping (C = 30.0) -> Zero-Sum Centering
3. 2D Analytic e-Thermostat probability calibration (zero validation-fitted temperature scalars)
Usage:
python quickstart.py
python quickstart.py --model Ethan33X/Tractus-decision-0.8B
"""
from __future__ import annotations
import argparse
import importlib.util
import sys
import time
from pathlib import Path
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
ROOT = Path(__file__).resolve().parent
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from apse.inference.thermostasis_readout import thermostasis_calibrate_logits # noqa: E402
def _apply_chat_template(
tokenizer: AutoTokenizer,
messages: list[dict[str, str]],
enable_thinking: bool = False,
) -> str:
try:
return tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=enable_thinking,
)
except TypeError:
return tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
def _resolve_option_token_ids(tokenizer: AutoTokenizer, option_keys: list[str]) -> list[int]:
token_ids: list[int] = []
seen: dict[int, str] = {}
for key in option_keys:
if not key or not key.strip():
raise ValueError("Option keys must be non-empty strings.")
ids = tokenizer.encode(key, add_special_tokens=False)
if len(ids) != 1:
raise ValueError(
f"Option key {key!r} tokenized to {len(ids)} tokens ({ids}); "
"single-pass readout requires single-token option keys."
)
tok_id = ids[0]
if tok_id in seen:
raise ValueError(f"Option keys {seen[tok_id]!r} and {key!r} collide on token ID {tok_id}.")
seen[tok_id] = key
token_ids.append(tok_id)
return token_ids
def run_single_pass(model_id: str, state: str, question: str, options: dict[str, str]) -> None:
print(f"Loading Tractus-decision checkpoint: {model_id}")
tokenizer = AutoTokenizer.from_pretrained(model_id)
dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
load_kwargs = {"dtype": dtype}
if importlib.util.find_spec("accelerate") is not None:
load_kwargs["device_map"] = "auto"
model = AutoModelForCausalLM.from_pretrained(model_id, **load_kwargs).eval()
if "device_map" not in load_kwargs:
device = "cuda" if torch.cuda.is_available() else ("mps" if torch.backends.mps.is_available() else "cpu")
model = model.to(device)
messages = [
{
"role": "system",
"content": (
"You are a decision engine. Read the state, then answer the question "
"by replying with exactly one option key from the list. Do not explain."
),
},
{
"role": "user",
"content": (
f"State:\n{state}\n\n"
f"Question:\n{question}\n\n"
"Options:\n"
+ "\n".join(f"{k}: {v}" for k, v in options.items())
+ "\n\nReply with exactly one option key."
),
},
]
prompt = _apply_chat_template(tokenizer, messages, enable_thinking=False)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
option_keys = list(options.keys())
option_texts = [options[k] for k in option_keys]
option_token_ids = _resolve_option_token_ids(tokenizer, option_keys)
t0 = time.perf_counter()
with torch.inference_mode():
terminal_logits = model(input_ids=inputs["input_ids"], logits_to_keep=1).logits[0, -1]
latency_ms = (time.perf_counter() - t0) * 1000.0
raw_scores = [float(terminal_logits[tok_id].item()) for tok_id in option_token_ids]
probs, centered_scores, phase_zone, delta_z, delta_f, thermo_t = thermostasis_calibrate_logits(
raw_scores, option_texts=option_texts
)
prob_map = {k: round(p, 4) for k, p in zip(option_keys, probs)}
best_idx = max(range(len(centered_scores)), key=lambda i: centered_scores[i])
best_key = option_keys[best_idx]
print("-" * 64)
print(f"Mode : Tractus-decision (Single-Pass System 1, 0 generated tokens)")
print(f"Prediction : {best_key} -> {options[best_key]}")
print(f"Confidence : {prob_map[best_key]:.4f} (e-Thermostat T={thermo_t:.3f})")
print(f"Phase Plane : {phase_zone} | delta_z={delta_z:.3f} | delta_F={delta_f:.3f}")
print(f"Probs : {prob_map}")
print(f"Latency : {latency_ms:.2f} ms")
def main() -> None:
parser = argparse.ArgumentParser(description="Tractus-decision Single-Pass Quickstart")
parser.add_argument(
"--model",
type=str,
default="Ethan33X/Tractus-decision-0.8B",
help="HF repo or local path (e.g. Ethan33X/Tractus-decision-0.8B)",
)
args = parser.parse_args()
sample_state = "My integration keeps failing with HTTP 401 since we rotated our API key this morning."
sample_question = "Which support queue should handle this request?"
sample_options = {
"A": "Billing and subscription invoices",
"B": "Technical API authentication support",
"C": "New enterprise sales inquiries",
"D": "Account closure and retention",
}
run_single_pass(args.model, sample_state, sample_question, sample_options)
if __name__ == "__main__":
main()
|