feat: nerd-Brain (呆脑子) - 初始提交

- anchor_writer.py: 记忆写入与情感打标
- anchor_search.py: 多维语义检索引擎
- anchor_decay.py: 遗忘曲线 + 归档 + 随机返场
- anchor_vault_sync.py: Vault 索引生成
- README.md: 项目说明文档
This commit is contained in:
fyah
2026-04-26 22:19:40 +08:00
commit 837c5f66fb
5 changed files with 702 additions and 0 deletions

66
README.md Normal file
View File

@@ -0,0 +1,66 @@
# nerd-Brain (呆脑子)
> 一个轻量级、全本地化的 AI 长效记忆系统。
## 简介
nerd-Brain 是一套基于 Obsidian Markdown 笔记库的 AI 记忆引擎。它不依赖 Docker、向量数据库或外部服务仅用纯 Python 脚本 + 本地 LLM API 实现:
- **记忆写入**:自动生成摘要、情感坐标、关键词打标
- **多维检索**:关键词 + 情感 + 时间 + 重要性加权搜索
- **自然遗忘**:改进版艾宾浩斯遗忘曲线,自动衰减与归档
- **随机返场**10% 概率让旧记忆/旧 Idea 从归档中复活
## 架构
```
┌─────────────┐ ┌──────────────┐ ┌───────────────┐
│ anchor_ │────▶│ Obsidian │────▶│ Qwen 3.5 Plus│
│ writer.py │ │ Vault (MD) │ │ (百炼 API) │
└─────────────┘ └──────────────┘ └───────────────┘
│ │
▼ ▼
┌─────────────┐ ┌──────────────┐
│ anchor_ │ │ anchor_ │
│ search.py │ │ decay.py │
│ (多维检索) │ │ (遗忘+返场) │
└─────────────┘ └──────────────┘
```
## 核心脚本
| 脚本 | 功能 | 用法 |
|------|------|------|
| `anchor_writer.py` | 记忆写入与情感打标 | `python3 anchor_writer.py "内容"` |
| `anchor_search.py` | 多维语义检索 | `python3 anchor_search.py "关键词"` |
| `anchor_decay.py` | 遗忘曲线扫描与归档 | `python3 anchor_decay.py` |
| `anchor_vault_sync.py` | Vault 索引生成 | `python3 anchor_vault_sync.py sync` |
## 配置
所有路径和 API 配置在脚本顶部常量区:
- `VAULT_DIR`: Obsidian 笔记库路径
- `API_URL`: LLM 接口地址
- `API_KEY`: 百炼 API 密钥
- `RESURRECTION_CHANCE`: 返场概率(默认 0.1
- `DECAY_LAMBDA`: 遗忘速率(默认 0.05
- `THRESHOLD`: 归档阈值(默认 0.3
## 依赖
```bash
pip install requests pyyaml
```
## 状态
- ✅ 记忆写入(含情感标签)
- ✅ 多维检索引擎
- ✅ 遗忘曲线 + 自动归档
- ✅ 归档后随机返场10% 概率)
- 🔄 A100 本地 Qwen 3.6 部署中(待切换)
## 备份
原始脚本备份在 `~/.hermes/anchor_memory_backup/`,随时可回滚。