/docs/latentscript

LATENTSCRIPT v0.1

A small, typed DSL for latent-space manipulation — with explicit inputs/outputs, deterministic validation, and safety gates.

Design goal

Auditable latent ops

No hidden side-effects. Every transform is explicit.

Core idea

Typed vector spaces

Dimensions + space tags are validated.

Safety

Constraints + gated emit

No decode/emit unless constraints pass.

Spec & syntax overview

LATENTSCRIPT is typed, validator-first, and built for ML engineers doing prompt steering, embedding/activation engineering, and latent-vector pipelines.

Status: v0.1 reference draft

Program structure

  • let name : type? = expr; — bind values (single global scope in v0.1)
  • set key = literal; — set safety + runtime policy knobs
  • constraint name? : predicate; — hard safety checks
  • emit expr as "json"|"text"; — privileged output

Minimal example

set max_norm = 20.0;

let p : prompt = "Make this more formal";
let v = encode(p, encoder="emb:my-encoder") @space("emb:my-encoder");

let dir = encode("more formal", encoder="emb:my-encoder") @space("emb:my-encoder");
let v2 = shift(v, dir, alpha=1.0);

constraint bounded : norm(v2) <= 20.0;
emit v2 as "json";

Types & built-ins (v0.1)

Value types

  • prompt
  • vec[d] (space-tagged)
  • mat[d,k] (optional in v0.1)
  • scalar / bool

Core built-ins

  • shift, mix
  • project, orthogonalize
  • dot, norm, cosine
  • encode / decode

Safety model (validator-first)

  • Hard bounds: max_norm, max_shift_alpha, max_decode_tokens
  • Space compatibility via @space("...") tags
  • emit is privileged — runtimes should refuse decode/emit if any constraint fails

Why LATENTSCRIPT

Most teams start with notebooks, prompt templates, or ad-hoc vector scripts. That works — until you need audits, reproducibility, and safety gates across environments.

Approach What it's great for Where it breaks LATENTSCRIPT advantage
Raw prompt engineering Fast iteration, simple style steering Hard to quantify, brittle, no typed safety gates Explicit transforms + constraints; reproducible intent
Notebooks + Python scripts Research prototypes, full flexibility Difficult to audit; policy enforcement is ad-hoc Small surface area; validator-friendly; portable pipelines
LCEL / orchestration graphs Tool routing, chains, agent workflows Not a first-class language for latent geometry Geometry primitives (project/orthogonalize) as core
Activation steering scripts Feature-level control, SAE/probing workflows Opaque policy; difficult to describe + share safely Space tags + hard bounds + gated emit for safer sharing

Operational win

Auditability

A small DSL is easier to diff, review, and gate than free-form code.

Engineering win

Portability

Same program can target embeddings, activations, or SAE spaces via runtime backends.

Safety win

Constraint-first

Hard bounds and explicit emit gating are built into the language.

Runnable examples

This in-browser playground runs a lightweight validator + compiler preview (no model calls). It shows how a runtime would interpret bindings, settings, and emissions.

Program (.ls)

Tip: the preview compiler understands set, let, constraint, emit, and simple annotations like @space("...").

Preview output

Validation

 

Compiled manifest (preview)

 
Note: a production runtime would execute encode/decode against a configured backend. This page intentionally runs no external calls.

Pricing

Validator-first tooling is free. Production runtimes (model backends, policy modules, and governance) are available as hosted or enterprise deployments.

LATENTSCRIPT v0.1 tiers (draft)

Starter

$0

Parser + validator for local workflows.

  • • Reference grammar + AST
  • • Static checks: types/dims/space tags
  • • Constraint evaluation hooks

Pro (hosted)

$99/seat/mo

Production runtime with backend connectors.

  • • Hosted validator + policy gating
  • • Backend connectors (embeddings / activations / SAE)
  • • Program registry + versioning
  • • Usage analytics & audit logs

Enterprise

Custom

On-prem + governance integrations.

  • • On-prem deployment + SSO
  • • Policy modules for regulated domains
  • • Custom validators (space allowlists, content gates)
  • • SLA + dedicated support

Pricing shown is a draft for presentation purposes. Final tiers depend on which model backends, vector spaces, and compliance requirements your deployment needs.