Over the last year, Large Language Models (LLMs) such as ChatGPT have taken center stage. Alongside this, another technology rocketed to center stage: vector search. In contrast to traditional keyword search, vector search significantly enhances natural language understanding of queries and documents. We refer the interested reader to our intro talk for more details.
As a result, more users than ever have built engaging, personalized chatbots that can consult custom data sources. To address the needs of developers going from idea to production quickly, we built Momento Vector Index (MVI): a fully serverless, turnkey solution to index and search vector datasets. MVI now plays a key role in the development workflow. That said, standing up a full production service is still tricky.
Enter LangChain Templates
Not stopping there, LangChain has taken ease of development a step further with their introduction of Templates. As they recently announced, “Templates [offer] a collection of easily deployable reference architectures that anyone can use… This is a new way to create, share, maintain, download, and customize chains and agents. They are all in a standard format [which] allows them to easily be deployed with LangServe, allowing you to easily get production-ready APIs and a playground for free”.
What does that mean for us? An even shorter path from experimentation to production. With this, you don’t just get a reference architecture, you get ready-to-go REST endpoints for invoking a chain, batching, and streaming.
While LangChain simplified building applications leveraging LLMs, Templates offer cookiecutter recipes that developers can import into their applications in a one liner, as you’ll soon see. With these templates imported in your applications, you can tweak and customize them however you like. With a Momento retrieval-augmented generation (RAG) template, developers have one less barrier to getting started!
Use Momento with LangChain Templates
We now offer a LangChain RAG template featuring MVI so you can spin up a Momento-powered, retrieval-backed chatbot in just a few minutes. You can access the sample code here under the template name rag-momento-vector-index.
Just follow these instructions:
- Install the LangChain CLI: pip install -U langchain-cli[serve]
- Bootstrap a new project with Momento: langchain app new momento –package rag-momento-vector-index
2. langchain app new momento
3. cd momento
4. langchain app add rag-momento-vector-index
Then follow the instructions on screen to integrate the demo into the templated app.
To run the sample dataset, uncomment the lines in packages/rag-momento-vector-index/rag_momento_vector_index/chain.py to load the data for the first time:
To load the sample dataset, you will need to install the bs4 library. Add that by running poetry add bs4.
Then in your environment, ensure you have set MOMENTO_API_KEY and OPENAI_API_KEY to your keys. To get your Momento API key, sign up from the console for free; to access MVI select us-west-2 and superuser key.
Now you’re ready to start using the chat live! Next start LangServe by running:
poetry run langchain app serve
Then navigate to http://localhost:8000/rag-momento-vector-index/playground to use an interactive UI!
Now you can use your creativity to customize the chatbot and data sources to your liking!
Try it yourself!
Deploying a RAG-based chatbot is easier than ever with Momento Vector Index and LangChain Templates. While Templates gives a push-button service layer, configuring and managing a vector index is still your responsibility. MVI removes that burden so you can get going even faster.
Be on the lookout for future Templates featuring Momento services. But until then, give this one a try! Have an idea for a new Template? Need help with this one? Reach out to us on Discord!