Spaces:
Running
Running
File size: 2,199 Bytes
d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 ed9438a d5a5b38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ---
title: Prompt Squirrel
colorFrom: gray
colorTo: gray
sdk: gradio
sdk_version: 5.43.1
python_version: 3.10.12
app_file: app.py
pinned: false
license: apache-2.0
---
# Prompt Squirrel RAG
Prompt Squirrel converts rough natural-language image descriptions into a structured, editable prompt built from a fixed image-tag vocabulary.
The intent is practical: produce a strong starting prompt quickly, then let users directly refine tag choices in the UI.
## What This Space Does
- Rewrites free text into retrieval-friendly pseudo-tags.
- Retrieves candidate tags from a fixed vocabulary.
- Uses closed-set LLM selection (index-only) so models cannot invent arbitrary tags.
- Expands implications and groups tags into ranked editable rows.
- Builds the final suggested prompt from current toggle states.
## How To Use
1. Enter an image description in `Enter Prompt`.
2. Click `Run`.
3. Toggle tags in rows to add/remove them.
4. Copy the final text from `Suggested Prompt`.
## Technologies Used
- FastText embeddings for semantic retrieval.
- HNSW indexes for efficient nearest-neighbor search.
- Reduced TF-IDF vectors for context-aware ranking.
- OpenRouter instruction models for rewrite, structural inference, probe inference, and closed-set selection.
Default model: `mistralai/mistral-small-24b-instruct-2501` (chosen empirically on internal caption-evident evaluations; configurable).
- Gradio for the interactive web UI.
## Current Snapshot
Latest relabel-aware rescore on caption-evident n=30:
- Micro precision/recall/F1: `0.554 / 0.750 / 0.638`
- Macro precision/recall/F1: `0.564 / 0.764 / 0.633`
- Ground-truth scale: 30 images, 440 total tag assignments, 205 unique tags
Latency from local UI timing logs (n=110 runs):
- Median: `8.56s`
- P75: `12.56s`
- P90: `18.33s`
## Documentation And Contracts
- Full architecture and rationale (same source used by the in-app docs accordion): [docs/space_overview.md](docs/space_overview.md)
- Retrieval contract: [docs/retrieval_contract.md](docs/retrieval_contract.md)
- Rewrite contract: [docs/rewrite_contract.md](docs/rewrite_contract.md)
- Closed-set selection contract: [docs/stage3_contract.md](docs/stage3_contract.md)
|