agentleFS
topprismdatatopprismdata/cultivating-ml-agent/skills/examples/mem0-dynamic-graph-memory/SKILL.md

mem0-dynamic-graph-memory

Skill5 starsChanged 34 days agoMITView on GitHub

Use when extracting entities and relationships from text, when building dynamic knowledge graphs, when wanting to upgrade from static OKF to entity-aware memory, or when analyzing papers/discussions for concepts. Triggers when ingesting new papers, processing Kaggle writeups, or when existing skills can't capture connections between concepts.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When OKF misses connections you see in papers

    line 91

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mem0 Dynamic Graph Memory (Entity-Relation Extraction)

Context

Static OKF stores predefined edges. Mem0/Letta (2025) extract entities + relations dynamically from text. agy suggested upgrading our existing EntityRelationExtractor as P2: enables automatic concept discovery instead of manual OKF curation.

The core insight: knowledge graphs are useful only if they reflect real relationships, and those relationships must be extracted, not hardcoded.

Guidance

Extract from Paper/Discussion

from framework.src.memory.entity_extraction import EntityRelationExtractor

ext = EntityRelationExtractor()
text = """
LightGBM uses histogram-based gradient boosting.
XGBoost improves LightGBM with second-order gradients.
CatBoost handles categorical features natively, unlike LightGBM.
We evaluated F1 score on Spaceship Titanic.
Walk-forward validation prevents data leakage in time series.
"""

entities, relations = ext.extract(text)
# → 8 entities (techniques, metrics, competitions, concepts)
# → relations: "XGBoost improves LightGBM", etc.

for e in entities:
    print(f"{e.type}: {e.name} ({e.mentions} mentions)")
for r in relations:
    print(f"{r.source} --{r.relation}--> {r.target}")

With LLM Enhancement

def my_llm(prompt: str) -> str:
    return openai_client.chat.completions.create(...).choices[0].message.content

ext = EntityRelationExtractor(llm_call=my_llm)
entities, relations = ext.extract(text)
# → 规则抽取 + LLM 抽取合并去重

Integrate with OKF Index

# 已存在 OKFIndex,可叠加 entity edges
from framework.src.memory.okf_index import OKFIndex
from framework.src.memory.entity_extraction import EntityRelationExtractor

okf = OKFIndex(okf_dir="docs/ml-agent-memory")
okf.build()

ext = EntityRelationExtractor()
entities, relations = ext.extract(paper_abstract)

# 把 entity edges 添加到 OKF 图
for e in entities:
    okf.items[f"entity:{e.name.lower()}"] = MemoryItem(
        id=f"entity:{e.name.lower()}",
        content=f"{e.type}: {e.name}",
        type="entity",
        importance=0.6,
    )

Why This Matters

Static OKFDynamic Entity-Relation
Edges hardcoded in markdownEdges extracted from text
Stale (doesn't reflect new content)Always current
Misses implicit connectionsFinds "X improves Y" relations
Manual curation requiredAuto-scaling

agy: "Mem0 dynamic graph memory enables cross-Competition knowledge transfer at scale."

When to Apply

When to Use

  • Ingesting new paper or discussion
  • Building knowledge graph from corpus
  • Analyzing relationships between techniques
  • When OKF misses connections you see in papers

When NOT to Use

  • Short texts (LLM overhead not worth it)
  • Highly specialized domain (entity patterns need extension)
  • Real-time scenarios (extraction takes seconds)

Notes

  • Pattern-based fallback: works without LLM, slightly lower recall
  • Type coverage: technique / tool / metric / competition / concept
  • Dedup is critical: same entity mentioned multiple times = single node
  • Confidence scoring: relation extraction includes evidence snippet
  • See also: memory-hierarchy-management, time-series-walk-forward-validation

References

  • Implementation: framework/src/memory/entity_extraction.py
  • Inspired by: Mem0 (2024), Letta/MemGPT (2023), GLiNER (NER model)
  • Pairing: framework/src/memory/okf_index.py (existing static OKF)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.