TENS LAB
TENS LAB
Works
SYSTEM 01ACTIVE BUILD

CONTEX

A deterministic token compiler for structured data before it enters an LLM context window.

THE PROBLEM

Modern frontier models operate on discrete token sequences, yet production applications routinely feed them raw web JSON. Between 60% and 80% of prompt tokens are spent on syntax boilerplate: braces, brackets, quotes, and repeated column keys across hundreds of rows.

The transformer self-attention mechanism computes quadratic operations over structural punctuation that contains zero factual intelligence.

THE THESIS

What if structured database payloads were compiled into a canonical, token-aligned columnar representation before the tokenizer runs, preserving schema types while eliminating syntax noise?

ARCHITECTURE & APPROACH

Measured token density and serialization overhead across representative structured payloads: relational tables, nested entity graphs, and tool-call API responses.

Tested model reasoning accuracy on multi-row extraction, numeric aggregation, and classification tasks when syntax is compiled to clean columnar slot tables. Accuracy held at 100% in all tested cases.

INTERACTIVE COMPILER PREVIEW

Built Contex: an ultra-fast deterministic compiler (<4ms on standard CPU) with drop-in SDK middleware for OpenAI and Anthropic. Produces a token-efficient canonical format designed to maximize static prefix reuse and KV-cache hit rates.

Compiler Preview
JSON Input325 Tokens
[
  { "id": 1, "name": "Alice", "role": "admin", "dept": "Engineering" },
  { "id": 2, "name": "Bob",   "role": "user",  "dept": "Marketing"  },
  { "id": 3, "name": "Sam",   "role": "admin", "dept": "Engineering" }
]
Canonical IR Output
65 Tokens80%
@enum role: a=admin u=user
@d	Engineering

id	name	role	dept
1	Alice	a	@0
2	Bob	u	Marketing
3	Sam	a	@0
Projected Savings:$14/yr

BENCHMARK FINDINGS

Achieved 60% to 80% input token reduction across structured tabular payloads in sub-4ms compilation time.

Frontier models achieved 100% extraction and mathematical precision, matching raw JSON responses byte-for-byte while cutting latency and API costs significantly.

NEXT MILESTONES

Expanding intent-conditioned field selection and packaging local MCP server support for autonomous coding agents.