Co Occurrence Engine

# co-occurrence-engine

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Co Occurrence Engine" with this command: npx skills add whoisme007/co-occurrence-engine

co-occurrence-engine

独立的 Hebbian 共现图引擎,为星型记忆架构提供记忆关联发现与权重计算服务。

功能

  • 共现记录:自动记录同时被检索的记忆对,建立关联边
  • 关联查询:查询与指定记忆最相关的其他记忆
  • 权重计算:基于使用频率与时间衰减计算关联强度
  • 统计信息:提供边数、唯一记忆数、平均权重等统计
  • 维护工具:清理过旧的边,保持数据库健康

架构

┌─────────────────────────────────────────────────────┐
│               共现图引擎 (独立插件)                  │
│                                                     │
│  • CoOccurrenceEngine 类                            │
│  • SQLite 数据库 (共现图)                            │
│  • 遗忘曲线集成 (可选)                               │
└─────────────────────────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────┐
│               适配器 (co_occurrence_adapter)         │
│                                                     │
│  • 实现统一记忆接口                                   │
│  • 注册到星型架构适配器框架                           │
└─────────────────────────────────────────────────────┘

核心类

CoOccurrenceEngine

主引擎类,提供共现图的所有操作。

engine = CoOccurrenceEngine(db_path="~/.config/cortexgraph/co_occurrence.db")

主要方法

  • record_co_occurrence(memory_ids: List[str], context: str = "")
  • get_co_occurrence_score(memory_id: str, related_ids: List[str] = None) -> float
  • get_related_memories(memory_id: str, top_k: int = 10) -> List[Tuple[str, float]]
  • get_stats() -> Dict
  • decay_old_edges(days: int = 90) -> int

## 数据库

默认数据库位置:`~/.config/cortexgraph/co_occurrence.db`

表结构:
```sql
CREATE TABLE co_occurrence (
    memory_a TEXT,
    memory_b TEXT,
    weight REAL,
    last_updated TEXT,
    created_at TEXT,
    PRIMARY KEY (memory_a, memory_b)
)

集成

1. 独立使用

from scripts.co_occurrence_tracker import CoOccurrenceEngine

engine = CoOccurrenceEngine()
engine.record_co_occurrence(["mem_001", "mem_002"])
related = engine.get_related_memories("mem_001")

2. 通过适配器集成

from adapter_factory import AdapterFactory

factory = AdapterFactory()
adapter = factory.get_adapter("co_occurrence")
results = adapter.search("mem_001", max_results=10)

配置

通过环境变量或配置文件:

  • CO_OCCURRENCE_DB_PATH:数据库路径(默认:~/.config/cortexgraph/co_occurrence.db
  • CO_OCCURRENCE_HALF_LIFE_DAYS:衰减半衰期(默认:30天)

依赖

  • Python 3.8+
  • SQLite3(内置)
  • 可选forgetting-curve 插件(提供更精确的衰减计算)

版本历史

  • v0.1.0(初始版本):从 memory-sync-enhanced 中提取的共现图引擎

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Gigo Lobster Resume

🦞 GIGO · gigo-lobster-resume: 续跑入口:v2 stable 当前会清理旧 checkpoint 并从头重跑;保留此 slug 作为旧 checkpoint 兼容入口。 Triggers: 继续试吃 / 恢复评测 / resume tasting / continue lobster...

Registry SourceRecently Updated
General

YiHui CONTEXT MODE

context-mode is an MCP server that saves 98% of your context window by sandboxing tool outputs. It routes large file reads, shell outputs, and web fetches th...

Registry SourceRecently Updated
General

xinyi-drink

Use when users ask about 新一好喝/新一咖啡 drinks, stores, menu, activities, Skill用户大礼包, today drink recommendations, afternoon tea, feeling sleepy, or personalized...

Registry SourceRecently Updated
General

vedic-destiny

吠陀命盘分析中文入口。用于完整命盘研判、命主盘 Rashi chart 与九分盘 Navamsha chart 联读、既往事件回看、出生时间稳定度判断、事业主题、婚姻主题、时空盘专题,以及基于 Jagannatha Hora PDF、星盘截图或文本命盘数据的系统拆盘。当用户提到完整星盘、事业方向、婚姻问题、关系窗...

Registry SourceRecently Updated