返回顶部
f

forgetting-curve遗忘曲线

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

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

forgetting-curve

遗忘曲线模块

独立的艾宾浩斯遗忘曲线实现,为记忆系统提供标准化衰减计算。

功能特性

  • - 多种衰减模型:艾宾浩斯指数衰减、幂律衰减、自定义半衰期
  • 间隔重复调度:基于记忆强度的下次复习时间计算
  • 可配置参数:半衰期、初始强度、衰减因子
  • 跨平台兼容:独立模块,无外部依赖

核心算法

艾宾浩斯指数衰减

decay = 2^(-agedays / halflife_days)

其中:

  • - agedays:距离上次复习的天数
  • halflife_days:半衰期(默认30天)

间隔重复调度(SRS)

nextreviewdays = base_interval * (strength ^ factor)

其中:

  • - base_interval:基础间隔(如1天)
  • strength:当前记忆强度(0.0-1.0)
  • factor:强度因子(默认1.5)

使用方法

基本衰减计算

python
from forgetting_curve import ForgettingCurve

创建衰减器(默认半衰期30天)

curve = ForgettingCurve(halflifedays=30.0)

计算衰减因子

age_days = 7 # 7天前记忆 decay = curve.calculatedecay(agedays) # 返回0.82

将衰减应用于记忆强度

original_strength = 0.9 decayedstrength = curve.applydecay(originalstrength, agedays) # 0.74

间隔重复调度

python
from forgetting_curve import SpacedRepetitionScheduler

scheduler = SpacedRepetitionScheduler()

计算下次复习时间

current_strength = 0.6 nextreviewdays = scheduler.nextreviewinterval(current_strength) # 3.1天

更新记忆强度(复习后)

newstrength = scheduler.updatestrength(current_strength, success=True) # 0.75

批量处理

python

批量计算衰减


import pandas as pd
from forgettingcurve import batchdecay

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 = batchdecay(memories, halflife_days=30)

返回包含衰减后强度的列表

配置参数

参数类型默认值说明
halflifedaysfloat30.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

在cooccurrencetracker.py中替换硬编码衰减


旧代码:


decay = math.pow(2, -age_days / 30.0)

新代码:

from forgetting_curve import ForgettingCurve curve = ForgettingCurve(halflifedays=30.0) decay = curve.calculatedecay(agedays)

2. CortexGraph集成

python

在检索时应用遗忘曲线过滤


from forgetting_curve import ForgettingCurve

def retrievememories(query, topk=10):
# ... 语义搜索 ...
for mem in results:
agedays = (datetime.now() - mem.lastused).days
decay = curve.calculatedecay(agedays)
mem.score *= decay
# ... 返回结果 ...

扩展性

自定义衰减函数

python
from forgetting_curve import ForgettingCurve

自定义衰减函数

def customdecay(agedays, strength): return strength * math.exp(-age_days / 45.0)

curve = ForgettingCurve(decayfunction=customdecay)

多级记忆系统

python

不同记忆类型使用不同半衰期


shortterm = ForgettingCurve(halflife_days=3.0) # 短期记忆
longterm = ForgettingCurve(halflife_days=90.0) # 长期记忆
procedural = ForgettingCurve(halflifedays=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] 基本艾宾浩斯衰减计算
  • [x] 可配置半衰期
  • [x] 强度衰减应用

v0.2.0

  • - [ ] 间隔重复调度
  • [ ] 多种衰减模型(幂律、指数混合)
  • [ ] 批量处理优化

v0.3.0

  • - [ ] 记忆分类(STM/LTM)
  • [ ] 自适应半衰期(基于使用频率)
  • [ ] 可视化工具

v1.0.0

  • - [ ] 完整SRS算法
  • [ ] 与Anki/Mnemosyne兼容
  • [ ] 跨语言绑定

参考

  • - Hermann Ebbinghaus(1885)- 遗忘曲线
  • Piotr Wozniak(1987)- SuperMemo算法
  • 间隔重复系统 - 现代间隔重复理论

版本:0.1.0 独立的艾宾浩斯遗忘曲线模块

标签

skill ai

通过对话安装

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

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

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

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

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

通过命令行安装

skillhub install forgetting-curve-1776217322

下载

⬇ 下载 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
返回顶部