Skip to content

rehan-shafi/semantic-search-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 Semantic Q&A Search App

This is a simple but powerful semantic search engine built using SentenceTransformers and Gradio. It allows users to ask questions and receive the top 3 most relevant answers from a predefined Q&A dataset using embedding-based similarity.


🚀 Features

  • Uses intfloat/e5-small-v2 transformer model
  • Supports domain-specific question-answer search
  • Logs every user query and matched results to CSV
  • Saves sentence embeddings to avoid reprocessing
  • Simple Gradio-based web interface

🗂️ Project Structure

semantic-search-app/ ├── app.py # Main entry point (Gradio UI) ├── model_utils.py # Model and embedding handling ├── search_engine.py # Core semantic search logic ├── logger.py # Query logging utility ├── data/ │ └── qa_dataset.csv # Input dataset (questions and answers) ├── embeddings/ │ └── corpus_embeddings.pt # Cached embeddings (auto-created) ├── logs/ │ └── query_log.csv # Logs of user queries ├── requirements.txt # Required Python libraries ├── .gitignore # Ignored folders/files └── README.md # This file


📊 Dataset Format

Place your Q&A dataset in data/qa_dataset.csv with the following columns:

Question Answer
How to return? Visit our returns page
... ...

🛠️ Installation & Usage

1. Clone the Repo

git clone https://github.com/rehan-shafi/semantic-search-app.git cd semantic-search-app

2. Install Requirements

pip install -r requirements.txt

3. Add Dataset

Place your dataset in: data/qa_dataset.csv

4. Run the App

python app.py Open the provided URL to interact with the semantic Q&A system.

🧠 How It Works

Model: intfloat/e5-small-v2 Format: Adds query: and passage: prefixes as per model guidelines Similarity: Uses cosine similarity on sentence embeddings Results: Shows top 3 answers above a similarity threshold (default 0.5)

📌 Example Output

User Query: How can I return a damaged product Top Match: Q: How do I return my product? A: Please visit the returns page and fill out the return form. Score: 0.78

🧾 License

This project is released under the MIT License.

🙌 Credits

Model: SentenceTransformers UI: Gradio Author: Rehan Shafi

About

Gradio-powered semantic Q&A app using Sentence Transformers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages