pub trait LearnModel: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn objective(&self) -> &str;
fn build_episodes(&self, records: &[Record]) -> Vec<Episode>;
fn evaluate(&self, context: &EpisodeContext) -> Outcome;
fn convert(&self, episode: &Episode) -> Result<TrainingData, LearnError>;
// Provided methods
fn convert_batch(&self, episodes: &[Episode]) -> Vec<TrainingData> { ... }
fn build_episodes_from_actions(
&self,
actions: &[ActionEvent],
) -> Vec<Episode> { ... }
}Expand description
学習の統合モデル
何を学習対象とし、何を成功とするかを統合的に定義する。 Record[] から Episode を構築し、TrainingData に変換するまでの全責務を担う。
§Record による統一インターフェース
ActionEvent も LlmDebugEvent も Record として統一的に扱う。
これにより:
- ActionEvent ベースの Learn
- LlmDebugEvent ベースの Learn
- 両方を混ぜた Learn
全て同じインターフェースで実装可能。
Required Methods§
Sourcefn build_episodes(&self, records: &[Record]) -> Vec<Episode>
fn build_episodes(&self, records: &[Record]) -> Vec<Episode>
Record のストリームから Episode を構築
N-gram、Worker単位、任意のグルーピングが可能。 Core が 3-gram までしか取れなくても、Learn は 5-gram や 10-gram を 自由に構築できる。
Sourcefn evaluate(&self, context: &EpisodeContext) -> Outcome
fn evaluate(&self, context: &EpisodeContext) -> Outcome
Records から Success/Failure を判定
純粋なロジック: EpisodeContext (Records) → Outcome build_episodes() 内でこれを呼んで Episode.outcome を設定する。
Sourcefn convert(&self, episode: &Episode) -> Result<TrainingData, LearnError>
fn convert(&self, episode: &Episode) -> Result<TrainingData, LearnError>
Episode を TrainingData に変換
Provided Methods§
Sourcefn convert_batch(&self, episodes: &[Episode]) -> Vec<TrainingData>
fn convert_batch(&self, episodes: &[Episode]) -> Vec<TrainingData>
複数 Episode を一括変換(デフォルト実装)
Sourcefn build_episodes_from_actions(&self, actions: &[ActionEvent]) -> Vec<Episode>
fn build_episodes_from_actions(&self, actions: &[ActionEvent]) -> Vec<Episode>
便利メソッド: ActionEvent[] から直接変換
Implementors§
impl LearnModel for DependencyGraphLearnModel
impl LearnModel for WorkerDecisionSequenceLearn
impl LearnModel for WorkerTaskLearn
impl<F> LearnModel for DpoLearnModel<F>
LearnModel trait の実装(Record ベースの Episode 構築用)
DPO は通常、既存の Episode を比較するため、build_episodes は空を返す。 実際の DPO ペア生成は build_pairs メソッドを使用。