Skip to content

Commit e10b391

Browse files
feat: add kg_accuracy & kg_consistency metrics
1 parent 4f0350b commit e10b391

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

examples/evaluate/evaluate_kg/kg_evaluation_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ nodes:
4141
params:
4242
metrics:
4343
- kg_structure
44-
# - kg_accuracy
45-
# - kg_consistency
44+
- kg_accuracy
45+
- kg_consistency

graphgen/models/evaluator/kg/accuracy_evaluator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ def _evaluate_relation_extraction(
279279
"issues": [f"Evaluation error: {str(e)}"],
280280
}
281281

282+
@staticmethod
282283
def _aggregate_evaluation_results(
283-
self, entity_evaluations: List[Dict], relation_evaluations: List[Dict]
284+
entity_evaluations: List[Dict], relation_evaluations: List[Dict]
284285
) -> Dict[str, Any]:
285286
"""Aggregate evaluation results from all chunks."""
286287

graphgen/operators/evaluate/evaluate_kg.py

Whitespace-only changes.

graphgen/operators/evaluate/evaluate_service.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ def __init__(
1818
working_dir: str = "cache",
1919
metrics: list[str] = None,
2020
graph_backend: str = "kuzu",
21+
kv_backend: str = "rocksdb",
2122
**kwargs,
2223
):
2324
super().__init__(working_dir=working_dir, op_name="evaluate_service")
2425
self.llm_client: BaseLLMWrapper = init_llm("synthesizer")
2526
self.metrics = metrics or []
2627
self.kwargs = kwargs
27-
self.graph_backend = init_storage(
28+
self.graph_storage = init_storage(
2829
backend=graph_backend, working_dir=working_dir, namespace="graph"
2930
)
31+
self.chunk_storage = init_storage(
32+
backend=kv_backend, working_dir=working_dir, namespace="chunk"
33+
)
3034

3135
# Initialize evaluators
3236
self.qa_evaluators = {}
@@ -62,21 +66,23 @@ def _init_evaluators(self):
6266
from graphgen.models import AccuracyEvaluator
6367

6468
self.kg_evaluators[metric] = AccuracyEvaluator(
65-
graph_storage=self.graph_backend,
66-
**self.kwargs.get("accuracy_params", {}),
69+
graph_storage=self.graph_storage,
70+
chunk_storage=self.chunk_storage,
71+
llm_client=self.llm_client,
6772
)
6873
elif metric == "kg_consistency":
6974
from graphgen.models import ConsistencyEvaluator
7075

7176
self.kg_evaluators[metric] = ConsistencyEvaluator(
72-
graph_storage=self.graph_backend,
73-
**self.kwargs.get("consistency_params", {}),
77+
graph_storage=self.graph_storage,
78+
chunk_storage=self.chunk_storage,
79+
llm_client=self.llm_client,
7480
)
7581
elif metric == "kg_structure":
7682
from graphgen.models import StructureEvaluator
7783

7884
self.kg_evaluators[metric] = StructureEvaluator(
79-
graph_storage=self.graph_backend,
85+
graph_storage=self.graph_storage,
8086
**self.kwargs.get("structure_params", {}),
8187
)
8288
else:

0 commit comments

Comments
 (0)