ML-powered prompt complexity analyzer for LLM routing
Project description
complexity-analyzer
ML-powered prompt complexity analyzer for LLM routing.
Install
pip install . # basic (keyword features)
pip install ".[embeddings]" # + semantic embeddings (better accuracy)
pip install ".[all]" # everything
Usage
from complexity_analyzer import complexity
r = complexity("prove P≠NP")
print(r.score) # 9.2
print(r.model) # claude-opus-4-6
print(r.tier) # capable
print(r) # Score 9.2/10 | Tier: capable | Model: claude-opus-4-6 | Backend: ml
r.explain() # full breakdown with dimension scores
With semantic embeddings (requires pip install ".[embeddings]")
from complexity_analyzer import load_embedding_model, complexity
load_embedding_model() # call once at startup — downloads ~80MB once, cached
r = complexity("your prompt")
print(r.backend) # ml
CLI
complexity-analyzer -p "your prompt"
complexity-analyzer --only score -p "your prompt"
complexity-analyzer --provider openai -p "your prompt"
complexity-analyzer --json -p "your prompt"
Retrain with your own data
# Generate labeled data
python generate_dataset.py # 50k examples, free APIs
python generate_targeted.py # targeted complex examples
# Retrain
python training.py --data dataset.jsonl --balance
# Replace bundled model
cp model.joblib complexity_analyzer/model.joblib
pip install -e . # re-install to pick up new model
Score scale
| Score | Tier | Use |
|---|---|---|
| 1–3.5 | fast | Haiku / GPT-4o-mini / Gemini Flash |
| 3.6–6.5 | balanced | Sonnet / GPT-4o / Gemini Pro |
| 6.6–10 | capable | Opus / o1 / Gemini Ultra |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prompt_complexity_analyzer-0.1.0.tar.gz.
File metadata
- Download URL: prompt_complexity_analyzer-0.1.0.tar.gz
- Upload date:
- Size: 268.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ffa88f07cfd5ba5c254f61ef78352c1411465540f40143b8ff250ec419322e0
|
|
| MD5 |
eed0fdcaf74419b42420fd11ad0cec9f
|
|
| BLAKE2b-256 |
c353a11779fd5f88a73da024cc59d848ae990dffd24e559553e3ac9bdb080bbe
|
File details
Details for the file prompt_complexity_analyzer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prompt_complexity_analyzer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 274.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60fd3a689cc95c9eba8720bc12cab8cdd33f92d01064e975766278d35fd5e596
|
|
| MD5 |
c959033dc8d9ff7e236e5df15965839e
|
|
| BLAKE2b-256 |
2d664fcf190e2c2fabafffd8fb6a246e4d675e1fff64c51a544e5668cdc44b05
|