November 6, 2023
-
2
Min Read

Announcing Momento Vector Index LangChain Template

Explore the new Momento Vector Index LangChain template for easy chatbot development with RAG pipelines.
Michael Landis
Headshot of the blog author
by
Michael Landis
,
,
by
Michael Landis
by
green squirrel logo for momento
Michael Landis
,
,
AI/ML

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

LangChain provides key abstractions and building blocks to get an application using LLMs up and running in record time. Because of this great fit, we have fully integrated Momento in the LangChain Python and JavaScript ecosystems. We offer MVI as a vector store, Momento Cache as a prompt caching layer, and Momento Cache as a chat session store. You can read more about our integrations here and here. Indeed, MVI and LangChain power our very own chatbot, robo-mo (source here). 

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:

  1. Install the LangChain CLI: pip install -U langchain-cli[serve]
  2. Bootstrap a new project with Momento: langchain app new momento –package rag-momento-vector-index

Alternatively:

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:

 
# Sample Ingest Code - this populates the vector index with data
# Run this on the first time to seed with data
from rag_momento_vector_index import ingest
ingest.load(API_KEY_ENV_VAR_NAME, MOMENTO_INDEX_NAME)

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!

Michael Landis
by
Michael Landis
,
,
by
Michael Landis
by
green squirrel logo for momento
by
Michael Landis
,
,
Author
Michael Landis

Michael Landis is a Software Engineer at Momento. He has over 15 years of experience in software and product development with special expertise in data science and machine learning. He's passionate about making developers' lives easier and is well-loved by customers for his attentiveness, scrappiness, and drive for complete solutions.

Author
Author
Open