SemIf-OpenJev README

The project's README from github.com/TheoLeeCJ/SemIf-OpenJev. As one markdown file: README.md.

SemIf (formerly OpenJev)

Semantic ifs from open models, on a 3090 at home.

Independent project; not affiliated with Jev or TypeSafe.

Wow! No waitlist. Run it in your browser today.

Measured replay: typed decisions appear together while JSON streams token by token

Same frozen 4B model · same state · same 21 questions · measured separately, aligned at t=0 in the replay

Independent research project. SemIf was formerly called OpenJev. It is not affiliated with or endorsed by TypeSafe. Jev, TypeSafe, and other names and marks are the property of their respective owners. No infringement is intended.

Some AI company asks you to join a waitlist; SemIf runs in your browser today

Most agent decisions are small: route this, retry that, does the evidence support X? A chat model can answer them, but it spends time generating text that software immediately parses back into an if statement.

Jev is TypeSafe's closed service for runtime-defined semantic decisions. This project reproduces that interface pattern with open models; it does not reproduce Jev's undisclosed model or training.

This baseline reads typed option probabilities directly from a model. No answer sentence, JSON repair, or decoding loop.

Latest changes

2026-09-22

2026-09-18

Quick start

Apple Silicon: use the native MLX backend for direct scoring, serial prefix reuse, and parallel shared-state decisions on macOS arm64. Install pip install -e '.[test,mlx]' and add --backend mlx to the scorer command. PyTorch/MPS (--device mps) is also supported for direct, serial, and shared modes — see Apple Silicon.

Python 3.10+, CUDA, and a GPU that can hold a 4B BF16 model:

python -m venv .venv
. .venv/bin/activate
export HF_HOME=/path/to/large-drive/huggingface
pip install -e '.[test]'

CPU only: the llama.cpp backend scores the same prompts from a local GGUF checkpoint with no CUDA device. Install pip install -e '.[test,llamacpp]', fetch a GGUF (for example Qwen_Qwen3.5-4B-Q4_K_M.gguf from bartowski/Qwen_Qwen3.5-4B-GGUF), and add --backend llamacpp --gguf /path/to/model.gguf; --llama-threads caps the CPU threads. Prompt construction stays on the pinned reference tokenizer, so prompt_sha256 matches the Torch backend row for row; scores carry the GGUF checksum and are conditional on the quantized weights. Direct and prefix-cached execution can have small numerical differences from different llama.cpp evaluation paths; compare decisions or probabilities with a tolerance rather than raw logits bit for bit. One loaded backend owns one stateful scoring context.

Run the owned examples:

CUDA_VISIBLE_DEVICES=0 semif-score \
  --mode direct \
  --model Qwen/Qwen3.5-4B \
  --revision 851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a \
  --input examples/decisions.jsonl \
  --output results.jsonl

Each result contains typed option scores, timing, the exact model revision, and a prompt hash.

If every row has the same exact state, switch to --mode shared to prefill it once and evaluate the criteria in parallel.

How it works

flowchart LR
    S[Unstructured state] --> M[4B model]
    C[Runtime criteria] --> M
    O[Typed options] --> M
    M -- native option logits --> P[Probabilities]

Speed

Decisions versus a compact generated array

Same frozen Qwen3.5-4B, same owned state, same 21 binary criteria, one RTX 3090:

Output path Time Output tokens Result
Direct typed logits, median of 3 1.023 s 0 21 probability pairs
Autoregressive JSON array, median of 3 5.332 s 111 Valid ordered 21-value array

The compact generative baseline emits only ordered "yes"/"no" values—no keys, confidence objects, or explanations. Its median first-token time was 0.489 s, but completing the array took 5.21× as long as direct readout. All three arrays were valid and identical. Their choices agreed with direct argmax on 18/21 criteria, so this is a systems comparison rather than a claim that the two readouts are semantically equivalent. Exact prompt, outputs, token timeline, and runs are committed.

Reusing a state across 21 decisions

On an owned 37-state × 21-criterion workload:

Execution path Decisions/s 777 decisions
Fresh direct scoring 2.33 333.1 s
Serial prefix reuse 10.75 72.3 s
Parallel suffixes 20.03 38.8 s
Native reranker 1.86 417.3 s

The owned 37×21 fixture, direct/reuse runner, reranker runner, raw timings, and row-level predictions are included. The fast reuse paths are experimental: BF16 execution changed 5–6 of 777 argmaxes relative to fresh scoring.

Quality

Browser model ladder

System Browser artifact Download Authored balanced accuracy Perturbation balanced accuracy TypeSafe subset agreement
Qwen3-0.6B Q8_0 639 MB 0.440 0.528 0.407
MiniCPM5-2B Q4_K_M 1.56 GB 0.686 0.693 0.637
Qwen3.5-4B Q4_K_M 3.01 GB 0.813 0.766 0.845
Published Jev Closed hosted service — — — 0.883

Native BF16 scores. Browser builds use quantized GGUF. Jev is TypeSafe's published result on the same 102-row subset.

General decision baseline

Frozen workload Rows Direct logits (4B BF16) EXL3 direct (27B, 5 bpw) Native reranker (4B) Published Jev
Authored decisions, balanced accuracy 144 0.813 0.958 0.625 —
WANLI, balanced accuracy 256 0.637 — 0.522 —
TypeSafe selected subset, modal agreement 102 across 20 cases 0.845 — 0.560 0.883
Every judgment grid, accuracy 36 0.806 — 0.694 —
Every action firewall, composed accuracy 10 actions 0.700 — 0.700 —
Every code retrieval, Recall@1 6 queries 1.000 — 1.000 —
Every company knowledge, Recall@1 7 queries 0.929 — 0.929 —

The reranker remained strong at retrieval ranking, but direct logits were the better general-decision baseline.

The Jev number is read from TypeSafe's published records; we did not run a live Jev endpoint. The comparison covers the 102 rows that could be aligned from public artifacts, not TypeSafe's reported 711-row aggregate.

The Qwen3.8-27B EXL3 bridge uses the same 144 authored rows, matching prompt hashes, options, direct-logit readout, and metric as the 4B baseline. It is a system-level quality comparison rather than a controlled model-size or quantization ablation: model family, size, quantization, and runtime all differ. It has not yet been run on the other quality workloads. Across the 777-decision shared-state fixture, its choices agree with the pinned 4B model on 84.43% of rows.

Calibration

Option probabilities are useful only when their confidence matches observed accuracy. SemIf includes per-workload temperature scaling fitted on labeled decisions:

Workload Raw ECE Calibrated ECE, out of fold Temperature
Authored decisions 0.068 0.038 1.23
WANLI 0.208 0.069 2.50
Every judgments 0.050 0.047 1.71

Calibration does not change the selected option. The clear improvement is on WANLI; the intervals overlap on the authored and Every workloads. See the method, caveats, and reproduction commands.

Input

{
  "id": "route-1",
  "state": "Customer cannot access an account after a password reset.",
  "question": "Which queue should handle this request?",
  "options": [
    {"id": "access", "description": "Account access support."},
    {"id": "billing", "description": "Billing support."}
  ]
}

Returned probabilities are conditional on the supplied options. Calibrate and validate them on the workload where they will make decisions. state may also be a nonempty JSON object or array. Direct modes preserve it as structured JSON; reranker mode renders it as document text.

Documentation

Star history

SemIf star history

Evaluation sources

Model weights and third-party source records are not included. Upstream models retain their licenses. Project code is released under the MIT License.

SemIf-OpenJev (TheoLeeCJ/SemIf-OpenJev)

Searching Database…

这是什么?SemIf(原名 OpenJev)是一个独立研究项目,在一块消费级 GPU 上用开放模型运行运行时定义的语义判断,接口与 TypeSafe 的闭源 Jev 服务一致,但不涉及后者未公开的模型。
它是我注册使用的托管服务,还是安装的软件包?既不是服务,也没有等候名单:它是一个可安装的 Python 打分器,附带已提交的基准测试数据,另外还有一个纯浏览器版的 WebGPU 演示,现在就能打开。
我怎么把它跑起来?在 Apple Silicon 上运行 pip install -e '.[test,mlx]',并在打分命令中加上 --backend mlx;纯 CPU 机器则安装 '.[test,llamacpp]',下载一个 GGUF 权重文件,再传入 --backend llamacpp --gguf /path/to/model.gguf。还有一个零安装的浏览器演示。
我需要 Python 和 NVIDIA GPU 才能运行吗?Python 3.10+ 是必需的;默认路线还需要 CUDA 和一块能装下 4B BF16 模型的 GPU。替代方案:通过 MLX 或 PyTorch/MPS 在 Apple Silicon 上运行,或通过 llama.cpp 在纯 CPU 上打分。
它返回的概率有多大程度可以信?这些概率取决于你提供的选项,所以要针对自己的工作负载做校准(内置了按工作负载的温度缩放);另外快速共享状态复用路径仍是实验性的——与全新打分相比,BF16 执行在 777 个 argmax 中翻转了 5-6 个。
所有东西都留在我的电脑上,还是会调用云端 API?完全本地运行:CUDA、MLX、MPS 和 CPU 后端都是给本地权重打分,浏览器演示通过 WebGPU 在浏览器内运行 0.6B-4B 的模型,下载体积为 639 MB-3.01 GB。
代码开源吗?MIT 许可。模型权重不随代码分发——上游模型沿用各自自己的许可证。
必须用 RTX 3090 吗,还是别的硬件也行?任何能装下 4B BF16 模型的 GPU 都可以,Apple Silicon 可通过 MLX/MPS 原生运行,纯 CPU 的 llama.cpp 后端也能从本地 GGUF 权重文件给同样的提示词打分,完全不需要 CUDA 设备。
直接读取 logit 比生成 JSON 数组快多少?在同一块 RTX 3090 上用同一个冻结的 Qwen3.5-4B,21 个二元判据直接读取输出 token 的中位耗时为 1.023 秒,而自回归生成 JSON 数组需要 5.332 秒和 111 个 token——慢了 5.21 倍。
在质量上它和闭源的 Jev 服务有多接近?在对齐的 102 行子集上,Qwen3.5-4B 与 TypeSafe 公布结果的一致率为 0.845,而 Jev 为 0.883;Qwen3.8-27B EXL3 桥接在人工判定的决策工作负载上达到了 0.958 的平衡准确率。
开箱即用支持哪些模型?提供 Qwen3-0.6B、MiniCPM5-2B 和 Qwen3.5-4B 的冻结基线和浏览器版本,另有 Qwen3.8-27B EXL3 桥接以及用于对比的 Qwen3-Reranker-4B;权重需要单独下载,绝不捆绑。
Creator
TheoLeeCJ
Size
9.3 MB
Stars
4.8K
Updated
CommitSep 23
Age
1mo
Commits · 90 Days