Skip to content

Repository files navigation

PaRAGraph - A Technical Question Answering RAG System

PaRAGraph is a Retrieval-Augmented Generation (RAG) system designed to answer technical questions using IBM's Tech-QA dataset. The system uses different models suited for embedding, query rewriting, context reranking, answerability prediction, answer generation and answer evaluation.

System Architecture

PaRAGraph Workflow

The RAG pipeline consists of the following components, each one is a notebook contained in the techqa_report folder:

  1. Data Preprocessing - Document parsing and section extraction
  2. Vector Store Creation - Embedding generation and indexing
  3. Query Rewriting - Query optimization for better retrieval
  4. Query Embedding - Queries are embedded in a separate notebook to speed up the subsequent retrieval phase
  5. Contexts Retrieval - Semantic search and document reconstruction
  6. Contexts Reranking - Retrieved contexts are re-ranked based on relevance
  7. Contexts Evaluation - Evaluation of retrieved contexts using metrics such as hits@k, ndcg@k, and mrr
  8. Answerability Prediction - Determining if a question can be answered (binary classification)
  9. Answerability Evaluation - Computing classification metrics such as true positives, false positives, precision, recall, and F1-score
  10. Answer Generation - LLM-based response generation
  11. Evaluation - Performance evaluation using multiple metrics such as BLEU, ROUGE-L, METEOR, cosine similarity, Longest Match Ratio and Answer Relevancy (computed with a LLM-as-a-Judge)

Web-App Components (DEMO)

RAG Engine (app/PaRAGraph.py)

The main RAG system implementation consists of:

  • Document Retrieval: Semantic search with score thresholding
  • Answer Generation: Context-aware response generation

Web Interface (app/start_gui.py)

Streamlit-based GUI providing:

  • Interactive chat interface
  • Real-time document visualization
  • Conversation history management
  • Reference document display with official links

PaRAGraph web-app interface

Conversation Management (app/ConversationRepository.py)

MongoDB-based system for chat history persistence

Built With

Models

Infrastructure

  • Vector Database: Elasticsearch 9.0.3
  • Conversations Database: MongoDB
  • GPU Support: DirectML (for AMD GPUs) / CUDA
  • Framework: LlamaIndex for RAG orchestration
  • UI: Streamlit for web interface

Key Libraries

  • beautifulsoup4 - Text extraction from HTML pages
  • deepeval - Evaluation of generated answers
  • evaluate - Evaluation of generated answers
  • groq - Answer generation (used only in the demo)
  • llama-index - Document retrieval framework
  • nltk - Evaluation of generated answers
  • peft - LoRA adapter application during answer generation
  • ranx - Evaluation of retrieved context documents
  • scikit-learn - Evaluation of generated answers
  • textdistance - Evaluation of generated answers
  • transformers - Hugging Face model integration
  • vllm - Efficient LLM inference

Setup and Usage

  1. Prerequisites: Install Elasticsearch and requirements.txt
  2. Environment: Set up Python environment with required packages (3.10 if using torch_directml)
  3. Launch Elasticsearch DB: for storing the embeddings
  4. Data Preparation: Run notebooks 1-2 to process data and create indices
  5. Application Launch: Execute streamlit run start_gui.py to start the GUI

About

Rag System for Technical Question Answering (Tech-QA) - University project for Data Architecture exam

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages