LLMs 的记忆和信息检索服务器 Motorhead

LLMs 的记忆和信息检索服务器 Motorhead

  • [1. 为什么使用 Motorhead?](#1. 为什么使用 Motorhead?)
  • [2. 通过 Docker 启动 Motorhead](#2. 通过 Docker 启动 Motorhead)
  • [3. Github 地址](#3. Github 地址)
  • [4. python 使用示例地址](#4. python 使用示例地址)

1. 为什么使用 Motorhead?

使用 LLMs构建聊天应用程序时,每次都必须构建记忆处理。Motorhead是协助该过程的服务器。

它提供了 4 个简单的 API:

  • GET /sessions/:id/memory 返回最多 MAX_WINDOW_SIZE 的 messages
json 复制代码
{
    "messages": [
        {
            "role": "AI",
            "content": "Electronic music and salsa are two very different genres of music, and the way people dance to them is also quite different."
        },
        {
            "role": "Human",
            "content": "how does it compare to salsa?"
        },
        {
            "role": "AI",
            "content": "Electronic music is a broad genre that encompasses many different styles, so there is no one \"right\" way to dance to it."
        },
        {
            "role": "Human",
            "content": "how do you dance electronic music?"
        },
        {
            "role": "AI",
            "content": "Colombia has a vibrant electronic music scene, and there are many talented DJs and producers who have gained international recognition."
        },
        {
            "role": "Human",
            "content": "What are some famous djs from Colombia?"
        },
        {
            "role": "AI",
            "content": "Baum opened its doors in 2014 and has quickly become one of the most popular clubs for electronic music in Bogotá."
        }
    ],
    "context": "The conversation covers topics such as clubs for electronic music in Bogotá, popular tourist attractions in the city, and general information about Colombia. The AI provides information about popular electronic music clubs such as Baum and Video Club, as well as electronic music festivals that take place in Bogotá. The AI also recommends tourist attractions such as La Candelaria, Monserrate and the Salt Cathedral of Zipaquirá, and provides general information about Colombia's diverse culture, landscape and wildlife.",
    "tokens": 744 // tokens used for incremental summarization
}
  • POST /sessions/:id/memory - 向 Motorhead 发送数组 messages 进行存储
bash 复制代码
curl --location 'localhost:8080/sessions/${SESSION_ID}/memory' \
--header 'Content-Type: application/json' \
--data '{
    "messages": [{ "role": "Human", "content": "ping" }, { "role": "AI", "content": "pong" }]
}'

存储消息时,可以使用现有会话或新 SESSION_ID 会话,如果会话以前不存在,则会自动创建会话。

(可选) context 如果需要从其他数据存储加载,则可以将其送入。

  • DELETE /sessions/:id/memory - 删除会话的消息列表。

A max window_size is set for the LLM to keep track of the conversation. Once that max is hit, Motorhead will process (window_size / 2 messages) and summarize them. Subsequent summaries, as the messages grow, are incremental.

为跟踪对话设置了 LLM 最大值 window_size 。一旦达到最大值,Motorhead 将处理( window_size / 2 messages)并汇总它们。随着消息的增长,后续摘要是增量的。

  • POST /sessions/:id/retrieval - 使用 VSS 按文本查询进行搜索
bash 复制代码
curl --location 'localhost:8080/sessions/${SESSION_ID}/retrieval' \
--header 'Content-Type: application/json' \
--data '{
    "text": "Generals gathered in their masses, just like witches in black masses"
}'

2. 通过 Docker 启动 Motorhead

复制代码
docker run --rm --name some-redis -p 6379:6379 -d redis
docker run --rm --name motorhead -p 8080:8080 -e PORT=8080 -e REDIS_URL='redis://some-redis:6379' -d ghcr.io/getmetal/motorhead:latest

3. Github 地址

https://github.com/getmetal/motorhead

4. python 使用示例地址

https://github.com/getmetal/motorhead/tree/main/examples/chat-py

p.s. 暂时使用的可能性不大,所以先不做深入研究。

完结!

相关推荐
BFT白芙堂5 分钟前
睿尔曼系列机器人——以创新驱动未来,重塑智能协作新生态(上)
人工智能·机器学习·机器人·协作机器人·复合机器人·睿尔曼机器人
aneasystone本尊11 分钟前
使用 MCP 让 Claude Code 集成外部工具
人工智能
码农101号18 分钟前
Linux中容器文件操作和数据卷使用以及目录挂载
linux·运维·服务器
静心问道21 分钟前
SEW:无监督预训练在语音识别中的性能-效率权衡
人工智能·语音识别
xwz小王子27 分钟前
从LLM到WM:大语言模型如何进化成具身世界模型?
人工智能·语言模型·自然语言处理
我爱一条柴ya28 分钟前
【AI大模型】深入理解 Transformer 架构:自然语言处理的革命引擎
人工智能·ai·ai作画·ai编程·ai写作
静心问道29 分钟前
FLAN-T5:规模化指令微调的语言模型
人工智能·语言模型·自然语言处理
李师兄说大模型29 分钟前
KDD 2025 | 地理定位中的群体智能:一个多智能体大型视觉语言模型协同框架
人工智能·深度学习·机器学习·语言模型·自然语言处理·大模型·deepseek
静心问道30 分钟前
SqueezeBERT:计算机视觉能为自然语言处理在高效神经网络方面带来哪些启示?
人工智能·计算机视觉·自然语言处理
Sherlock Ma31 分钟前
百度开源文心一言4.5:论文解读和使用入门
人工智能·百度·自然语言处理·开源·大模型·文心一言·多模态