This repository contains a simple FAQ search functionality using FastAPI and Sentence-BERT. The application consists of a FastAPI backend that processes search queries and a frontend built with HTML, CSS, and JavaScript to interact with the backend.
git clone https://github.com/your-username/faq-search-app.git
cd faq-search-appMake sure you have Python 3.7+ installed.
Install the required Python packages:
pip install fastapi uvicorn sentence-transformers torchThe frontend is a simple HTML file. No additional dependencies are needed.
.
├── main.py # FastAPI backend handling search functionality
├── index.html # Frontend for the FAQ search
├── README.md # Project documentation
└── requirements.txt # Python dependencies (optional)Run the following command to start the backend server:
uvicorn main:app --reloadThe backend will be available at http://127.0.0.1:8000.
Open the index.html file in your browser. Make sure the FastAPI server is running, as the frontend fetches results from http://127.0.0.1:8000/search.

This application consists of two components:
- The FastAPI backend uses the Sentence-BERT model to process and find the most relevant FAQs for a given search query.
- Cosine similarity is used to match user queries to pre-embedded FAQs.
- The backend includes a single API route
/searchwhere the frontend sends search queries and receives results.
- The frontend provides a simple user interface where users can enter a search query and receive FAQ results.
- JavaScript is used to dynamically fetch search results from the backend and display them without refreshing the page.
- The backend loads a predefined set of FAQ questions and their answers, embedding them using Sentence-BERT.
- When a user submits a search query, the backend compares the query to the FAQ embeddings and returns the most relevant results using cosine similarity.
- The frontend displays the results dynamically, with each FAQ's section, question, answer, and similarity score.
