Spaces:
Sleeping
Sleeping
|
Download README.md from lydiaavin/rag-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 3.04 kB
-
https://huggingface.co/spaces/lydiaavin/rag-chatbot/resolve/main/README.md
- Command line
-
hf download hf://spaces/lydiaavin/rag-chatbot/README.md
-
curl -L -o README.md https://huggingface.co/spaces/lydiaavin/rag-chatbot/resolve/main/README.md
3.04 kB
A newer version of the Streamlit SDK is available: 1.67.0
metadata
title: RAG Chatbot
emoji: 🤖
colorFrom: blue
colorTo: green
sdk: streamlit
sdk_version: 1.30.0
app_file: app/streamlit_app.py
pinned: true
RAG Chatbot
A Retrieval-Augmented Generation (RAG) chatbot that enables interactive conversations with PDF documents. Upload PDFs, process them, and ask questions in a chat interface powered by advanced NLP models.
Features
- PDF Ingestion: Extract and chunk text from PDF documents using pdfplumber.
- Embeddings: Generate sentence embeddings with Sentence Transformers for semantic search.
- Vector Search: Efficient similarity search using FAISS vector database.
- Question Answering: Generate answers using pre-trained language models (e.g., FLAN-T5).
- Chat Interface: Interactive chat UI built with Streamlit for seamless user experience.
- Session Management: Persistent chat history and processed data per session.
- Source Citations: View relevant text chunks as sources for answers.
Architecture
The application follows a modular RAG pipeline:
- Ingestion (
src/ingest.py): Extracts text from PDFs and chunks it into manageable pieces. - Embedding (
src/embed.py): Converts text chunks into vector embeddings. - Vector Store (
src/vectorstore.py): Builds and manages FAISS index for fast retrieval. - Query (
src/query.py): Embeds user queries, retrieves relevant chunks, and generates answers. - UI (
app/streamlit_app.py): Provides a chat interface for user interaction.
Setup
Clone the repository:
git clone https://github.com/lydiamavin/rag-chatbot.git cd rag-chatbotCreate and activate a virtual environment:
python -m venv venv source venv/bin/activateInstall dependencies:
pip install -r requirements.txt
Usage
Run the Streamlit app:
streamlit run app/streamlit_app.pyOpen your browser to the provided URL.
In the sidebar:
- Upload one or more PDF files.
- Click "Process PDFs" to ingest and index the documents.
Once processed, use the chat input at the bottom to ask questions about the PDFs.
View answers in the chat, with expandable sources for transparency.
Example
- Upload a PDF about machine learning.
- Ask Questions
- Receive answers with relevant excerpts from the document.
Configuration
- Models: Default embedding model is
all-MiniLM-L6-v2. Generation model isgoogle/flan-t5-small. Modify in source code for customization. - Chunking: Default chunk size is 1000 characters with 200 overlap. Adjust in
src/ingest.py. - Data Storage: Processed data (chunks, embeddings, index) is stored in the
data/directory.
Testing
Run tests with pytest:
pytest tests/
Acknowledgments
- Built with Streamlit, Sentence Transformers, FAISS, and Transformers.