September 28, 2026
Building decengine: A Local, Embedding-Based Alternative to JEV
How decengine uses local embedding models for typed semantic decisions, with JEV as a closed-source reference point and Laya's ModernBERT approach as a contrasting design.
decengine started with a deliberately unglamorous question: what should an application use when it needs a small semantic judgment, but does not need a chatbot?
One useful way to frame the project is as a local, embedding-based alternative to JEV. JEV is the viral reference point for this kind of narrow semantic decision interface, but it is closed source. decengine does not claim to reproduce JEV’s behavior exactly. Instead, it takes the shape of the problem seriously—state in, typed decisions out—and builds an inspectable local implementation around embedding models that can run offline on Apple Silicon.
That framing also makes the Laya comparison useful. Laya approaches similar decision tasks through ModernBERT used directly as a masked language model, whereas decengine’s planned runtime represents the state/question and candidates as embeddings, then scores their relationship. Both are attempts to turn language-model capability into structured decisions rather than generated text, but they make different modeling choices. The point of retaining both comparisons is not to crown a universal winner; it is to make the trade-offs visible.
There are plenty of situations where software needs to interpret a piece of state and make a bounded decision. A support system might need to select the best owner for a ticket. An internal workflow might need to determine whether the available evidence supports a proposition. A triage tool might need to place an issue on an ordered severity rubric. These are semantic tasks, but they are not open-ended conversations. They should not require generated prose, tool calls, an agent loop, or an implicit cloud request.
That is the premise behind decengine: a local runtime that accepts application JSON plus a small set of typed questions and returns structured, machine-readable decisions. The v1 target is Python developers on Apple-Silicon Macs. The intended production path uses local embedding inference through MLX/Metal, and the public surfaces are a pure-Python CFFI package and a loopback HTTP service.
The interesting part of the project is not simply that it uses embeddings. It is the collection of constraints around them: keep the decision contract narrow; keep models local; make integration independent of a Rust build; prevent hardware-specific details from leaking into application code; and keep research findings, fixture behavior, and release claims rigorously separate.
This post is a cleaned-up narrative of the product requirements, technical design, implementation, verification plan, and retained experiment record. It also describes the most important current fact about the repository: it is a tested development vertical slice, not yet a releasable v1 model runtime.
The comparison: local embeddings, ModernBERT, and a closed reference
The three systems in the archive should not be collapsed into the same thing.
- JEV is a closed-source external system and a useful behavioral reference for a typed semantic-decision interface. The archive retains comparison requests, normalized results, timing, errors, and descriptive metrics, while excluding credentials. It is not a decengine backend, and a comparison result is not evidence of SDK compatibility or behavioral equivalence.
- decengine is the local runtime being built. Its intended production route uses Qwen3-family embedding models, model-profile-controlled query/candidate formatting, last non-padding-token pooling, L2 normalization, and similarity-based typed decisions. The architecture is designed so this path is offline, inspectable, and available through the same Rust service for Python and localhost HTTP clients.
- Laya is a distinct comparison system. It uses ModernBERT directly as a masked language model rather than treating embeddings as the primary decision interface. Its MLX work and CPU-reference parity evidence are retained as comparison material, not as a substitute engine for decengine.
This distinction changes what “local JEV” can reasonably mean. It should not mean claiming an implementation has copied a closed model’s latent behavior. It means offering the same category of application primitive—a typed decision over state—through a transparent local architecture. With decengine, the supported model identities, model profiles, scoring operation, cache key, execution boundary, local-install process, and release gates are all explicit. That transparency is the product advantage even where a closed reference may have stronger behavior today.
The comparison record is deliberately conservative. On one archived 100-case prompt report, JEV recorded 258/300 (86.0%) and the Qwen baseline recorded 141/300 (47.0%). That is descriptive context from a fictional fixture, not calibrated accuracy, platform equivalence, or a release claim. Likewise, a Laya float32 run recorded 59.0% owner, 61.0% urgency, 41.0% impact, and 18.0% complete-case accuracy on its stated 300-case comparison. Those numbers locate the systems in an experiment; they do not make Laya a decengine backend or prove that either approach will generalize to an arbitrary production workflow.
The useful question is therefore architectural rather than tribal: for a bounded decision task, do we want a local embedding representation scored against explicit candidates, or a direct masked-language-model formulation? decengine is choosing the first route because it makes candidate reuse, GPU-resident matrix scoring, a small typed output, and clear separation between model-specific formatting and application code natural parts of the system.
The product begins by saying no
The fastest way for a local AI project to become vague is to call it an “agent” and leave the job definition open. decengine takes the opposite approach. Its product boundary is intentionally narrow: applications ask typed semantic questions about supplied state, and the engine returns typed results.
There are three result classes:
- Choice selects one named candidate, returning that choice, the candidate distribution, and directional confidence.
- Noul evaluates whether the supplied state supports a proposition, returning support as a value in ([0, 1]).
- Score evaluates an ordered rubric, returning a selected level, its distribution, a legend, an expected numeric score, and confidence.
These types are deliberately more constrained than text generation. A caller does not need to parse prose or invent its own response schema. It provides state and explicit candidate/rubric semantics, then branches on a stable result type.
That decision has a corresponding list of non-goals. v1 is not a general-purpose language-model API. It does not generate text, execute tools, train or fine-tune models, call an external inference provider, or silently fall back to one. It does not promise arbitrary architectures, vector-database features, ANN search, reranking, mobile distribution, broad operating-system support, calibrated correctness, out-of-distribution guarantees, or behavioral equivalence with a proprietary System One implementation.
Those exclusions are not missing features accidentally left for later. They are what make the intended product legible. The question is not “how can an application call an LLM locally?” It is “how can an application make a few repeatable semantic decisions locally, with a contract it can integrate and test?”
Why local is more than an inference location
“Runs locally” often means only that a model happens to be installed on a developer machine. decengine treats local execution as an operational property with a defined lifecycle.
The only normal network-capable operation is explicit model installation through decengine pull <model>. Models are limited to an allowlist for v1:
Qwen/Qwen3-Embedding-0.6Bmicrosoft/harrier-oss-v1-0.6b
Both are intended to use the same dense Qwen3 0.6B embedding path. Their profile configuration controls checkpoint packaging, tokenizer behavior, padding, query and candidate formatting, pooling, normalization, token limits, and temperature. Public callers should not need to know which prompt prefix, pooling position, or checkpoint-specific compatibility detail is correct. They ask a typed question; the model profile owns the embedding details.
Installation records each file’s SHA-256 hash in install.json, and the runtime verifies those hashes again before resolving a model. Once a checkpoint is installed, ordinary inference is offline. There is no telemetry path and no cloud fallback path waiting in reserve. The server defaults to a loopback binding, rather than accidentally becoming a network service by default.
This makes privacy and failure behavior easier to reason about. If local model loading fails, the result should be a local error—not an invisible request to a remote provider and not a fabricated result from a different backend.
A decision model, not a similarity API
Embedding systems are often exposed as raw vectors and cosine similarity. decengine intentionally stops one level higher. Applications declare a semantic decision rather than receiving hidden states, cosine scores, or device arrays to interpret themselves.
The intended calculation is conventional but useful when placed behind a typed contract. For normalized query vector (q), normalized candidate matrix (C), and model-profile temperature (T):
Choice takes (\arg\max(p)). Noul returns the probability assigned to the semantic supported outcome. Score maps each rubric level to an ordinal value and calculates:
The default confidence proposal is a normalized distribution-entropy measure:
where (k) is the number of candidates. That confidence is bounded and directional: a concentrated distribution produces a higher value than a diffuse one. It is not a claim that the result has that probability of being correct. Preserving that distinction matters. A model can be decisive and wrong, especially on an unfamiliar task or incomplete state.
The product therefore tries to give an application the useful outputs it needs—typed decisions, distributions, directional confidence, and cache information—without promoting a raw similarity score into a broader claim about correctness.
Turning the boundary into an architecture
The technical design starts with one strict dependency direction:
flowchart TD
P["Python CFFI / HTTP"] --> R["DecisionService"]
R --> C["Versioned compiler"]
C --> E["DecisionEngine trait"]
E --> M["MlxDecisionEngine"]
M --> X["mlx-rs 0.32.0"]
X --> G["MLX / Metal"]
Only decengine-engine-mlx may depend on mlx-rs, MLX arrays, Metal, or GPU buffers. That is not merely a preference for clean modules. It is a way of enforcing the promise that application code, the protocol, the Python SDK, and the ABI remain independent of device tensor types and MLX implementation details.
The engine boundary is intentionally coarse. It supports loading, evaluating a compiled batch, and unloading. It does not expose an embed function, a cosine helper, raw softmax outputs, hidden states, or device tensors to the rest of the workspace. Everything above the boundary sees an opaque decision engine.
This makes a few later changes possible without rewriting clients. Batching strategies, candidate residency, memory behavior, or even multiple resident models can change internally while the public decision contract stays stable. For v1, DecisionService serializes access to the engine. That is a valid constraint for a first local runtime: it makes GPU ownership and model state explicit, and it can later be replaced by more advanced scheduling behind the same interface.
The workspace is organized around these responsibilities rather than around a monolithic “AI crate”:
| Component | Responsibility |
|---|---|
decengine-core | Stable questions, results, errors, and validation. |
decengine-compiler | Versioned semantic compilation and cache-key construction. |
decengine-engine | The opaque engine contract and test-only fixture engine. |
decengine-engine-mlx | Apple-Silicon MLX implementation and the only mlx-rs dependency. |
decengine-models | Model profiles, allowlist, downloads, checksums, and local storage. |
decengine-runtime | Model-bound orchestration through the shared decision service. |
decengine-protocol | Versioned localhost wire mapping. |
decengine-ffi | Panic-contained C ABI and allocation ownership rules. |
decengine-server | Axum routes and HTTP error mapping. |
decengine-cli | serve, pull, list, and rm commands. |
The project pins Rust 1.88, uses edition 2024, and pins dependencies rather than leaving important runtime behavior floating. The MLX dependency is exactly mlx-rs 0.32.0, conditional on macOS/aarch64. That specificity matters because a change in the MLX binding is not considered an ordinary package update; it triggers defined parity, regression, performance, memory, CFFI, and HTTP revalidation work.
Compilation and cache identity are part of correctness
The compiler does more than turn a request into strings. It canonicalizes and versions semantic inputs, builds the formatted query and candidates, and produces deterministic cache identity.
Every compiled decision contains its semantic kind, formatted query, candidates, optional ordinal values, and cache key. Candidate-cache identity includes the model ID, model-profile version, compiler version, question kind, prompt, candidate text, and role templates. Those are the inputs that can change a candidate vector’s meaning.
There is one intentional omission: application state is not part of the candidate key. State changes the query representation; it does not change the meaning of a named candidate or rubric level. Keeping those concerns separate makes it possible to reuse candidate representations across changing state instead of treating every new request as an entirely new candidate set.
The target model path is equally explicit:
flowchart LR
T["Token IDs"] --> Q["Qwen3 forward"]
Q --> P["Last non-padding token pool"]
P --> N["L2 normalize"]
N --> S["Matrix similarity"]
S --> F["Temperature + softmax"]
F --> O["Small typed result"]
The aim is to keep the tensor-heavy steps—forward pass, pooling, normalization, matrix similarity, temperature application, softmax, expected-score calculation, and simple confidence logic—in the engine and on the GPU where practical. The rest of the system receives the small result it needs, not a large intermediate representation that it could accidentally materialize or misuse.
Two integration surfaces, one service
The primary intended developer is a Python user on Apple Silicon. The in-process path is deliberately independent of building native code at package-install time:
Python → CFFI ABI mode → extern C → libdecengine.dylib → Rust core
The native Rust library is installed independently. The Python package is a pure-Python typed CFFI wrapper; it should not invoke Cargo, Xcode, MLX, or a native compiler when it is installed. That separation lowers packaging friction and makes the lifecycle of the native runtime explicit.
The C ABI uses opaque handles, UTF-8 JSON inputs and outputs, integer status codes, explicit response-string ownership, and thread-local error reporting. No Rust type, allocator assumption, panic, MLX type, or GPU buffer crosses the ABI boundary. Callers release responses only through de_string_free; de_last_error is valid until the next ABI call on that thread. The internal ABI JSON is versioned independently from the HTTP wire format.
The second surface is decengine serve, exposing:
GET /healthzGET /v1/modelsPOST /v1/systemone
The systemone-v1 wire contract includes model selection, JSON state, named typed questions, typed results, metadata/usage, and { "error": { "code", "message" } } error envelopes. It is an inferred compatibility target for a System One-shaped interface, not a claim of behavioral equivalence with a proprietary product. A release would still require a sanitized real SDK request/response transcript and an approved SDK-against-server test.
The important architectural property is convergence: Python and HTTP are two ways of reaching the same Rust decision implementation. They are not parallel decision engines that can silently diverge.
Fixture mode is not model mode
One of the most deliberate decisions in decengine is that it exposes two clearly separated execution modes:
| Mode | Intended use | What it proves |
|---|---|---|
fixture | Portable development, unit tests, UAT, and integration | The software contract behaves correctly. It is deterministic lexical logic, not a model. |
mlx | Offline local inference on macOS/Apple Silicon | Model behavior, but only after separate hardware and parity gates pass. |
This seems like a small implementation detail until a project reaches the point where its tests are green. A fixture backend is extremely useful: it lets a Python SDK, C ABI, HTTP client, error mapper, and application integration be tested portably. But it cannot demonstrate that a real model loaded, embedded text correctly, matched reference vectors, kept tensors resident, or produced useful decisions.
decengine names and feature-gates this distinction rather than hiding it. The boundary checker rejects MLX/device-symbol leakage outside the MLX engine crate and rejects known remote-inference clients from inference crates. Release builds use --no-default-features --features mlx, and fixture functionality must be excluded from release artifacts.
The current MLX behavior makes the point even more plainly. The dense Qwen3 forward path is not yet implemented in decengine-engine-mlx. The engine returns a clear model-load failure instead of silently substituting fixture logic or a remote provider. That is a less satisfying demo, but a more trustworthy engineering boundary.
What the portable vertical slice already establishes
The existing green work is substantial. The repository contains validated public types; deterministic compilation and cache keys; fixture inference; the allowlisted model lifecycle and integrity checks; a shared service; a C ABI; the pure-Python client; localhost HTTP routes; CLI commands; source packaging checks; protocol fixtures; and native, Python, UAT, and route-level tests.
The verification strategy is intentionally layered:
| Layer | Environment | What it can establish |
|---|---|---|
| Rust tests | Portable | Core types, compiler, cache, model store, runtime, ABI, routes, and CLI behavior. |
| Python tests | Portable | Public API, validation, CFFI status/ownership, and exception mapping. |
| Developer UAT | Portable | A developer can install, integrate, and branch on typed results. |
| HTTP black-box UAT | Portable with Rust | A wire client can use each required route and result shape. |
| Model parity | Apple Silicon | Embeddings match documented official references. |
| Decision regression | Apple Silicon | Both models preserve frozen semantic behavior. |
| Residency and performance | Apple Silicon | GPU/host-boundary, latency, and unified-memory evidence. |
The first four categories are software-contract evidence. The final three are model/runtime evidence. Passing make lint, make test, make uat, and python scripts/check-boundaries.py does not establish that a production checkpoint works. This distinction is repeated throughout the project because it is exactly the kind of boundary that becomes blurry when an AI prototype starts to look polished.
The CFFI test strategy is a good example of that discipline. Python tests compile a minimal independent C fixture implementing the public header, then call it through the production ffi.dlopen wrapper. This tests declarations, status conversion, pointer ownership, JSON decoding, and context management without hiding a wrapper bug behind a Rust-linked Python test. Separate Rust ABI tests exercise the real shared core.
Research was kept separate from release claims
The repository also retains a broad set of experiments: Qwen prompt variants, fixed-task probes, varied-question scorers, all-Metal replay, prompt-serialization work, LoRA comparisons, and contextual comparisons with JEV and Laya. The research record is useful, but it has a strict interpretation boundary: these experiments are not a substitute for the missing native MLX release path.
The fixtures are fictional and annotation-bearing. Request fields are inference inputs; references, rationales, and metadata are evaluation-only. The experiment process preserves hashes, manifests, configuration, raw predictions, distributions, timing scope, and post-hoc metrics. Predictions are written before metric functions open test references. Grouped cross-validation keeps declared and near-duplicate examples together. Sealed test sets are not pooled into selection or fitting. When an intervention is label-informed, that is recorded rather than recast as independent generalization evidence.
The retained chronology begins with prompt work on 2026-09-23. A direct binary-rubric variant reached 75/150 on one inspected 50-case holdout compared with a 69/150 baseline, but the gain came entirely through urgency and the variant did not win on development. A development-only task-instruction sweep improved impact slightly—75/150 versus 72/150 on cases 001–050—but did not improve owner or urgency. Neither result justified a production-profile change.
The separate locked 60-case evaluation made the limitation more obvious. The baseline scored 88/180 (48.9%) and the frozen task-instruction configuration scored 96/180 (53.3%), yet both predicted urgent for every case: 100% sensitivity and 0% specificity. The revised format was therefore not promoted. The lesson was not that prompt work is useless; it was that a small aggregate improvement can conceal a failure mode that matters more than the headline number.
Fixed-task embedding probes provide another example. Train-only grouped logistic-regression heads evaluated on an untouched 90-case set produced task-specific macro-F1 averages of .744 for Qwen and .765 for Harrier. But state-only controls were stronger at .805 and .795. That means the experiment did not support a causal claim that task-specific query vectors caused the apparent success on this small fixture. A later Metal replay matched all 300 archived CPU labels with maximum probability drift below (4 \times 10^{-7}), and reported roughly 79 ms per case at p50. That is useful parity evidence for the frozen probe path—not proof that the decengine runtime is release ready.
The project then moved from fixed owner/urgency/impact questions toward varied question forms. A generic pairwise scorer used query/candidate embeddings and feature construction ([q, c, q*c, |q-c|]), scoring candidates with a within-question softmax and calculating ordinal expectation separately. A quality-screened 300-row, 15-family training set was separated from a 200-row, 10-family test set under leave-one-question-family-out constraints. The completed bounded optimizer selected Qwen (C=1.0) and Harrier (C=.01), reaching exact accuracies of .495 and .465. Those results support only the narrow single-question LOQFO fixture; they do not establish generalization to unknown domains or arbitrary future questions.
Matched multi-question evaluation stayed similarly conservative. On 60 cases and 180 questions, Qwen scored .333 on Choice, .483 on Noul, and .350 on Score; Harrier scored .367, .450, and .367. Each model got all three questions right in 6 of the 60 cases. The archive calls calibration figures descriptive and question-local rather than making a general correctness claim.
Later all-Metal work kept pair construction and scoring on the GPU after transferring only token IDs into MLX, returning only final probabilities. It reproduced all 180 matched selected labels. The first observed Qwen latency was an unresolved outlier at 527 ms/case p50; repeated fresh processes put both models near 296–298 ms/case p50. The record retains the outlier rather than editing it away.
The same approach appears in the explicit-state, prompt serialization, and LoRA studies. The explicit-state clarity condition was correctly labeled an authored, label-informed intervention. Prompt serialization was isolated from frozen runtime/compiler/holdout inputs and restricted to train-only grouped CV. A fresh-60 LoRA evaluation used a hash-bound selection freeze and disclosed an inference-only 512-token policy because every question exceeded the 288-token training guard. Both LoRAs achieved 15/60 Choice, 30/60 Noul, 20/60 Score, and 0/60 all-three, and the interpretation explicitly keeps the out-of-training-length limitation in view.
These experiments give the project a real engineering record. They do not magically transform an unfinished native engine into a released product. That separation is the point.
Evidence, provenance, and what the archive cannot say
The source tree retains the product and technical documents, implementation, model manifests and profiles, test fixtures, research scripts, results, benchmarks, CI/release scripts, and public C header. The research archive indexes 63 Markdown reports under results/ and benchmarks/ alone. It also provides an interpretation checklist: before drawing a conclusion, identify the execution path, data status, metric scope, and claim boundary.
The project documentation is careful about a second limitation: there is no usable Git history for the examined checkout, and the accessible OpenCode databases did not contain historical decengine construction sessions. The chronological account is therefore an artifact-derived reconstruction from dated result directories, reports, source documentation, fixtures, code, and preserved failures—not a fabricated transcript of prompts and tool calls. This is a useful constraint to state publicly. A precise history should be backed by actual provenance, not reconstructed with false confidence.
For future work, the archive recommends retaining sanitized session exports, meaningful commits or signed source snapshots, and short decision records that link questions, input hashes, commands, outputs, and whether a result changes a product or release decision. Those are mundane practices, but they make a project easier to trust and easier to continue.
The result, and the remaining red gate
The result today is a carefully bounded local-decision design with a working portable developer surface and a substantial measurement discipline. It has a frozen product contract, a compartmentalized architecture, model-store lifecycle, compiler, fixture backend, runtime, ABI, Python wrapper, localhost server, CLI, tests, UAT, packaging checks, and a retained research record.
It does not yet have a releasable v1 inference engine. The release gate remains red until the project can demonstrate all of the following:
- Dense Qwen3 inference through the pinned MLX binding for both allowed model profiles.
- Tokenization, pooling, normalization, embedding, ranking, and similarity parity against documented reference tolerances.
- Frozen semantic regressions across Choice, Noul, Score, multi-question, English, Indonesian, clear, and ambiguous fixtures.
- Offline inference, cache reuse, local-error handling, CFFI, and HTTP behavior on the production path.
- Evidence that avoidable tensor/scoring work is not materialized on the CPU.
- Published latency and peak unified-memory measurements.
- A
--no-default-features --features mlxproduct build that excludes fixture functionality. - Release-dylib UAT, an approved System One SDK test, and complete release packaging, checksums, licensing, supported-model metadata, and benchmark reporting.
The planned Apple-Silicon distribution is correspondingly concrete: bin/decengine, lib/libdecengine.dylib, include/decengine.h, Python installation guidance, checksums, licenses, and supported-model metadata. The pure-Python wheel remains independent and must not bundle the native library or contain a Rust build hook.
That may sound like a lot of caveats for a project post. I think it is the right conclusion. decengine is most useful if it remains honest about the boundary between a good architecture, a tested software contract, an interesting research record, and a production model-runtime claim. The next release-critical chapter is not another prompt tweak. It is the dense Qwen3 MLX implementation, two-checkpoint Apple-Silicon parity, GPU-residency evidence, and complete packaging verification.
The project is available at github.com/rifqi2320/decengine.