类功能
功能描述
用于对知识图谱的质量进行评估。
函数原型
from mx_rag.graphrag import GraphEvaluator GraphEvaluator(llm, llm_config)
输入参数说明
参数名  | 
数据类型  | 
可选/必选  | 
说明  | 
|---|---|---|---|
llm  | 
Text2TextLLM  | 
必选  | 
大模型接口实例对象。  | 
llm_config  | 
LLMParameterConfig  | 
必选  | 
通过langchain调用时生效,描述参见LLMParameterConfig类;非langchain方式调用通过chat和chat_streamly方法传入参数,参见chat和chat_streamly。  | 
返回值说明
GraphEvaluator对象。
调用示例
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)
父主题: GraphEvaluator