Giter VIP home page Giter VIP logo

openai-milvus-qa-over-docs's Introduction

OpenAI-Milvus-QA-Over-Docs

screenshot of program

Uses Milvus as a document store and OpenAI's chat API for a simple app that allows the user ask question based on given sources. Stores every question asked and answer generated in an SQLite relational database which provides additional functionality and analysis.

  • Supports CSV, PDF files
  • Supports web pages
  • Shows sources in response
  • Aims to provide as much context to the AI model
  • Stores all questions and answers
  • No chat memory/history

How it works

diagram of architecture

  1. A Milvus and SQLite instance is run
  2. Files and websites are ingested through Langchain's document loaders and text splitter
  3. Documents embedded by OpenAI embeddings and added to Milvus collection through langchain. References of these documents are put in an SQLite table.
  4. Only data ingestion done through Langchain, rest uses pymilvus and openai
  5. A user inputs a query into the chat interface, and gets embedded by OpenAI embeddings (okay embeddings still done through langchain)
  6. Similarity search is done with the embedded query on previous questions
  7. Using distance, it deems whether the question is similar or identical to a previous question.
  8. If so, retrieve the previous response
  9. If there are no relevant questions or users specifies to generate a new answer, do a similarity search on the sources and retrieve the top 20 most similar documents
  10. From the top 20, as much context/text is retrieved until the token limit is reached. 4096 for OpenAI gpt-3.5 (maximum set to 3700 to leave room for response tokens)
  11. Instructions, the context, and the original question is given to the OpenAI chat model
  12. Response is returned and displayed in a chat interface

How to run

Install and run a Milvus instance

Make sure you have the necessary requirements to run the Python program

pip install -r requirements.txt

Create a .env file in the directory and put the OpenAI API key in as follows:

OPENAI_API_KEY=...

Then run the app with

flask run or python3 app.py

A Flask app will run locally. Click on the url provided in the terminal to open the app. For example:

http://127.0.0.1:5000

openai-milvus-qa-over-docs's People

Contributors

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