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.