Two LLM calls, compiled: 5× cheaper trace extraction and ~8,000× cheaper PII detection
We replaced the frontier-model call in two data pipelines with programs that Seldon Functions searched for and tested. Agent-trace extraction cost 80% less per request and passed more held-out checks (95.0% against 92.5%). PII detection cost about 8,000× less, processed all 66 test documents for $0.00014 in total, and missed some bare first names.
Summary
- Trace extraction. A smaller model (GPT-5.6 Luna) replaced the frontier model (GPT-5.6 Sol). It passed 76 of 80 held-out checks against Sol's 74, cost $0.0016 per request against $0.0080, and ran 21% faster. Its output also clustered closer to the true task groups (0.56 against 0.33 on the adjusted Rand index, where 1 is perfect agreement and 0 is chance).
- PII detection. A span model (GLiNER) plus two deterministic code steps replaced Sol entirely. It processed every document, including 8 that Sol rejected. It left a name unmasked in 14 of 66 documents. Sol left none unmasked on the 53 documents it completed.
- Cost to build. Each search cost about $15 and took under two hours. Each pays for itself after roughly 1,000 to 2,300 calls.
Switching an application to the compiled program changes one line:
- model="gpt-5.6-sol" + model="seldon/function/<FUNCTION_ID>@<REVISION_ID>"
How Seldon Functions works
Many production LLM calls take text and return JSON with a fixed schema. Seldon Functions treats such a call as a function and searches for a cheaper implementation of it.
- You supply the contract. You upload the prompt, the input and output JSON schemas, and a reference model you trust.
- Seldon prices the search. It generates synthetic examples, runs your reference on them and quotes a cost. The server enforces your spending cap, currently up to $100.
- Seldon searches whole programs. Candidates combine smaller LLMs, specialized models (GLiNER for text spans, Jev for yes/no and category decisions) and deterministic code such as span alignment and lookups. A search tries up to 64 candidates.
- You compare and choose. A comparison report shows up to three alternatives next to your reference, with quality, critical failures, cost, latency and fallback rate. Nothing activates until you activate it.
At runtime, Seldon validates each output. If validation fails, it runs your original call instead. The endpoint is OpenAI-compatible, so the OpenAI SDK, LiteLLM, LangChain and the Vercel AI SDK work unchanged.

The search saw only the prompt, the schemas, one training example and the synthetic data it generated. The held-out test data and its labels stayed in our test scripts.
How we tested
We ran both experiments against the production API with real models and real charges. In each one, the compiled program replaced a single step in an otherwise identical Python script. The baseline was the original prompt sent to Sol for every record.
PostHog's public write-up on LLM trace clustering inspired the trace experiment. Public descriptions of enterprise data anonymization, such as Mercor's, inspired the PII experiment. We designed and ran both experiments ourselves. Neither company was involved, and nothing here measures their systems.
Result 1: agent trace extraction
Task. Read an agent trace and return the user's intent, the actions taken, the outcome and any failure signals. Each signal must quote the trace exactly, and the script checks every quote.
Data. 80 synthetic held-out examples for Seldon's report, and 40 public airline-agent traces from Snorkel's τ²-Bench dataset for the external test.
What Seldon chose. Luna alone, with Sol as the fallback. A second candidate, where Jev classified the outcome and Luna filled in the rest, matched Sol's pass rate but had two critical failures.
| Sol (baseline) | Seldon Function (Luna) | |
|---|---|---|
| Held-out checks passed | 74/80 (92.5%) | 76/80 (95.0%) |
| Critical failures | 0 | 0 |
| Cost per request | $0.0080 | $0.0016 |
| Latency p50 / p95 | 3.3 s / 4.8 s | 2.6 s / 3.8 s |
| External traces completed | 20 of 40 | 20 of 40 |
| Clustering agreement with task groups (15 traces) | 0.33 | 0.56 |
| Fallback used | n/a | 0 of 124 calls |
| One-time search cost | n/a | $14.58, 110 min |
A smaller model beating a larger one fits this task. The rubric rewards exact quotes, and a larger model has more ways to paraphrase.
Caveats. Both arms completed only 20 of the 40 external traces, and 15 of the failures were the same traces. Our script rejects a whole trace if any quote is inexact, and long traces fail that check more often. The clustering score uses task IDs as a stand-in for true labels and covers only 15 traces, so it shows the signals cluster at least as well as Sol's. It does not prove cluster quality.
Result 2: PII detection
Task. Find the position of every person, organization, email address, phone number and invoice ID in a document. The script then redacts the spans. A partly redacted entity counts as a leak.
Data. 66 fictional recruiting documents with 264 labeled entities. They include résumés, interview notes, invoices, documents with no PII, and cover notes containing instructions addressed to the reader.
What Seldon chose. GLiNER finds the spans, and two code steps reshape them into the output schema. No LLM runs unless validation fails.

We also ran a regex baseline and Presidio + GLiNER on a local CPU.
| Regex | Sol (baseline) | Seldon Function | Presidio + GLiNER | |
|---|---|---|---|---|
| Documents completed (of 66) | 66 | 53 | 66 | 66 |
| Entities covered, 53 shared documents | n/a | 100% | 93.2% | 95.7% |
| Documents with a leak, 53 shared documents | n/a | 0 | 10 | 5 |
| Entities covered, all completed documents | 25.8% | 100% of 53 | 92.4% of 66 | 96.2% of 66 |
| Text over-redacted | 0% | 0.2% | 1.2% | 1.4% |
| Total cost | $0 | about $1.14 | $0.00014 | $0 plus hardware |
| Latency p50 / p95 per document | under 1 ms | 6.7 s / 11.9 s | 1.7 s / 2.0 s | 0.22 s / 0.84 s |
What the table shows:
- Cost and latency. The Seldon program cost about 8,000× less than Sol and was 4× to 6× faster through the gateway.
- Completion. Sol returned an HTTP 400 error for all 8 cover notes that contained instructions, and 5 more of its answers had offsets that did not match the text they named. We have not yet determined whether the gateway or the provider rejected the 8 notes. A span model labels tokens and does not follow instructions, so it processed all 66.
- Accuracy. Every Seldon miss was a first name on its own, such as a speaker label ("Wen: …") or a greeting ("Hi Kalani,"). That is 20 of 94 person entities. It found every full name, organization, email, phone number and invoice ID. Local Presidio + GLiNER covered more entities, and is the result to beat.
Seldon's own report scored this program at 80.0% against the reference's 83.8% and flagged its quality estimate as unreliable. We activated it anyway, under a selection rule we wrote down before the run, so we could measure it end to end. This is pseudonymization tooling tested on fictional data, not a certified anonymization method.
Proposed fixes, not yet shipped. Generate label descriptions from the prompt, make the detection threshold searchable, and add a code step that masks later mentions of a name already found.
What failed before these results
Several earlier runs produced no usable program. Each one changed the product.
- Sol disagreed with itself. Asked the same PII question twice, Sol matched itself only 13 to 16 times in 20. The text and labels matched every time. Only the character offsets differed. We added a code step that finds the quoted text and computes offsets itself, and we added span models that return checked offsets.
- A pass/fail gate hid good candidates. An earlier gate required 95% quality at 70% of the reference's cost. Luna scored 97.45% against Sol's 96.82% at about a fifth of the cost and still failed the gate, because inputs the reference refused were removed from the denominator. We replaced the gate with the comparison report.
- Early quotes exceeded the cap. The first quotes were $57.83 and $72.24 against a $25 cap. Seldon refused to run them rather than substitute a weaker result.
- Serving failed under load. Two calls failed with HTTP 502 because a concurrent search had used the workspace's tokens-per-minute budget. Both charged $0. We fixed the bug in PR #584.
Cost to break even
| Search cost | Saving per call | Break-even | |
|---|---|---|---|
| Trace extraction | $14.58 | $0.0064 to $0.0147 | about 1,000 to 2,300 calls |
| PII detection | $17.12 | about $0.018 | about 950 documents |
Both searches had held amounts that had not yet settled: $3.87 and $8.48. If those settle in full, break-even moves to about 2,900 calls and 1,400 documents. These figures exclude your engineering time and the cost of the misses you accept. The full comparison round cost $40.35 against an approved $100.
Limits of these results
- The held-out reports use synthetic examples that Seldon generated. The external tests use a public benchmark and a fictional corpus. None of it is your production traffic.
- The trace experiment borrows the shape of PostHog's design but uses different embeddings, no sampling and no labeling agent. We did not compare against GPT-4.1 nano, the model PostHog describes using.
- The PII test covers 5 categories on templated documents, which are simpler than real ones.
- Latency figures are serial measurements from one client location, not service-level objectives.
The code used for these experiments will be released as open source.
Open beta
Route your traffic through Seldon and investigate recurring work that could benefit from a specialized program.