I built this project as a small FAQ search API. It takes a text query, compares it with the questions and answers in a CSV file, and returns the closest matches.
The current retrieval method is TF-IDF with cosine similarity. Despite the project name, this version is a lexical retrieval baseline; it does not use transformer embeddings or a vector database.
POST /search— returns the top matching FAQ entries.POST /embed— returns the dimensions and values of a query's TF-IDF vector.GET /ui— serves a browser interface.GET /— returns basic API information.- FAQ records are loaded from
data/faq.csv.
The vectorizer is fitted on the combined FAQ question and answer text when the application starts.
- Python
- FastAPI and Pydantic
- pandas
- scikit-learn
- TF-IDF and cosine similarity
On Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
uvicorn app.main:app --reload --port 8002
Open the local interface at http://127.0.0.1:8002/ui or API documentation at http://127.0.0.1:8002/docs.
POST /search
{
"query": "webhook api integration",
"top_k": 3
}
A result includes the FAQ identifier, question, answer, domain, and cosine-similarity score.
- Retrieval quality depends on the vocabulary and wording in the CSV dataset.
- TF-IDF does not capture meaning as well as contextual embedding models for queries that use different wording.
- There is no persistent query analytics or relevance feedback in the current API.
- Automated test results and deployment status have not been verified.
- Add tests with representative FAQ queries.
- Add relevance evaluation so retrieval changes can be compared.
- Experiment with hybrid lexical and embedding-based retrieval.
- Add query logging if usage analytics become necessary.
Afzal Hussain · @Afzu01