mem0
mem0 copied to clipboard
Feature: VoyageAI embeddings integration
Description
This PR integrates VoyageAI's embedding models for use with mem0.
Type of change
Please delete options that are not relevant.
- [X] New feature (non-breaking change which adds functionality)
- [X] Refactor (does not change functionality, e.g. code style improvements, linting)
- [X] Documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Please delete options that are not relevant.
- [X] Unit Test
@Dev-Khant I'm sorry for the ping, I noticed the latest couple of PRs were merged by you so I assumed you're the designated reviewer. I was wondering if I could get a review on this? We're using VoyageAI embeddings internally and I'd like to know if there's a problem with this PR that I can fix or not. I'd appreciate it if you'd let me know.
Hi @Adversarian,
Sure, I’d review the PR. Before diving in, can I kindly ask how this integration is beneficial for you? You mentioned using it internally, and we would like to understand the use case you’re applying it to.
Hi @Adversarian,
Sure, I’d review the PR. Before diving in, can I kindly ask how this integration is beneficial for you? You mentioned using it internally, and we would like to understand the use case you’re applying it to.
Of course @Dev-Khant ! Thank you for taking the time. As I said, our embedding provider (VoyageAI) is not listed in any of your the providers that you currently support, this simply extends the list of embedders with another well-known provider so that me and people who would like to use VoyageAI as their embedding provider can use their services in tandem with mem0.
If you don't think this is a valid use-case I would appreciate hearing your thoughts as to why.
@Adversarian hey it's been a while, I just made a crude drop-in patch you can install via pypi. I implemented it with litellm as abstraction layer so you can plug in whatever embedding provider litellm is supporting (including voyage ai). It is confirmed to be working for the current version of mem0ai (0.1.115) using a python:3.11-slim docker container. I willl have to find a more elegant way of patching their code instead of just drop-in replacing their files, add tests, check actual range of versions supported into the past, etc but for now if you are using the latest version of mem0 you can just install the patch and then configure your embeddings like so:
embedconfig = {
"provider": "litellm",
"config": {
"api_key": os.getenv("VOYAGEAI_API_KEY"),
"model": "voyage/voyage-3-large",
"embedding_dims": 1024
},
}
Personally I would prefer if @Dev-Khant would just merge the prs for things like bugs and additions of industry leading providers or use the litellm abstraction layer for embeddings (it's used for llms already, not sure why stop there) so they don't have to keep up with the latest themselves, that way i don't need to track changes to their files to see when my patches are breaking or freeze my mem0 version ;D
PS: Also made another db patch that switches out the hardcoded sqlite for a more powerful sqlalchemy version and lets you use eg postgres db instead of sqlite for scalability. (or whatever else is supported by sqlalchemy, I only care to switch from sqlite to postgres)
@nocyphr We have moved on from mem0 but this looks like a very elegant solution and it didn't occur to me to add support for litellm instead of VoyageAI specifically. Thank you for your effort.
@nocyphr We have moved on from
mem0but this looks like a very elegant solution and it didn't occur to me to add support forlitellminstead of VoyageAI specifically. Thank you for your effort.
@Adversarian If you don't mind me asking, what have you moved on to use instead?
@nocyphr We have moved on from
mem0but this looks like a very elegant solution and it didn't occur to me to add support forlitellminstead of VoyageAI specifically. Thank you for your effort.@Adversarian If you don't mind me asking, what have you moved on to use instead?
@nocyphr Sorry for the late response, it slipped my mind to get back to you sooner. We were using Llama-Index to orchestrate our application internally. Llama-Index dropped support for mem0 and it's new memory system was enough for our use case. We simply migrated from the old one (ChatMemoryBuffer if you're familiar) to the new system with memory blocks. I imagine it might not cover as much ground as what mem0 claims to do but it was starting to get a bit old going back and forth and getting nowhere with this PR so we just decided to work with what's available and it turned out just fine.