Spaces:
Sleeping
Sleeping
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 | |