CoolFace
Apppublic

build-small-hackathon/code-shrink-token-decimator

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
1likes
README.md75 linesDownload Raw Back to root
1---2title: Code Shrink Token Decimator3emoji: 👀4colorFrom: gray5colorTo: pink6sdk: gradio7sdk_version: 6.16.08python_version: '3.13'9app_file: app.py10pinned: false11license: apache-2.012short_description: 'Ultra-lightweight lexical token compressor that reduces LLM '13thumbnail: >-14  https://cdn-uploads.huggingface.co/production/uploads/6989c34475b229ddd8f18be3/ZTXpy1-KYjq7lfqHSb0ic.png15---16 17# ⚡ Code-Shrink: Token-Decimator v1.018 19> **An Ultra-Lightweight Computational Utility Built to Eliminate LLM Context Bloat Natively on the Edge Container.**20> *Submitted for the Hugging Face Build Small Hackathon (Track 2: Performance & Efficiency Optimization).*21 22---23 24## 📽️ Project Demonstration & Walkthrough25 26Check out the full workflow, speed metrics, and feature breakdown in action here:27🔗 **[Watch the Live Demo on TikTok](https://www.tiktok.com/@salarai123/video/7648566501598940436)**28 29---30 31## 🔍 The Problem & The Solution32 33### The Bottleneck: LLM Context Inflation34Modern production applications relying on Large Language Model (LLM) APIs suffer from massive financial overhead. Upstream providers charge by the token—meaning heavy indentation loops, generic code comments, raw text formatting, and large structural blocks exponentially inflate infrastructure bills.35 36### The Engine: Code-Shrink37**Code-Shrink v1.0** passes raw context inputs through an edge-computed Abstract Syntax Tree (AST) framework. Instead of hosting gigabytes of neural network weights that lag and crash free hosting tiers, this application runs entirely on zero-cost, lightweight lexical optimization models. It reduces prompt token sizes by **up to 66% in under 10 milliseconds**.38 39---40 41## ⚡ Technical Core Features42 43* **Abstract Syntax Tree (AST) De-bloating:** Fully parses Python/R/SQL environments natively to structurally strip docstrings, developer comments, and empty lines while maintaining 100% semantic code integrity.44* **Lexical JSON Minification:** Collapses raw object dictionaries, spacing grids, and redundant string arrays into tight, machine-readable micro-streams.45* **On-Edge Real-Time Diagnostic Metrics:** Computes compression percentages and displays an estimated API cost savings panel instantly on execution.46* **Zero Infrastructure Overhead:** Operates 100% standalone with zero dependency on third-party backend servers, making it completely immune to public inference timeouts.47 48---49 50## 🛠️ Tech Stack & System Compatibility51 52- **Interface Framework:** Gradio (v6.0 Transition-Optimized Layer)53- **Computational Core:** Native Python AST & Lexical Pattern RegEx Engine54- **Data Manifestation:** Memory Buffer Stream Handlers (PIL/JSON Core)55- **Hardware Benchmarking:** Heavily optimized for restricted legacy processors (runs smooth down to Intel Core i3 4th Gen / 8GB RAM specs).56 57---58 59## 🎛️ Parameters Matrix60 611. **Raw Context Input:** Inject bloated code strings or massive JSON arrays into the terminal panel.622. **Lexical Processing Mode:** Set structural parser rules (`Python/R/SQL Code Matrix` or `Structured JSON / Raw Text Array`).633. Click **⚡ DECIMATE CONTEXT TOKENS** to immediately wipe empty tokens and render the optimized micro-stream for your prompt.64 65---66 67## 📦 Local Workspace Setup68 69To clone and execute this performance node locally:70 71```bash72git clone [https://huggingface.co/spaces/build-small-hackathon/code-shrink-token-decimator](https://huggingface.co/spaces/build-small-hackathon/code-shrink-token-decimator)73cd code-shrink-token-decimator74pip install -r requirements.txt75python app.py