Skip to content

Commit 62f95c3

Browse files
committed
fix: change hardcode language to auto detect
1 parent f395a08 commit 62f95c3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

graphgen/models/evaluator/kg/consistency_evaluator.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ def _check_entity_type_consistency(
269269
if entity_type
270270
]
271271

272-
# Use default language (zh) for conflict detection prompts
273-
# as they compare multiple chunks which may have different languages
274-
lang = "zh" # Default to Chinese, can be made configurable
272+
# Detect language from type extraction text
273+
type_text = "\n".join(type_list)
274+
lang = detect_main_language(type_text)
275275
prompt = CONSISTENCY_EVALUATION_PROMPT[lang]["ENTITY_TYPE_CONFLICT"].format(
276-
entity_name=entity_id, type_extractions="\n".join(type_list)
276+
entity_name=entity_id, type_extractions=type_text
277277
)
278278

279279
response = asyncio.run(self.llm_client.generate_answer(prompt))
@@ -315,10 +315,11 @@ def _check_entity_description_consistency(
315315
for chunk_id, description in valid_descriptions.items()
316316
]
317317

318-
# Use default language (zh) for conflict detection prompts
319-
lang = "zh" # Default to Chinese, can be made configurable
318+
# Detect language from description text
319+
desc_text = "\n".join(desc_list)
320+
lang = detect_main_language(desc_text)
320321
prompt = CONSISTENCY_EVALUATION_PROMPT[lang]["ENTITY_DESCRIPTION_CONFLICT"].format(
321-
entity_name=entity_id, descriptions="\n".join(desc_list)
322+
entity_name=entity_id, descriptions=desc_text
322323
)
323324

324325
response = asyncio.run(self.llm_client.generate_answer(prompt))
@@ -355,12 +356,13 @@ def _check_relation_consistency(
355356
if relation
356357
]
357358

358-
# Use default language (zh) for conflict detection prompts
359-
lang = "zh" # Default to Chinese, can be made configurable
359+
# Detect language from relation description text
360+
rel_text = "\n".join(rel_list)
361+
lang = detect_main_language(rel_text)
360362
prompt = CONSISTENCY_EVALUATION_PROMPT[lang]["RELATION_CONFLICT"].format(
361363
source_entity=src_id,
362364
target_entity=dst_id,
363-
relation_descriptions="\n".join(rel_list),
365+
relation_descriptions=rel_text,
364366
)
365367

366368
response = asyncio.run(self.llm_client.generate_answer(prompt))

0 commit comments

Comments
 (0)