LangGraph Enhances Memory Capabilities with Semantic Search

Ted Hisokawa  Dec 05, 2024 21:38  UTC 13:38

0 Min Read

LangGraph has announced the addition of semantic search capabilities to its BaseStore, further enhancing its memory functionalities. This new feature is now accessible in the open source PostgresStore and InMemoryStore, as well as in all LangGraph Cloud deployments, according to LangChain Blog.

Why Semantic Search?

The inclusion of semantic search addresses the need for more sophisticated retrieval methods of unstructured information within the LangGraph framework. Unlike traditional filtering methods that rely on exact matches, semantic search allows agents to retrieve information based on meaning. This is particularly useful for recalling user preferences, learning from past interactions, and maintaining consistent knowledge.

Implementation Details

The BaseStore's search and asynchronous search (asearch) methods now support a natural language query term. Documents are scored and returned based on semantic similarity if the store supports this feature. Both the InMemoryStore and PostgresStore have integrated this functionality for development and production environments, respectively.

For LangGraph Platform users, configuring the server to embed new items can be achieved through a store configuration in the langgraph.json file. Key configuration options include the 'embed' provider, dimension size, and fields to index.

Migration and Customization

Current users of LangGraph's memory store can integrate semantic search without disrupting existing operations. LangGraph OSS users can start using this feature by setting up their PostGresStore with an index configuration. LangGraph platform users can add an index configuration to their deployment, allowing new documents to be indexed for search based on semantic similarity.

Custom embedding logic can also be defined for those who do not wish to use LangChain's default embeddings. This involves creating a custom function and referencing it in the configuration file.

Next Steps

LangGraph has updated its documentation and templates to include examples of semantic search in action. Users are encouraged to try out the new feature and provide feedback on GitHub. For more conceptual information on AI memory, LangGraph offers detailed documentation on its website.

For further information on the semantic search feature, visit the LangChain Blog.



Read More