A local prompt optimizer that compresses verbose English prompts into compact Spaceman Speech to reduce LLM token usage — without using a heavy LLM. Built with a Windows 95 retro UI.
Verbose prompt --> Spaceman Compressor --> Optimized prompt (fewer tokens, same meaning)
The compressor uses local NLP only (spaCy + sentence-transformers) to:
- Strip politeness, filler words, and hedge phrases
- Lemmatize and compress common verbose phrases
- Restructure into prompt-engineering best practices (ROLE/TASK/CONSTRAINTS/OUTPUT)
- Score variants by token count + semantic similarity
- Auto-select the best compression
Original (76 tokens):
I would like you to act as a senior data analyst. Could you please take a look at our quarterly sales data and provide me with a comprehensive summary of the key trends? Specifically, I need you to identify which product categories are performing well and which ones are underperforming. Please present your findings in a clear bullet point format and include percentage changes compared to the previous quarter.
Space Marine (40 tokens, 47% saved):
ROLE: senior data analyst. TASK: check quarterly sale data, find product category perform well, find underperforming. OUTPUT: bullet point format, include percentage changes, compare previous quarter.
| Strategy | Description | Typical Savings |
|---|---|---|
| Space Cadet | Gentle cleanup — removes filler and politeness words | 5-20% |
| Spaceman | Signature mode — strips stopwords, lemmatizes, structures into ROLE/TASK/OUTPUT | 25-50% |
| Space Marine | Aggressive — extracts only keywords into structured template | 30-50% |
| Space Commander | Full rewrite into clean imperative format | 30-75% |
- Role/persona definitions
- Negations and constraints ("don't", "never", "without")
- Output format specs ("as JSON", "bullet list", "table")
- Examples and few-shot blocks
- Chain-of-thought triggers ("step by step")
- Numbers, names, technical terms
| Component | Technology |
|---|---|
| Frontend | HTML/CSS/JS + 98.css (Windows 95 style) |
| Backend | Python, FastAPI, Uvicorn |
| NLP | spaCy (en_core_web_sm) |
| Similarity | sentence-transformers (all-MiniLM-L6-v2) |
| Tokenizer | tiktoken (cl100k_base) |
# Clone
git clone <repo-url>
cd SpaceSpeech
# Setup
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm
# Run
python run.pyOpen http://localhost:8000 in your browser.
SpaceSpeech/
├── run.py # Entry point
├── requirements.txt
├── backend/
│ ├── app.py # FastAPI app, model loading, static serving
│ ├── routes.py # API endpoints
│ ├── models.py # Pydantic schemas
│ ├── config.py # Constants
│ └── optimizer/
│ ├── pipeline.py # Orchestrator
│ ├── strategies.py # 4 compression strategies
│ ├── scorer.py # Token counting + semantic similarity
│ └── preprocess.py # Text normalization
├── frontend/
│ ├── index.html # Windows 95 style UI
│ ├── css/custom.css
│ ├── js/app.js
│ └── assets/ # Background + logo
└── bg/ # Source background images
{
"text": "your verbose prompt here",
"strategy": null,
"tokenizer": "cl100k_base",
"similarity_threshold": 0.7
}Response:
{
"original_text": "...",
"original_token_count": 76,
"variants": [
{"strategy": "mild", "text": "...", "token_count": 63, "similarity": 0.979},
{"strategy": "spaceman", "text": "...", "token_count": 41, "similarity": 0.875},
{"strategy": "extreme", "text": "...", "token_count": 40, "similarity": 0.873},
{"strategy": "command", "text": "...", "token_count": 41, "similarity": 0.757}
],
"best": {"strategy": "extreme", "text": "...", "token_count": 40, "similarity": 0.873},
"savings_percent": 47.4
}Returns model load status.
There might be a galaxy worth clicking on...