Update (10/7/2023): I revised another “ChatPDF” app using LangChain and Qdrant here.
Instead of using the well-known term RAG (Retrieval Augmented Generation), I created a new acronym for this common architecture:
MVP: M (large language Model) + V (Vector database) + P (Prompt engineering)
If a fine-tuned LLM is used, then it is FMVP (Fine-tuned MVP).
My revised code repo with setup instructions is here.
I used the rulebooks from NBA and IFAB for the demo.
If you want to use other data, just put the PDF files in
I list the basic steps of the development workflow below - many of the steps have nothing to do with ChatGPT:
text-embedding-ada-002 is used but this can be replaced by any text embedding API/Package)
Q&A (single-turn chat via Completion endpoint):
summary_prompt = '''Summarise this result in a bulleted list to answer the search query a customer has sent.
Search query: SEARCH_QUERY_HERE
Search result: SEARCH_RESULT_HERE
Chatbot (multi-turn chat via Chat Completion endpoint):
system_prompt = '''
You are a helpful sports knowledge base assistant. You need to capture a Question and Sport from each customer.
The Question is their query on sports rules, and the Sport should be either basketball or soccer.
Think about this step by step:
- The user will ask a Question
- You will ask them for the Sport if their question didn't include a Sport
- Once you have the Sport, say "searching for answers".
User: I'd like to know how many players are on each team
Assistant: Certainly, what sport would you like this for?
User: basketball please.
Assistant: Searching for answers.
The following figures are from the slides shared by the original author of the app.
How to use triage prompts and chat agents to build apps for various business scenarios:
How companies can build their own moats based on the MVP architecture:
PS. The featured image for this post is generated using Stable Diffusion, whose full parameters and the model links can be found at Replicable.Art.