惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
KODA Format: A Schema-First Data Format to Reduce LLM Tok...
Om Kawale · 2026-05-04 · via DEV Community

When building applications with large language models (LLMs), one of the most overlooked costs is how structured data is represented.

Most systems use JSON.

And JSON is inefficient for LLM input.


What is KODA?

KODA (Knowledge-Oriented Data Abstraction) is a schema-first data format designed to reduce token usage when sending structured data to LLMs.

It works by:

  • Defining structure once (schema-first)
  • Encoding values positionally
  • Eliminating repeated keys found in JSON

KODA is optimized for:

  • RAG pipelines
  • Tool calling systems
  • Agent workflows
  • High-volume structured LLM input

The Problem with JSON in LLM Pipelines

JSON repeats field names for every record.

Example:

[
  {"id": 1, "title": "Bug", "state": "open"},
  {"id": 2, "title": "Fix", "state": "closed"}
]

Enter fullscreen mode Exit fullscreen mode

Each object repeats:

  • id
  • title
  • state

If you send 1000 records:

  • those keys are repeated 1000 times
  • tokens are wasted
  • costs increase
  • context window shrinks

KODA Equivalent

KODA/1
@META
schemas:issue
counts:issue=3

@SCHEMA
issue:id title state

@DATA:issue
1|Bug|open
2|Fix|closed

Enter fullscreen mode Exit fullscreen mode

No repeated keys.

Only structure + values.


Token Reduction Benchmark

Measured using a gpt-4o-mini tokenizer on real datasets.

Case JSON Tokens KODA Tokens Reduction
Repetitive Logs 3202 1233 61.5%
GitHub Issues 4137 2576 37.7%
Small Dataset 26 35 -34.6%

Key insight

KODA performs best on large, repetitive structured data.

For small datasets, schema overhead can outweigh benefits.


Why This Matters

In LLM systems:

  • Tokens = cost
  • Tokens = latency
  • Tokens = context capacity

Reducing tokens by ~30–40%:

  • lowers API costs
  • increases usable context
  • improves system efficiency

How KODA Works

KODA separates:

  • Schema → defined once
  • Data → streamed positionally

This removes structural redundancy.


Quick Python Example

from koda import Schema, Field, encode

schema = Schema("user", [
    Field("id"),
    Field("name"),
    Field("email", optional=True),
    Field("active", default="true")
])

data = [
    {"id": 1, "name": "Alice", "email": "alice@example.com"},
    {"id": 2, "name": "Bob"}
]

koda_str = encode(data, schema)
print(koda_str)

Enter fullscreen mode Exit fullscreen mode


KODA vs JSON vs YAML vs TOON

Format Token Efficiency Readability Best Use Case
JSON Low High APIs
YAML Medium Medium Config files
TOON High Medium LLM structured data
KODA High Low LLM pipelines

When to Use KODA

Use KODA if you are:

  • sending large structured datasets to LLMs
  • building RAG pipelines
  • working with tool calls or agents
  • optimizing token usage in production systems

When NOT to Use KODA

Do not use KODA for:

  • small datasets (1–2 records)
  • irregular or deeply nested JSON
  • human-authored configuration files

JSON is better in those cases.


Design Principles

  • Schema-first design
  • Positional encoding
  • Deterministic parsing
  • No repeated keys
  • Optimized for LLM input

Is KODA a JSON Replacement?

No.

KODA is a transport format for LLM pipelines.

Typical workflow:

JSON → KODA → LLM


FAQ

What is KODA?

KODA is a schema-first data format that reduces token usage for structured data in LLM systems.

Is KODA better than JSON?

For LLM input, yes. For general use, JSON is still better.

Does KODA always reduce tokens?

No. It works best on large structured datasets.

Where should I use KODA?

RAG pipelines, tool calls, and structured LLM input.


Try It

GitHub: https://github.com/Om7035/koda

pip install koda

Enter fullscreen mode Exit fullscreen mode


Final Thoughts

If you're sending structured data to LLMs, you're likely wasting tokens.

KODA is a simple way to reduce that overhead.

It’s not a replacement for JSON it’s an optimization layer for LLM pipelines.


Feedback and contributions are welcome.