Skip to main content

LearnModel

Trait LearnModel 

Source
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§

Source

fn name(&self) -> &str

名前

Source

fn objective(&self) -> &str

目的を表す説明

Source

fn build_episodes(&self, records: &[Record]) -> Vec<Episode>

Record のストリームから Episode を構築

N-gram、Worker単位、任意のグルーピングが可能。 Core が 3-gram までしか取れなくても、Learn は 5-gram や 10-gram を 自由に構築できる。

Source

fn evaluate(&self, context: &EpisodeContext) -> Outcome

Records から Success/Failure を判定

純粋なロジック: EpisodeContext (Records) → Outcome build_episodes() 内でこれを呼んで Episode.outcome を設定する。

Source

fn convert(&self, episode: &Episode) -> Result<TrainingData, LearnError>

Episode を TrainingData に変換

Provided Methods§

Source

fn convert_batch(&self, episodes: &[Episode]) -> Vec<TrainingData>

複数 Episode を一括変換(デフォルト実装)

Source

fn build_episodes_from_actions(&self, actions: &[ActionEvent]) -> Vec<Episode>

便利メソッド: ActionEvent[] から直接変換

Implementors§

Source§

impl LearnModel for DependencyGraphLearnModel

Source§

impl LearnModel for WorkerDecisionSequenceLearn

Source§

impl LearnModel for WorkerTaskLearn

Source§

impl<F> LearnModel for DpoLearnModel<F>
where F: Fn(&Episode) -> Option<(String, String)> + Send + Sync,

LearnModel trait の実装(Record ベースの Episode 構築用)

DPO は通常、既存の Episode を比較するため、build_episodes は空を返す。 実際の DPO ペア生成は build_pairs メソッドを使用。