Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph base relation saving works with extreme high token cost #2066

Open
ChenMa2017 opened this issue Dec 2, 2024 · 1 comment
Open

Graph base relation saving works with extreme high token cost #2066

ChenMa2017 opened this issue Dec 2, 2024 · 1 comment

Comments

@ChenMa2017
Copy link

ChenMa2017 commented Dec 2, 2024

🚀 The feature

The relationship storage mechanism based on graphs consumes a significant amount of tokens for large models. It is necessary for large models to analyze entities and their relationships more efficiently to reduce both time consumption and token usage.

Motivation, pitch

The first time I tried:

Using ChatGPT-4 to extract photo descriptions.
Saving the textual descriptions of the photos into Mem0.
However, I found that the cost of saving one photo description was 15 times higher than the cost of generating the description itself. Moreover, the saving process was extremely slow—saving 62 descriptions took over an hour.

The Chaggpt token cost consumption is shown in the figure below。

openai_money_cost_cpmparison_1121

The second time I tried:

Using ChatGPT-4 to extract photo descriptions, e.g., image_name.jpg.
Saving the textual descriptions of the photos into files, e.g., image_name.json.
Storing the correspondence between [image_name.jpg, image_name.json] in Mem0.
However, after extensive testing, I discovered that Mem0 does not actually record the file correspondence relationships.

Here is a sample dialogue example:

User: The file './result/test_polly.json' is the json/JSON file has the text description of the './image/test_polly.jpg'.

Assistant: If you have a file at './result/test_polly.json', it likely contains the text description for the image of Polly, Jim Green's parrot, which is stored at './image/test_polly.jpg'. If you need any assistance regarding this file, feel free to ask!

User: do I have any json/JSON file?

Assistant: I don't have information about any specific JSON files you may have saved. If you recall storing any JSON files, you might want to check your project directories or other locations where you typically save such files. Let me know if there's anything else I can assist you with!

You: the file './result/test_polly.json' is the json/JSON file has the text description of the image './image/test_polly.jpg'.

Assistant: It sounds like you have a JSON file located at ./result/test_polly.json which contains the text description of the image of Polly the parrot, located at ./image/test_polly.jpg. If you need any assistance with these files, feel free to let me know!

You: do you know waht is the file './result/test_polly.json' is?

Assistant: I don't have information on a file named './result/test_polly.json'. However, I do know about a photo of Polly, Jim Green's parrot, which is saved at './image/test_polly.jpg'. If the .json file is related to Polly, it might contain metadata or some form of structured data related to the photo or Polly, but I can't provide specific details without further context.

@ChenMa2017
Copy link
Author

I carefully reviewed the code for Mem0's memory mechanism.

During the search phase of memory:
* One call to llm.generate_response() is required once for the graph search.
During the add phase of memory:
* Two calls to llm.generate_response() are needed to add the vector store.
* Three calls to llm.generate_response() are required to add the graph.

Excluding the embedding phase, the memory mechanism requires seven calls to llm.generate_response().
Are there additional instances of llm.generate_response() being called that I may have missed?

This results in significant token consumption, which might explain the token usage issue mentioned earlier.
Is there a more efficient memory mechanism available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant