返回顶部
f

forgetting-curve

独立的 Ebbinghaus 遗忘曲线模块,提供记忆衰减计算和间隔重复调度

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
132
下载量
0
收藏
概述
安装方式
版本历史

forgetting-curve

# Forgetting Curve 模块 独立的 Ebbinghaus 遗忘曲线实现,为记忆系统提供标准化衰减计算。 ## 功能特性 - **多种衰减模型**:Ebbinghaus 指数衰减、幂律衰减、自定义半衰期 - **间隔重复调度**:基于记忆强度的下一次复习时间计算 - **可配置参数**:半衰期、初始强度、衰减因子 - **跨平台兼容**:独立模块,无外部依赖 ## 核心算法 ### Ebbinghaus 指数衰减 ``` decay = 2^(-age_days / half_life_days) ``` 其中: - `age_days`: 距离最后一次复习的天数 - `half_life_days`: 半衰期(默认 30 天) ### 间隔重复调度(SRS) ``` next_review_days = base_interval * (strength ^ factor) ``` 其中: - `base_interval`: 基础间隔(如 1 天) - `strength`: 当前记忆强度(0.0-1.0) - `factor`: 强度因子(默认 1.5) ## 使用方法 ### 基本衰减计算 ```python from forgetting_curve import ForgettingCurve # 创建衰减器(默认半衰期 30 天) curve = ForgettingCurve(half_life_days=30.0) # 计算衰减因子 age_days = 7 # 7 天前记忆 decay = curve.calculate_decay(age_days) # 返回 0.82 # 应用衰减到记忆强度 original_strength = 0.9 decayed_strength = curve.apply_decay(original_strength, age_days) # 0.74 ``` ### 间隔重复调度 ```python from forgetting_curve import SpacedRepetitionScheduler scheduler = SpacedRepetitionScheduler() # 计算下一次复习时间 current_strength = 0.6 next_review_days = scheduler.next_review_interval(current_strength) # 3.1 天 # 更新记忆强度(复习后) new_strength = scheduler.update_strength(current_strength, success=True) # 0.75 ``` ### 批量处理 ```python # 批量计算衰减 import pandas as pd from forgetting_curve import batch_decay memories = [ {"id": "mem1", "strength": 0.9, "age_days": 3}, {"id": "mem2", "strength": 0.7, "age_days": 15}, {"id": "mem3", "strength": 0.5, "age_days": 60} ] decayed = batch_decay(memories, half_life_days=30) # 返回带衰减后强度的列表 ``` ## 配置参数 | 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | `half_life_days` | float | 30.0 | 半衰期(天) | | `initial_strength` | float | 1.0 | 初始记忆强度 | | `minimum_strength` | float | 0.1 | 最低强度阈值 | | `base_interval` | float | 1.0 | 基础复习间隔(天) | | `strength_factor` | float | 1.5 | 强度因子 | | `easy_factor` | float | 1.3 | 简单记忆因子 | | `hard_factor` | float | 0.8 | 困难记忆因子 | ## 与现有系统集成 ### 1. Memory Sync Enhanced ```python # co_occurrence_tracker.py 中替换硬编码衰减 # 旧代码: # decay = math.pow(2, -age_days / 30.0) # 新代码: from forgetting_curve import ForgettingCurve curve = ForgettingCurve(half_life_days=30.0) decay = curve.calculate_decay(age_days) ``` ### 2. CortexGraph 集成 ```python # 在检索时应用遗忘曲线过滤 from forgetting_curve import ForgettingCurve def retrieve_memories(query, top_k=10): # ... 语义搜索 ... for mem in results: age_days = (datetime.now() - mem.last_used).days decay = curve.calculate_decay(age_days) mem.score *= decay # ... 返回结果 ... ``` ## 扩展性 ### 自定义衰减函数 ```python from forgetting_curve import ForgettingCurve # 自定义衰减函数 def custom_decay(age_days, strength): return strength * math.exp(-age_days / 45.0) curve = ForgettingCurve(decay_function=custom_decay) ``` ### 多级记忆系统 ```python # 不同记忆类型使用不同半衰期 short_term = ForgettingCurve(half_life_days=3.0) # 短期记忆 long_term = ForgettingCurve(half_life_days=90.0) # 长期记忆 procedural = ForgettingCurve(half_life_days=7.0) # 程序性记忆 ``` ## 性能基准 ``` 1000 次衰减计算: 0.8ms 10000 次批量衰减: 5.2ms 内存占用: < 1MB ``` ## 安装 ### 作为独立模块 ```bash # 从当前目录安装 pip install -e . # 或直接复制文件 cp forgetting_curve.py /your/project/ ``` ### 作为 OpenClaw 技能 ```bash # 通过 ClawHub 发布后 clawhub install forgetting-curve ``` ## 开发指南 ### 项目结构 ``` forgetting-curve/ ├── forgetting_curve.py # 核心模块 ├── test_decay.py # 单元测试 ├── examples/ # 使用示例 ├── config/ # 配置文件 └── SKILL.md # 本文档 ``` ### 运行测试 ```bash python test_decay.py ``` ## 路线图 ### v0.1.0 (MVP) - [x] 基本 Ebbinghaus 衰减计算 - [x] 可配置半衰期 - [x] 强度衰减应用 ### v0.2.0 - [ ] 间隔重复调度 - [ ] 多种衰减模型(幂律、指数混合) - [ ] 批量处理优化 ### v0.3.0 - [ ] 记忆分类(STM/LTM) - [ ] 自适应半衰期(基于使用频率) - [ ] 可视化工具 ### v1.0.0 - [ ] 完整 SRS 算法 - [ ] 与 Anki/Mnemosyne 兼容 - [ ] 跨语言绑定 ## 参考 - Hermann Ebbinghaus (1885) - 遗忘曲线 - Piotr Wozniak (1987) - SuperMemo 算法 - Spaced Repetition Systems - 现代间隔重复理论 --- *版本: 0.1.0* *独立的 Ebbinghaus 遗忘曲线模块*

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 forgetting-curve-1776217322 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 forgetting-curve-1776217322 技能

通过命令行安装

skillhub install forgetting-curve-1776217322

下载 Zip 包

⬇ 下载 forgetting-curve v1.0.0

文件大小: 5.59 KB | 发布时间: 2026-4-17 14:52

v1.0.0 最新 2026-4-17 14:52
Initial release of the forgetting-curve skill — a standalone Ebbinghaus forgetting curve and spaced repetition module.

- Implements exponential and power-law decay models for memory.
- Provides interval scheduling based on memory strength (SRS support).
- All parameters (half-life, strength, decay factor) are configurable.
- Easy integration with other systems; fully independent with no external dependencies.
- Includes batch operations and custom decay/extensibility support.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部