Class Introduction

Function

Evaluates the knowledge graph quality.

Prototype

from mx_rag.graphrag import GraphEvaluator

GraphEvaluator(llm, llm_config)

Parameters

Parameter

Data Type

Required/Optional

Description

llm

Text2TextLLM

Required

LLM instance object.

llm_config

LLMParameterConfig

Required

See LLMParameterConfig.

Return Value

GraphEvaluator object.

Example

import json
from paddle.base import libpaddle
from mx_rag.graphrag.graph_evaluator import GraphEvaluator
from mx_rag.llm import Text2TextLLM, LLMParameterConfig
from mx_rag.utils import ClientParam
llm_config = LLMParameterConfig(temperature=0.5, top_p=0.8, max_tokens=8192)
llm = Text2TextLLM(
    base_url="https://ip:port/v1/chat/completions",
    model_name="Llama3-8B-Chinese-Chat",
    llm_config=llm_config,
    client_param=ClientParam(ca_file="/path/to/ca.crt", timeout=120),
)
graph_evaluator = GraphEvaluator(llm, llm_config)
relations_path = "/path/to/graph_relations.json"
with open(relations_path, "r", encoding="utf-8") as f:
    relations = json.load(f)
    graph_evaluator.evaluate(relations)