TOON: Beyond JSON for LLMs
Summary
TOON, or Token-Oriented Object Notation, is introduced as a novel method for representing structured data more efficiently for Large Language Models (LLMs). While JSON remains the standard for traditional application-to-application communications due to its robustness and ease of use, its verbose syntax incurs an "invisible price tag" when processed by LLMs. Every quotation mark, comma, brace, bracket, and repeated key consumes valuable tokens, depleting the LLM's context window, especially when handling large data like API responses, search results, or RAG chunks. TOON aims to provide a token-efficient alternative specifically for data intended for LLM consumption, without seeking to replace JSON in broader enterprise systems. This approach addresses the cost and context limitations associated with JSON's tokenization by LLMs.
Key takeaway
For AI Engineers optimizing LLM application performance and cost, consider TOON for structured data inputs. If you are passing large API responses, search results, or RAG chunks to an LLM, adopting TOON can significantly reduce token consumption and preserve valuable context window space. Evaluate TOON's potential to enhance efficiency in your LLM workflows, especially where JSON's verbosity currently incurs high token costs.
Key insights
TOON offers a token-efficient structured data format specifically designed to optimize LLM context window usage over traditional JSON.
Principles
- LLMs process data as tokens, not objects.
- JSON's verbose syntax inflates LLM token usage.
- Context window depletion is a key LLM cost factor.
In practice
- Use TOON for LLM-bound structured data.
- Optimize API responses for LLM input.
- Reduce token cost for RAG chunks.
Topics
- TOON
- Large Language Models
- Token Efficiency
- Structured Data
- Context Window
- API Integration
Best for: NLP Engineer, AI Engineer, Machine Learning Engineer, AI Architect
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Towards AI - Medium.