Methodology
Adapter Contractv1.0
Graph / RAG Adapter Spec
Adapter contract for graph-based memory and RAG systems. These systems use knowledge graphs, graph databases, or graph-enhanced retrieval to store and query information.
Required methods
def setup(self) -> NoneInitialize graph database, embeddings, and any required services.
def reset(self) -> NoneClear the graph. Must remove all nodes and edges.
def teardown(self) -> NoneClose connections, stop services, clean up temporary data.
def ingest(self, turns: List[Dict[str, Any]]) -> NoneExtract entities and relationships from conversation turns and add to graph.
def recall(self, query: str) -> strQuery the graph for relevant information. May use graph traversal, embedding search, or both.
Required capabilities
- -Entity extraction and relationship mapping
- -Graph-based or graph-enhanced retrieval
- -Knowledge scale handling
- -Session isolation (full graph clear on reset)
Applicable benchmarks
| Benchmark | Alignment |
|---|---|
| Knowledge Retrieval | core |
| Knowledge Scale | core |
| Truth Arbitration | core |
| Budget Curves | core |
| Memory Poisoning | adjacent |
| Reliability | adjacent |
Example implementation
python
"""Example graph memory adapter."""
from typing import Any, Dict, List, Optional
from benchd_harness.adapters.base import BaseAdapter
class MyGraphAdapter(BaseAdapter):
@property
def name(self) -> str:
return "my-graph"
@property
def version(self) -> Optional[str]:
return "1.0.0"
def setup(self) -> None:
self._graph = GraphStore(uri="bolt://localhost:7687")
def reset(self) -> None:
self._graph.clear_all()
def teardown(self) -> None:
self._graph.close()
def ingest(self, turns: List[Dict[str, Any]]) -> None:
text = "\n".join(
f"[{t['role']}]: {t['content']}" for t in turns
)
self._graph.extract_and_store(text)
def recall(self, query: str) -> str:
nodes = self._graph.query(query, max_hops=2)
return "\n".join(n.text for n in nodes)Quick start
Install
bash
pip install benchd-harnessValidate & test
bash
benchd adapter validate my-graph && benchd run -a my-graph -b knowledge-retrieval-v0Stable URL: benchd.ai/spec/adapter/graph/v10
Version: 1.0 | This spec is referenced in adapter manifests and will not change within the same major version.