又一个用于LLM的内存系统
Show HN: Yet another memory system for LLMs

原始链接: https://github.com/trvon/yams

## YAMS:用于LLM的持久内存 - 摘要 YAMS是一个为大型语言模型(LLM)和需要持久内存的应用设计的基于内容的存储系统。它使用SHA-256哈希存储数据,确保数据完整性,并具有去重(Rabin指纹)和压缩(Zstandard/LZMA)功能。它提供全文搜索(SQLite FTS5)和语义搜索(向量嵌入)。 **主要特性:** 高性能(100MB/s+),通过预写日志实现崩溃恢复,以及线程安全。安装可以通过shell脚本、Docker或Conan(推荐用于构建)轻松完成。 **用法:** YAMS允许存储文本、代码和文件,并使用标签以便于检索。命令包括`add`、`delete`、`search`、`list`和`get`。它支持通过stdin管道传输数据,并提供JSON输出用于脚本编写。 **LLM集成:** YAMS擅长维护对话上下文、缓存研究以及跟踪LLM的代码更改。它还支持模型上下文协议(MCP),可以通过WebSocket或StdIO与Claude Desktop等客户端直接集成。配置选项允许自定义块大小、缓存大小和压缩,以实现最佳性能。该项目采用Apache-2.0许可。

## YAMS:为LLM设计的本地可搜索内存系统 一名开发者创建了YAMS,一个用C++编写的内容寻址存储系统,旨在为LLM工作流提供持久、可搜索的内存,解决存储成本和本地研究需求方面的限制。它利用了块级去重技术,实现了30-40%的存储节省,尤其是在代码库方面。 虽然目前主要通过代码用例进行演示,但YAMS本质上是通用的。用户正在探索其管理代理会话和非代码数据的潜力,旨在克服Bedrock和GitHub等工具的上下文限制。目前,它生成模拟嵌入向量,并计划集成all-MiniLM-L6-v2等模型。 该项目包含版本控制和检索功能,虽然性能基准测试尚未全面完成,但开发者计划将其与向量数据库进行比较。讨论围绕着与现有工具(如Letta)的潜在集成,以及使用Boost等库来实现HTTP/WebSocket支持的权衡。该项目可在GitHub上找到 ([github.com/trvon/yams](github.com/trvon/yams))。
相关文章

原文

Release CI

Persistent memory for LLMs and applications. Content-addressed storage with deduplication, semantic search, and full-text indexing.

  • Content-Addressed Storage - SHA-256 based, ensures data integrity
  • Deduplication - Block-level with Rabin fingerprinting
  • Compression - Zstandard and LZMA with intelligent policies
  • Search - Full-text (SQLite FTS5) and semantic (vector embeddings)
  • Crash Recovery - Write-ahead logging for durability
  • High Performance - 100MB/s+ throughput, thread-safe

My prompt for CLI usage is PROMPT.md and PROMPT-eng.md for programming.

Quick Install (Recommended)

curl -fsSL https://raw.githubusercontent.com/trvon/yams/main/install.sh | bash

This script downloads pre-built binaries and will:

  • Auto-detect your platform (Linux/macOS, x86_64/ARM64)
  • Download the appropriate binary from GitHub Releases
  • Install to ~/.local/bin by default
  • Set up shell completions if available
  • Verify the installation

Supported platforms:

  • Linux x86_64, ARM64
  • macOS x86_64 (Intel), ARM64 (Apple Silicon)

Docker:

docker run --rm -it ghcr.io/trvon/yams:latest --version

Homebrew (coming soon):

brew tap trvon/yams && brew install yams
# Install Conan
pip install conan

# One-time: create default Conan profile
conan profile detect --force

# Build with Conan (recommended - this is what creates the release binaries)
conan install . --output-folder=build/conan-release -s build_type=Release --build=missing
cmake --preset conan-release
cmake --build --preset conan-release
sudo cmake --install build/conan-release/build/Release

Requirements:

  • C++20 compiler (GCC 11+, Clang 14+, AppleClang 14+)
  • CMake 3.20+
  • Python 3.8+ (for Conan)

Known Issue: Traditional CMake builds (without Conan) currently have dependency resolution issues. Use Conan builds for reliable compilation.

Option Default Description
YAMS_USE_CONAN OFF Use Conan package manager
YAMS_BUILD_CLI ON CLI with TUI browser
YAMS_BUILD_MCP_SERVER ON MCP server (requires Boost)
YAMS_BUILD_TESTS OFF Unit and integration tests
YAMS_BUILD_BENCHMARKS OFF Performance benchmarks
YAMS_ENABLE_PDF ON PDF text extraction support
CMAKE_BUILD_TYPE Release Debug/Release/RelWithDebInfo
# macOS
brew install openssl@3 protobuf sqlite3 ncurses
export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)

# Linux
apt install libssl-dev libsqlite3-dev protobuf-compiler libncurses-dev
# Initialize with XDG defaults (non-interactive)
yams init --non-interactive

# Optional: custom storage root
export YAMS_STORAGE="$HOME/.local/share/yams"
yams init --non-interactive

# Print resulting config (secrets masked)
yams init --non-interactive --print

If you see:

ERROR: The default build profile '/home/trevon/.conan2/profiles/default' doesn't exist.
You need to create a default profile (type 'conan profile detect' command)
or specify your own profile with '--profile:build=<myprofile>'

Fix:

# Create default profile
conan profile detect --force

# Optional: ensure C++20 in the default profile
# Linux/macOS (GNU sed):
sed -i 's/compiler.cppstd=.*/compiler.cppstd=20/' ~/.conan2/profiles/default || true
# macOS (BSD sed):
# sed -i '' 's/compiler.cppstd=.*/compiler.cppstd=20/' ~/.conan2/profiles/default || true

Then re-run:

conan install . \
  --output-folder=build/conan-ninja-release \
  -s build_type=Release \
  --build=missing

cmake --preset conan-ninja-release
cmake --build build/conan-ninja-release -j

If PDF extraction fails or PDFium download fails:

# Disable PDF support temporarily
cmake -B build -DYAMS_ENABLE_PDF=OFF

# Or explicitly specify a different PDFium version if needed
# (check https://github.com/bblanchon/pdfium-binaries/releases for available versions)

If you see network errors during PDFium download:

  • Check internet connectivity
  • Corporate firewalls may block GitHub releases
  • Consider using a VPN or different network
  • PDFium binaries are ~20MB per platform

YAMS is designed to work seamlessly with Large Language Models through simple, pipeline-friendly commands:

# Store conversation context with descriptive name
echo "User asked about X, I explained Y" | yams add - --name "context-$(date +%Y%m%d).txt"

# Store code snippets with tags
echo "def function(): return 42" | yams add - --name "helper.py" --tags "python,utils"

# Delete temporary files by pattern
yams delete --pattern "temp_*.txt" --force

# Delete multiple specific files
yams delete --names "draft1.md,draft2.md,notes.txt"

# Retrieve documents by name (coming soon)
# yams get --name "meeting-notes.txt"

# Search with fuzzy matching
yams search "databse" --fuzzy --similarity 0.8

# List with rich metadata
yams list --format table --limit 20

# Chain commands for batch operations
yams list --format minimal | tail -5 | while read hash; do
  yams get $hash
done

# Preview deletions before executing
yams delete --pattern "*.log" --dry-run
  1. Use stdin for content storage: Avoids file creation

    echo "content to store" | yams add -
  2. Use minimal format for piping: Clean output for processing

    yams list --format minimal | head -5
  3. Explicit data directory: Always specify storage location

    yams --data-dir /tmp/project-memory add -
  4. JSON for structured data: Parse responses easily

    yams stats --format json | jq '.totalObjects'
  5. Direct stdout retrieval: No intermediate files

    yams get <hash> | process_somehow

Start the MCP server over WebSocket:

yams serve --transport websocket --host 127.0.0.1 --port 8080 --path /mcp

Use TLS (wss):

yams serve --transport websocket --host your.domain --port 443 --path /mcp --ssl

StdIO transport (recommended for local integration and Claude Desktop):

yams serve --transport stdio

Claude Desktop (MCP) Integration

Use stdio (recommended). Add this to your Claude Desktop config (e.g., ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "yams": {
      "command": "/usr/local/bin/yams",
      "args": ["serve", "--transport", "stdio"],
      "env": {
        "YAMS_STORAGE": "$HOME/.local/share/yams"
      }
    }
  }
}

Alternative (WebSocket) for clients that support ws:

{
  "mcpServers": {
    "yams-ws": {
      "command": "/usr/local/bin/yams",
      "args": ["serve", "--transport", "websocket", "--host", "127.0.0.1", "--port", "8080", "--path", "/mcp"],
      "env": {
        "YAMS_STORAGE": "$HOME/.local/share/yams"
      }
    }
  }
}
# One-time setup with defaults
yams init --non-interactive --no-keygen

# Custom storage location
yams --data-dir /path/to/storage init --non-interactive
# Add a file
yams add file.txt

# Add from stdin
echo "content" | yams add -
cat file.txt | yams add -

# Add multiple files
find . -name "*.txt" -exec yams add {} \;
# Table format (default)
yams list

# JSON output for programmatic use
yams list --format json

# Just hashes for piping
yams list --format minimal

# Sort and filter
yams list --sort size --reverse --limit 10
yams list --sort date
# Output to stdout
yams get <hash>

# Save to file
yams get <hash> -o output.txt

# Pipe to other commands
yams get <hash> | grep pattern
yams get <hash> | wc -l

# Get first document from list
yams list --format minimal --limit 1 | xargs yams get
# Launch ranger-style browser
yams browse

# Navigation:
#   j/k or ↑/↓     - Move up/down
#   h/l or ←/→     - Switch columns
#   g/G           - Jump to top/bottom
#   d then D      - Delete document
#   r             - Refresh
#   ?             - Help
#   q or Esc      - Quit

yams search "query" --limit 10 yams search "error" --type "log"

yams get yams get --output file.txt

yams list --recent 20 yams stats --json # JSON output for scripts

yams browse # Interactive document browser


### API
```cpp
#include <yams/api/content_store.h>

auto store = yams::api::createContentStore(getenv("YAMS_STORAGE"));

// Store
yams::api::ContentMetadata meta{.tags = {"code", "v1.0"}};
auto result = store->store("file.txt", meta);

// Search
auto results = store->search("query", 10);

// Retrieve
store->retrieve(hash, "output.txt");
import subprocess, json

def yams_store(content, tags=[], type="text"):
    cmd = ["yams", "store", content]
    if tags: cmd.extend(["--tags", ",".join(tags)])
    if type: cmd.extend(["--type", type])
    return subprocess.run(cmd, capture_output=True, text=True)

def yams_search(query, limit=10):
    cmd = ["yams", "search", query, "--limit", str(limit)]
    return subprocess.run(cmd, capture_output=True, text=True)
# Always specify data directory explicitly
export YAMS_STORAGE="/tmp/yams-data"

# Initialize once (quiet mode)
yams --data-dir "$YAMS_STORAGE" init --non-interactive --force

# Store content from stdin (most common for LLMs)
echo "Important information to remember" | yams --data-dir "$YAMS_STORAGE" add --tags "memory"

# Search for content
yams --data-dir "$YAMS_STORAGE" search "important" --json

# Retrieve specific document
yams --data-dir "$YAMS_STORAGE" get <hash> --json

# Get storage statistics
yams --data-dir "$YAMS_STORAGE" stats --json
# Store code changes
git diff | yams --data-dir "$YAMS_STORAGE" add --tags "git-diff,$(date +%Y%m%d)"

# Store conversation context
echo "User asked about: $TOPIC" | yams --data-dir "$YAMS_STORAGE" add --tags "context,$TOPIC"

# Store external documentation
curl -s "$API_DOCS_URL" | yams --data-dir "$YAMS_STORAGE" add --tags "api-docs,external"

# Search and retrieve in one line
hash=$(yams --data-dir "$YAMS_STORAGE" search "$QUERY" --json | jq -r '.results[0].hash')
yams --data-dir "$YAMS_STORAGE" get "$hash"

YAMS is ideal for LLMs to maintain persistent memory across sessions:

  • Code Development: Track changes, store working versions, remember context
  • Research: Cache web content, API responses, documentation
  • Conversation Context: Store important discussions, decisions, requirements
  • Knowledge Base: Build searchable repository of project knowledge
# Store current code state before making changes
git diff | yams store - --tags "pre-refactor,auth-module,$(date +%Y%m%d)"

# Track implementation decisions
yams store "Decided to use JWT tokens with 24h expiry for auth" \
  --tags "decision,auth,architecture"

# Store error context for debugging
yams store "$(tail -100 app.log)" --tags "error,production,$(date +%Y%m%d-%H%M)"

# Save working implementation
yams store-file auth_handler.py --tags "working,auth,v2.1"
# Store web research
curl -s https://api.example.com/docs | yams store - \
  --tags "api-docs,external,example-api" \
  --source "https://api.example.com/docs"

# Cache fetched content
yams store "$WEB_CONTENT" --tags "research,oauth,implementation-guide"

# Store meeting notes
yams store-file meeting-notes-2024-01-15.md --tags "meeting,requirements,client"
# Find related code changes
yams search "authentication" --type "code" --limit 10

# Retrieve specific version
yams search "working auth" --tags "v2.1"

# Get recent errors
yams list --recent 20 --tags "error"

# Semantic search for concepts
yams search "token expiry handling"

MCP (Model Context Protocol) Integration

MCP provides direct integration with Claude Desktop and other MCP-compatible clients.

Optimize for large files:

# Adjust chunk size for better deduplication
export YAMS_CHUNK_SIZE=64KB  # Default: 16KB

# Increase cache size
export YAMS_CACHE_SIZE=1GB   # Default: 256MB

Reduce memory usage:

# Use streaming mode for large files
yams store-file --stream large-file.bin

# Enable compression
export YAMS_COMPRESSION=zstd  # Options: none, zstd, lzma

Apache-2.0

联系我们 contact @ memedata.com