In this article, we’ll guide you through setting up a local Large Language Model (LLM) that employs Retrieval-Augmented Generation (RAG). Picture this project as a wizard experimenting with powerful spells to conjure up answers from PDFs by harnessing the might of Ollama and other tools. Let’s dive in and explore how you can create your own enchanting AI assistant!
Requirements
- Ollama version 0.1.26 or higher
Setup Steps
- Clone the repository to your local machine.
- Create a Python virtual environment by running:
python3 -m venv .venv - Activate the virtual environment:
- On Unix or MacOS:
source .venv/bin/activate - On Windows:
.venv\Scripts\activate
- On Unix or MacOS:
- Install the required Python packages by running:
pip install -r requirements.txt
Running the Project
When you first run the project, it will fetch the necessary models from Ollama for the LLM and embeddings. This process is akin to a wizard gathering ingredients for a powerful potion—it may take some time based on your internet speed.
- Ensure your virtual environment is activated.
- Run the main script with:
This allows you to specify a model and the path to your documents. If you choose not to specify a model, it defaults to mistral. The document path defaults to a sample location called “Research”.python app.py -m model_name -p path_to_documents - You can optionally specify the embedding model with:
If you leave this unspecified, it defaults to nomic-embed-text.-e embedding_model_name
This process loads your PDFs and Markdown files, generates embeddings, queries the collection, and delivers answers as outlined in app.py.
Running the Streamlit UI
- Ensure your virtual environment is activated.
- Navigate to the directory containing ui.py.
- Run the Streamlit application by executing:
streamlit run ui.py
This command starts a local web server and opens a new tab in your default web browser, allowing you to interact with the application through a user-friendly interface. The Streamlit UI makes it significantly easier to select models, choose folder paths, and communicate with the RAG chatbot.
Troubleshooting Tips
If you encounter issues during setup or execution, consider the following:
- Ensure that your Python version is compatible with the packages you are trying to install.
- Verify your internet connection; downloading models can be interrupted by unstable connectivity.
- If you receive errors regarding missing packages, re-run the installation command specified in the setup section.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Technologies Used
- Langchain: A Python library tailored for working with Large Language Models.
- Ollama: A robust platform for local LLM usage.
- Chroma: A vector database for storing and retrieving embeddings.
- PyPDF: A Python library for reading and manipulating PDF files.
- Streamlit: A web framework designed for creating interactive applications in machine learning and data science.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
