使用命令行界面¶
Instructor CLI 提供了在 OpenAI 上管理微调任务的功能。
不完整的 API
CLI 仍在开发中,尚未支持 API 的所有功能。如果您想使用尚不支持的功能,请考虑贡献到我们的库 jxnl/instructor。
!!! note "Low hanging fruit"
If you want to contribute we're looking for a few things:
1. Adding filenames on upload
创建微调任务¶
查看任务选项¶
$ instructor jobs --help
Usage: instructor jobs [OPTIONS] COMMAND [ARGS]...
Monitor and create fine tuning jobs
╭─ Options ───────────────────────────────────────────────────────────────────────────────╮
│ --help Display the help message. │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ cancel Cancel a fine-tuning job. │
│ create-from-file Create a fine-tuning job from a file. │
│ create-from-id Create a fine-tuning job from an existing ID. │
│ list Monitor the status of the most recent fine-tuning jobs. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
从文件创建¶
create-from-file 命令在一个步骤中上传并训练模型。
❯ instructor jobs create-from-file --help
Usage: instructor jobs create-from-file [OPTIONS] FILE
Create a fine-tuning job from a file.
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────╮
│ * file TEXT Path to the file for fine-tuning [default: None] [required] │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────╮
│ --model TEXT Model to use for fine-tuning [default: gpt-3.5-turbo] │
│ --poll INTEGER Polling interval in seconds [default: 2] │
│ --n-epochs INTEGER Number of epochs for fine-tuning │
│ --batch-size TEXT Batch size for fine-tuning │
│ --learning-rate-multiplier TEXT Learning rate multiplier for fine-tuning │
│ --validation-file TEXT Path to the validation file [default: None] │
│ --model-suffix TEXT Suffix to identify the model [default: None] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────
用法¶
$ instructor jobs create-from-file transformed_data.jsonl --validation_file validation_data.jsonl --n_epochs 3 --batch_size 16 --learning_rate_multiplier 0.5
从 ID 创建¶
create-from-id 命令使用已上传的文件并训练模型
❯ instructor jobs create-from-id --help
Usage: instructor jobs create-from-id [OPTIONS] ID
Create a fine-tuning job from an existing ID.
╭─ Arguments ───────────────────────────────────────────────────────────────────────────╮
│ * id TEXT ID of the existing fine-tuning job [default: None] [required] │
╰───────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────╮
│ --model TEXT Model to use for fine-tuning │
│ [default: gpt-3.5-turbo] │
│ --n-epochs INTEGER Number of epochs for fine-tuning │
│ --batch-size TEXT Batch size for fine-tuning │
│ --learning-rate-multiplier TEXT Learning rate multiplier for fine-tuning │
│ --validation-file-id TEXT ID of the uploaded validation file │
│ [default: None] │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────╯
用法¶
$ instructor files upload transformed_data.jsonl
$ instructor files upload validation_data.jsonl
$ instructor files list
...
$ instructor jobs create_from_id <file_id> --validation_file <validation_file_id> --n_epochs 3 --batch_size 16 --learning_rate_multiplier 0.5
查看文件和任务¶
查看任务¶
$ instructor jobs list
OpenAI Fine Tuning Job Monitoring
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ ┃ ┃ ┃ Completion ┃ ┃ ┃ ┃ ┃
┃ Job ID ┃ Status ┃ Creation Time ┃ Time ┃ Model Name ┃ File ID ┃ Epochs ┃ Base Model ┃
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ ftjob-PWo6uwk… │ 🚫 cancelled │ 2023-08-23 │ N/A │ │ file-F7lJg6Z4… │ 3 │ gpt-3.5-turbo-… │
│ │ │ 23:10:54 │ │ │ │ │ │
│ ftjob-1whjva8… │ 🚫 cancelled │ 2023-08-23 │ N/A │ │ file-F7lJg6Z4… │ 3 │ gpt-3.5-turbo-… │
│ │ │ 22:47:05 │ │ │ │ │ │
│ ftjob-wGoBDld… │ 🚫 cancelled │ 2023-08-23 │ N/A │ │ file-F7lJg6Z4… │ 3 │ gpt-3.5-turbo-… │
│ │ │ 22:44:12 │ │ │ │ │ │
│ ftjob-yd5aRTc… │ ✅ succeeded │ 2023-08-23 │ 2023-08-23 │ ft:gpt-3.5-tur… │ file-IQxAUDqX… │ 3 │ gpt-3.5-turbo-… │
│ │ │ 14:26:03 │ 15:02:29 │ │ │ │ │
└────────────────┴──────────────┴────────────────┴────────────────┴─────────────────┴────────────────┴────────┴─────────────────┘
Automatically refreshes every 5 seconds, press Ctrl+C to exit
查看文件¶
$ instructor files list
OpenAI Files
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━┓
┃ File ID ┃ Size (bytes) ┃ Creation Time ┃ Filename ┃ Purpose ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━┩
│ file-0lw2BSNRUlXZXRRu2beCCWjl │ 369523 │ 2023-08-23 23:31:57 │ file │ fine-tune │
│ file-IHaUXcMEykmFUp1kt2puCDEq │ 369523 │ 2023-08-23 23:09:35 │ file │ fine-tune │
│ file-ja9vRBf0FydEOTolaa3BMqES │ 369523 │ 2023-08-23 22:42:29 │ file │ fine-tune │
│ file-F7lJg6Z47CREvmx4kyvyZ6Sn │ 369523 │ 2023-08-23 22:42:03 │ file │ fine-tune │
│ file-YUxqZPyJRl5GJCUTw3cNmA46 │ 369523 │ 2023-08-23 22:29:10 │ file │ fine-tune │
└───────────────────────────────┴──────────────┴─────────────────────┴──────────┴───────────┘
贡献¶
我们的目标是提供一个围绕 API 的轻量级封装,而不是一个完整的 CLI。欢迎贡献!请随时在jxnl/instructor/issues创建议题或提交拉取请求。