ghostai1's picture
Update README.md
f24b473 verified
---
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
[![Hugging Face Space](https://img.shields.io/badge/HF%20Space-Launch-lightgrey?logo=huggingface)](https://huggingface.co/spaces/your-username/minilm-semantic-search)
[![Gradio UI](https://img.shields.io/badge/Gradio-5.31.0-green?logo=gradio)](https://gradio.app)
[![Model](https://img.shields.io/badge/Model-all--MiniLM--L6--v2-blue)](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
[![License](https://img.shields.io/github/license/your-username/minilm-semantic-search)](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 &mdash; 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