GraphRAG-Benchmark icon indicating copy to clipboard operation
GraphRAG-Benchmark copied to clipboard

generation_eval

Open 7HHHHH opened this issue 1 year ago • 3 comments

Very valuable work! While running the tests, I noticed that the faithfulness metric is always NaN. Could you help me understand why this is happening?

7HHHHH avatar Aug 06 '25 04:08 7HHHHH

Hi, thank you for your interest! Could you please specify which framework you were testing, which dataset (medical or novel), and which models were evaluated? This information would help us debug the issue more effectively.

Eric-Xiang-526 avatar Aug 06 '25 07:08 Eric-Xiang-526

I used gpt-4o-mini and llama3.1-8B as evaluation models, and encountered this issue with HippoRAG2 on both datasets. It seems I resolved it this afternoon. The main reason was a JSON format mismatch: the LLM responses included an Output: prefix or markdown code blocks, which the original parsing logic couldn't handle. I suspect this might be because the evaluation models I used were too weak. I added a filtering function in the hope that it might help others who encounter the same issue. If this kind of problem also occurs with more advanced models, you might consider adding it to your code as well.

def _improved_json_parse(content: str): """Improved JSON parsing that handles various LLM response formats""" # Remove common prefixes and suffixes content = re.sub(r"^Output:\s*", "", content.strip()) content = re.sub(r"^Answer:\s*", "", content.strip()) content = re.sub(r"^Response:\s*", "", content.strip())

# Remove markdown code blocks
content = re.sub(r"```json\s*", "", content)
content = re.sub(r"```\s*", "", content)

# Try to find JSON array or object in the content
json_match = re.search(r'(\[.*?\]|\{.*?\})', content, re.DOTALL)
if json_match:
    content = json_match.group(1)

return json.loads(content.strip())

7HHHHH avatar Aug 06 '25 08:08 7HHHHH

Thank you very much for pointing out the issue. During our testing, the model may not have encountered this specific problem, which led us to overlook the validation of the JSON format. We truly appreciate the code you provided — we will refer to it and update our code to make it more robust. Thank you for your valuable contribution!

Eric-Xiang-526 avatar Aug 06 '25 08:08 Eric-Xiang-526