Spaces:
Sleeping
Sleeping
File size: 2,753 Bytes
d291479 f24b473 |
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 64 65 66 67 68 |
---
title: Sentence Transformers
emoji: 📚
colorFrom: yellow
colorTo: blue
sdk: gradio
sdk_version: 5.31.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: Small CNN
---
# 🔍 MiniLM Semantic FAQ Search — Smart, Lightning-Fast Knowledge Retrieval
[](https://huggingface.co/spaces/your-username/minilm-semantic-search)
[](https://gradio.app)
[](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
[](LICENSE)
---
## 🚀 TL;DR
**Ask a question → get the three most relevant answers from a curated FAQ — all in real time on a free CPU-only Hugging Face Space.**
Powered by the _all-MiniLM-L6-v2_ sentence-transformer (∼90 MB, < 1 GB RAM) and a minimalist Gradio 5 UI.
---
## ✨ Why You’ll Love It
| · | Capability | Why It Matters |
|---|------------|----------------|
| ⚡ | **Instant Retrieval** | 50-200 ms response time even on CPU-only hardware. |
| 🧠 | **Semantic Matching** | Goes beyond keywords; understands intent and phrasing. |
| 📈 | **Live Similarity Scores** | Transparent confidence metrics for every hit. |
| 🎛️ | **Interactive Slider** | Choose 1-5 results in a single drag. |
| 🎨 | **Sleek Gradio GUI** | No setup friction — just open a browser and explore. |
| 💸 | **Free-Tier Friendly** | Fits comfortably inside Hugging Face Spaces’ 2 vCPU / 16 GB RAM limit. |
| 🛠️ | **Drop-in Dataset Swap** | Replace `faqs.csv` with thousands of your own Q-A pairs — no retraining required. |
---
## 🏗️ How It Works
1. **Vectorisation**
Every FAQ question is embedded with `sentence-transformers/all-MiniLM-L6-v2` into a 384-dimensional vector (done once at start-up).
2. **Inference**
A user query is embedded on the fly and cosine-compared with all FAQ vectors via 🤗 `util.cos_sim`.
3. **Ranking**
Top-_k_ indices are extracted with PyTorch’s efficient `topk`, then mapped back to the original FAQ rows.
4. **Presentation**
Gradio displays the question, answer and similarity score in a responsive dataframe.
> _No database, no external search engine, just straight Python & PyTorch embeddings._
---
## 🖥️ Quick Start (Local Dev, Optional)
```bash
git clone https://github.com/your-username/minilm-semantic-search.git
cd minilm-semantic-search
python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py
|