当前位置: 首页 > news >正文

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

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

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

1. 为什么使用 Motorhead?

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

它提供了 4 个简单的 API:

  • GET /sessions/:id/memory 返回最多 MAX_WINDOW_SIZE 的 messages
{"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 进行存储
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 按文本查询进行搜索
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. 暂时使用的可能性不大,所以先不做深入研究。

完结!

http://www.lryc.cn/news/290324.html

相关文章:

  • vue3项目中让echarts适应div的大小变化,跟随div的大小改变图表大小
  • springboot启动异常
  • 直播主播之互动率与促单
  • Android 基础技术——Bitmap
  • 数据结构奇妙旅程之七大排序
  • 【JavaScript】Generator
  • 河南省考后天网上确认,请提前准备证件照哦
  • 【前端】防抖和节流
  • 【网络】:网络套接字(UDP)
  • Linux编程 1/2 数据结构
  • 【UE Niagara】实现闪电粒子效果的两种方式
  • js数组/对象的深拷贝与浅拷贝
  • HCIA学习第六天:OSPF:开放式最短路径优先协议
  • 从四个方面来解决企业在项目管理中遇到的各类问题
  • 使用代码取大量2*2像素图片各通道均值,存于Excel文件中。
  • React16源码: React中commit阶段的commitBeforeMutationLifecycles的源码实现
  • 压制二元组的总价值
  • 【习题】保存应用数据
  • Flask框架小程序后端分离开发学习笔记《5》简易服务器代码
  • “计算机视觉处理设计开发工程师”专项培训(第二期)
  • R语言学习case7:ggplot基础画图(核密度图)
  • Ubuntu18配置Docker
  • Keil/MDK平台 - 结构体成员指针注意事项
  • 一款超级好用的远程控制APP,你值得拥有
  • NumPy必知必会50例 | 18. 使用 NumPy 解决线性方程组:数学问题的实用解决方案
  • C/C++编码问题研究
  • 二刷代码随想录|Java版|回溯算法3|子集问题
  • mongodb config
  • pytorch 实现中文文本分类
  • 【MySQL】聚合函数和内置函数