How amitkumarshorthillsai/rag-project---amit-kumar works
Project type and purpose
• This is a full-pipeline Retrieval-Augmented Generation (RAG) system specialized for Wikipedia Q&A.
• It combines:
• A data-ingestion (scraper) service
• A processing/embedding pipeline
• A vector store (FAISS)
• A retrieval + generation service (RAG)
• A Streamlit-based front-end
• Offline evaluation modules (traditional and LLM-based)
Top-level directory analysis
• app/
• ui_app.py: Streamlit chatbot UI
• test_chatbot_ui.py & test_result_chatbot_ui/: UI tests & logs
• scrapers/
• wiki_scraper.py: crawl & JSON-dump Wikipedia pages
• test_scraper.py & logs: unit tests & execution logs
• src/
• rag_pipeline.py: chunk → embed → index into FAISS
• mini_rag.py: minimal end-to-end demo
• embeddings/: serialized FAISS indexes
• GroundTruth_Context_Generation/
• groundTruth_context.py: enrich Q&A with contexts
• bert_evaluation/
• bert_score_eval.py: computes BLEU, ROUGE, BERTScore
• outputs/: results and logs
• ragas_eval_custom/
• evaluate.py, gemini_client.py, prompts.py: custom LLM evaluation via Gemini
• requirements.txt, .env, .gitignore
README insights
• Clearly spells out:
• Scraping → chunking → embedding → FAISS storage → reranking → generation via LLaMA3/Ollama → UI
• Two evaluation paths: traditional (BERTScore, ROUGE, BLEU) and LLM-based (Gemini)
• Technologies: WikipediaAPI, BeautifulSoup, RecursiveCharacterTextSplitter, HuggingFace, FAISS, Ollama, Streamlit
Components & interactions
a. Components
1) Scraper Service
• wiki_scraper.py
• External: WikipediaAPI, BeautifulSoup
• Output: raw JSON → scrapers/data/raw_scraped/
2) Chunking & Embedding Pipeline
• rag_pipeline.py
• RecursiveCharacterTextSplitter → embeddings via BAAI/bge-large-en-v1.5
• Output: FAISS index stored in src/embeddings/
3) Vector Store (FAISS)
• High-dimensional index on disk/in-memory
4) Reranker
• cross-encoder/ms-marco-MiniLM-L-6-v2
• Re-orders top-k retrieved chunks
5) Generation Service
• llama3:8b via Ollama
• Accepts reranked context + question → produces answer
6) Streamlit UI
• app/ui_app.py
• Fetches from RAG service, logs to app/test_result_chatbot_ui/
7) Ground-Truth Context Generation
• groundTruth_context.py
• Generates enriched Q&A for evaluation
8) Evaluation Modules
• Traditional metrics: bert_score_eval.py → outputs to bert_evaluation/bert_eval_output/
• LLM-based: evaluate.py → uses Gemini-2.0-flash, logs under ragas_eval_custom/
b. Data flow & dependencies
• Scraper → Raw JSON → Pipeline
• Pipeline → FAISS index
• UI / RAG service → Query → FAISS → Reranker → LLaMA3 → Response → UI
• GroundTruth script + generated answers → Evaluation modules → Reports
c. Architectural patterns
• Modular ETL + retrieval pipeline
• Clear separation of concerns (ingestion, processing, storage, serving, evaluation)
• Pluggable embedding & reranking models
• Service-oriented structure (could be isolated as microservices)
d. Key technologies & libraries
• Data ingestion: WikipediaAPI, BeautifulSoup
• Chunking: LangChain’s RecursiveCharacterTextSplitter
• Embedding: HuggingFace Transformers (BAAI/bge-large-en-v1.5)
• Vector DB: FAISS
• Reranker: cross-encoder/ms-marco-MiniLM-L-6-v2
• Generation: LLaMA3 via Ollama
• UI: Streamlit
• Evaluation: BERTScore, ROUGE, BLEU, Google Gemini
Final recommendations
• As many logical components as possible without clutter
• Modularity: each folder → separate service
• Keep it high-level but annotate major sub-steps (scrape, chunk, embed, index, retrieve, rerank, generate, evaluate)