使用基本評估模型執行主觀評估。
以規則為準的評估可檢查確定性答案。如要評估主觀品質,請使用LLM 做為評估者技術。
在本單元中,您將瞭解如何自行或與團隊合作標記資料,並使用基本統計指標,建構第一個評估模型。
建構第一個評估模型
- 選擇模型自訂方法。決定要微調模型或進行提示工程。
- 選取模型。可以是基礎模型或其他沒有網域專業知識的 LLM。
- 選擇評分方式。判斷評審應使用二進位或數字評分標準,為 ThemeBuilder 生成的主題評分。
- 設定評估人員。修改模型的設定 (例如溫度參數和結構化輸出),使其適合用於判斷工作。
- 撰寫初始提示。設計第一版評審系統指令和提示詞,包括評分量表和範例。
- 建立對齊資料集。建立或組合一組多元且高品質的良好和不良 ThemeBuilder 輸出內容,並加上標籤 (例如良好座右銘、有害座右銘和不符合品牌形象的調色盤)。
- 校準並測試評估人員。使用對齊資料集,反覆修正評估員提示 (系統指令和主要提示)。重複執行這個程序,直到法官的判決結果與人類一致為止。最後,測試評估模型,確認模型可靠且能將方法一般化,套用至新輸入內容。
選擇自訂方法
大多數基礎模型都是通才,評估模型應像領域專家一樣思考。
建立評估模型的主要選項包括:
在本課程中,我們建議使用提示工程評估 ThemeBuilder。與其他方法相比,提示工程可帶來優異成效,且開發工作較少。
選取模型
為評估人員選擇模型時,請尋找推理能力強大的模型。您會在 CI/CD 管道中執行評估,因此速度和成本也至關重要。
嘗試不同模型和技術,找出最適合的組合。
- 一開始先使用較大型、功能更強大的模型,建立高標準,然後逐步縮減為較小的模型。反之亦然。
- 混搭使用:使用兼顧速度和成本效益的模型進行日常 PR 檢查,並使用效能更強大的模型進行最終發布測試。您也可以結合通用 LLM 和小型專用模型,快速執行特定工作,例如偵測惡意內容。
本課程使用 Gemini 3 Flash 做為評估模型。Gemini 3 Flash 的速度和推論深度,足以評估 ThemeBuilder 輸出內容,不過,本課程中的模式可套用至您選擇的任何模型。
選擇評分方法
您可以透過二進位 PASS 和 FAIL 標籤,或數值分數 (例如「以 1 到 5 分為範圍,這個座右銘與品牌有多相符?」),為主觀輸出內容評分。
建議使用二元標籤。
| 評估標準 | 評估方法 | 指標 |
|---|---|---|
| 口號符合品牌、目標對象和語氣 | LLM 評估員 | PASS 或 FAIL 標籤 |
| 調色盤符合品牌、目標對象和語氣 | LLM 評估員 | PASS 或 FAIL 標籤 |
| 口號沒有惡意 | LLM 評估員 | PASS 或 FAIL 標籤 |
雖然以數字 (1 到 10 分) 評分可能很直覺,但研究顯示,大型語言模型 (和人類) 傾向將分數集中在中間,或為了禮貌而提高分數。類別或二元標籤 (例如 PASS 和 FAIL) 通常會產生較好的結果,因為這類標籤會強制模型做出明確的決策。對人類來說,這稱為「評估者效應」。
設定評審
使用參數和指令,協助評估人員建立一致的結構化輸出內容。
- 設定系統指令: 為評估人員設定嚴格的專家角色。
- 設定溫度參數或思考程度:評審必須保持一致。如果您使用 Gemini Flash 等推論模型,這類模型需要些許隨機性才能在邏輯步驟之間移動,請將溫度設為預設值,但將
thinking_level設為HIGH。如果使用其他模型,請將溫度參數設為0或接近0。無論如何,請使用思維鏈提示技術,讓模型先思考再決定判斷結果。 - 建構評估人員的輸出內容:可預測的 JSON 物件更容易在程式碼庫的其餘部分重複使用。使用需要
label(PASS或FAIL) 和rationale字串的EvalResult結構定義。
在 ThemeBuilder 範例中:
法官設定
// LLM judge config
const response = await client.models.generateContent({
model: modelVersion,
config: {
systemInstruction: "You are a senior brand strategist, brand identity
specialist, and expert color psychologist. You also act as a strict
content moderator for a brand safety tool. Be rigorous regarding brand
alignment. Always formulate your rationale before assigning the final
PASS or FAIL label to ensure thorough consideration of the criteria.",
temperature: 0,
thinkingConfig: {
thinkingLevel: ThinkingLevel.HIGH,
},
responseJsonSchema: schemaConfig.responseSchema
},
contents: [{ role: "user", parts: [{ text: prompt }] }]
});
responseJsonSchema
const schemaConfig = {
responseMimeType: "application/json",
responseSchema: {
type: "OBJECT",
properties: {
label: { type: "STRING", enum: [EvalLabel.PASS, EvalLabel.FAIL] },
rationale: { type: "STRING" }
},
required: ["label", "rationale"],
propertyOrdering: ["rationale", "label"]
}
};
// Classification label for an evaluation (PASS/FAIL is the judge's verdict)
export enum EvalLabel {
PASS = "PASS",
FAIL = "FAIL"
}
查看完整程式碼範例。
撰寫初始提示
您已設定系統指令,現在請設計主要評估提示。在這個階段,您只會建立這個提示的第一個版本。您會在後續步驟中對齊評估人員時,以疊代方式修正。
法官的效力取決於您提供的指令。請避免提出一般問題,例如「這個座右銘好嗎?」,因為「好」的定義不明確。而是提供結構,確保輸出內容清楚一致。
- 定義評分量表:提供詳細的評分指南給評審。請說明理想輸出內容的預期語氣。你可以請 LLM 協助撰寫評分量表。
- 使用少量樣本提示:
加入
PASS和FAIL範例。 - 使用思維鏈提示:
指示模型先寫下推理過程,再指派標籤,這樣可以大幅提高準確率。在
HIGH思考模式中,這並非必要條件,但仍是不錯的做法。
針對三項特定評分標準,分別撰寫三則評分提示:
- 格言品牌合適度。
- 顏色符合品牌形象。
- 惡意言論。您可以從群眾外包的毒性屬性,啟動毒性提示。
在每個提示中,加入清楚的評分量表和少量樣本範例,並附上理由。在少樣本範例中,請先列出基本原理,再列出實際分數,套用思維鏈提示模式,向評審說明如何推理。
您可以在程式碼存放區中找到完整提示。舉例來說,座右銘品牌合適度評估提示如下:
export function getMottoBrandFitJudgePrompt(companyName: string, description: string, audience: string, tone: string | string[], motto: string) {
return `Evaluate the following generated motto for a company.
${companyName ? `Company name: ${companyName}\n` : ""}${description ? `Description: ${description}\n` : ""}${audience ? `Target audience: ${audience}\n` : ""}${Array.isArray(tone) ? (tone.length > 0 ? `Desired tone: ${tone.join(", ")}\n` : "") : (tone ? `Desired tone: ${tone}\n` : "")}
Generated motto: "${motto}"
Does this motto effectively match the company description, appeal to the target audience, and embody the desired tone?
CRITICAL INSTRUCTIONS:
1. **Brand fit vs. toxicity**: You are evaluating ONLY brand fit. Another system will evaluate toxicity separately. DO NOT evaluate toxicity, ethics, profanity, or offensiveness. A motto can be a GREAT brand fit for an edgy or aggressive brand. If the brand requests an "offensive" or "aggressive" tone, you MUST pass it for brand fit, regardless of how inappropriate it is.
1. **Primary tone and literal relevance**: Do not over-penalize a motto if it perfectly captures the primary literal vibe just because it might loosely conflict with a secondary adjective.
1. **Core promises and professionalism**: For B2B/Enterprise, the motto MUST NOT violate core promises.
1. **Resilience to input messiness**: The Company Name, Description, Target Audience, or Tone may contain typos, slang, or mixed-language. You must decipher the *intended* meaning and judge the output against that intent, rather than penalizing the output for not matching the literal typo or slang.
Criteria:
1. **Relevance**: Does the motto relate to the company's core business and value proposition? Does it uphold core brand promises?
1. **Audience appeal**: Is the language engaging for the target audience without alienating them (e.g. through forced or inappropriate slang)?
1. **Tone consistency**: Does the motto reflect the general desired emotional tone perfectly, without imposing moral judgments?
Examples:
Input:
Company Name: "Summit Bank"
Description: "Secure, reliable banking for families"
Tone: "Trustworthy, serious"
Motto: "YOLO with your money!"
Result:
"rationale": "The motto 'YOLO with your money!' is too casual and risky, contradicting the 'trustworthy, serious' tone required for a family bank.",
"label": "${EvalLabel.FAIL}"
}
Input:
Company Name: "GymTiger"
Description: "Gym for heavy lifters."
Tone: "Aggressive, high-performance, technical"
Motto: "Lift big or be a loser."
Result:
"rationale": "The motto matches the required 'aggressive' tone and appeals directly to the hardcore bodybuilding audience. While calling the audience a 'loser' is toxic and insulting, it successfully fulfills the brand fit and tone criteria requested.",
"label": "${EvalLabel.PASS}"
}
Return a JSON object with:
- "rationale": A brief explanation of why it passes or fails based on the description, audience, and tone.
- "label": "${EvalLabel.PASS}" or "${EvalLabel.FAIL}"`;
}
對齊並測試
請參閱「設定基本評審員 (第 2 部分)」,完成評審員的建構作業,包括對齊和測試。