跳到内容

命令行界面 (CLI)

Distilabel 提供了一个 CLI探索重新运行现有的 Pipeline 转储,这意味着可以探索现有的转储以查看步骤、这些步骤是如何连接的、使用的运行时参数,并且还可以分别使用相同或不同的运行时参数重新运行它。

可用命令

截至当前 distilabel 版本,唯一可用的命令是 distilabel pipeline

$ distilabel pipeline --help

 Usage: distilabel pipeline [OPTIONS] COMMAND [ARGS]...

 Commands to run and inspect Distilabel pipelines.

╭─ Options ───────────────────────────────────────────────────────────────────────────────╮
 --help          Show this message and exit.                                             ╰─────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────╮
 info      Get information about a Distilabel pipeline.                                   run       Run a Distilabel pipeline.                                                    ╰─────────────────────────────────────────────────────────────────────────────────────────╯

因此,distilabel pipeline 有两个子命令:inforun,如下所述。请注意,出于测试目的,我们将使用以下 数据集

distilabel pipeline info

$ distilabel pipeline info --help

 Usage: distilabel pipeline info [OPTIONS]

 Get information about a Distilabel pipeline.

╭─ Options ───────────────────────────────────────────────────────────────────────────╮
 *  --config        TEXT  Path or URL to the Distilabel pipeline configuration file.                           [default: None]                                                                      [required]                                                     --help                Show this message and exit.                                ╰─────────────────────────────────────────────────────────────────────────────────────╯

正如我们从帮助消息中看到的,我们需要传递 PathURL。第二个选项对于存储在 Hugging Face Hub 中的数据集非常方便,例如

distilabel pipeline info --config "https://hugging-face.cn/datasets/distilabel-internal-testing/instruction-dataset-mini-with-generations/raw/main/pipeline.yaml"

如果我们看一下

CLI 1

pipeline 信息包括 Pipeline 中使用的步骤以及使用的 Runtime Parameter,以及每个步骤的描述,以及这些步骤之间的连接。这些对于在本地探索 Pipeline 可能很有帮助。

distilabel pipeline run

我们还可以从 CLI 运行 Pipeline,只需指向相同的 pipeline.yaml 文件或指向它的 URL 并调用 distilabel pipeline run。或者,可以使用指向包含 distilabel pipeline 的 Python 脚本的 URL

$ distilabel pipeline run --help

 Usage: distilabel pipeline run [OPTIONS]

 Run a Distilabel pipeline.

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 --param                                          PARSE_RUNTIME_PARAM  [default: (dynamic)]                                          --config                                         TEXT                 Path or URL to the Distilabel pipeline configuration file.                                                                          [default: None]                                               --script                                         TEXT                 URL pointing to a python script containing a distilabel                                                                             pipeline.                                                                                                                           [default: None]                                               --pipeline-variable-name                         TEXT                 Name of the pipeline in a script. I.e. the 'pipeline'                                                                               variable in `with Pipeline(...) as pipeline:...`.                                                                                   [default: pipeline]                                           --ignore-cache              --no-ignore-cache                         Whether to ignore the cache and re-run the pipeline from                                                                            scratch.                                                                                                                            [default: no-ignore-cache]                                    --repo-id                                        TEXT                 The Hugging Face Hub repository ID to push the resulting                                                                            dataset to.                                                                                                                         [default: None]                                               --commit-message                                 TEXT                 The commit message to use when pushing the dataset.                                                                                 [default: None]                                               --private                   --no-private                              Whether to make the resulting dataset private on the Hub.                                                                           [default: no-private]                                         --token                                          TEXT                 The Hugging Face Hub API token to use when pushing the                                                                              dataset.                                                                                                                            [default: None]                                               --help                                                                Show this message and exit.                                  ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

使用 --config 选项,我们必须传递一个包含 pipeline.yaml 文件的路径。要指定步骤的运行时参数,我们将需要使用 --param 选项和以下格式的参数值

distilabel pipeline run --config "https://hugging-face.cn/datasets/distilabel-internal-testing/instruction-dataset-mini-with-generations/raw/main/pipeline.yaml" \
    --param load_dataset.repo_id=distilabel-internal-testing/instruction-dataset-mini \
    --param load_dataset.split=test \
    --param generate_with_gpt35.llm.generation_kwargs.max_new_tokens=512 \
    --param generate_with_gpt35.llm.generation_kwargs.temperature=0.7 \
    --param to_argilla.dataset_name=text_generation_with_gpt35 \
    --param to_argilla.dataset_workspace=admin

或者使用 --script 我们可以直接传递一个远程 python 脚本(请记住 --config--script 是互斥的)

distilabel pipeline run --script "https://hugging-face.cn/datasets/distilabel-internal-testing/pipe_nothing_test/raw/main/pipe_nothing.py"

您还可以将运行时参数传递给 python 脚本,就像我们在 --config 选项中看到的那样。

同样,这有助于结果的可重现性,并简化了不仅共享最终数据集,而且共享生成数据集的过程。