LLM评测框架Ragas Agents or Tool Use Cases指标(解决了Ollama推理框架不支持的问题)
代理或工具使用工作流程可以从多个维度进行评估。以下是一些可用于评估代理或工具在特定任务中的性能的指标。
Topic Adherence
Topic Adherence(主题一致性),评价AI在交互过程中能够保持在预定义领域内的能力。TopicAdherenceScore需要AI能遵守一组由reference_topics和user_input提供的预定义主题。该指标可计算Topic Adherence的precision、recall和f1评分。
from ragas.dataset_schema import SingleTurnSample, MultiTurnSample, EvaluationDataset
from ragas.messages import HumanMessage,AIMessage,ToolMessage,ToolCall
from ragas.metrics import TopicAdherenceScore
from langchain_ollama import ChatOllama
from ragas.llms import OllamaLLMWrapper
import asyncioasync def main():llm = ChatOllama(model="llama3.1:8b")evaluator_llm = OllamaLLMWrapper(ollama_llm=llm)sample_input_4 = [HumanMessage(content="Can you provide me with details about Einste