Giter VIP home page Giter VIP logo

ollama-local-rag's Introduction

Langchain RAG Project

This repository provides an example of implementing Retrieval-Augmented Generation (RAG) using LangChain and Ollama. The RAG approach combines the strengths of an LLM with a retrieval system (in this case, FAISS) to allow the model to access and incorporate external information during the generation process.

The application will load any Markdown documents in the docs/ directory. As an example this directory has two documents on Amazon Bedrock and Knowledge Bases for Amazon Bedrock. Since these products were released in the last 6 months their documentation was not included in the training data for most popular LLMs.

Credit to pixegami for the inspiration for this project.

LangChain

LangChain is a framework for developing applications with LLMs. It provides a modular and extensible approach to building applications, allowing you to combine different components (e.g., LLMs, retrieval systems, data sources) in a flexible manner.

FAISS

FAISS (Facebook AI Similarity Search) is a library for efficient similarity search and dense vector clustering. In this example, we use FAISS as the retrieval system to store and search through text data.

Ollama

Ollama is a tool for running large language models locally. Supported models are listed here.

Getting Started

To get started with this example, follow these steps:

Install python dependencies:

pip3 install -r requirements.txt

Start Ollama with a model of you choice:

ollama run llama2:13b

NOTE: This model needs to match the model referenced in the python code.

Create the FAISS database:

python3 create_database.py

This script reads files from a directory (specified in the script) and creates a FAISS index.

Query the FAISS database.

python3 query_data.py "What is Amazon Bedrock?"

This script takes a query as input, uses the LangChain retrieval to retrieve relevant information from the FAISS database, and generates a response using an LLM (specified in the script).

Adding Documents

To add additional documents just copy them to the docs/ directory. The application can support formats other than Markdown but you may need to install additional python packages.

ollama-local-rag's People

Watchers

Jerod Culpepper 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.