AutoTrain 文件

句子轉換器

您正在檢視的是需要從原始碼安裝。如果您希望使用常規的 pip 安裝,請檢視最新的穩定版本 (v0.8.24)。
Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

句子轉換器

此任務可讓您在自己的資料集上輕鬆訓練或微調句子轉換器模型。

AutoTrain 支援以下型別的句子轉換器微調:

  • pair:包含兩個句子(anchor 和 positive)的資料集
  • pair_class:包含兩個句子(premise 和 hypothesis)和一個目標標籤的資料集
  • pair_score:包含兩個句子(sentence1 和 sentence2)和一個目標分數的資料集
  • triplet:包含三個句子(anchor、positive 和 negative)的資料集
  • qa:包含兩個句子(query 和 answer)的資料集

資料格式

句子轉換器微調接受 CSV/JSONL 格式的資料。您也可以使用 Hugging Face Hub 上的資料集。

pair

對於 pair 訓練,資料應採用以下格式:

anchor 正面
hello
how are you I am fine
What is your name? My name is Abhishek
Which is the best programming language? Python

pair_class

對於 pair_class 訓練,資料應採用以下格式:

premise hypothesis label
hello 1
how are you I am fine 0
What is your name? My name is Abhishek 1
Which is the best programming language? Python 1

pair_score

對於 pair_score 訓練,資料應採用以下格式:

sentence1 sentence2 score
hello 0.8
how are you I am fine 0.2
What is your name? My name is Abhishek 0.9
Which is the best programming language? Python 0.7

triplet

對於 triplet 訓練,資料應採用以下格式:

anchor 正面 負面
hello bye
how are you I am fine I am not fine
What is your name? My name is Abhishek Whats it to you?
Which is the best programming language? Python Javascript

qa

對於 qa 訓練,資料應採用以下格式:

query 答案
hello
how are you I am fine
What is your name? My name is Abhishek
Which is the best programming language? Python

引數

class autotrain.trainers.sent_transformers.params.SentenceTransformersParams

< >

( data_path: str = None model: str = 'microsoft/mpnet-base' lr: float = 3e-05 epochs: int = 3 max_seq_length: int = 128 batch_size: int = 8 warmup_ratio: float = 0.1 gradient_accumulation: int = 1 optimizer: str = 'adamw_torch' scheduler: str = 'linear' weight_decay: float = 0.0 max_grad_norm: float = 1.0 seed: int = 42 train_split: str = 'train' valid_split: typing.Optional[str] = None logging_steps: int = -1 project_name: str = 'project-name' auto_find_batch_size: bool = False mixed_precision: typing.Optional[str] = None save_total_limit: int = 1 token: typing.Optional[str] = None push_to_hub: bool = False eval_strategy: str = 'epoch' username: typing.Optional[str] = None log: str = 'none' early_stopping_patience: int = 5 early_stopping_threshold: float = 0.01 trainer: str = 'pair_score' sentence1_column: str = 'sentence1' sentence2_column: str = 'sentence2' sentence3_column: typing.Optional[str] = None target_column: typing.Optional[str] = None )

引數

  • data_path (str) — 資料集路徑。
  • model (str) — 要使用的預訓練模型的名稱。預設為“microsoft/mpnet-base”。
  • lr (float) — 訓練的學習率。預設為 3e-5。
  • epochs (int) — 訓練輪數。預設為 3。
  • max_seq_length (int) — 輸入的最大序列長度。預設為 128。
  • batch_size (int) — 訓練的批次大小。預設為 8。
  • warmup_ratio (float) — 用於學習率預熱的訓練比例。預設為 0.1。
  • gradient_accumulation (int) — 在更新前累積梯度的步數。預設為 1。
  • optimizer (str) — 使用的最佳化器。預設為“adamw_torch”。
  • scheduler (str) — 使用的學習率排程器。預設為“linear”。
  • weight_decay (float) — 應用的權重衰減。預設為 0.0。
  • max_grad_norm (float) — 用於裁剪的最大梯度範數。預設為 1.0。
  • seed (int) — 用於可復現性的隨機種子。預設為 42。
  • train_split (str) — 訓練資料拆分的名稱。預設為“train”。
  • valid_split (Optional[str]) — 驗證資料拆分的名稱。預設為 None。
  • logging_steps (int) — 日誌記錄之間的步數。預設為 -1。
  • project_name (str) — 用於輸出目錄的專案名稱。預設為“project-name”。
  • auto_find_batch_size (bool) — 是否自動尋找最佳批次大小。預設為 False。
  • mixed_precision (Optional[str]) — 混合精度訓練模式(fp16、bf16 或 None)。預設為 None。
  • save_total_limit (int) — 要儲存的最大檢查點數量。預設為 1。
  • token (Optional[str]) — 用於訪問 Hugging Face Hub 的令牌。預設為 None。
  • push_to_hub (bool) — 是否將模型推送到 Hugging Face Hub。預設為 False。
  • eval_strategy (str) — 使用的評估策略。預設為“epoch”。
  • username (Optional[str]) — Hugging Face 使用者名稱。預設為 None。
  • log (str) — 用於實驗跟蹤的日誌記錄方法。預設為“none”。
  • early_stopping_patience (int) — 訓練在沒有改進的情況下停止的輪數。預設為 5。
  • early_stopping_threshold (float) — 用於衡量新最優值的閾值,以確定是否為改進。預設為 0.01。
  • trainer (str) — 要使用的訓練器的名稱。預設為“pair_score”。
  • sentence1_column (str) — 包含第一個句子的列的名稱。預設為“sentence1”。
  • sentence2_column (str) — 包含第二個句子的列的名稱。預設為“sentence2”。
  • sentence3_column (Optional[str]) — 包含第三個句子的列的名稱(如果適用)。預設為 None。
  • target_column (Optional[str]) — 包含目標變數的列的名稱。預設為 None。

SentenceTransformersParams 是一個配置類,用於設定訓練句子轉換器的引數。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.