mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34:10 +08:00
docs: overhaul TOON example
This commit is contained in:
49
README.md
49
README.md
@@ -37,7 +37,15 @@ Think of it as a translation layer: use JSON programmatically, and encode it as
|
|||||||
|
|
||||||
## Why TOON?
|
## Why TOON?
|
||||||
|
|
||||||
AI is becoming cheaper and more accessible, but larger context windows allow for larger data inputs as well. **LLM tokens still cost money** – and standard JSON is verbose and token-expensive:
|
AI is becoming cheaper and more accessible, but larger context windows allow for larger data inputs as well. **LLM tokens still cost money** – and standard JSON is verbose and token-expensive. TOON offers a more compact alternative:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>JSON</th>
|
||||||
|
<th>TOON</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -76,8 +84,29 @@ AI is becoming cheaper and more accessible, but larger context windows allow for
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
```toon
|
||||||
|
context:
|
||||||
|
task: Our favorite hikes together
|
||||||
|
location: Boulder
|
||||||
|
season: spring_2025
|
||||||
|
|
||||||
|
friends[3]: ana,luis,sam
|
||||||
|
|
||||||
|
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
|
||||||
|
1,Blue Lake Trail,7.5,320,ana,true
|
||||||
|
2,Ridge Overlook,9.2,540,luis,false
|
||||||
|
3,Wildflower Loop,5.1,180,sam,true
|
||||||
|
```
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>YAML already conveys the same information with <strong>fewer tokens</strong>.</summary>
|
<summary>YAML already achieves <strong>fewer tokens</strong> than JSON, but TOON goes further.</summary>
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
context:
|
context:
|
||||||
@@ -113,22 +142,6 @@ hikes:
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
TOON conveys the same information with **even fewer tokens**, while keeping the hikes in a clear tabular layout:
|
|
||||||
|
|
||||||
```toon
|
|
||||||
context:
|
|
||||||
task: Our favorite hikes together
|
|
||||||
location: Boulder
|
|
||||||
season: spring_2025
|
|
||||||
|
|
||||||
friends[3]: ana,luis,sam
|
|
||||||
|
|
||||||
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
|
|
||||||
1,Blue Lake Trail,7.5,320,ana,true
|
|
||||||
2,Ridge Overlook,9.2,540,luis,false
|
|
||||||
3,Wildflower Loop,5.1,180,sam,true
|
|
||||||
```
|
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- 💸 **Token-efficient:** typically 30-60% fewer tokens on large uniform arrays vs formatted JSON[^1]
|
- 💸 **Token-efficient:** typically 30-60% fewer tokens on large uniform arrays vs formatted JSON[^1]
|
||||||
|
|||||||
Reference in New Issue
Block a user