Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semantic FAQ Retriever

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.

Features in the code

  • 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.

Technology

  • Python
  • FastAPI and Pydantic
  • pandas
  • scikit-learn
  • TF-IDF and cosine similarity

Run locally

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.

Example request

POST /search

{
  "query": "webhook api integration",
  "top_k": 3
}

A result includes the FAQ identifier, question, answer, domain, and cosine-similarity score.

Current limitations

  • 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.

Next improvements

  • 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.

Author

Afzal Hussain · @Afzu01

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages