SOPHIA XT
Sign in
Open spec · Apache 2.0 · v0.1.0a1

Lock the tokens
that must not move.

A .lensx file declares which positions in an answer are fixed to literal text or a retrieved fact, where the facts come from, and how the result is validated. The runtime turns that into a forced-anchor decode. Locked positions are excluded from the unmasking loop, so no denoising step can overwrite them.

Decode Locked positions never change Sample tokens
Refunds
are
accepted
within
30
days
of
delivery.
You
&
start
#
return
▒
░
+
*
@
&
%
#
▓
▒
░
step 3 of 12 free positions resolved 3 of 16 locked positions: 8, rewritten 0 times
With locks on, the first eight positions hold a literal retrieved from a locus and are excluded from the unmasking loop, so no denoising step can overwrite them. With locks off, the same positions diffuse like the rest and the answer drifts from the source. The spec example further down generates 192 positions. This grid shows 24.
253tests passing on a default clone, 259 collected
2backends shipped, with Anthropic next
DETERMINISTICguarantee level on masked-diffusion backends
Apache 2.0licence, code and runtime

The suite collects 259 tests, and what it reports depends on the install. On a default clone without the optional PyTorch extra it runs 253 passed, 5 skipped, 1 deselected and nothing fails. With that extra present, at commit 01e5eed, ten more tests run and it reports 256 passed, 2 skipped, 1 failed. The one failure is test_variant_factory_set, which expects the variant registry to hold exactly the seven base variants when five width-sweep entries have since been added beside them. That is a stale assertion and not a fault in the library, and it is written here because you will meet it.

60-second tour

YAML in. Token-locked output out.

1 · Write a spec
medical_basic.lensx yaml
version: "0.1"
base:
  model: "cassandra-t1.5"
locks:
  - range: [0, auto]
    source: locus("medical:cardiology:nitroglycerin:standard_dose")
generation:
  total_length: 192
2 · Run it
shell bash
lensx validate examples/medical_basic.lensx
lensx run examples/medical_basic.lensx --backend cassandra-t1.5 --show-provenance

The locked content from the locus appears at exactly the positions you specified. On masked-diffusion backends that holds by construction. On an autoregressive API the runtime uses logit bias and retries, and the guarantee is best-effort. The model id cassandra-t1.5 is the repository's identifier for its Cassandra T1 family backend.

Why this exists

Other tools constrain the shape of an answer.

lens-xt constrains the content at specific token positions. That matters when a literal disclaimer has to appear early, or a retrieved fact has to appear unchanged inside a freely generated answer.

ApproachWhat it constrainsGuarantee level
Prompt engineeringinformal natural-language hintsnone
OpenAI structured outputsschema fieldstype-level
Outlines, LMQL, Guidanceregex or grammar over the outputtype-level
JSON Schema validationpost-hoc checkretry on failure
LENS-XTtoken positions in the answer slotDETERMINISTIC on masked diffusion, BEST_EFFORT on an API
Backends and guarantees

The same spec, four guarantee levels

The runtime picks the strongest available backend for your spec. Switching from a local Cassandra model to OpenAI does not mean rewriting it.

BackendRuns whereGuarantee
Local masked diffusion (Cassandra T1 family, LLaDA)self-hostedDETERMINISTIC
API-compatible (OpenAI, Anthropic)remote APIBEST_EFFORT
API-native diffusion (future)remote APIDETERMINISTIC
Hybrid (API plus local)mixedDETERMINISTIC
SDKs

Three-line drop-in. Two languages.

Python · pip install lens-xt

python
from lens_xt import LensX

lens = LensX("medical_basic.lensx")
print(lens.run(user_input="What's the standard dose?"))

Node and TypeScript · npm install @sophiaxt/lens-xt

typescript
import { LensX } from "@sophiaxt/lens-xt";

const lens = new LensX("medical_basic.lensx");
console.log(await lens.run({ user_input: "What's the dose?" }));

Or skip the SDK and run the CLI directly: lensx run examples/medical_basic.lensx

v0.1 status

What is shipped, what is next

v0.1.0a1 is an alpha, and APIs may shift before v0.1.0. End-to-end verified against a Cassandra T1 checkpoint with anchor_preservation_rate 1.000 and the DETERMINISTIC guarantee preserved.

  • YAML parser, AST and validator shipped
  • Lock resolver (literal, locus, retrieval, compose) shipped
  • LTMi-XT keyword retrieval (v0.1) shipped
  • LTMi-XT lattice-walk retrieval (v0.2, BLAKE2b section 2.4) shipped
  • Reasoning scaffold runtime (multi-stage) shipped
  • Local masked-diffusion backend (Cassandra T1 family) shipped
  • OpenAI backend (logit-bias and retry) shipped
  • HTTP API server (FastAPI) shipped
  • Python SDK (LensX class) shipped
  • TypeScript SDK (@sophiaxt/lens-xt) shipped
  • Anthropic backend next
  • Native backend for hosted diffusion APIs (Mercury) planned