Retrieval-augmented generation, or RAG, is a technique used with large language models (LLMs) to provide additional context without fine-tuning or retraining. It enhances the ability of language models to provide factual responses without hallucinating, which is a limitation of classical setups.
The goal of this project is to build a question-answering bot for movie-related questions.
We will be using the following tools and models:
- OpenAI's gpt-3.5-turbo model for prompt completions
- OpenAI's text-embedding-ada-002 model to create vector embeddings
- Pinecone as the vector database to store the embeddings
- langchain as the tool to interact with OpenAI and Pinecone
- Create a developer account in OpenAI and obtain a secret key.
- Create a Pinecone account and obtain an API key for it.
- Download the IMDb Movies/Shows with Descriptions data set from Kaggle.
pip install pinecone-client==4.0.0
pip install langchain==0.1.19
pip install langchain-openai==0.1.6
pip install langchain-pinecone==0.1.0
pip install tiktoken==0.7.0
pip install typing_extensions==4.11.0
from chat_bot import ChatBot
chatbot = ChatBot(context_path=<<insert_dataset_path>>)
question = "What's a good movie about a dogs to watch with my kid"
response = chatbot.generate_response(question)
print(response)
{'question': "What's a good movie about a dogs to watch with my kid",
'answer': "'A Dog's Purpose' is a heartwarming movie about a dog's journey through multiple lives and the bond it forms with humans. It would be a good movie to watch with a kid.\n",
'sources': 'https://www.imdb.com/title/tt1753383'}
question = "What's a good movie about a nature?"
response = chatbot.generate_response(question)
print(response)
{'question': "What's a good movie about a nature?",
'answer': "'Big Miracle' is a movie about environmental activism and saving whales. It showcases the beauty of nature and the importance of conservation efforts.\n",
'sources': 'https://www.imdb.com/title/tt1430615'}