Giter Site home page Giter Site logo

siri1410 / retrieval-augmented-generation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kesamet/retrieval-augmented-generation

0.0 0.0 0.0 296 KB

Retrieval augmented generation demos with open-source Llama-2 / Mistral / Zephyr / Gemma

License: Apache License 2.0

Python 100.00%

retrieval-augmented-generation's Introduction

retrieval-augmented-generation

Retrieval augmented generation (RAG) demos with Llama-2-7b, Mistral-7b, Zephyr-7b, Gemma

The demos use quantized models and run on CPU with acceptable inference time. They can run offline without Internet access, thus allowing deployment in an air-gapped environment.

The demos also allow user to

  • apply propositionizer to document chunks
  • perform reranking upon retrieval
  • perform hypothetical document embedding (HyDE)

๐Ÿ”ง Getting Started

You will need to set up your development environment using conda, which you can install directly.

conda env create --name rag python=3.11
conda activate rag
pip install -r requirements.txt

Activate the environment.

conda activate rag

Download model artefacts

Download and save the models in ./models and update config.yaml. The models used in this demo are:

Add prompt format

Since each model type has its own prompt format, include the format in ./src/prompt_templates.py. For example, the format used in openbuddy models is

_openbuddy_format = """{system}
User: {user}
Assistant:"""

Refer to the file for more details.

๐Ÿ’ป App

We use Streamlit as the interface for the demos. There are two demos:

  • Conversational Retrieval
streamlit run app_conv.py
  • Retrieval QA
streamlit run app_qa.py

๐Ÿ” Usage

To get started, upload a PDF and click on Build VectorDB. Creating vector DB will take a while.

screenshot

retrieval-augmented-generation's People

Contributors

kesamet 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.