|
1 | 1 | # OpenAI-Milvus-QA-Over-Docs
|
2 | 2 |
|
3 |
| - |
| 3 | + |
4 | 4 |
|
5 |
| -Uses [Milvus](https://milvus.io/) as a document store and [OpenAI's](https://platform.openai.com/docs/models/gpt-3-5) chat API for a simple app that allows the user ask question based on given sources. |
| 5 | +Uses [Milvus](https://milvus.io/) as a document store and [OpenAI's](https://platform.openai.com/docs/models/gpt-3-5) 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. |
6 | 6 |
|
7 | 7 | - Supports CSV, PDF files
|
8 | 8 | - Supports web pages
|
9 |
| -- Provides the maximum possible context to the AI model |
| 9 | +- Shows sources in response |
| 10 | +- Aims to provide as much context to the AI model |
| 11 | +- Stores all questions and answers |
10 | 12 | - No chat memory/history
|
11 | 13 |
|
12 | 14 | ## How it works
|
13 | 15 |
|
14 | 16 | 
|
15 | 17 |
|
16 |
| -1. A Milvus instance is run |
17 |
| -2. Files and websites are ingested through [Langchain's](https://github.com/hwchase17/langchain) document loaders and text splitter |
18 |
| -3. Documents embedded by OpenAI embeddings and added to Milvus collection through `langchain` |
19 |
| -4. Only data ingestion done through Langchain, rest uses `pymilvus` and `openai` |
20 |
| -5. A user inputs a query into the chat interface, and gets embedded by OpenAI embeddings (okay embeddings still done through `langchain`) |
21 |
| -6. Similarity search is done with the embedded query and the top 20 most similar documents are returned |
22 |
| -7. 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 4000) |
23 |
| -8. Instructions for the model, the context, and the original question is given to the OpenAI chat model |
24 |
| -9. Response is returned and displayed in a chat interface |
| 18 | +1. A Milvus and SQLite instance is run |
| 19 | +3. Files and websites are ingested through [Langchain's](https://github.com/hwchase17/langchain) document loaders and text splitter |
| 20 | +4. Documents embedded by OpenAI embeddings and added to Milvus collection through `langchain`. References of these documents are put in an SQLite table. |
| 21 | +5. Only data ingestion done through Langchain, rest uses `pymilvus` and `openai` |
| 22 | +6. A user inputs a query into the chat interface, and gets embedded by OpenAI embeddings (okay embeddings still done through `langchain`) |
| 23 | +7. Similarity search is done with the embedded query on previous questions |
| 24 | +8. Using distance, it deems whether the question is similar or identical to a previous question. |
| 25 | +9. If so, retrieve the previous response |
| 26 | +10. 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 |
| 27 | +11. 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) |
| 28 | +12. Instructions, the context, and the original question is given to the OpenAI chat model |
| 29 | +13. Response is returned and displayed in a chat interface |
25 | 30 |
|
26 | 31 | ## How to run
|
27 | 32 |
|
|
0 commit comments