--- title: Mistral Rag Chat emoji: 🏢 colorFrom: pink colorTo: green sdk: gradio sdk_version: 5.34.2 app_file: app.py pinned: false --- # 📚 Mistral RAG Chat - Document Question Answering **Chat with your documents using Mistral AI's powerful language models!** Upload any text document and ask questions about its content. This app uses Retrieval-Augmented Generation (RAG) to provide accurate, context-aware answers based on your uploaded documents. ## 🚀 Features - **📄 Document Upload**: Support for `.txt` files - **🔍 Smart Retrieval**: Uses FAISS vector search to find relevant content - **🤖 Mistral AI**: Powered by Mistral's large language model - **💬 Chat Interface**: Intuitive conversation-style interaction - **⚡ Fast Processing**: Efficient document chunking and embedding ## 🛠️ How It Works 1. **Upload** your text document (.txt format) 2. **Process** the document (creates searchable embeddings) 3. **Ask** questions about the content 4. **Get** accurate answers based on the document context ## 💡 Use Cases - **📖 Research Papers**: Ask questions about academic papers - **📋 Company Documents**: Query policy manuals, reports, handbooks - **📚 Educational Content**: Study materials, textbooks, lecture notes - **📰 News Articles**: Analyze and understand news content - **📄 Legal Documents**: Extract key information from contracts, agreements ## 🎯 Example Queries After uploading a document, try asking: - "What is the main topic of this document?" - "Summarize the key points" - "What does the author say about [specific topic]?" - "Are there any statistics or numbers mentioned?" - "What conclusions does the document reach?" ## 🔧 Technical Details - **Embedding Model**: `mistral-embed` for document vectorization - **LLM**: `mistral-large-latest` for answer generation - **Vector Database**: FAISS for similarity search - **Chunk Size**: 2048 characters for optimal context - **Retrieval**: Top-2 most relevant chunks per query ## 📝 Supported Formats Currently supports: - `.txt` files (UTF-8 encoded) *More formats coming soon!* ## 🚦 Getting Started 1. Click **"Upload Text File"** and select your document 2. Click **"Process Document"** and wait for confirmation 3. Start asking questions in the chat interface 4. Get instant, context-aware answers! ## ⚠️ Important Notes - **File Size**: Keep documents under 10MB for best performance - **Language**: Works best with English text - **Context**: The AI only knows what's in your uploaded document - **Privacy**: Documents are processed temporarily and not stored permanently ## 🔐 Privacy & Security - Your documents are processed in real-time - No permanent storage of uploaded files - Conversations are not logged or saved - API calls are made securely to Mistral AI ## 🆘 Troubleshooting **Document won't process?** - Ensure your file is in `.txt` format - Check that the file contains readable text - Try a smaller file if you're having issues **Getting irrelevant answers?** - Make sure your question relates to the document content - Try rephrasing your question more specifically - Check that the document was processed successfully **Error messages?** - Refresh the page and try again - Ensure your document is properly formatted - Contact support if issues persist ## 🚀 Built With - **[Gradio](https://gradio.app/)**: Web interface framework - **[Mistral AI](https://mistral.ai/)**: Language model and embeddings - **[FAISS](https://faiss.ai/)**: Vector similarity search - **[NumPy](https://numpy.org/)**: Numerical computing - **[Hugging Face Spaces](https://huggingface.co/spaces)**: Hosting platform ## 📊 Model Information - **Base Model**: Mistral Large (latest version) - **Embedding Dimension**: 1024 - **Context Window**: 32k tokens - **Languages**: Optimized for English, supports multiple languages ## 🎨 Interface Preview ``` 📚 RAG Chat Interface Upload a text file and chat with its content! [Upload Text File] [Process Document] Processing Status: Document processed successfully! Split into 15 chunks. 💬 Chat: User: What is this document about? Assistant: Based on the uploaded document, this appears to be about... [Your Message: Ask questions about the uploaded document...] [Send] [Clear Chat] ``` ## 📄 License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. --- **Made with ❤️ using Mistral AI and Gradio** *Try it now - upload a document and start chatting!*