跳至主要內容

指南

SDK 參考

oloproof 和 oloproof.evaluators 套件匯出的每個名稱,附帶其簽章、它是同步還是非同步的,以及它回傳什麼。如需引導式介紹,請先閱讀 Python API。

只有這兩個套件是公開介面。從 oloproof_core 匯入的任何東西都是引擎內部實作,可能在不另行通知的情況下改變。下面的每個函式都在本機針對專案的儲存執行;除非你傳入的某個評估器呼叫了模型提供者,否則它們都不會把資料發送到任何地方。

執行評估

evaluate 與 aevaluate

def evaluate(*, system, dataset, evaluators, policy=None, **kwargs) -> EvaluationResult
async def aevaluate(*, system, dataset, evaluators, policy=None, **kwargs) -> EvaluationResult
參數類型它是什麼
system一個 @system 函式、一個 @rag_system 類別或實例,或一個可呼叫物件被測系統。
dataset路徑一個 JSONL 套件。見套件。
evaluators清單來自 oloproof.evaluators 的實例,或 @evaluator 函式。
policyrelease.yaml 的路徑、一個 ReleasePolicy,或 None發布政策。None 不執行閘門:result.gate 為 None,什麼都不決策。
concurrencyConcurrencyConfig 或像 {"system": 8, "judge": 4} 這樣的對映同時進行的呼叫數。
slices字串清單探索性切片,與 oloproof.yaml 中相同。
min_slice_support整數符合條件的案例少於這個數時,切片沒有區間。預設 30。
replicates整數每個案例量測這麼多次。預設 1。
code_pathsglob 模式清單系統在其模組及其匯入的專案模組之外讀取的檔案,相對於工作目錄;其內容會進入系統的版本,如同 oloproof.yaml 中的 system.code_paths。在這裡或 @system 上宣告,不要兩處都宣告。

evaluate 是同步的。在沒有執行中的事件迴圈時呼叫,它使用 asyncio.run;在執行中的迴圈內部呼叫時(筆記本、非同步測試),它在一個單獨的執行緒上執行評估並阻塞直到完成,所以在兩種場合都可以安全使用。aevaluate 是協程;在非同步程式碼中 await 它。

其餘的關鍵字參數(metrics、store、predictive、event_sink、retry_policy、traffic_draw_id)接受來自 oloproof_core 的引擎類型,不屬於穩定介面。

from oloproof import evaluate, system, current_case
from oloproof.evaluators import ExactMatch, evaluator

@system(name="support-bot", version="1")
def answer(case):
    current_case().usage(input_tokens=12, output_tokens=3)
    return {"label": "refund" if "refund" in case["question"].lower() else "other"}

@evaluator(criterion="short_label")
def short_label(case):
    return len(case.output["label"]) <= 6

result = evaluate(
    system=answer,
    dataset="cases.jsonl",
    evaluators=[ExactMatch(criterion="correct_label", field="label"), short_label],
)
for metric in result.metrics:
    print(metric.metric, metric.estimate, metric.interval, metric.n_observed, metric.n_missing)

在一個兩案例的套件上不帶政策執行,印出:

correct_label 1.0 lower=0.15811388300841903 upper=1.0 2 0
short_label 1.0 lower=0.15811388300841903 upper=1.0 2 0

EvaluationResult

成員類型它是什麼
run執行記錄已儲存的執行,帶有它的 id、狀態和完整性。
suite、system、evaluators版本記錄這次執行所量測的確切版本。
metrics指標結果的元組每個準則和宣告的指標一個:metric、estimate、interval、n_total、n_eligible、n_observed、n_missing、exclusions、method。
gate閘門結果或 None有政策時:release_action、exit_code、decisions 和 reasons。
decisions元組閘門的決策,沒有政策時為空。
cases()清單每個案例及其執行和評判結果。
failures()清單沒有完成、出錯或至少在一個評估器上失敗的案例。
print(stderr=False)無oloproof run 印出的終端機報告。
to_bundle(path)路徑寫出一個可移植的證據包,與 oloproof export 相同。

狀態、原因代碼和計數的意義見結果與執行。

evaluate_comparison 與 aevaluate_comparison

def evaluate_comparison(*, candidate_system, baseline_system, dataset, evaluators, policy, **kwargs) -> ComparisonEvaluationResult
async def aevaluate_comparison(*, candidate_system, baseline_system, dataset, evaluators, policy, **kwargs) -> ComparisonEvaluationResult

以同一個帶種子的順序在同一個套件上執行兩個系統,並對政策中的比較規則作出決策。policy 是必需的,並且必須至少包含一條 superiority、non_inferiority 或 equivalence 規則,否則呼叫會拋出設定錯誤。額外的關鍵字參數:concurrency、replicates,以及引擎類型的 metrics、store 和 retry_policy。同步和非同步的行為與 evaluate 相同。

ComparisonEvaluationResult 包含 candidate 和 baseline(各為一個 EvaluationResult)以及 comparison,後者帶有配對差異及其決策。見比較兩個版本。

宣告系統

@system

def system(func=None, *, name=None, version=None, config=None, timeout_s=None, records=(), simulated_user=None, per_step=False)

可以直接使用(@system),也可以帶參數使用(@system(name=..., version=...)),或者對一個物件呼叫(system(model.answer, version="v2"))。函式接收的是案例的 input 物件,而不是整個案例,並回傳評估器讀取的輸出。它可以是 def 或 async def;同步函式在工作執行緒上執行。

參數預設值它是什麼
name函式的名稱版本身份的一部分。
version無對於綁定方法或可呼叫物件是必需的,因為它們的行為取決於 Oloproof 看不到的狀態。
config空與版本一同記錄的設定。
timeout_s120每次呼叫的時限。逾時的呼叫會被記錄為逾時的執行。
records空系統記錄的產物類型,例如 retrieval/v1。如果某個評估器需要一個系統沒有宣告的類型,它會在執行開始之前被拒絕。
simulated_user無扮演每個案例角色設定的 UserSimulator;見下文。如此系統無需宣告即可記錄 conversation/v1 和 simulated_user/v1。
per_stepFalse對案例 input["steps"] 的每一步呼叫一次函式,傳入 {"observation": ..., "history": [...]},即該步的觀測以及它之前的各步,並把各個回答彙集為 {"steps": [...]}。用於序列離策略評估器。
environment無呼叫之前被重設為每個案例 initial_state 的沙箱(Stateful:reset(state) 與 snapshot());呼叫之後的狀態記錄為 environment_state/v1(EnvironmentState)。同時具有這兩個方法的可呼叫物件就是它自己的環境。
code_paths空系統讀取、而其版本原本不會雜湊的檔案的 glob 模式,相對於工作目錄,例如提示詞檔案或透過計算出的名稱匯入的模組。其內容會進入版本;未指定時版本不變。若在這裡同時又在 evaluate() 或 system.code_paths 中宣告,則會被拒絕。

函式自身模組的原始碼會計入版本摘要,所以編輯它會使快取的執行失效。還有哪些會、哪些不會,見設定參考。

current_case

def current_case() -> CaseRecorder

只有在 Oloproof 呼叫你的系統期間才可用;在其他任何地方它都會拋出 RuntimeError。它的 replicate 屬性說明這次呼叫是該案例的第幾次量測:第一次為 0,之後每多一次重複量測(replicates:)加一,如此環境就能用它為回合設定種子。記錄器的方法:

方法記錄
usage(*, input_tokens=None, output_tokens=None, cost_usd=None)一次模型呼叫的 token 數和成本。省略的值保持未記錄,而不是零。
artifact(kind, data)任意 JSON 值或 Pydantic 模型,歸入 trace 或 conversation/v1 這樣的類型下。
retrieval(retrieval)檢索器回傳的排序後的候選(retrieval/v1)。
context(context)為生成組裝的脈絡(context/v1)。
citations(ids)回答引用的 id,形式為 doc_id 或 doc_id#chunk_id(citations/v1)。
agent_trajectory(trajectory)代理的步驟、工具呼叫和結果,以及檢查點(agent_trajectory/v1)。
rl_episode(episode)一個強化學習回合:每一步的獎勵與成本,以及它是否成功(rl_episode/v1)。
media(items)以參照記錄的影像、音訊或影片:每個檔案在哪裡、它的類型、大小與 sha256,以及它是系統接收的、產生的還是被提供的(media/v1)。內容留在原處。

系統宣告了模擬使用者時,simulated_user() 回傳該案例的 SimulatedUser,否則拋出 RuntimeError。

每個方法都回傳一個 ArtifactRef(usage 除外,它什麼都不回傳)。media_file(path) 為一個本機檔案建置 MediaItem,帶有它的 file:// URI、大小、摘要值與檔名;read_media(item) 回傳其位元組,如果它們不是記錄下來的位元組就會拋出例外。為了建置這些記錄,匯出了以下有類型的酬載:Retrieval、Passage、Context、ContextItem、DroppedItem、Citations、StageTimings、AgentTrajectory、AgentStep、AgentCheckpoint、AgentConstraintCheck、RLEpisode、EpisodeStep、Media、MediaItem,以及類型名 CONVERSATION(conversation/v1)。

模擬使用者

UserSimulator(*, provider, model, api_key_env=None, base_url=None, temperature=0.7, max_tokens=300, timeout_s=60.0, max_turns=8, persona_field="persona", instructions=None)

扮演每個案例角色設定的模型,帶有 system.simulated_user 的各項設定(設定參考);provider 是提供者名稱或提供者物件。它的 digest 是每次執行的快取鍵所攜帶的版本。Persona(description、goal、facts、opening、max_turns)從每個案例的輸入中讀取。

系統保留自己的迴圈,並與該案例的 SimulatedUser 對話:

user = current_case().simulated_user()
message = user.opening()
while message is not None:
    message = user.reply(my_assistant.answer(message))
方法作用
opening()使用者的第一則訊息:角色設定的 opening,或由它的模型寫出的一則訊息。
reply(answer)接收系統對上一則訊息的回答,並回傳下一則訊息;使用者停止後回傳 None。
end(answer)接收系統的最後一個回答,並從系統一方結束對話,就像轉接(handoff)那樣。
aopening()、areply(answer)、aend(answer)同上,以 await 方式呼叫,用於 async def 系統;這類系統不得呼叫阻塞版本。
turns、ended使用者已傳送多少則訊息,以及是什麼結束了對話(goal_reached、user_left、turn_limit、system_ended);對話仍在進行時為 None。

Oloproof 把經過它的對話記錄為 conversation/v1,並把對話如何結束、哪個模擬使用者扮演了哪個角色設定,以及它消耗的 token 記錄為 simulated_user/v1(SimulatedUserRecord,類型名 SIMULATED_USER)。最後一則訊息沒有得到回答時,對話以 unanswered 結束,且對話被截斷。系統自己記錄這兩種類型中的任何一種,或不按順序呼叫該協定,都會停止執行(結束代碼 2)。重試之後仍失敗的模型呼叫會以 SimulatedUserError 使該案例失敗,即使系統捕捉了它也是如此。

@rag_system

def rag_system(*, name, depth, top_k, token_budget=None, index_version=None, version=None, config=None, citations_path="citations")

一個類別裝飾器。該類別提供 retrieve(input, depth) 和 generate(input, context),設定了 token_budget 時還要提供 count_tokens(passage)。context 是經過 top_k 和預算篩選後留下的 Passage 物件清單,按排名順序排列。Oloproof 自己記錄 retrieval/v1、context/v1、citations/v1 和 stage_timings/v1,並分別快取每個階段。citations_path 指明保存回答所引用 id 的輸出欄位。見 RAG。

run_langgraph 與 arun_langgraph

def run_langgraph(graph, graph_input, config=None, *, messages_key="messages", record_state=True, agent_per_node=False, output=None, terminal_status=None)

在宣告了 records=["agent_trajectory/v1"] 的 @system 函式中執行一個已編譯的 LangGraph 圖,把它的 agent_trajectory/v1 記錄到目前的案例上,並回傳它的輸出。工具呼叫、工具結果和 AI 訊息成為步驟;不新增訊息的節點成為一個 observation;每個步驟在 metadata.node 中寫明它的節點,節點寫入狀態的內容保存在 metadata.state_update 中(record_state 接受 True、False 或一個鍵清單)。agent_per_node=True 用每個步驟的節點為其代理命名。output(state) 選出回答(預設:最後一則訊息的內容),terminal_status(state) 回傳 success、failure、unknown 或 None。因遞迴上限而停止的執行被記錄為截斷。arun_langgraph 是用於非同步系統的同一函式。trajectory_from_updates(updates, ...) 從你已經用 stream_mode="updates" 串流取得的區塊建構軌跡。不從 LangGraph 匯入任何東西。見代理。

評估器

所有類別都在 oloproof.evaluators 中。每個類別的 criterion 指明它產生的指標。每個評估器讀取哪些產物,以及它在 YAML 中的對應寫法,見設定參考中的評估器表。

類別簽章
ExactMatch(*, criterion, field=None, expected_field=None, strip=True, casefold=False)
Contains(*, criterion, field=None, expected_field=None)
Regex(*, criterion, pattern, field=None, pass_if="match")
JsonSchema(*, criterion, schema, field=None)
RubricJudge(*, criterion, provider, model, rubric_text=None, rubric_file=None, api_key_env=None, base_url=None, temperature=0, max_tokens=512, timeout_s=60.0, media="none", media_base=None, audio="transcribe", transcriber=None, video_frames=4)
Transcriber(*, model, base_url="https://api.openai.com/v1", api_key_env="OPENAI_API_KEY", timeout_s=120.0),為 RubricJudge 的音訊做語音轉文字
Groundedness(*, provider, model, criterion="groundedness", **options)
CitationSupport(*, provider, model, criterion="citation_support", **options)
CitationValidity(*, criterion="citations_valid", require_citations=False)
HitRate、Recall(k=None, *, criterion=None, relevance_unit="doc"),k 預設為 5
MRR、NDCG(k=None, *, criterion=None, relevance_unit="doc"),k 預設為 10
AgentMaxSteps(max_steps, *, criterion=None)
AgentToolCalled(tool_name, *, min_calls=1, criterion=None)
AgentNoToolLoop(*, max_repeats=2, criterion="agent_no_tool_loop")
AgentToolSequence(*, ordered=True, criterion="agent_tool_sequence")
AgentNoUndeclaredTool(*, criterion="agent_no_undeclared_tool")
AgentConstraintsSatisfied(constraints=(), *, criterion="agent_constraints_satisfied")
AgentRoute(*, criterion="agent_route")
AgentToolPermissions(permissions, *, criterion="agent_tool_permissions")
AgentMaxHandoffs(max_handoffs, *, criterion=None)
StateMatches(*, criterion="state_matches", paths=None, mode="exact", tolerance=None, expected_field="state")
StateUnchanged(*, paths, criterion="state_unchanged")
FaultRecovery(*, tool, fault, occurrence=1, escalate_tools=(), criterion=None)
MetamorphicRelation(relation, *, transform=None, field=None, checked=False, criterion=None)
EpisodeReturn(return_range, *, discount=1.0, criterion="episode_return")
EpisodeSuccess(*, criterion="episode_success")
EpisodeCostWithin(budget, *, criterion=None)
OffPolicyValue、OffPolicyImprovement(reward_range, *, propensity_floor, criterion, probabilities_field="probabilities")
SequentialOffPolicyValue、SequentialOffPolicyImprovement(reward_range, *, propensity_floor, horizon, discount=1.0, criterion, probabilities_field="probabilities")
CanaryAbsent(*, criterion, canary=None, tool_calls=False)
PersonalDataAbsent(*, criterion, kinds=KINDS, patterns=None, allow=())
MemorizedAbsent(*, criterion, protected=(), min_length=50)
MediaCheck(*, criterion, role="output", kind="any", formats=None, min_width=None, max_width=None, min_height=None, max_height=None, min_duration_s=None, max_duration_s=None, min_bytes=None, max_bytes=None, media_base=None)
ImageMatchesReference(*, criterion, reference_file=None, reference_field=None, max_distance=8, role="output", media_base=None)
ConversationCompleted(*, criterion="conversation_completed")
ConversationJudge與 RubricJudge 相同
EveryTurn(*, criterion="every_turn", contains=(), not_contains=(), regex=None, not_regex=None, max_chars=None, casefold=False)
GoalReached(*, criterion="goal_reached")
TurnsToGoal(max_turns, *, criterion=None)
PredictiveCorrect、PredictiveRecall、PredictivePrecision(*, criterion, positive=True, field="label", expected_field="label")
AbsoluteError(*, criterion, target_range, field="label", expected_field="label")
Brier、PredictiveRanking(*, criterion, positive=True, field="score", expected_field="label")
LogLoss(*, clip, criterion, positive=True, field="score", expected_field="label")
CustomEvaluator(func, *, criterion, reads=("output", "expected"), cacheable=False, version=None, value_type="binary", score_range=None)

provider 是 "anthropic"、"openai" 或 "openai_compatible"。評審從 api_key_env 指定的環境變數中讀取金鑰(預設為 ANTHROPIC_API_KEY 或 OPENAI_API_KEY),並由該提供者計費。Groundedness 和 CitationSupport 透過 **options 接受 RubricJudge 的其餘設定。機率評審、模型分類器和串聯(cascade)沒有 SDK 類別;它們只存在於 YAML 中。

ConversationCompleted、ConversationJudge 和 EveryTurn 讀取 conversation/v1 產物,它由你的系統記錄,或者對於帶有模擬使用者的系統,由 Oloproof 記錄;GoalReached 和 TurnsToGoal 讀取模擬使用者的 simulated_user/v1。Oloproof 不驅動對話:你的應用執行每一輪。見代理。

@evaluator

def evaluator(*, criterion, reads=("output", "expected"), cacheable=False, version=None, value_type="binary", score_range=None)

把一個單參數(即案例)的函式包裝成一個 CustomEvaluator。案例具有 output、expected 和 scenario,而 artifacts(name) 回傳某個已記錄類型的酬載。函式可以是 def 或 async def。二元評估器回傳 True 或 False;分數評估器宣告 value_type="score" 和 score_range=(low, high),並回傳一個數字。函式擲出的例外會把該案例在這個準則上記為缺失,而絕不會記為失敗。

reads 必須列出函式讀取的每個欄位(input、output、expected、metadata、metadata.<key> 或 artifacts.<name>),因為快取的評判結果正是以這些欄位為鍵的。只有在 cacheable=True 時,評判結果才會在多次執行之間被重複使用。定義模組的原始碼會計入版本,所以編輯它會使這些評判結果失效。YAML 無法指定自訂評估器。

自訂評估器即使函式是確定性的,也和評審器一樣屬於需要測量的類型:Oloproof 無法看出這一點,因此在 require_validated_evaluators(預設)下,其規則會給出 INSUFFICIENT_EVIDENCE 和 evaluator_not_validated,直到人工標籤驗證它(oloproof review RUN --criterion NAME --by YOU)。若只讀取巢狀欄位的檢查想避免這種情況,請使用帶欄位路徑的 exact_match、contains 或 regex(field: choices.0.message.content,見設定);它們無需測量。

診斷

diagnose 與 adiagnose

def diagnose(run_id, **kwargs) -> InterventionResult
async def adiagnose(run_id, *, system, evaluators, intervention, criterion, control=True, top_k=None, reranker=None, reranker_root=None, store=None, concurrency=None) -> InterventionResult

在一種介入下重新執行已儲存執行中失敗的案例:"gold-context"、"top-k"(配合 top_k)或 "reranker"(配合 reranker)。system 和 evaluators 必須是該執行所用的版本;不同的版本會在任何執行之前被拒絕。使用 control=True 時,會在介入旁邊執行一個全新的對照樣本,從而把變更與執行之間的波動區分開。diagnose 是同步形式,在執行中的迴圈內部的行為與 evaluate 相同。工作流程見 RAG。

InterventionResult 保存父執行 id、介入、它是否受支援、介入執行和對照執行、每個案例的結果,以及在生成了報告時由 CaseDiagnosis 條目組成的 DiagnosisReport。

代理重播

def supports_replay(system) -> bool
def checkpoint_for(trajectory, step_index) -> AgentCheckpoint | None
async def replay_case(system, *, scenario_id, trajectory, checkpoint, change) -> ReplayOutcome
def label_case(outcome) -> CaseDiagnosis
def label_cases(outcomes) -> tuple[CaseDiagnosis, ...]
def unnecessary_steps(labels) -> tuple[UnnecessaryStep, ...]

重播是你的系統做的事,而不是 Oloproof 模擬的事。系統只有透過實作 async def replay(self, trajectory, *, checkpoint, change) -> AgentTrajectory,回傳代理從檢查點開始所做的事,才能支援重播;Oloproof 把記錄下來的前綴拼接上去並進行比較。你的應用負責其狀態、工作階段和工具副作用,包括在重播之前重設它們。supports_replay 報告一個系統是否宣告了該方法。

replay_case 是一個協程:await 它,或透過 asyncio.run 呼叫它。它在重播之前執行一個對照(使用 ReplayChange(kind="resume") 的同一個檢查點),當對照無法重現記錄時,不會嘗試重播。change 是 ReplayChange(kind="drop_step", step_index=...) 或 ReplayChange(kind="resume")。checkpoint_for 選取嚴格位於某一步之前的最新記錄檢查點,或者 None,在後一種情況下,結果會以 no_checkpoint_recorded 被丟棄,而不觸及系統。

注入故障時,ReplayChange(kind="inject_fault", step_index=..., fault="error")(或 "timeout"、"malformed")要求一個 Replayable 系統讓該步記錄的工具呼叫回傳 FAULT_RESULTS[fault],而不是執行工具。未為該呼叫恰好記錄這一結果的重播會以 replay_did_not_inject_the_fault 被捨棄。FaultRecovery 為每個案例執行一次,並讀取代理隨後做了什麼。

ReplayOutcome 帶有 scenario_id、change、重播和對照的終止狀態,以及當該案例沒有產生證據時帶原因的 discarded。被丟棄的案例不是失敗的案例。label_case 把一個結果轉換為帶有 FailureLabel 及其 LabelReason 的 CaseDiagnosis;unnecessary_steps 列出去掉後結果不變的步驟。見代理。

人工標籤與評估器信任

def record_label(*, run_id, scenario_id, criterion, passed, labelled_by, note=None, purpose="measurement", sample_index=0, config="oloproof.yaml", store=None, ...) -> HumanLabel

儲存一個人對已儲存執行中某個案例給出的通過/失敗結論。標籤供 oloproof evaluators validate 使用,它量測評審與標籤的一致性(AgreementResult)並記錄其狀態(RegistryEntry)。其餘的 measurement_sample_* 參數把標籤綁定到一個量測樣本;CLI 的 oloproof labels export 和 oloproof labels import 會為你填寫它們。見評審。

def paired_sample(store, *, candidate_run_id, baseline_run_id, criterion, labels, size, requested_by) -> PairedDraw
def record_paired_preference(store, draw, *, scenario_id, preferred, labelled_by, note=None) -> PreferenceLabel
def record_paired_verdict(store, draw, *, scenario_id, candidate_passed, baseline_passed, labelled_by, note=None) -> PairedLabel

paired_sample 在本機上從基準執行完成的案例中抽取隨機樣本,並為每個案例擲一枚硬幣決定先顯示哪個答案(labels="preference" 或 "pass_fail");對同樣的執行、準則與類型,無論之後要求多大的規模,都會再次傳回第一次抽取。record_paired_preference 在其中一個案例上記錄一個偏好("candidate"、"baseline" 或 "tie"),並帶上抽取的硬幣所定的位置;record_paired_verdict 為 "pass_fail" 抽取記錄每次執行上的通過或不通過,供 human_difference 指標讀取。本機抽取屬於善意,oloproof review --against 也是如此。見評審。

在測試中斷言門檻

def assert_gate(result: EvaluationResult | ComparisonEvaluationResult) -> None

結果的門檻阻擋發布,或沒有政策作出決定時,拋出 AssertionError;門檻只發出警告時,用 GateWarning 警告;允許時靜默返回。訊息列出每條未通過的規則,以及它的估計值、範圍和門檻。參見 Python API。

在筆記本中分析 Inspect 日誌

def analyze_inspect(log, *, scale=None, policy=None, project=".", judge=None) -> InspectAnalysis

將 UK AISI Inspect 日誌匯入位於 project 的專案(若其中沒有 oloproof.yaml,則在那裡寫入一個),與 oloproof scores import --from inspect LOG 的做法相同:多個 epoch 取每個樣本的平均,樣本是單位。scale 是數值評分器的範圍,policy 像該命令一樣判定執行。回傳的 InspectAnalysis 包含 run_id、methods(方法段落)、table(Markdown)與 files(figure.svg、table.md、table.tex、methods.md,即 oloproof report RUN --paper DIR 寫出的檔案);write(directory) 儲存它們,筆記本中會顯示圖、表格與段落。每個數字都來自儲存的執行,段落由記錄的事實組成,絕不由模型產生。參見對另一個工具的分數提出第二意見。

在程式碼中編寫政策

ReleasePolicy、IntervalThresholdRule、ObservedCountRule 和 DecisionRule(前兩者的聯合)無需檔案即可建置政策。它們的欄位就是設定參考中 release.yaml 的欄位;區間規則使用 direction(min 或 max)和 threshold,而不是 min: 或 max:。比較規則沒有匯出的類別;把它們寫在 release.yaml 中並傳入其路徑。

from oloproof import IntervalThresholdRule, ReleasePolicy

policy = ReleasePolicy(
    rules=(IntervalThresholdRule(id="accuracy", metric="correct_label", direction="min", threshold=0.8),),
)

其他匯出

名稱它是什麼
ConcurrencyConfigsystem 和 judge 的限制,與 oloproof.yaml 中相同。
TransientError在系統中帶 retryable=True 拋出它,讓呼叫以退避方式重試。
ConfigError在無法讀取設定、資料集或政策時,於任何執行之前拋出;捕捉它即可區分設定錯誤與失敗的執行。
ArtifactRef記錄產物時回傳的引用:它的類型和摘要。
__version__已安裝的軟體套件版本。