Coder Social home page Coder Social logo

rag-demo's Introduction

๐Ÿ“ฆ Setup

With Conda, Mamba, or Micromamba

conda env create -f environment.yaml

Without Conda

pip install -r requirements.txt

๐Ÿ”€๐Ÿ” Data collection workflows

Chunk Markdown files in GitHub repositories

Run the repository extraction and Markdown chunking flow. Looks in /flows/config/repo_params.py to specify new configurations; be mindful of repository licensing!

python flows/markdown_chunker.py run

Post-process the results

Post-process the results of the MarkdownChunker flow.

python flows/data_table_processor.py run

Analyze what just happened

Let's inspect the results of these workflows in a notebook.

If you are in a Conda environment, you need to install the kernel like so before opening the notebooks:

pip install ipykernel
python -m ipykernel install --user --name rag-demo --display-name "RAG demo"

Open notebooks/analyze_chunks.ipynb to use the Metaflow Client API to explore the results of the flow runs:

jupyter notebook notebooks/analyze_chunks.ipynb

๐Ÿฆ™๐Ÿง  RAG time

LlamaIndex

Now that we have indexed a bunch of source objects, let's index them and use them to modify an LLM context window.

You can either use a Llama 2 model, or OpenAI APIs. Letting LlamaIndex use Llama 2 runs locally, so it doesn't require an API key but takes a lot longer. Using OpenAI APIs is faster and cheap. You can create/find your API key here.

Open notebooks/llama_index_exploration.ipynb

jupyter notebook notebooks/llama_index_exploration.ipynb

โ–ถ๏ธ Run a demo in Streamlit

๐Ÿ”‘ Get an OpenAI API Key

Go here, copy your key value, and set the following environment variable:

export OPENAI_API_KEY=<YOUR KEY>

๐Ÿค– Run the app

streamlit run chat_app.py

Setup for indexing workflows

There are two indexing workflows in the /flows folder, one indexes into Pinecone for a VectorDB and another that uses the open-source LanceDB.

๐Ÿ”‘ Get a Pinecone API Key

Go here, create a Pinecone account if you have to, copy your API key, and set the following environment variable:

export PINECONE_API_KEY=<YOUR KEY>

Set the following environment variable too:

export GCP_ENVIRONMENT=us-central1-gcp

โ–ถ๏ธ Run the flows

python flows/pinecone_index.py run
python flows/lancedb_index.py run

rag-demo's People

Contributors

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