进入RAGFlow的docker目录: cd 你的路径\ragflow\docker docker compose -f docker-compose.yml up -d [Image]
等待命令执行完成,当看到类似以下输出时表示安装成功:
[+] Running 4/4 ✓ Container ragflow-elasticsearch Started ✓ Container ragflow-mysql Started ✓ Container ragflow-redis Started ✓ Container ragflow Started
You are an explainer for primary school students. Use short sentences, vivid examples, and emojis when helpful. Always explain complex concepts in simple terms a child can understand.
职场专业口吻:
You are a professional corporate assistant answering in concise bullet points. Maintain formal language and focus on factual information. Highlight key takeaways that are relevant to business contexts.
八、开始使用RAG系统
创建完成后,你可以直接在浏览器中与RAG系统交互:
进入Chat Assistant页面
点击刚创建的助手
在输入框中输入问题,如"公司的年假政策是什么?"
系统会检索知识库中的相关信息并给出回答
九、使用RAGAS评估RAG系统性能
RAGAS是一个专门用于评估RAG系统质量的框架,它提供了四个核心指标来衡量系统性能:
Context Precision:检索内容的准确性
Context Recall:检索内容的完整性
Answer Relevancy:回答与问题的相关程度
Faithfulness:回答内容对检索内容的忠实度
9.1 安装RAGAS
pip install ragas datasets
9.2 创建评估脚本
创建一个名为evaluate_rag.py的文件,内容如下:
from ragas.testset import TestsetGenerator from ragas.datasets import Dataset from ragas.embeddings import OpenAIEmbeddings from ragas.llms import OpenAI as RagasOpenAI from ragas import evaluate from ragas.metrics import context_precision, context_recall, answer_relevancy, faithfulness import pandas as pd sample = pd.DataFrame([ {"question": "公司年假政策是什么?", "ground_truth": "每年 15 天带薪年假"}, {"question": "周报包括什么内容?", "ground_truth": "本周工作、问题、进度、需要支持"} ]) generator = TestsetGenerator.from_langchain(llm=RagasOpenAI(), embedding=OpenAIEmbeddings()) dataset = generator.generate_with_ground_truth(sample) results = evaluate(dataset, [context_precision, context_recall, answer_relevancy, faithfulness]) for m, score in results.items(): print(f"{m}: {score*100:.2f}%")