Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZingLix committed Jan 11, 2024
1 parent 39adfe7 commit e5cc562
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 12 deletions.
57 changes: 56 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,59 @@ $ qianfan dataset view [OPTIONS] DATASET
* `--row TEXT`:待预览的数据集行。用 `,` 分隔数个行,用 `-` 表示一个范围 (e.g. 1,3-5,12)。默认情况下仅打印前 5 行,可以通过 `--row all` 来打印所有数据。
* `--column TEXT`:待预览的数据集的列。用 `,` 分隔每个列名称。 (e.g. prompt,response)
* `--raw`:展示原始数据。
* `--help`:展示帮助文档。
* `--help`:展示帮助文档。

## trainer 训练

**用法**:

```console
$ qianfan trainer [OPTIONS] COMMAND [ARGS]...
```

**Options 选项**:

* `--help`:展示帮助文档

**Commands 命令**:

* `run`:运行 trainer 任务

### run

运行 trainer 任务

**用法**:

```console
$ qianfan trainer run [OPTIONS]
```

**Options 选项**:

* `--train-type TEXT`:训练类型 [required]
* `--dataset-id INTEGER`:数据集 id [required]
* `--help`:展示帮助文档

训练相关配置,参数含义与 [训练 API 文档](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/mlmrgo4yx#body%E5%8F%82%E6%95%B0) 中对应参数含义一致:

* `--train-epoch INTEGER`:训练轮数
* `--train-batch-size INTEGER`:训练每轮 batch 的大小
* `--train-learning-rate FLOAT`:学习率
* `--train-max-seq-len INTEGER`:最大训练长度
* `--train-peft-type [all|p_tuning|lo_ra]`:Parameter efficient finetuning 方式
* `--trainset-rate INTEGER`:数据拆分比例 [default:20]
* `--train-logging-steps INTEGER`:日志记录间隔
* `--train-warmup-ratio FLOAT`:预热比例
* `--train-weight-decay FLOAT`:正则化系数
* `--train-lora-rank INTEGER`:LoRA 策略中的秩
* `--train-lora-all-linear TEXT`:LoRA 是否所有均为线性层

部署相关配置,参数含义与 [创建服务 API 文档](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Plnlmxdgy#body%E5%8F%82%E6%95%B0) 中对应参数含义一致:

* `--deploy-name TEXT`:部署服务名称。设置该值后会开始部署 action。
* `--deploy-endpoint-prefix TEXT`:部署服务的 endpoint 前缀
* `--deploy-description TEXT`:服务描述
* `--deploy-replicas INTEGER`:副本数 [default:1]
* `--deploy-pool-type [public_resource|private_resource]`:资源池类型 [default:private_resource]
* `--deploy-service-type [chat|completion|embedding|text2_image]`:服务类型 [default:chat]
24 changes: 13 additions & 11 deletions src/qianfan/common/client/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def handle_evaluate(self, event: Event) -> None:
self.progress.update(self.current_task, total=100, completed=100)

def dispatch(self, event: Event) -> None:
# self.progress.log(str(event))
if event.action_state == ActionState.Stopped:
print_error_msg(f"{event.action_class.__name__} {event.action_id} stopped.")
return
Expand Down Expand Up @@ -187,7 +186,7 @@ def dispatch(self, event: Event) -> None:

@trainer_app.command()
def run(
dataset_id: int = typer.Option(..., help="Dataset name"),
dataset_id: int = typer.Option(..., help="Dataset id"),
train_type: str = typer.Option(..., help="Train type"),
train_epoch: Optional[int] = typer.Option(
None, help="Train epoch", rich_help_panel=TRAIN_CONFIG_PANEL
Expand All @@ -199,7 +198,7 @@ def run(
None, help="Train learning rate", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_max_seq_len: Optional[int] = typer.Option(
None, help="Train max seq len", rich_help_panel=TRAIN_CONFIG_PANEL
None, help="Max sequence length", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_peft_type: Optional[PeftType] = typer.Option(
None,
Expand All @@ -208,25 +207,29 @@ def run(
rich_help_panel=TRAIN_CONFIG_PANEL,
),
trainset_rate: int = typer.Option(
20, help="Trainset rate", rich_help_panel=TRAIN_CONFIG_PANEL
20, help="Trainset ratio", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_logging_steps: Optional[int] = typer.Option(
None, help="Train logging steps", rich_help_panel=TRAIN_CONFIG_PANEL
None, help="Logging steps", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_warmup_ratio: Optional[float] = typer.Option(
None, help="Train warmup ratio", rich_help_panel=TRAIN_CONFIG_PANEL
None, help="Warmup ratio", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_weight_decay: Optional[float] = typer.Option(
None, help="Train weight decay", rich_help_panel=TRAIN_CONFIG_PANEL
None, help="Weight decay", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_lora_rank: Optional[int] = typer.Option(
None, help="Train lora rank", rich_help_panel=TRAIN_CONFIG_PANEL
None, help="Lora rank", rich_help_panel=TRAIN_CONFIG_PANEL
),
train_lora_all_linear: Optional[str] = typer.Option(
None, help="Train lora all linear", rich_help_panel=TRAIN_CONFIG_PANEL
None,
help="Whether lora is all linear layer",
rich_help_panel=TRAIN_CONFIG_PANEL,
),
deploy_name: Optional[str] = typer.Option(
None, help="Deploy name", rich_help_panel=DEPLOY_CONFIG_PANEL
None,
help="Deploy name. Set this value to enable deploy action.",
rich_help_panel=DEPLOY_CONFIG_PANEL,
),
deploy_endpoint_prefix: Optional[str] = typer.Option(
None, help="Deploy endpoint prefix", rich_help_panel=DEPLOY_CONFIG_PANEL
Expand All @@ -253,7 +256,6 @@ def run(
"""
Run a trainer job.
"""
# qianfan.enable_log("INFO")
console = replace_logger_handler()
callback = MyEventHandler(console=console)
ds = Dataset.load(qianfan_dataset_id=dataset_id)
Expand Down

0 comments on commit e5cc562

Please sign in to comment.