You need to enable JavaScript to run this app. Vertex AI批量预测:如何在程序中选择Cloud Storage文件列表选项及设置格式?
优惠活动
大模型
产品
解决方案
定价
更多

Vertex AI批量预测:如何在程序中选择Cloud Storage文件列表选项及设置格式?

在Vertex AI批量预测中使用「Cloud Storage文件列表」的实现方法

一、程序中指定「Files on Cloud Storage (file list)」模式

使用Vertex AI Python SDK时,无需额外设置专门选项,只需将批量预测的输入源指向存储在Cloud Storage中的文件列表文本文件,Vertex AI会自动识别该模式。

示例代码:

from google.cloud import aiplatform

# 初始化Vertex AI客户端
aiplatform.init(project="your-project-id", region="your-target-region")

# 加载目标模型
model = aiplatform.Model("projects/your-project-id/locations/your-region/models/your-model-id")

# 创建批量预测作业
batch_job = model.batch_predict(
    job_display_name="batch-pred-with-file-list",
    # 指向Cloud Storage中的文件列表文本文件
    gcs_source="gs://your-bucket/path/to/input_file_list.txt",
    # 预测结果输出路径前缀
    gcs_destination_prefix="gs://your-bucket/prediction-outputs",
    # 输入文件格式(需与模型兼容,如jsonl/csv等)
    input_format="jsonl",
    output_format="jsonl",
    # 计算资源配置
    machine_type="n1-standard-4",
    starting_replica_count=1,
    max_replica_count=3
)

# 等待作业完成
batch_job.wait()
print(f"批量预测作业完成,结果路径:{batch_job.output_info.gcs_output_directory}")

二、文件列表的格式要求

文件列表必须满足以下规则:

  • 为纯文本文件(后缀为.txt),存储在Cloud Storage中
  • 每行仅包含一个输入文件的完整Cloud Storage URI,示例内容:
    gs://your-batch-inputs/data_batch_1.jsonl
    gs://your-batch-inputs/data_batch_2.jsonl
    gs://your-batch-inputs/data_batch_3.csv
    
  • 每行不能包含空格、注释或多余字符
  • 列表中的输入文件格式需与模型的输入格式兼容(如JSON Lines、CSV、TFRecord等)
  • 确保Vertex AI服务账号拥有该文件列表及所有输入文件的读取权限

三、控制台操作界面说明

在Vertex AI控制台创建批量预测作业时,选择该模式的步骤:

  1. 进入批量预测作业创建页面,在「输入数据」模块选择「Cloud Storage」
  2. 选中「Files on Cloud Storage (file list)」单选按钮
  3. 在「文件列表路径」输入框中填写文件列表的完整GCS URI(如gs://your-bucket/path/to/input_file_list.txt)

界面截图说明:
[Vertex AI批量预测文件列表选项界面](截图展示了控制台输入数据区域,「Files on Cloud Storage (file list)」单选框处于选中状态,下方配有文件路径输入框和路径选择按钮,明确标识该模式用于指定包含多个输入文件路径的文本文件)

内容的提问来源于stack exchange,提问作者Ariana

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 16:24:32