pub struct TrainingData {
pub system: Option<String>,
pub prompt: String,
pub chosen: String,
pub rejected: Option<String>,
pub format: TrainingFormat,
pub metadata: TrainingMetadata,
}Expand description
LoRA 学習用データ形式
DPO/SFT 両対応を想定した設計。 初期実装は SFT のみで開始し、データが蓄積されたら DPO に移行予定。
Fields§
§system: Option<String>システムプロンプト(オプション)
prompt: String入力プロンプト(ユーザー入力)
chosen: String選択された応答(成功ケース)
rejected: Option<String>拒否された応答(失敗ケース、DPO 用) SFT の場合は None
format: TrainingFormat学習形式
metadata: TrainingMetadataメタデータ
Implementations§
Source§impl TrainingData
impl TrainingData
Sourcepub fn sft(system: &str, prompt: &str, response: &str) -> TrainingData
pub fn sft(system: &str, prompt: &str, response: &str) -> TrainingData
SFT 形式のデータを作成(システムプロンプト付き)
§Arguments
system- システムプロンプトprompt- ユーザープロンプトresponse- アシスタントレスポンス(chosen)
Sourcepub fn sft_simple(prompt: &str, response: &str) -> TrainingData
pub fn sft_simple(prompt: &str, response: &str) -> TrainingData
Sourcepub fn dpo_with_system(
system: &str,
prompt: &str,
chosen: &str,
rejected: &str,
) -> TrainingData
pub fn dpo_with_system( system: &str, prompt: &str, chosen: &str, rejected: &str, ) -> TrainingData
DPO 形式のデータを作成(システムプロンプト付き)
Sourcepub fn with_episode_id(self, episode_id: String) -> TrainingData
pub fn with_episode_id(self, episode_id: String) -> TrainingData
Episode ID を設定
Sourcepub fn with_outcome_score(self, score: f64) -> TrainingData
pub fn with_outcome_score(self, score: f64) -> TrainingData
Outcome スコアを設定
Sourcepub fn with_model(self, model: &str) -> TrainingData
pub fn with_model(self, model: &str) -> TrainingData
モデル名を設定
Sourcepub fn with_lora(self, lora: Option<String>) -> TrainingData
pub fn with_lora(self, lora: Option<String>) -> TrainingData
LoRA 名を設定
Sourcepub fn with_strategy(self, strategy: &str) -> TrainingData
pub fn with_strategy(self, strategy: &str) -> TrainingData
Strategy 名を設定
Sourcepub fn with_scenario(self, scenario: &str) -> TrainingData
pub fn with_scenario(self, scenario: &str) -> TrainingData
シナリオ名を設定
Sourcepub fn with_custom(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> TrainingData
pub fn with_custom( self, key: impl Into<String>, value: impl Into<String>, ) -> TrainingData
カスタムメタデータを追加
Sourcepub fn is_valid_dpo(&self) -> bool
pub fn is_valid_dpo(&self) -> bool
DPO として有効かどうか(rejected も必要)
Source§impl TrainingData
impl TrainingData
Sourcepub fn to_conversation(&self) -> ConversationData
pub fn to_conversation(&self) -> ConversationData
Conversation 形式に変換
Trait Implementations§
Source§impl Clone for TrainingData
impl Clone for TrainingData
Source§fn clone(&self) -> TrainingData
fn clone(&self) -> TrainingData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TrainingData
impl Debug for TrainingData
Source§impl<'de> Deserialize<'de> for TrainingData
impl<'de> Deserialize<'de> for TrainingData
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrainingData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrainingData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&TrainingData> for ConversationData
impl From<&TrainingData> for ConversationData
Source§fn from(data: &TrainingData) -> ConversationData
fn from(data: &TrainingData) -> ConversationData
Converts to this type from the input type.
Source§impl Serialize for TrainingData
impl Serialize for TrainingData
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for TrainingData
impl RefUnwindSafe for TrainingData
impl Send for TrainingData
impl Sync for TrainingData
impl Unpin for TrainingData
impl UnwindSafe for TrainingData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more