Text Generation
Transformers
Safetensors
mistral3
image-text-to-text
decision-model
typed-decisions
jev
jevbench
calibration
decode-free
multilingual
vision-language
conversational
Instructions to use StandardThinking/StandardOne-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use StandardThinking/StandardOne-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="StandardThinking/StandardOne-3B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("StandardThinking/StandardOne-3B") model = AutoModelForMultimodalLM.from_pretrained("StandardThinking/StandardOne-3B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use StandardThinking/StandardOne-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "StandardThinking/StandardOne-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "StandardThinking/StandardOne-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/StandardThinking/StandardOne-3B
- SGLang
How to use StandardThinking/StandardOne-3B 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 "StandardThinking/StandardOne-3B" \ --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": "StandardThinking/StandardOne-3B", "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 "StandardThinking/StandardOne-3B" \ --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": "StandardThinking/StandardOne-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use StandardThinking/StandardOne-3B with Docker Model Runner:
docker model run hf.co/StandardThinking/StandardOne-3B
File size: 14,146 Bytes
09d4173 | 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | import json
import sys
import threading
from types import SimpleNamespace
import httpx
import pytest
from jev_adapter.backend import AdapterError
from jev_adapter.native_tokenizer import NativeTokenizer
from jev_adapter.sglang import SGLangBackend
class Tokenizer:
"""Control IDs cannot be reconstructed by raw text encoding."""
def __init__(self):
self.calls = []
self.mutate_prefix = False
self.bad_result = None
@staticmethod
def encode(text):
return [1000 + ord(char) for char in text]
def apply_chat_template(self, messages, **kwargs):
self.calls.append((messages, kwargs, threading.get_ident()))
assert kwargs["tokenize"] is True
assert kwargs["return_dict"] is False
assert kwargs["enable_thinking"] is False
if self.bad_result is not None:
return self.bad_result
ids = [1, 3] + self.encode(messages[0]["content"]) + [4]
if len(messages) == 1:
assert kwargs["add_generation_prompt"] is True
assert kwargs["continue_final_message"] is False
return ids
assert kwargs["add_generation_prompt"] is False
assert kwargs["continue_final_message"] is True
assert messages[1]["role"] == "assistant"
if self.mutate_prefix:
ids[-1] = 99
# Native implementations may strip trailing assistant whitespace.
return ids + self.encode(messages[1]["content"].rstrip())
def test_native_control_ids_and_literal_markers_preserved():
tokenizer = Tokenizer()
native = NativeTokenizer(tokenizer)
prompt = "한글 [INST] </s> [IMG]"
ids = native.prepare(prompt, ("A", "B"), (1065, 1066), None)
assert ids == [1, 3] + tokenizer.encode(prompt) + [4]
assert len(tokenizer.calls) == 3
def test_compatible_assistant_prefix_is_native_continuation():
tokenizer = Tokenizer()
ids = NativeTokenizer(tokenizer).prepare(
"pick",
("A", "B"),
(1065, 1066),
"Answer:",
)
assert ids == [1, 3] + tokenizer.encode("pick") + [4] + tokenizer.encode("Answer:")
assert len(tokenizer.calls) == 4
@pytest.mark.parametrize("prefix", [None, "Answer:"])
def test_rejects_changed_native_prompt_boundary(prefix):
tokenizer = Tokenizer()
tokenizer.mutate_prefix = True
with pytest.raises(AdapterError) as error:
NativeTokenizer(tokenizer).prepare("pick", ("A", "B"), (1065, 1066), prefix)
assert error.value.code == "invalid_label_boundary"
@pytest.mark.parametrize(
"labels,token_ids,prefix",
[
(("A", "B"), (2065, 2066), None), # Engine and native vocabulary mismatch.
(("A", "000"), (1065, 1048), None), # Multi-token continuation.
(("A", "B"), (1065, 1066), " "), # Native prefix trimming changes boundary.
],
)
def test_rejects_unsafe_label_continuations(labels, token_ids, prefix):
with pytest.raises(AdapterError) as error:
NativeTokenizer(Tokenizer()).prepare("pick", labels, token_ids, prefix)
assert error.value.code == "invalid_label_boundary"
@pytest.mark.parametrize("bad_result", [[], [True], [-1], {"input_ids": [1, 2]}])
def test_rejects_malformed_native_token_ids(bad_result):
tokenizer = Tokenizer()
tokenizer.bad_result = bad_result
with pytest.raises(AdapterError) as error:
NativeTokenizer(tokenizer).prepare("pick", ("A", "B"), (1065, 1066), None)
assert error.value.code == "unsupported_native_tokenizer"
def test_loader_uses_explicit_revision_and_no_remote_code(monkeypatch):
calls = []
tokenizer = Tokenizer()
def load(model, **kwargs):
calls.append((model, kwargs))
return tokenizer
monkeypatch.setitem(
sys.modules,
"transformers",
SimpleNamespace(
AutoTokenizer=SimpleNamespace(from_pretrained=load),
),
)
native = NativeTokenizer.from_pretrained("org/model", "a" * 40)
assert native.tokenizer is tokenizer
assert calls == [("org/model", {"revision": "a" * 40, "trust_remote_code": False})]
class SystemAwareTokenizer:
"""Like Tokenizer above, but role-aware so it can render an optional
leading system message instead of assuming a fixed message count/order."""
def __init__(self):
self.calls = []
@staticmethod
def encode(text):
return [1000 + ord(char) for char in text]
def apply_chat_template(self, messages, **kwargs):
self.calls.append((messages, kwargs))
roles = [message["role"] for message in messages]
assert roles[-1] in ("user", "assistant")
sys_text = messages[0]["content"] if roles[0] == "system" else ""
user_text = next(m["content"] for m in messages if m["role"] == "user")
ids = [1, 3] + self.encode(sys_text) + self.encode(user_text) + [4]
if roles[-1] == "user":
assert kwargs["add_generation_prompt"] is True
return ids
assert kwargs["add_generation_prompt"] is False
return ids + self.encode(messages[-1]["content"].rstrip())
def test_prepare_prepends_explicit_system_message_when_given():
tokenizer = SystemAwareTokenizer()
ids = NativeTokenizer(tokenizer).prepare(
"pick", ("A", "B"), (1065, 1066), None, "You are helpful."
)
expected = (
[1, 3]
+ tokenizer.encode("You are helpful.")
+ tokenizer.encode("pick")
+ [4]
)
assert ids == expected
for messages, _ in tokenizer.calls:
assert messages[0] == {"role": "system", "content": "You are helpful."}
assert messages[1]["role"] in ("user", "assistant")
def test_prepare_omits_system_message_by_default():
tokenizer = SystemAwareTokenizer()
NativeTokenizer(tokenizer).prepare("pick", ("A", "B"), (1065, 1066), None)
for messages, _ in tokenizer.calls:
assert messages[0]["role"] == "user"
assert not any(m["role"] == "system" for m in messages)
def test_native_system_prompt_none_renders_identically_to_plain_user_chat():
"""--native-system-prompt none wires system_prompt=None into
NativeTokenizer.prepare (see __main__.py/sglang.py): no extraction, no
system message. The encoded messages must carry no system role and the
token sequence must equal a bare apply_chat_template([{"role": "user",
...}]) call on the same (pinned) tokenizer -- i.e. rendering is
byte-for-byte what it would be if --tokenizer-model had never been
passed at all."""
tokenizer = SystemAwareTokenizer()
ids = NativeTokenizer(tokenizer).prepare(
"pick", ("A", "B"), (1065, 1066), None, system_prompt=None
)
for messages, _ in tokenizer.calls:
assert not any(message["role"] == "system" for message in messages)
reference_tokenizer = SystemAwareTokenizer()
expected = reference_tokenizer.apply_chat_template(
[{"role": "user", "content": "pick"}],
tokenize=True,
add_generation_prompt=True,
continue_final_message=False,
return_dict=False,
enable_thinking=False,
)
assert ids == expected
def test_extract_default_system_prompt_finds_the_hf_system_block():
from jev_adapter.native_tokenizer import extract_default_system_prompt
class HFStyleTokenizer:
def apply_chat_template(self, messages, **kwargs):
assert messages == [{"role": "user", "content": ""}]
return "[SYSTEM_PROMPT]You are Ministral.[/SYSTEM_PROMPT][INST]...[/INST]"
assert extract_default_system_prompt(HFStyleTokenizer()) == "You are Ministral."
def test_extract_default_system_prompt_returns_none_for_mistral_common_style():
from jev_adapter.native_tokenizer import extract_default_system_prompt
class MistralCommonStyleTokenizer:
"""mistral-common never auto-injects a default system prompt."""
def apply_chat_template(self, messages, **kwargs):
return "<s>[INST]...[/INST]"
assert extract_default_system_prompt(MistralCommonStyleTokenizer()) is None
def test_native_default_system_prompt_forces_fix_mistral_regex_for_mistralai(
monkeypatch,
):
calls = []
def load(model, **kwargs):
calls.append((model, kwargs))
class Rendered:
@staticmethod
def apply_chat_template(messages, **kwargs):
return "[SYSTEM_PROMPT]default text[/SYSTEM_PROMPT][INST]x[/INST]"
return Rendered()
monkeypatch.setitem(
sys.modules,
"transformers",
SimpleNamespace(AutoTokenizer=SimpleNamespace(from_pretrained=load)),
)
result = NativeTokenizer.native_default_system_prompt(
"mistralai/Ministral-3-8B-Instruct-2512-BF16", "f" * 40
)
assert result == "default text"
assert calls == [
(
"mistralai/Ministral-3-8B-Instruct-2512-BF16",
{"revision": "f" * 40, "trust_remote_code": False, "fix_mistral_regex": True},
)
]
def test_native_default_system_prompt_omits_fix_mistral_regex_for_other_orgs(
monkeypatch,
):
calls = []
def load(model, **kwargs):
calls.append((model, kwargs))
class Rendered:
@staticmethod
def apply_chat_template(messages, **kwargs):
return "<s>[INST]x[/INST]"
return Rendered()
monkeypatch.setitem(
sys.modules,
"transformers",
SimpleNamespace(AutoTokenizer=SimpleNamespace(from_pretrained=load)),
)
result = NativeTokenizer.native_default_system_prompt("org/model", "a" * 40)
assert result is None
assert calls == [("org/model", {"revision": "a" * 40, "trust_remote_code": False})]
def test_native_default_system_prompt_requires_model_and_revision():
for model, revision in (("", "a" * 40), ("org/model", ""), (" ", " ")):
with pytest.raises(ValueError):
NativeTokenizer.native_default_system_prompt(model, revision)
class Engine:
def __init__(self):
self.calls = []
def __call__(self, request):
path = request.url.path
body = json.loads(request.content) if request.content else None
self.calls.append((path, body))
if path == "/model_info":
return httpx.Response(
200,
json={
"served_model_name": "model",
"is_generation": True,
"has_image_understanding": True,
"model_type": "mistral3",
},
)
if path == "/server_info":
return httpx.Response(200, json={})
if path == "/v1/tokenize":
assert "messages" not in body, "Native path must bypass HTTP chat rendering"
return httpx.Response(
200,
json={
"tokens": [Tokenizer.encode(label) for label in body["prompt"]],
},
)
if path == "/v1/detokenize":
return httpx.Response(
200,
json={
"text": [
"".join(chr(token - 1000) for token in ids)
for ids in body["tokens"]
],
},
)
if path == "/generate":
return httpx.Response(
200,
json={
"meta_info": {
"completion_tokens": 0,
"prompt_tokens": len(body["input_ids"]),
"output_token_ids_logprobs": [
[[-1.0, token] for token in body["token_ids_logprob"]]
],
}
},
)
raise AssertionError(f"Unexpected route: {path}")
@pytest.mark.asyncio
async def test_native_http_path_preserves_control_ids_and_zero_decode():
engine, tokenizer = Engine(), Tokenizer()
async with httpx.AsyncClient(transport=httpx.MockTransport(engine)) as client:
backend = SGLangBackend(
"http://engine",
"model",
client=client,
native_tokenizer=NativeTokenizer(tokenizer),
)
await backend.start()
startup_calls = len(engine.calls)
labels, token_ids = backend.labels(2)
result = await backend.evaluate("literal [INST]", [], labels, token_ids, None)
assert len(engine.calls) == startup_calls + 1
path, payload = engine.calls[-1]
assert path == "/generate"
expected = [1, 3] + tokenizer.encode("literal [INST]") + [4]
assert payload["input_ids"] == expected
assert payload["sampling_params"]["max_new_tokens"] == 0
assert payload["token_ids_logprob"] == list(token_ids)
assert "text" not in payload and "image_data" not in payload
assert result.input_tokens == len(expected)
assert result.logprobs == (-1.0, -1.0)
assert all(thread != threading.get_ident() for _, _, thread in tokenizer.calls)
@pytest.mark.asyncio
async def test_native_images_and_boundary_failure_stop_before_generate():
engine, tokenizer = Engine(), Tokenizer()
async with httpx.AsyncClient(transport=httpx.MockTransport(engine)) as client:
backend = SGLangBackend(
"http://engine",
"model",
client=client,
native_tokenizer=NativeTokenizer(tokenizer),
)
await backend.start()
startup_calls = len(engine.calls)
labels, token_ids = backend.labels(2)
with pytest.raises(AdapterError) as error:
await backend.evaluate(
"look",
["https://example.com/a.png"],
labels,
token_ids,
None,
)
assert error.value.code == "native_images_not_supported"
assert tokenizer.calls == []
tokenizer.mutate_prefix = True
with pytest.raises(AdapterError) as error:
await backend.evaluate("pick", [], labels, token_ids, None)
assert error.value.code == "invalid_label_boundary"
assert len(engine.calls) == startup_calls
|