Prompt_Squirrel_RAG / README.md
FoodDesert's picture
Update README.md
89fa3ee verified
|
Raw
History Blame
2.79 kB
metadata
title: Prompt Squirrel  Tag Retrieval System
colorFrom: indigo
colorTo: purple
sdk: gradio
sdk_version: 5.43.1
python_version: 3.10.12
app_file: app.py
pinned: false
license: apache-2.0
short_description: Closed-vocabulary tag retrieval from natural language
emoji: 🧠

Prompt Squirrel — Tag Retrieval System

Prompt Squirrel performs semantic search over a fixed image-tag vocabulary, mapping natural-language descriptions to relevant tags via retrieval and ranking.

The interface then allows users to interactively refine these retrieved tags into a final prompt.

System Overview

This project demonstrates a multi-stage retrieval pipeline:

  1. Query rewriting (LLM)
  2. Candidate generation (TF-IDF + embeddings)
  3. Candidate ranking and selection (closed-set LLM)
  4. Interactive refinement (UI)

Key Properties

  • Closed vocabulary (no hallucinated tags)
  • Retrieval-first architecture (no direct generation)
  • Transparent intermediate stages for inspection and debugging

What This Space Does

  • Rewrites free text into retrieval-friendly query phrases (LLM).
  • Retrieves candidate tags from a fixed vocabulary using semantic search.
  • Ranks and filters candidates via closed-set LLM selection (no invented tags).
  • Expands implied concepts and organizes results into editable groups.
  • Lets users refine and assemble the final prompt via interactive controls.

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