Skip to content

Commit 4f0350b

Browse files
feat: add kg_structure evaluation
2 parents f6cce9b + 71ebba2 commit 4f0350b

File tree

7 files changed

+11
-13
lines changed

7 files changed

+11
-13
lines changed

graphgen/models/evaluator/kg/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ This module provides comprehensive quality evaluation for knowledge graphs built
44

55
## Module Structure
66

7-
The evaluation functionality has been split into modular components:
7+
The evaluation functionality is organized into modular components:
88

99
- **`accuracy_evaluator.py`**: Entity/relation extraction quality evaluation using LLM-as-a-Judge
1010
- **`consistency_evaluator.py`**: Attribute value conflict detection
1111
- **`structure_evaluator.py`**: Graph structural robustness metrics
12-
- **`kg_quality_evaluator.py`**: Main evaluator class that integrates all modules
12+
13+
The evaluation components are integrated in `graphgen/operators/evaluate/evaluate_kg.py`, which provides functions to create and use these evaluators.
1314

1415
## Features
1516

graphgen/models/evaluator/qa/length_evaluator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66

77
class LengthEvaluator(BaseEvaluator):
8-
def __init__(self):
9-
self.tokenizer: Tokenizer = Tokenizer(os.environ["TOKENIZER_MODEL"] or "cl100k_base")
8+
def __init__(self, tokenizer_name: str = None):
9+
tokenizer_model = tokenizer_name or os.environ.get("TOKENIZER_MODEL", "cl100k_base")
10+
self.tokenizer: Tokenizer = Tokenizer(tokenizer_model)
1011

1112
def evaluate(self, pair: QAPair) -> float:
1213
"""

graphgen/models/evaluator/qa/uni_evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def _build_input_text(dimension: str, question: str, answer: str) -> str:
5555
"""Construct input text for specified dimension."""
5656
if dimension == "naturalness":
5757
return f"question: Is this a natural response? </s> response: {answer}"
58-
elif dimension == "coherence":
58+
if dimension == "coherence":
5959
return f"question: Is this a coherent response? </s> response: {answer} </s> history: {question}"
60-
elif dimension == "understandability":
60+
if dimension == "understandability":
6161
return f"question: Is this an understandable response? </s> response: {answer}"
6262
raise NotImplementedError(f"Unsupported dimension '{dimension}'")
6363

graphgen/operators/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from .quiz import QuizService
99
from .read import read
1010
from .search import SearchService
11-
from .evaluate import EvaluateService
1211

1312

1413
operators = {

graphgen/operators/evaluate/evaluate_kg.py

Whitespace-only changes.

graphgen/templates/evaluation/kg/consistency_evaluation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@
100100
"en": "",
101101
"zh": ""
102102
}
103-

graphgen/utils/help_nltk.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
from typing import Dict, List, Final, Optional
44
import warnings
55
import nltk
6+
import jieba
67

78
warnings.filterwarnings(
8-
"ignore",
9+
"ignore",
910
category=UserWarning,
10-
module="jieba\._compat"
11+
module=r"jieba\._compat"
1112
)
1213

13-
14-
import jieba
15-
1614
class NLTKHelper:
1715
"""
1816
NLTK helper class

0 commit comments

Comments
 (0)