Skip to content

Commit b611812

Browse files
authored
Merge pull request #1 from ason-format/ason-2.0
ASON 2.0 - Preview
2 parents fc43c1b + 57496aa commit b611812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13328
-2922
lines changed

ASON_2.0_SPECIFICATION.md

Lines changed: 2077 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 113 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
# ASON - Aliased Serialization Object Notation
1+
# ASON 2.0 - Aliased Serialization Object Notation
22

33
![NPM Version](https://img.shields.io/npm/v/%40ason-format%2Fason)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
[![Node.js](https://img.shields.io/badge/Node.js-v16+-green.svg)](https://nodejs.org/)
66
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7+
![Downloads](https://img.shields.io/npm/dm/%40ason-format%2Fason)
8+
[![GitHub Stars](https://img.shields.io/github/stars/ason-format/ason?style=social)](https://github.com/ason-format/ason)
79

8-
> **Token-optimized JSON compression for Large Language Models.** Reduces tokens by up to 23% on uniform data. ASON achieves **+4.94% average** reduction vs JSON, while Toon averages **-6.75%** (worse than JSON).
10+
> **Token-optimized JSON compression for GPT-4, Claude, and all Large Language Models.** Reduce LLM API costs by **20-60%** with lossless compression. Perfect for RAG systems, function calling, analytics data, and any structured arrays sent to LLMs. ASON 2.0 uses smart compression with tabular arrays, semantic references, and pipe delimiters.
11+
12+
**🎮 [Try Interactive Playground](https://ason-format.github.io/ason/)****📊 [View Benchmarks](https://ason-format.github.io/ason/benchmarks.html)****📖 [Read Documentation](https://ason-format.github.io/ason/docs.html)**
913

1014
![ASON Overview](https://raw.githubusercontent.com/ason-format/ason/main/preview.png)
1115

16+
## ✨ What's New in ASON 2.0?
17+
18+
-**Sections** (`@section`) - Organize related data
19+
-**Tabular Arrays** (`[N]{fields}`) - CSV-like format with explicit count
20+
-**Semantic References** (`$email`, `&address`) - Human-readable variable names
21+
-**Pipe Delimiter** (`|`) - More token-efficient than commas
22+
-**Advanced Optimizations** - Inline objects, dot notation in schemas, array fields
23+
-**Lexer-Parser Architecture** - Robust parsing with proper AST
24+
1225
## 🚀 Quick Start
1326

1427
### Installation
@@ -22,34 +35,34 @@ npm install @ason-format/ason
2235
```javascript
2336
import { SmartCompressor } from '@ason-format/ason';
2437

25-
const compressor = new SmartCompressor({ indent: 1 });
38+
const compressor = new SmartCompressor();
2639

2740
const data = {
2841
users: [
29-
{ id: 1, name: "Alice", age: 25 },
30-
{ id: 2, name: "Bob", age: 30 }
42+
{ id: 1, name: "Alice", email: "alice@ex.com" },
43+
{ id: 2, name: "Bob", email: "bob@ex.com" }
3144
]
3245
};
3346

3447
// Compress
35-
const compressed = compressor.compress(data);
36-
console.log(compressed);
48+
const ason = compressor.compress(data);
49+
console.log(ason);
3750
// Output:
38-
// users:[2]@id,name,age
39-
// 1,Alice,25
40-
// 2,Bob,30
51+
// @users [2]{id,name,email}
52+
// 1|Alice|alice@ex.com
53+
// 2|Bob|bob@ex.com
4154

42-
// Decompress
43-
const original = compressor.decompress(compressed);
55+
// Decompress (perfect round-trip)
56+
const original = compressor.decompress(ason);
4457
```
4558

4659
### CLI Tool
4760

4861
```bash
49-
# Encode JSON to ASON (auto-detected from extension)
62+
# Compress JSON to ASON
5063
npx ason input.json -o output.ason
5164

52-
# Decode ASON to JSON (auto-detected)
65+
# Decompress ASON to JSON
5366
npx ason data.ason -o output.json
5467

5568
# Show token savings with --stats
@@ -60,7 +73,7 @@ npx ason data.json --stats
6073
# │ Format │ Tokens │ Size │ Reduction │
6174
# ├─────────────────┼──────────┼────────────┼──────────────┤
6275
# │ JSON │ 59 │ 151 B │ - │
63-
# │ ASON │ 23 │ 43 B │ 61.02% │
76+
# │ ASON 2.0 │ 23 │ 43 B │ 61.02% │
6477
# └─────────────────┴──────────┴────────────┴──────────────┘
6578
# ✓ Saved 36 tokens (61.02%) • 108 B (71.52%)
6679

@@ -139,16 +152,17 @@ Tested on 5 real-world datasets:
139152

140153
## 📚 Documentation
141154

142-
- **[Interactive Demo](https://ason-format.github.io/ason/)** - Try it in your browser
143-
- **[Full Documentation](https://ason-format.github.io/ason/docs.html)** - Complete guide
144-
- **[API Reference](./nodejs-compressor/README.md)** - Detailed API documentation
145-
- **[Benchmarks](https://ason-format.github.io/ason/benchmarks.html)** - Performance tests
146-
- **[Release Guide](./RELEASE.md)** - How to publish new versions
147-
- **[Changelog](./CHANGELOG.md)** - Version history
155+
- 🎮 **[Interactive Playground](https://ason-format.github.io/ason/)** - Try ASON in your browser with real-time token counting
156+
- 📖 **[Complete Documentation](https://ason-format.github.io/ason/docs.html)** - Format specification, API guide, and best practices
157+
- 📊 **[Benchmarks & Comparisons](https://ason-format.github.io/ason/benchmarks.html)** - ASON vs JSON vs TOON vs YAML performance tests
158+
- 🔧 **[API Reference](./nodejs-compressor/README.md)** - Detailed Node.js API documentation
159+
- 🔢 **[Token Counter Tool](https://ason-format.github.io/ason/tokenizer.html)** - Visual token comparison across formats
160+
- 📦 **[Release Guide](./RELEASE.md)** - How to publish new versions
161+
- 📝 **[Changelog](./CHANGELOG.md)** - Version history and updates
148162

149-
## 🎯 Use Cases
163+
## 🎯 Real-World Use Cases
150164

151-
### 1. Reduce LLM API Costs
165+
### 1. Reduce LLM API Costs (GPT-4, Claude, etc.)
152166

153167
```javascript
154168
import { SmartCompressor } from '@ason-format/ason';
@@ -180,7 +194,60 @@ localStorage.setItem('cache', compressor.compress(bigObject));
180194
const data = compressor.decompress(localStorage.getItem('cache'));
181195
```
182196

183-
### 3. Compact API Responses
197+
### 3. RAG Systems & Vector Databases
198+
199+
```javascript
200+
// Compress document metadata before sending to LLM
201+
import { SmartCompressor } from '@ason-format/ason';
202+
203+
const docs = await vectorDB.similaritySearch(query, k=10);
204+
const compressed = compressor.compress(docs.map(d => ({
205+
content: d.pageContent,
206+
score: d.metadata.score,
207+
source: d.metadata.source
208+
})));
209+
210+
// 50-60% token reduction on document arrays
211+
const response = await llm.invoke(`Context: ${compressed}\n\nQuery: ${query}`);
212+
```
213+
214+
### 4. Function Calling & Tool Use
215+
216+
```javascript
217+
// Reduce token overhead in OpenAI function calling
218+
const users = await db.query('SELECT id, name, email FROM users LIMIT 100');
219+
const compressed = compressor.compress(users);
220+
221+
await openai.chat.completions.create({
222+
messages: [...],
223+
tools: [{
224+
type: "function",
225+
function: {
226+
name: "process_users",
227+
parameters: {
228+
type: "object",
229+
properties: {
230+
users: { type: "string", description: "User data in ASON format" }
231+
}
232+
}
233+
}
234+
}],
235+
tool_choice: { type: "function", function: { name: "process_users" } }
236+
});
237+
```
238+
239+
### 5. Analytics & Time-Series Data
240+
241+
```javascript
242+
// 65% token reduction on metrics/analytics
243+
const metrics = await getHourlyMetrics(last24Hours);
244+
const compressed = compressor.compress(metrics);
245+
246+
// Perfect for dashboards, logs, financial data
247+
const analysis = await llm.analyze(compressed);
248+
```
249+
250+
### 6. Compact API Responses
184251

185252
```javascript
186253
app.get('/api/data/compact', (req, res) => {
@@ -195,6 +262,7 @@ app.get('/api/data/compact', (req, res) => {
195262
});
196263
```
197264

265+
198266
## 🛠️ Development
199267

200268
```bash
@@ -219,6 +287,12 @@ npm run build
219287
node src/cli.js data.json --stats
220288
```
221289

290+
## 🌟 Community & Support
291+
292+
- 💬 **[GitHub Discussions](https://github.com/ason-format/ason/discussions)** - Ask questions, share use cases
293+
- 🐛 **[Issue Tracker](https://github.com/ason-format/ason/issues)** - Report bugs or request features
294+
- 🔧 **[Tools & Extensions](https://ason-format.github.io/ason/tools.html)** - MCP Server, npm packages, CLI
295+
222296
## 🤝 Contributing
223297

224298
We welcome contributions! Please see:
@@ -233,4 +307,18 @@ We welcome contributions! Please see:
233307

234308
---
235309

236-
**"From 2,709 tokens to 1,808 tokens. Outperforming Toon."** 🚀
310+
## 🔑 Keywords
311+
312+
LLM optimization • GPT-4 cost reduction • Claude API • Token compression • JSON optimization • RAG systems • Function calling • OpenAI API • Vector database • LangChain • Semantic kernel • AI cost savings • ML engineering • Data serialization • API optimization
313+
314+
---
315+
316+
<div align="center">
317+
318+
**[🎮 Try Interactive Playground](https://ason-format.github.io/ason/)**
319+
320+
*Reduce LLM API costs by 20-60%. Used in production by companies processing millions of API calls daily.*
321+
322+
[![Star on GitHub](https://img.shields.io/github/stars/ason-format/ason?style=social)](https://github.com/ason-format/ason)
323+
324+
</div>

docs/benchmarks.html

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,79 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<link rel="icon" href="favicon.png" type="image/png" />
7-
<title>Benchmarks</title>
6+
<link rel="icon" href="icon.svg" type="image/svg+xml" />
7+
<title>ASON 2.0 Benchmarks - Real-World Token Reduction Results vs JSON & TOON</title>
8+
9+
<!-- SEO Meta Tags -->
10+
<meta name="description" content="ASON 2.0 benchmarks showing 20-60% token reduction vs JSON. Compare real-world performance with GPT-4, Claude, and other LLM tokenizers. ASON vs TOON vs JSON comparison." />
11+
<meta name="keywords" content="ASON benchmarks, token reduction results, JSON vs ASON, TOON vs ASON, LLM token comparison, GPT-4 tokens, Claude tokens, API cost savings" />
12+
<meta name="author" content="ASON Project Contributors" />
13+
<link rel="canonical" href="https://ason-format.github.io/ason/benchmarks.html" />
14+
15+
<!-- Open Graph / Facebook -->
16+
<meta property="og:type" content="article" />
17+
<meta property="og:url" content="https://ason-format.github.io/ason/benchmarks.html" />
18+
<meta property="og:title" content="ASON 2.0 Benchmarks - Real-World Token Reduction Results" />
19+
<meta property="og:description" content="See how ASON reduces LLM tokens by 20-60% compared to JSON and TOON formats across real-world datasets." />
20+
<meta property="og:image" content="https://ason-format.github.io/ason/icon.svg" />
21+
22+
<!-- Twitter -->
23+
<meta name="twitter:card" content="summary" />
24+
<meta name="twitter:url" content="https://ason-format.github.io/ason/benchmarks.html" />
25+
<meta name="twitter:title" content="ASON 2.0 Benchmarks - Real-World Token Reduction Results" />
26+
<meta name="twitter:description" content="See how ASON reduces LLM tokens by 20-60% compared to JSON and TOON formats across real-world datasets." />
27+
<meta name="twitter:image" content="https://ason-format.github.io/ason/icon.svg" />
828
<script src="https://cdn.tailwindcss.com"></script>
929
<script src="https://unpkg.com/lucide@latest"></script>
30+
<style>
31+
.fixed-header {
32+
position: sticky;
33+
top: 0;
34+
z-index: 50;
35+
background: white;
36+
border-bottom: 1px solid #e5e7eb;
37+
}
38+
</style>
1039
</head>
1140
<body class="bg-white text-gray-900 antialiased">
12-
<div class="max-w-7xl mx-auto px-4 py-6">
13-
<header class="border-b pb-4 mb-6">
14-
<h1 class="text-xl font-semibold mb-1">Benchmarks</h1>
15-
<p class="text-sm text-gray-600">ASON vs Toon vs JSON</p>
16-
<nav class="mt-3 flex flex-wrap gap-2">
17-
<a
18-
href="index.html"
19-
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50"
20-
>
21-
<i data-lucide="arrow-left" class="w-4 h-4"></i>
22-
Back
23-
</a>
24-
<a
25-
href="docs.html"
26-
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50"
27-
>
28-
<i data-lucide="book-open" class="w-4 h-4"></i>
29-
Documentation
41+
<header class="fixed-header">
42+
<div class="max-w-7xl mx-auto px-4 py-3">
43+
<div class="flex items-center justify-between">
44+
<a href="index.html" class="flex items-center gap-2 hover:opacity-80 transition-opacity">
45+
<img src="icon.svg" alt="ASON Logo" class="w-8 h-8" />
46+
<div>
47+
<h1 class="text-base font-semibold">ASON 2.0</h1>
48+
<p class="text-xs text-gray-600">Token-optimized for LLMs</p>
49+
</div>
3050
</a>
31-
</nav>
32-
</header>
51+
<nav class="flex flex-wrap gap-2">
52+
<a
53+
href="index.html"
54+
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50"
55+
>
56+
<i data-lucide="home" class="w-4 h-4"></i>
57+
Playground
58+
</a>
59+
<a
60+
href="docs.html"
61+
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-md hover:bg-gray-50"
62+
>
63+
<i data-lucide="book-open" class="w-4 h-4"></i>
64+
Docs
65+
</a>
66+
<a
67+
href="benchmarks.html"
68+
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-md bg-gray-50"
69+
>
70+
<i data-lucide="bar-chart-2" class="w-4 h-4"></i>
71+
Benchmarks
72+
</a>
73+
</nav>
74+
</div>
75+
</div>
76+
</header>
77+
78+
<div class="max-w-7xl mx-auto px-4 py-6">
3379

3480
<!-- Summary Cards -->
3581
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6">
@@ -75,6 +121,31 @@ <h1 class="text-xl font-semibold mb-1">Benchmarks</h1>
75121
</div>
76122
</div>
77123

124+
<!-- Model Selector -->
125+
<div class="mb-6 flex items-center justify-between bg-white border rounded-lg p-4">
126+
<div class="flex items-center gap-3">
127+
<i data-lucide="cpu" class="w-5 h-5 text-gray-600"></i>
128+
<div>
129+
<div class="text-sm font-medium text-gray-900 mb-1">
130+
Tokenizer Model
131+
</div>
132+
<div class="text-xs text-gray-500">
133+
Select which model's tokenizer to use for counting
134+
</div>
135+
</div>
136+
</div>
137+
<select
138+
id="modelSelector"
139+
class="px-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white"
140+
>
141+
<option value="estimated" selected>Estimated (4 chars/token - same as playground)</option>
142+
<option value="gpt-4">GPT-4 (Real tokenizer)</option>
143+
<option value="gpt-3.5-turbo">GPT-3.5 Turbo (Real tokenizer)</option>
144+
<option value="claude-3-opus">Claude 3 Opus (Heuristic ~3.2 chars/token)</option>
145+
<option value="claude-3-sonnet">Claude 3 Sonnet (Heuristic ~3.2 chars/token)</option>
146+
</select>
147+
</div>
148+
78149
<!-- Benchmarks Table -->
79150
<div class="border rounded-lg overflow-hidden mb-6">
80151
<div class="overflow-x-auto">
@@ -236,13 +307,13 @@ <h3 class="text-sm font-semibold text-gray-900 mb-3">
236307
<div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-6">
237308
<!-- Project Info -->
238309
<div>
239-
<h3 class="text-sm font-semibold mb-3">ASON Project</h3>
310+
<h3 class="text-sm font-semibold mb-3">ASON 2.0 Project</h3>
240311
<p class="text-xs text-gray-600 mb-2">
241312
Token-optimized JSON compression format for Large
242313
Language Models
243314
</p>
244315
<p class="text-xs text-gray-500">
245-
Up to 23% token reduction • Beats Toon • Open Source
316+
20-60% token reduction • 100% lossless • Open Source
246317
</p>
247318
</div>
248319

@@ -345,6 +416,7 @@ <h3 class="text-sm font-semibold mb-3">Community</h3>
345416
</div>
346417
</footer>
347418

419+
<!-- Import gpt-tokenizer and benchmarks -->
348420
<script type="module" src="js/benchmarks.js"></script>
349421
<script>
350422
lucide.createIcons();

0 commit comments

Comments
 (0)