Giter Club home page Giter Club logo

local-rag-with-langchain's Introduction

Local-RAG-with-LangChain

This project implements a local QA system by combining RAG with LangChain. LangChain's library assists in building the RAG pipeline, which leverages a powerful LLM hosted on OLLAMA. Notably, this system operates entirely on your local machine, offering privacy and control over your data. A user-friendly Streamlit interface visualizes the process and results.

Dependencies:

  • langchain
  • streamlit
  • streamlit-chat
  • pypdf
  • chromadb
  • fastembed
pip install langchain streamlit streamlit_chat chromadb pypdf fastembed

This project creates a local Question Answering system for PDFs, similar to a simpler version of ChatPDF. It leverages Langchain, Ollama, and Streamlit for a user-friendly experience.

Tech Stack:

  Ollama: Provides a robust LLM server that runs locally on your machine.
  
  Langchain: A powerful library used to build the Retrieval-Augmented Generation (RAG) pipeline.
  
  Chroma: A vector storage solution that integrates well with Langchain.
  
  Streamlit: Creates a straightforward user interface for uploading PDFs and asking questions.

Building the App:

      Setting Up Ollama: Download and run the Ollama application suitable for your OS. Install the "Mistral-7B" LLM model within Ollama for its compact size and good performance.
      
      RAG Pipeline Construction: This core component handles ingesting and processing user queries.
      
      ingest(pdf_file_path):
      Loads the PDF using PyPDFLoader.
      
      Splits the document into manageable chunks with RecursiveCharacterTextSplitter.
      
      Uses Chroma for vector storage with FastEmbedEmbeddings for lightweight processing.
      
      Creates a retriever to find relevant passages based on user queries using vector similarity search.
      
      Builds a Langchain conversation chain to connect these functionalities.

ask(query):

      Takes the user's question and feeds it through the predefined chain, retrieving the answer from the LLM server.
      
      Drafting a Simple UI with Streamlit:
      
      The code utilizes Streamlit to create a user-friendly interface.
      
      Users can upload a PDF document.
      
      A chat window displays the conversation history.
      
      Users can type questions related to the uploaded document and receive answers generated by the LLM system.

Running the Project:

      Save the code as app.py and execute streamlit run app.py to launch the application.

local-rag-with-langchain's People

Contributors

ajithbalakrishnan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.