Skip to main content
Superintelligence
Back to all posts
•12 min read•By Milindu Sanoj Kumarage

How We Cut an AI's Input by About Half

How we cut a monthly AI prompt from 52,602 to 29,200 tokens (-44%) by mixing CSV with JSON, with 6 blind-judged runs verifying zero loss in accuracy.

Once a month, a quiet automation runs in the background of our stack. It pulls the last four weeks of sales pipeline data, feeds it to an AI model, and asks for an executive review.

The job was working fine. But one afternoon, I decided to check the payload logs.

I stared at the counter: 52,602 tokens.

For context, a typical novel is about 70,000 words. We were basically handing the model a small novella every month just to get a straightforward business report. It was slow, expensive, and crowded out the space the model needed to actually think and write.

We set a simple goal:

How much can we shrink this payload without losing any information the model actually needs?


The Short Version

  • The Cut: We shrank our monthly AI prompt by 44%.
  • Format Hype Failed: Switching to YAML or TOON saved almost nothing.
  • The Culprit: 94% of the bloat came from repetitive sentences across 3 lists.
  • The Fix: An AI reads text, not schemas. We mixed formats: CSV tables to kill repeating row keys, JSON for settings, and short codes for repetitive sentences.
  • Zero Quality Loss: Six runs and a blind judge confirmed no measurable drop in accuracy.

How We Measured

  • Data: Real input from one monthly run (a JSON payload of 124,652 characters).
  • Rule: Same data, same tokenizer, one change at a time.

Experiment 1: Try Other Data Formats

When developers want to save tokens, the first instinct is almost always: let’s switch the serialization format!

We have all seen the social media claims: “Stop using JSON! Use YAML! Use TOON! It saves 30% of your tokens!”

So we started there. We took our baseline run and serialized the exact same data into different popular formats.

Format We TestedToken CountChange vs Baseline
Compact JSON (Our starting point)52,602Baseline
Pretty JSON (With 2-space indentation)72,801+38.4%
YAML59,110+12.4%
TOON51,494-2.1%

The Result: At most, switching to TOON saved 2%. Switching to YAML actually made our payload 12% larger.

Why did format-switching fail so badly?

Formats like YAML or TOON shine on neat tables of numbers and short identifiers (x: 1, y: 2). But our payload was dominated by natural language: notes, descriptions, and system audit messages.

A serialization format cannot shrink an English sentence. Changing curly braces to indentation or commas does nothing to compress the words inside.

We had to stop guessing and look at where the tokens were actually living.


Finding the Culprit: The 94% Bloat

We wrote a quick profiling script to measure how many tokens each section of the JSON object consumed.

The breakdown was startling:

Section of the InputShare of Total TokensWhat Was Inside
Disagreed People List57%179 rows where automation rules and a human salesperson disagreed
System Warnings24%Audit and configuration warnings logged across the month
Rejected Job Titles13%Titles turned away by the qualification filter
Everything Else6%Configuration toggles, date ranges, and high-level totals

Three repetitive lists accounted for 94% of our entire prompt.

When I opened the list of disagreed people, the reason was obvious. It was the same robotic sentence repeated dozens of times with only one or two words swapped:

Department "Commercial" matches the excluded department "Commercial" for <segment>.
Department "Research & Development" matches the excluded department "Research & Development" for <segment>.
Department "Marketing" matches the excluded department "Marketing" for <segment>.

There were 179 rows with 102 different strings, but only about a dozen sentence templates. We were paying model providers to read the words “matches the excluded department” nearly two hundred times.


Experiment 2: The Dictionary Trick

An AI model is a text reader, not a rigid JSON parser. It does not crash on missing syntax.

So what if we define these boilerplate sentences once in a small dictionary at the top, and reference them with short symbols like $1 and $2?

[DICTIONARY]
$1 = Department matches the excluded department for <segment>
$2 = Job title matched exclusion criteria

[DATA]
{ "person": "Alex", "reason": "$1", "dept": "Marketing" }

While we were testing this, we also tested stripping quotation marks from JSON keys (dept: instead of "dept":).

Variant TestedToken CountChange vs Baseline
Dictionary only45,967-12.6%
Dictionary + unquoted keys44,450-15.5%
Unquoted keys alone52,803+0.4%

The Findings:

  1. The dictionary helped, but saving 13% was lower than we hoped. Because the department names sat inside the sentences, the strings were only partially identical.
  2. Removing quotes from keys did nothing. Byte-pair tokenizers already bundle common patterns like "department": into single tokens. Stripping quotes saved characters on our screen, but saved zero tokens for the model.

Experiment 3: Drop the Repeated Text Entirely

Next, we tried the aggressive option: what if we completely remove the verbose reason string from every person row, and group warnings that follow the same template?

Variant TestedToken CountChange vs Baseline
Reason removed entirely + warnings grouped39,591-24.7%
Above + job-title list removed34,135-35.1%
Above with dictionary added36,411-30.8%

The Catch: Removing content saved ten times more than changing formats. But deleting the reason created an unacceptable trade-off.

Without the reason, the model could see who the person was (their title and department), but had no way of knowing which rule fired to exclude them. We could not afford to lose that context.


Experiment 4: Short Deterministic Codes Instead of Sentences

Instead of choosing between a 40-word sentence and nothing at all, we mapped each sentence template to a concise status code:

  • Department matches excluded... →\rightarrow excluded_department
  • Job title matches exclusion... →\rightarrow title_no_match

We wrote this mapping with deterministic string rules in our code — zero AI calls and zero fuzzy matching:

  • The sentences originated from fixed templates in our own code, so every pattern was known in advance.
  • An AI step would add latency, cost, and non-determinism to every run.
  • Deterministic code is unit-testable and gives identical output every time.
Variant TestedToken CountChange vs Baseline
Reason as a short code + grouped warnings42,340-19.5%
Reason code + grouped warnings + dictionary39,148-25.6%

Keeping a short code cost about 6 percentage points compared to deleting the field entirely. But it retained the essential context the model needed to write its report.


Experiment 5: The Breakthrough — Mixing Formats

Then came the real breakthrough.

I was staring at the 179 rows of people where our automation rules and a human salesperson disagreed. Every single row had the exact same 9 fields: company, title, department, segment, reason, ai, rules_said, person, and outcome.

In JSON, you repeat every single key name on every row:

[
  {
    "company": "Acme Therapeutics",
    "title": "Director, Commercial Data Operations",
    "department": "Commercial",
    "segment": "Biotech/Emerging Pharma",
    "reason": "excluded_department",
    "ai": 0.16,
    "rules_said": "exclude",
    "person": "approved",
    "outcome": "overruled"
  }
]

Repeating "company":, "department":, and "rules_said": nearly two hundred times was pure waste.

The question became obvious:

Why are we forcing this entire prompt into one single format? An AI model reads text. It is not an SQL database parser. A table has headers once at the top and values underneath. Why don’t we mix formats?

So we stopped looking for a single format. We combined the right format for each kind of data:

  1. A tiny dictionary ($1, $2, $3) for heavy, repeated strings like recurring company names and market segments.
  2. JSON for the single settings and totals line.
  3. A plain CSV table for the uniform rows of people, printing column names just once at the top.
  4. Short bullet lines for system warnings.

Here is what the final mixed payload looks like in production (all names made up):

HOW TO READ THIS
- Lines like $1 = ... are a dictionary. Wherever you see $1 below, read the text after the = sign.
- Reason codes: excluded_department = the person's department is on the excluded list. title_no_match = the title is on no list for the segment.
- Tables are CSV: the first line holds the column names.

$1 = Biotech/Emerging Pharma
$2 = Research & Development
$3 = Acme Therapeutics

SETTINGS AND TOTALS
{"weeks":4,"hot_threshold":45,"qualification_version":8,"totals":{"people":214,"overruled":6,"need_decision":31}}

WEEK 2026-10-26: PEOPLE WHERE THE RULES AND A PERSON DISAGREED
company,title,department,segment,reason,ai,rules_said,person,outcome
$3,"Director, Commercial Data Operations",Commercial,$1,excluded_department,0.16,exclude,approved,overruled
$3,"Head, Research; Vice President",$2,$1,title_no_match,0.23,exclude,approved,overruled
Sample Labs,"Senior Manager, Clinical Data",$2,$1,title_no_match,0.71,exclude,approved,decided
Sample Labs,"Associate Director, Procurement",Procurement,$1,excluded_department,0.06,exclude,approved,overruled

WEEK 2026-10-26: WARNINGS
- 6x No campaign configured for a therapeutic area and company type [Unknown/Biotech; Oncology/Biotech; Unknown/Insurance]
- No intent signals this week. Check the intent search step of this run.
- Trial verification: unclear result, flagged for manual review instead of auto-routing.
Variant TestedToken CountChange vs Baseline
Reason code + grouped warnings (All JSON)40,777-22.5%
Big lists as CSV tables, rest JSON32,303-38.6%
TOON for everything33,258-36.8%
CSV lists + Dictionary26,815-49.0%
TOON + Dictionary28,452-45.9%

The core payload dropped from 52,602 down to 26,815 tokens — a clean 49% cut.

When wrapped with full system instructions, task prompts, and ground truth definitions, the entire production input dropped from roughly 52,600 to 29,200 tokens (a 44% overall reduction).


Experiment 6: Do the Answers Stay as Good?

A smaller prompt is only a victory if the model’s output remains just as good. If the model misses critical patterns or miscalculates numbers because of the compressed format, you have lost.

So we ran a rigorous blind evaluation.

How We Tested, Step by Step

  1. Two inputs: Input A was the old monolithic JSON (~52,600 tokens). Input B was our new mixed format (~29,200 tokens, 44% smaller).
  2. Six generation runs: A strong model wrote the monthly review 2 times using Input A and 4 times using Input B. Running multiple times is necessary because LLMs vary slightly from run to run.
  3. A blind judge: We shuffled and anonymized all six reviews. A separate model acted as an impartial judge, checking each claim against the original dataset.
  4. Scoring: The judge checked 12 critical business numbers, verified every other statistic it could find, scored practical usefulness from 1 to 5, and checked whether instructions were followed.

The Results

Input VariantRunsClaims CheckedErrorsError RateAccuracyErrors / RunUsefulness (1–5)
A (Old JSON)212165.0%95.0%3.04.50
B (Small Mixed)4239156.3%93.7%3.84.25

Key Discoveries from the Audit

  • The accuracy drop was pure noise. Accuracy moved from 95.0% to 93.7% — a tiny 1.3 point gap (p=0.81p = 0.81). The score varied more between two runs of the same input than between Input A and Input B. The single cleanest run of all six came from Input B (only 2 errors).
  • The small format captured more key facts. Input B stated 92% of the essential business metrics (43 of 48) compared to 83% for Input A (19 of 24).
  • Plain text beat nested JSON. Both Input A reviews completely missed a critical warning count. All four Input B reviews got it right. In B, the line plainly read "25x No campaign configured...". In A, that same count was buried three levels deep inside a JSON object.
  • Models make counting slips either way. Both inputs had minor arithmetic slips (like counting 9 job titles instead of 8). These were normal model calculation slips, not flaws caused by the format.
  • The small format followed privacy rules better. Both Input A reviews leaked employee names 26 times, breaking prompt rules. None of the Input B reviews leaked any names.

What We Did Not Do

  • No agentic tool loops: People often suggest giving the AI a database search tool instead of sending the data. But each tool round-trip resends the full conversation history. That burns more tokens, costs more money, and adds 10+ seconds of delay. One clean prompt is faster and cheaper.
  • Kept the job-title list: Deleting the rejected titles list would have shaved another 13% of tokens. But our team needed those titles to spot market trends, so we kept it.

What We Learned

  1. Measure before optimizing. 94% of our bloat came from three repetitive lists. Changing formats without looking at the text was a distraction.
  2. Content beats syntax. Replacing repeated English sentences with short codes saved ten times more tokens than switching to YAML or TOON.
  3. Mix formats without fear. Models read text like humans do. Use CSV tables for data rows, JSON for settings, and plain lines for notes.
  4. Make important numbers easy to see. The model caught "25x" in plain text, but missed the exact same count when buried in JSON.
  5. Let code do the counting. Never ask an LLM to count 179 rows in its head. Count with deterministic code and hand the model the finished number.

Master Comparison of All 15 Iterations

#MethodTokensChangeKey Takeaway
0Compact JSON (Baseline)52,602BaselineStarting production payload
1Pretty JSON72,801+38.4%Indentation whitespace bloat
2YAML59,110+12.4%Sentence text prevents compression
3TOON51,494-2.1%Minimal savings on prose-heavy data
4Dictionary only45,967-12.6%Replaces repeated templates
5Unquoted keys only52,803+0.4%Tokenizers already merge keys
6Delete reasons, group warnings39,591-24.7%Saves tokens, loses context
7Method 6 + drop job titles34,135-35.1%Loses useful business data
8Method 6 + dictionary36,411-30.8%Deletion plus string aliasing
9Reason as code, grouped warnings42,340-19.5%Keeps rule context clean
10Method 9 + dictionary39,148-25.6%Strong balance of size and context
11Big lists as CSV, rest JSON32,303-38.6%Eliminates repeated column keys
12TOON for everything33,258-36.8%Still heavier than CSV tables
13CSV lists + dictionary26,815-49.0%Best core payload structure
14TOON + dictionary28,452-45.9%Trailed CSV by ~1,600 tokens
15Final Build (With instructions)~29,200-44.5%Complete prompt with 93.7% accuracy