Views
No views yet
coreai-torch (LLMs: coreai.llm.export) into .aimodel bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol (apple-silicon-llm-bench, macOS 27 beta, 2026-06)..aimodel)yes or no
at the last prompt token, so the whole tail is baked into the graph:(input_ids [1,S] int32, attention_mask [1,S] int32) -> probs [1,2] = softmax([no, yes]).aimodel forward is one verdict. No KV cache, no decode loop, no sampling, and no
131 072-way head — two rows of the tied embedding are the head, which is 805 MB of fp16 a
classifier never reads.Requires macOS 27 / iOS 27 (Core AI ships with the OS). Conversion code, gates and knowledge base: coreai-model-zoo.
| path | size | verdict latency (M4 Max) | numerics |
|---|---|---|---|
gpu-classify/…_int4lin_s512 | 2.53 GB | 232.5 ms | 9/9 verdicts vs fp32, worst |ΔP| 0.030 |
gpu-classify/…_int4lin_s256 | 2.53 GB | 123.6 ms | 9/9, numerics identical to S=512 |
ios-h18p/…_int4lin_s512 | 2.336 GiB AOT | 624.7 ms (iPhone 17 Pro) | 9/9 on device |
ios-h18p/…_int4lin_s256 | 2.336 GiB AOT | 371.9 ms (iPhone 17 Pro) | 9/9 on device |
coreai-torch 0.4.1, median of 10 warm forwards,
engine ready in ~2 s.PB_SHIELD gate, median of 5 warm
forwards, engine ready in 10.9 s (S=512) / 5.3 s (S=256). Its probabilities match the Mac's to
four decimals, so what int4 costs this model is a property of the weights, not of where they
run.| flagged | fp32 | int4 | not flagged | fp32 | int4 | |
|---|---|---|---|---|---|---|
| violence (EN) | 0.9972 | 0.9988 | sourdough recipe | 0.0000 | 0.0000 | |
| violence (JA) | 0.9011 | 0.9315 | park recommendation (JA) | 0.0001 | 0.0001 | |
| weapon-making | 0.9919 | 0.9967 | chemical safety question | 0.0001 | 0.0001 | |
| doxxing request | 1.0000 | 1.0000 | refusal to dox | 0.0003 | 0.0004 | |
| help-seeking | 0.0001 | 0.0002 |
reference.json next to the bundle:PREFIX = "<s>[SYSTEM_PROMPT]" + SYSTEM + "[/SYSTEM_PROMPT][INST]"
BODY = "<Instruct>: {instruction}\n\n<Query>: {query}\n\n<Document>: {document}"
SUFFIX = "[/INST]"add_special_tokens=False — <s> is in the template text and this tokenizer's
post-processor does not add one, so letting it add specials gives you two;pad_token_id 11, mask 1 × real + 0 × pad. Under the causal
mask the last real token never sees the padding, which is why S=128 and S=512 agree exactly;probs[1] = P(violation).SYSTEM is fixed (it ships in reference.json); Instruct, Query and Document are yours.image_size 1540). Text only.1let guard = try await SafetyClassifier(model: .shieldstral3B) // .shieldstral3BShort for S=256
2let verdict = try await guard.check(message, policy: .selfHarm)SafetyClassifier owns the scaffolding,
the padding and the threshold. reference.json in each bundle ships the nine gated cases with
their fp32 probabilities, so any host — Swift, Python, yours — can check its own prompt
construction rather than trusting it.TokenizersBackend, AutoModelForCausalLM rejects Mistral3Config. The
oracle therefore runs on transformers git main, which knows ministral3 natively, and the
export is built on the claim that ministral3 is Mistral + YARN (4.57.6's MistralModel handed
this config's rope_parameters as rope_scaling)._smoke/test_shieldstral_torch_ladder.py,
conversion/export_shieldstral.py
and
knowledge/shieldstral-port.md.mistralai/Shieldstral-1.0-3B (revision
003ec7e2b0bab5f0e6307edbaf186fa5822b76f5). Not affiliated with Apple or Mistral AI.