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. 暂时使用的可能性不大,所以先不做深入研究。

完结!

相关推荐
钟屿8 分钟前
Cold Diffusion: Inverting Arbitrary Image Transforms Without Noise论文阅读
论文阅读·图像处理·人工智能·深度学习·计算机视觉
仙人掌_lz16 分钟前
用PyTorch在超大规模下训练深度学习模型:并行策略全解析
人工智能·pytorch·深度学习
商业讯16 分钟前
深圳无人机展览即将开始,无人机舵机为什么选择伟创动力
人工智能
视觉语言导航23 分钟前
AAAI-2025 | 中科院无人机导航新突破!FELA:基于细粒度对齐的无人机视觉对话导航
人工智能·深度学习·机器人·无人机·具身智能
孚为智能科技28 分钟前
无人机箱号识别系统结合5G技术的应用实践
图像处理·人工智能·5g·目标检测·计算机视觉·视觉检测·无人机
灏瀚星空32 分钟前
地磁-惯性-视觉融合制导系统设计:现代空战导航的抗干扰解决方案
图像处理·人工智能·python·深度学习·算法·机器学习·信息与通信
jstart千语35 分钟前
【消息队列】RabbitMQ基本认识
java·服务器·分布式·rabbitmq
Livan.Tang35 分钟前
LIO-SAM框架理解
人工智能·机器学习·slam
-曾牛42 分钟前
Spring AI 集成 Mistral AI:构建高效多语言对话助手的实战指南
java·人工智能·后端·spring·microsoft·spring ai
迅易科技1 小时前
当数控编程“联姻”AI:制造工厂的“智能大脑”如何炼成?
人工智能·ai·知识图谱·ai编程·deepseek