{"slug": "flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33", "title": "Flow – a compact data pipeline language that cuts LLM token usage by 33%", "summary": "A new open-source data pipeline language called Flow reduces LLM token usage by an average of 33% compared to Python by stripping away human-oriented boilerplate. Developed by Pinku, Flow uses single-character operators and transpiles to Python, with validated results on fine-tuned models like phi-2 and Qwen 3B Coder v2 running on consumer GPUs.", "body_md": "**A compact, AI-optimized data transformation language for LLMs**\n\n*~33% token reduction vs Python — validated with fine-tuned models on consumer GPUs*\n\n```\ngit clone https://github.com/pinku/Flow.git && cd Flow\npython3 flow.py \"1..10 | f:_>5 | m:_*2\"\n# → [12, 14, 16, 18, 20]\n```\n\nNo dependencies. No setup. Just Python 3.8+.\n\nLLMs are trained on verbose human-oriented languages, but that verbosity burns tokens without adding value for AI processing:\n\n| Problem | Impact |\n|---|---|\nKeywords like `function` , `const` , `return` |\nEvery one costs tokens |\n| Verbose variable names for human readability | No benefit for LLMs |\n| Syntactic sugar optimized for humans | Wasted context window |\n\n**Flow strips away the human-oriented boilerplate**, keeping only what the LLM needs to express the transformation. The result: **33% fewer tokens on average**, tested and verified with real models.\n\n| Python (24 tokens) | Flow (13 tokens) — 45% fewer |\n|---|---|\n`result = [x * 2 for x in range(1, 11) if x > 5]` |\n`1..10 | f:_>5 | m:_*2` |\n\nMore examples in the [Operator Reference](#operators-reference).\n\n| Feature | Description |\n|---|---|\nMinimal Syntax |\nSingle-character operators: `f:` (filter), `m:` (map), `g:` (group), `a:` (aggregate), etc. |\nPython Compatible |\nTranspiles to clean, readable Python |\nLLM Optimized |\nDesigned for minimal token usage without sacrificing expressiveness |\nJSON Native |\nBuilt-in JSON parsing and serialization |\nBatch Processing |\nWindowing and batching for large datasets |\nType Safety |\nType casting and validation |\nZero Dependencies |\nPure Python — no pip install required |\n\n```\ngit clone https://github.com/pinku/Flow.git\ncd Flow\npython3 flow.py --help\n# Filter and map\npython3 flow.py \"1..10 | f:_>5 | m:_*2\"\n\n# Group and aggregate\npython3 flow.py \"[{name:'Alice',age:30},{name:'Bob',age:25}] | g:_.age>=30 | a:len(v)\"\n\n# JSON processing\npython3 flow.py \"S:data.json\"  # Save to JSON\npython3 flow.py \"J\"             # Parse JSON input\npython3 flow.py\n# > 1..10 | f:_>5 | m:_*2\n# [12, 14, 16, 18, 20]\npython\nfrom flow import flow_run, flow_transpile\n\n# Execute directly\nresult = flow_run(\"1..10 | f:_>5 | m:_*2\")\nprint(result)  # [12, 14, 16, 18, 20]\n\n# Get transpiled Python\ncode = flow_transpile(\"1..10 | f:_>5 | m:_*2\")\nprint(code)  # [_*2 for _ in range(1, 11) if _>5]\n```\n\n| Operator | Name | Example |\n|---|---|---|\n`f:` |\nFilter | `data | f:_.age > 18` |\n`m:` |\nMap | `data | m:_.name.upper()` |\n`g:` |\nGroup | `data | g:_.category` |\n`a:` |\nAggregate | `data | g:_.cat | a:sum(v)` |\n`s:` |\nSort | `data | s:-_.age` |\n`t:` |\nTake | `data | t:10` |\n`d:` |\nDrop | `data | d:2` |\n`u` |\nUnique | `data | u` |\n`r` |\nReverse | `data | r` |\n`b:` |\nBatch | `data | b:32` |\n`w:` |\nWindow | `data | w:3` |\n`i:` |\nSplit | `data | i:'\\n'` |\n`o:` |\nJoin | `data | o:','` |\n`T:` |\nType cast | `data | T:int` |\n`J` |\nParse JSON | `data | J` |\n`S:` |\nSave JSON | `data | S:output.json` |\n`x` |\nFlatten | `nested | x` |\n`&` |\nAND filter | `data | f:_.a>0 & _.b<10` |\n`|` |\nOR filter | `data | f:_.a>0 | _.b>10` |\n\nFull interactive report: [benchmark_report.html](/pinku/Flow/blob/master/benchmark_report.html)\n\n| Task | Python Tokens | Flow Tokens | Savings |\n|---|---|---|---|\n| Filter + Map | 22 | 13 | 41% |\n| Group + Aggregate | 25 | 14 | 44% |\n| Sort + Take | 20 | 14 | 30% |\n| JSON Parse | 15 | 4 | 73% |\n| Batch Processing | 35 | 8 | 77% |\n\n**Average token saving: 33%**\n\nFlow has been validated with fine-tuned models on consumer hardware:\n\n| Model | Parameters | VRAM | Training Time | Accuracy |\n|---|---|---|---|---|\n| phi-2 | 2.7B | ~5.4 GB | ~20 min | 100% |\n| Qwen 3B Coder v2 | 3.7B | ~6.0 GB | ~5 min | 100% |\n\nBoth models were fine-tuned using QLoRA (4-bit quantization) on an RTX 4060.\n\nFlow includes training scripts for fine-tuning small language models:\n\n```\n# Install dependencies\npip install transformers peft bitsandbytes trl\n\n# Generate training dataset\npython3 generate_dataset.py\n\n# Train phi-2 (2.7B)\npython3 train_qlora.py\n\n# Train Qwen 3B Coder\npython3 train_qwen_flow.py\n```\n\n**Requirements:**\n\n- NVIDIA GPU with 8GB+ VRAM (RTX 4060 tested)\n- CUDA 12.x\n- Python 3.8+\n\nFlow includes a Hermes skill for seamless integration:\n\n```\n# Add to your Hermes skills\ncp -r .hermes/skills/flow-tool ~/.hermes/skills/\n\n# Use in chat\n/hermes run flow-tool \"1..10 | f:_>5 | m:_*2\"\nFlow/\n├── flow.py                  # Main implementation (transpiler + runtime)\n├── data/\n│   └── flow_dataset.json    # Training dataset (600 examples)\n├── models/                  # Fine-tuned LoRA adapters (not in repo)\n│   ├── flow-lora/           # phi-2 adapter\n│   └── qwen3b-flow-lora-v2/ # Qwen 3B adapter\n├── benchmark_report.html    # Visual benchmark report\n├── train_qlora.py           # phi-2 training script\n├── train_qwen_flow.py       # Qwen 3B training script\n└── generate_dataset.py      # Dataset generation script\n```\n\n[Hermes Agent](https://hermes-agent.nousresearch.com)— LLM agent platform; Flow is used as a tool skill[llama.cpp](https://github.com/ggerganov/llama.cpp)— Local LLM inference; models trained on Flow data run here\n\nMIT License — free for any use.\n\nThis project explores the hypothesis that **purpose-built languages for LLMs can achieve significant efficiency gains** compared to traditional programming languages. The key findings:\n\n**Token efficiency is real**: Flow achieves 33% token reduction on average** Small models can learn**: 2.7-3.7B parameter models achieve 100% accuracy after fine-tuning** Hardware accessible**: QLoRA enables training on consumer GPUs (RTX 4060)\n\nFor the full analysis and methodology, see [benchmark_report.html](/pinku/Flow/blob/master/benchmark_report.html).", "url": "https://wpnews.pro/news/flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33", "canonical_source": "https://github.com/pinku/Flow", "published_at": "2026-07-13 15:31:54+00:00", "updated_at": "2026-07-13 15:35:16.833683+00:00", "lang": "en", "topics": ["large-language-models", "developer-tools", "ai-tools"], "entities": ["Flow", "Pinku", "phi-2", "Qwen 3B Coder v2", "RTX 4060", "QLoRA"], "alternates": {"html": "https://wpnews.pro/news/flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33", "markdown": "https://wpnews.pro/news/flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33.md", "text": "https://wpnews.pro/news/flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33.txt", "jsonld": "https://wpnews.pro/news/flow-a-compact-data-pipeline-language-that-cuts-llm-token-usage-by-33.jsonld"}}