Get Started with Chroma DB and Retrieval Models using LangChain

A walk-through tutorial on how to use your data and ask questions using LangChain

George Pipis
4 min readFeb 16, 2024

In this tutorial, we will provide a walk-through example of how to use your data and ask questions using LangChain. The steps are the following:

DeepLearning.AI
  1. Load the Document
  2. Create chunks using a text splitter
  3. Create embeddings from the chunks
  4. Store the embeddings in a vector database (Chroma DB in our case)
  5. Use a retrieval model to get similar documents to your question
  6. Feed the ChatGPT model with the content of similar documents to get a tailored answer
  7. Explain who to keep the memory of your conversation to have a chat with your data

Let’s jump into the coding part!

Load the required libraries

from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.chat_models import ChatOpenAI
from langchain.chains import RetrievalQA
from langchain.prompts import PromptTemplate
from…

--

--

George Pipis
George Pipis

Written by George Pipis

Sr. Director, Data Scientist @ Persado | Co-founder of the Data Science blog: https://predictivehacks.com/

No responses yet