# Paul Graham Essays RAG Application This application is a Retrieval-Augmented Generation (RAG) system that allows users to ask questions about Paul Graham's essays. The system uses semantic search to find relevant passages from the essays and generates responses based on the retrieved context. ## Features - Semantic search using HuggingFace embeddings - Context-aware response generation - Chunk-based document processing - Interactive chat interface - Support for multiple questions in a single session ## How It Works 1. The application processes Paul Graham's essays by splitting them into chunks of 1000 characters with 30 character overlap 2. When a user asks a question, the system: - Converts the question into an embedding - Finds the most relevant passages from the essays - Combines the question and context - Generates a response using a HuggingFace LLM ## Example Questions Here are some example questions you can ask the system: 1. "What are Paul Graham's views on startup funding and when should founders raise money?" 2. "How does Paul Graham define a good startup idea and what are the key characteristics he looks for?" 3. "What does Paul Graham say about the relationship between programming languages and productivity?" 4. "What are Paul Graham's thoughts on the importance of focus and how it relates to startup success?" 5. "How does Paul Graham describe the process of finding product-market fit?" 6. "What are Paul Graham's views on the role of luck in startup success?" 7. "How does Paul Graham define a 'good' programmer and what qualities does he emphasize?" 8. "What does Paul Graham say about the importance of user feedback in the early stages of a startup?" 9. "How does Paul Graham describe the relationship between founders and investors?" 10. "What are Paul Graham's thoughts on the role of competition in the startup ecosystem?" ## Technical Details ### Embedding Model - Uses [BAAI/bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) - A powerful English language embedding model optimized for semantic search - Provides high-quality vector representations for text chunks - Enables efficient similarity search across the essay corpus ### Language Model - Uses [NousResearch/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/NousResearch/Meta-Llama-3.1-8B-Instruct) - An 8B parameter instruction-tuned model - Optimized for dialogue and instruction following - Capable of generating detailed, context-aware responses ### System Architecture - Document chunks are stored in a vector database for efficient retrieval - The RAG system uses a custom prompt template that combines the user's question with retrieved context - Responses are generated using the HuggingFace LLM endpoint - The system maintains conversation history for context-aware interactions ## Getting Started 1. Make sure you have the required dependencies installed 2. Place Paul Graham's essays in the `data/paul_graham_essays.txt` file 3. Run the application using `chainlit run app.py` 4. Open your browser to the provided local URL 5. Start asking questions about Paul Graham's essays ## Best Practices - Ask specific questions to get more focused answers - Use natural language - the system understands conversational queries - You can ask follow-up questions to dive deeper into topics - The system works best with questions that have clear answers in the essays ## Limitations - The system can only answer questions based on the content in Paul Graham's essays - Very specific or technical questions might not have enough context in the essays - The quality of answers depends on the relevance of the retrieved passages - The system might not always provide complete answers for complex topics ## Contributing Feel free to contribute to this project by: - Adding more example questions - Improving the prompt template - Enhancing the document processing pipeline - Adding new features to the chat interface