【问题标题】:Generate instances and prediction schema files for Vertex AI model evaluation (Google Cloud pipeline components)为 Vertex AI 模型评估(Google Cloud 管道组件)生成实例和预测架构文件
【发布时间】:2022-11-15 15:14:56
【问题描述】:

我构建了一个自定义模型并尝试使用 Google Cloud 管道组件在 Vertex AI 上进行模型评估。根据model_upload_predict_evaluate notebook 示例,我需要准备 instance_schema.yaml 和 prediction_schema.yaml 来导入非托管模型。

那么如何以编程方式生成实例和预测模式文件呢?

【问题讨论】:

    标签: google-cloud-vertex-ai


    【解决方案1】:

    对于自定义模型,不需要实例和预测模式:

    "predictSchemata": {
        "predictionSchemaUri": MODEL_URI + "/prediction_schema.yaml",
        "instanceSchemaUri": MODEL_URI + "/instance.yaml",
    },
    

    【讨论】:

      【解决方案2】:

      我也在搜索,但我的搜索正在取得进展。 所以首先,我必须搜索一些“文档”。对我来说幸运的是,python sdk 中有一些记录:

      instance_schema_uri (str):

      可选的。指向存储在 Google Cloud Storage 上的描述单个实例格式的 YAML 文件,在 PredictRequest.instancesExplainRequest.instancesBatchPredictionJob.input_config 中使用。架构定义为 OpenAPI 3.0.2 Schema Object <https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#schema-object-->__。 AutoML 模型始终具有由 AI Platform 填充的此字段。注意:输出中给出的 URI 将是不可变的,并且可能与输入中给出的不同,包括 URI 方案。输出 URI 将指向用户只有读取权限的位置。

      提供的 openapi 架构 url 的有趣部分是:https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#schemaObject

      这是一个工作 yaml 文件的示例。它是由从sushi dataset 构建的 AutoML 模型生成的(我只是在测试东西):

      type: object
      properties:
        gender:
          nullable: true
          type: string
        age:
          nullable: true
          type: string
        time_fill_form:
          nullable: true
          type: string
        prefecture_id_until_15yo:
          nullable: true
          type: string
        region_id_until_15yo:
          nullable: true
          type: string
        east_west_id_until_15yo:
          nullable: true
          type: string
        prefecture_id_now:
          nullable: true
          type: string
        region_id_now:
          nullable: true
          type: string
        east_west_id_now:
          nullable: true
          type: string
        same_prefecture_id_over_time:
          nullable: true
          type: string
      required:
      - gender
      - age
      - time_fill_form
      - prefecture_id_until_15yo
      - region_id_until_15yo
      - east_west_id_until_15yo
      - prefecture_id_now
      - region_id_now
      - east_west_id_now
      - same_prefecture_id_over_time
      nullable: true
      example:
        gender: '1'
        age: '2'
        time_fill_form: '277.0'
        prefecture_id_until_15yo: '13'
        region_id_until_15yo: '3'
        east_west_id_until_15yo: '0'
        prefecture_id_now: '13'
        region_id_now: '3'
        east_west_id_now: '0'
        same_prefecture_id_over_time: '0'
      

      现在关于以编程方式构建它,当/如果我能找到解决方案时,我会更新我的回复,但我正在尝试从pydantic model 构建它。 Pydantic 有一种方法可以将其模型转换为openapi schema,但是在导出我的自定义模型时,输出在 Vertex 中对我不起作用......

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-01-03
        • 2021-12-03
        • 2017-12-31
        • 2021-08-28
        • 2022-01-18
        • 2021-09-02
        • 2022-01-18
        • 2022-10-06
        相关资源
        最近更新 更多