GithubHelp home page GithubHelp logo

rag's Introduction

Adding your own data to LLMs

This project shows how to create a Chatbot that extends ChatGPT with your own data, using the RAG pattern with vector search. It shows three approaches to the problem: interacting directly with OpenAI APIs, using LangChain, and using Semantic Kernel.

Pre-requisites

  • You need to have an Azure subscription. You can get a free subscription to try it out.
  • Create a "Cognitive Search" resource on Azure.
  • Create an "OpenAI" resource on Azure. Create two deployments within this resource:
    • A deployment for the "text-embedding-ada-002" model.
    • A deployment for the "gpt-35-turbo" model.
  • Add a ".env" file to the project with the following variables set (you can use the ".env-example" file as a starting point):
    • AZURE_OPENAI_API_BASE - Go to https://oai.azure.com/, "Chat Playground", "View code", and find the API base in the code.
    • AZURE_OPENAI_API_KEY - In the same window, copy the "Key" at the bottom.
    • AZURE_OPENAI_EMBEDDING_DEPLOYMENT - Click on "Deployments" and find the name of the deployment for the "text-embedding-ada-002" model.
    • AZURE_OPENAI_CHATGPT_DEPLOYMENT - In the same window, find the name of the deployment for the "gpt-35-turbo" model.
    • AZURE_SEARCH_ENDPOINT - Go to https://portal.azure.com/, find your "Cognitive Search" resource, and find the "Url".
    • AZURE_SEARCH_KEY - On the same resource page, click on "Settings", then "Keys", then copy the "Primary admin key".
    • AZURE_SEARCH_SERVICE_NAME - This is the name of the "Cognitive Search" resource in the portal.

Install packages

Install the packages specified in the environment.yml file:

conda env create -f environment.yml
conda activate rag

How to run

You can run the same scenario using one of three approaches:

  • You can call the OpenAI APIs directly:
    • Run src/1_openai/init_search_1.py by opening the file and pressing F5. This initializes an Azure Cognitive Search index with our data.
    • Run src/1_openai/main_1.py. This runs a sequence of queries using our data.
  • You can use the LangChain package:
    • Run src/2_langchain/init_search_2.py.
    • Run src/2_langchain/main_2.py.
  • You can use the Semantic Kernel package:
    • Run src/3_semantic_kernel/init_search_3.py.
    • Run src/3_semantic_kernel/main_3.py.

rag's People

Contributors

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