struct JudgeResult
pub struct JudgeResult {
pub score f64
pub passed bool
pub reasoning string
}用途
承载 score、passed、reasoning 等属性的结构体。
公开字段
scoref64- 字段(f64)
passedbool- 字段(bool)
reasoningstring- 字段(string)
#github.com/xulang-org/packages/eval扩展包 `eval #github.com/xulang-org/packages/eval`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 1.17.2 · 安装与使用
struct JudgeResultpub struct JudgeResult {
pub score f64
pub passed bool
pub reasoning string
}承载 score、passed、reasoning 等属性的结构体。
score f64passed boolreasoning stringstruct EvalCasepub struct EvalCase {
pub id string
pub input string
pub expected string
}承载 id、input、expected 等属性的结构体。
id stringinput stringexpected stringstruct EvalSummarypub struct EvalSummary {
pub total int
pub exact_match_avg f64
pub token_f1_avg f64
pub rouge_l_avg f64
}承载 total、exact_match_avg、token_f1_avg、rouge_l_avg 等属性的结构体。
total intexact_match_avg f64token_f1_avg f64rouge_l_avg f64struct RagasReportpub struct RagasReport {
pub context_precision f64
pub context_recall f64
pub faithfulness f64
pub answer_relevancy f64
pub overall f64
}承载 context_precision、context_recall、faithfulness、answer_relevancy、overall 等属性的结构体。
context_precision f64context_recall f64faithfulness f64answer_relevancy f64overall f64exact_matchpub fn exact_match(pred &string, gold &string, normalize bool) f64执行 exact match 操作。
pred &stringgold &stringnormalize boolf64 — 该类型的值
token_f1pub fn token_f1(pred &string, gold &string) f64执行 token f1 操作。
pred &stringgold &stringf64 — 该类型的值
rouge_npub fn rouge_n(pred &string, reference &string, n int) f64执行 rouge n 操作。
pred &stringreference &stringn intf64 — 该类型的值
rouge_lpub fn rouge_l(pred &string, reference &string) f64执行 rouge l 操作。
pred &stringreference &stringf64 — 该类型的值
bleu_scorepub fn bleu_score(pred &string, reference &string, max_n int) f64执行 bleu score 操作。
pred &stringreference &stringmax_n intf64 — 该类型的值
json_valid_scorepub fn json_valid_score(output &string, required_keys &[]string) f64执行 json valid score 操作。
output &stringrequired_keys &[]stringf64 — 该类型的值
judge_openaipub fn judge_openai(client &openai.Client, model string, question string, answer string, rubric string, pass_threshold f64) JudgeResult执行 judge openai 操作。失败时抛出错误,调用方需处理或继续传播。
client &openai.Clientmodel stringquestion stringanswer stringrubric stringpass_threshold f64JudgeResult — 该类型的值
judge_anthropicpub fn judge_anthropic(client &anthropic.Client, model string, question string, answer string, rubric string, pass_threshold f64) JudgeResult执行 judge anthropic 操作。失败时抛出错误,调用方需处理或继续传播。
client &anthropic.Clientmodel stringquestion stringanswer stringrubric stringpass_threshold f64JudgeResult — 该类型的值
judge_geminipub fn judge_gemini(client &gemini.Client, model string, question string, answer string, rubric string, pass_threshold f64) JudgeResult执行 judge gemini 操作。失败时抛出错误,调用方需处理或继续传播。
client &gemini.Clientmodel stringquestion stringanswer stringrubric stringpass_threshold f64JudgeResult — 该类型的值
run_suitepub fn run_suite(cases &[]EvalCase, predictor fn(&string) string) EvalSummary执行 run suite 操作。
cases &[]EvalCasepredictor fn(&string) stringEvalSummary — 该类型的值
rag_context_precisionpub fn rag_context_precision(retrieved_texts &[]string, ground_truth &string) f64执行 rag context precision 操作。
retrieved_texts &[]stringground_truth &stringf64 — 该类型的值
rag_context_recallpub fn rag_context_recall(retrieved_texts &[]string, ground_truth &string) f64执行 rag context recall 操作。
retrieved_texts &[]stringground_truth &stringf64 — 该类型的值
rag_faithfulnesspub fn rag_faithfulness(answer &string, retrieved_texts &[]string) f64执行 rag faithfulness 操作。
answer &stringretrieved_texts &[]stringf64 — 该类型的值
rag_answer_relevancypub fn rag_answer_relevancy(question &string, answer &string) f64执行 rag answer relevancy 操作。
question &stringanswer &stringf64 — 该类型的值
evaluate_rag_triadpub fn evaluate_rag_triad(question &string, answer &string, retrieved_texts &[]string, ground_truth &string) RagasReport执行 evaluate rag triad 操作。
question &stringanswer &stringretrieved_texts &[]stringground_truth &stringRagasReport — 该类型的值
evaluate_rag_judge_openaipub fn evaluate_rag_judge_openai(client &openai.Client, model string, question string, answer string, retrieved_texts &[]string) RagasReport执行 evaluate rag judge openai 操作。失败时抛出错误,调用方需处理或继续传播。
client &openai.Clientmodel stringquestion stringanswer stringretrieved_texts &[]stringRagasReport — 该类型的值
struct PairwiseResultpub struct PairwiseResult {
pub winner string
pub reasoning string
}承载 winner、reasoning 等属性的结构体。
winner stringreasoning stringpass_at_kpub fn pass_at_k(n int, c int, k int) f64执行 pass at k 操作。
n intc intk intf64 — 该类型的值
compare_openaipub fn compare_openai(client &openai.Client, model string, question string, answer_a string, answer_b string, rubric string) PairwiseResult执行 compare openai 操作。失败时抛出错误,调用方需处理或继续传播。
client &openai.Clientmodel stringquestion stringanswer_a stringanswer_b stringrubric stringPairwiseResult — 该类型的值
load_cases_jsonlpub fn load_cases_jsonl(path string) []EvalCase执行 load cases jsonl 操作。失败时抛出错误,调用方需处理或继续传播。
path string[]EvalCase — 切片结果
struct SchemaFieldRulepub struct SchemaFieldRule {
pub name string
pub expected_type string
pub required bool
}承载 name、expected_type、required 等属性的结构体。
name stringexpected_type stringrequired boolstruct SchemaCheckResultpub struct SchemaCheckResult {
pub valid bool
pub pass_rate f64
pub missing_fields []string
pub type_mismatches []string
}承载 valid、pass_rate、missing_fields、type_mismatches 等属性的结构体。
valid boolpass_rate f64missing_fields []stringtype_mismatches []stringstruct RawSchemaResultpub struct RawSchemaResult {
pub valid bool
pub errors []string
}承载 valid、errors 等属性的结构体。
valid boolerrors []stringevaluate_json_schema_rawpub fn evaluate_json_schema_raw(output &string, schema_json &string) RawSchemaResult执行 evaluate json schema raw 操作。
output &stringschema_json &stringRawSchemaResult — 该类型的值
evaluate_json_schemapub fn evaluate_json_schema(output &string, rules &[]SchemaFieldRule) SchemaCheckResult执行 evaluate json schema 操作。
output &stringrules &[]SchemaFieldRuleSchemaCheckResult — 该类型的值
expected_calibration_errorpub fn expected_calibration_error(confidences &[]f64, correctness &[]bool, num_bins int) f64执行 expected calibration error 操作。
confidences &[]f64correctness &[]boolnum_bins intf64 — 该类型的值
struct RegressionGateResultpub struct RegressionGateResult {
pub passed bool
pub em_delta f64
pub f1_delta f64
pub rouge_delta f64
pub summary string
}承载 passed、em_delta、f1_delta、rouge_delta、summary 等属性的结构体。
passed boolem_delta f64f1_delta f64rouge_delta f64summary stringcompare_summariespub fn compare_summaries(baseline &EvalSummary, candidate &EvalSummary, max_drop f64) RegressionGateResult执行 compare summaries 操作。
baseline &EvalSummarycandidate &EvalSummarymax_drop f64RegressionGateResult — 该类型的值
format_summary_markdownpub fn format_summary_markdown(name string, s &EvalSummary) string格式化为 summary markdown。
name strings &EvalSummarystring — 结果字符串
format_summary_jsonpub fn format_summary_json(name string, s &EvalSummary) string格式化为 summary json。
name strings &EvalSummarystring — 结果字符串