A Retrieval-Augmented Generation (RAG) system that allows you to chat with your local documents using DeepSeek's powerful language model. This project demonstrates how to build an intelligent document Q&A system using modern AI technologies.
- Local Document Processing: Automatically processes MDX and other document formats
- Vector Database: Uses ChromaDB for efficient document embeddings and retrieval
- DeepSeek Integration: Leverages DeepSeek-Coder model for intelligent responses
- Streamlit Interface: Clean and intuitive web interface for document interaction
- Smart Text Processing: Cleans MDX files and splits documents into optimal chunks
- Language Model: DeepSeek-Coder (via Ollama)
- Vector Database: ChromaDB
- Embeddings: HuggingFace sentence-transformers/all-MiniLM-L6-v2
- Framework: LangChain
- Frontend: Streamlit
- Document Processing: UnstructuredFileLoader, CharacterTextSplitter
Before running this project, ensure you have:
- Python 3.8+ installed
- Ollama installed and running
- DeepSeek-Coder model pulled in Ollama
# Install Ollama (macOS)
brew install ollama
# Or download from https://ollama.ai
# Pull the DeepSeek-Coder model
ollama pull deepseek-coder
-
Clone the repository
git clone <your-repo-url> cd deepseek-rag
-
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Prepare your documents
- Place your documents in the
docs/
folder - Supports MDX files and other formats (PDF, TXT, etc.)
- The system will automatically process and clean MDX content
- Place your documents in the
-
Start the application
streamlit run app.py
-
Open your browser
- Navigate to
http://localhost:8501
- Start asking questions about your documents!
- Navigate to
You can modify the RAG configuration in rag_chain.py
:
# Adjust chunk size and overlap
splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=50)
# Change embedding model
embedding = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
# Switch to different DeepSeek model
llm = Ollama(model="deepseek-coder") # or "deepseek-chat"
The system automatically:
- Cleans HTML tags from MDX files
- Splits documents into chunks for better retrieval
- Creates vector embeddings for semantic search
- Persists the vector database in the
db/
directory
deepseek-rag/
├── app.py # Streamlit web interface
├── rag_chain.py # RAG implementation and configuration
├── requirements.txt # Python dependencies
├── docs/ # Document directory (Next.js docs included)
│ ├── 01-installation.mdx
│ ├── 02-project-structure.mdx
│ └── ...
└── db/ # ChromaDB vector database
├── chroma.sqlite3
└── ...
- Document Loading: The system scans the
docs/
folder and loads all supported documents - Text Processing: MDX files are cleaned of HTML tags, and all documents are split into chunks
- Embedding Creation: Text chunks are converted to vector embeddings using HuggingFace models
- Vector Storage: Embeddings are stored in ChromaDB for fast similarity search
- Query Processing: User questions are embedded and matched against document chunks
- Response Generation: DeepSeek-Coder generates answers based on retrieved context
This RAG system is perfect for:
- Documentation Q&A: Ask questions about technical documentation
- Knowledge Base: Build internal company knowledge systems
- Research Assistant: Query research papers and technical documents
- Learning Tool: Interactive way to explore complex documentation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- DeepSeek for the powerful language models
- LangChain for the RAG framework
- ChromaDB for vector database capabilities
- Streamlit for the user interface
- HuggingFace for embedding models
Ollama Connection Issues:
- Ensure Ollama is running:
ollama serve
- Verify DeepSeek model is available:
ollama list
Memory Issues:
- Reduce chunk_size in
rag_chain.py
- Use a smaller embedding model
Document Processing Errors:
- Check document formats are supported
- Ensure documents are readable and not corrupted
Built with ❤️ using DeepSeek, LangChain, and Streamlit