Skip to content

freddneos/dumbl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DUMBL

Dumb Universal Markup Brutally Lightweight

Token reduction algorithm for LLM inputs. Compress JSON/TOML prompts while maintaining LLM readability.

npm version npm downloads license github stars


πŸ’‘ Why DUMBL?

LLMs understand text with missing vowels and abbreviated words due to linguistic redundancy. DUMBL exploits this to reduce token count (and costs) by 15-30%.

Original:  "Desenvolva uma aplicaΓ§Γ£o completa utilizando programaΓ§Γ£o orientada"
DUMBL:     "Desenvlva uma aplicΓ§ complta utiliznd programΓ§ orientda"
Savings:   ~20% fewer tokens

Save money on API calls while maintaining semantic clarity for GPT-4, Claude, Llama, Gemini, and other LLMs.

✨ Features

  • πŸš€ 15-30% token reduction on typical LLM prompts
  • πŸ”§ Three compression levels - light, medium, aggressive
  • πŸ“¦ Zero dependencies - TOML support is optional
  • 🌍 Multilingual - English & Portuguese optimized
  • πŸ”’ Smart preservation - URLs, emails, paths, tech terms stay intact
  • πŸ“ TypeScript ready - Full type definitions included
  • ⚑ Fast - Minimal overhead for real-time use

πŸ“¦ Installation

npm install dumbl

For TOML support (optional):

npm install dumbl @iarna/toml

πŸš€ Quick Start

const { dumbl } = require('dumbl');

// Create instance (level 1-3)
const d = dumbl.aggressive(); // level 3

// Compress object
const result = d.compress({
  prompt: "Explique detalhadamente o processamento"
});
// β†’ { prompt: "Explqe detlhadmt o procesmt" }

// Output as JSON
const json = d.toJSON(data);

// Output as DUMBL format (most compact)
const compact = d.toDUMBL(data);

// Quick debug - see stats and result
const { dumblDry } = require('dumbl');
dumblDry(data); // logs stats + compressed result

πŸ“– API Reference

Factory Functions

const { dumbl } = require('dumbl');

// With options
const d = dumbl({ 
  level: 3,           // 1=light, 2=medium, 3=aggressive
  preserveKeys: true, // don't compress object keys
  minWordLength: 3    // min chars to compress
});

// Presets
dumbl.light()      // level 1 - safe, minimal
dumbl.medium()     // level 2 - balanced
dumbl.aggressive() // level 3 - maximum compression

Instance Methods

const d = dumbl.aggressive();

// Compress anything
d.compress(object)     // β†’ compressed object
d.compress(jsonString) // β†’ compressed object
d.compress(text)       // β†’ compressed string

// Output formats
d.toJSON(input)   // β†’ JSON string (compressed)
d.toDUMBL(input)  // β†’ DUMBL format (most compact)

// With TOML (requires @iarna/toml)
const TOML = require('@iarna/toml');
d.compress(tomlString, TOML)
d.toTOML(input, TOML)

// Parse DUMBL back
d.parseDUMBL(dumblString) // β†’ object

// Statistics
d.stats(original, compressed)
// β†’ { savedChars, ratio, estimatedTokensSaved, ... }

One-shot Functions

const { compress, toJSON, toDUMBL, dumblDry } = require('dumbl');

// Quick compression (uses level 3)
compress({ prompt: "..." })
toJSON({ prompt: "..." })
toDUMBL({ prompt: "..." })

// Dry run - logs stats and result to console
dumblDry({ prompt: "..." })

Dry Run (Debug/Preview)

Use dumblDry to preview compression results with statistics:

const { dumblDry } = require('dumbl');

dumblDry({ prompt: "Explique detalhadamente o processamento de dados" });

Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             DUMBL Dry Run               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Original:        56 chars
β”‚ Compressed:      44 chars
β”‚ Saved:           12 chars (21.4%)
β”‚ Est. tokens: ~3 saved
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Result:
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
{
  "prmpt": "Explque dtalhdamt o prcesmento de ddos"
}

πŸ“Š Compression Levels

Level Description Use Case
1 Remove duplicates only Conservative, max readability
2 + Suffix abbreviations Balanced
3 + Vowel removal Maximum savings

πŸ”§ DUMBL Format

Custom ultra-compact format, JSON-compatible:

// JSON
{"enabled":true,"count":null,"items":["a","b"]}

// DUMBL
{enabled:T,count:N,items:["a","b"]}

Features:

  • T/F for booleans
  • N for null
  • Unquoted keys when possible
  • No whitespace

πŸ“ˆ Benchmark

npm run benchmark

Sample results:

Format Size vs JSON
JSON (pretty) 1250 +45%
JSON (compact) 862 baseline
TOML 780 -10%
JSON+DUMBL L3 680 -21%
DUMBL format 620 -28%

πŸ›‘οΈ What's Preserved

DUMBL intelligently preserves:

  • βœ… Short words (≀3 chars)
  • βœ… Connectors (the, of, de, para, etc.)
  • βœ… URLs, emails, file paths
  • βœ… Tech terms (API, JSON, HTTP, etc.)
  • βœ… Numbers and booleans
  • βœ… Object structure

πŸ€– LLM Compatibility

Tested and confirmed readable by:

  • βœ… GPT-4 / GPT-4o / GPT-4o-mini
  • βœ… Claude 3.5 / Claude 4
  • βœ… Llama 3 / Llama 3.1
  • βœ… Gemini Pro / Gemini Ultra
  • βœ… Mistral / Mixtral

The compression maintains semantic meaning while reducing tokens.

πŸ“˜ TypeScript

Full type definitions included:

import { dumbl, DumblOptions, DumblStats } from 'dumbl';

const d = dumbl.aggressive();
const stats: DumblStats = d.stats(original, compressed);

πŸ§ͺ Testing

npm test

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

πŸ“„ License

MIT Β© Frederico Bezerra

πŸ‘€ Author

Frederico Bezerra


If you find DUMBL useful, please ⭐ star the repo!

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published