通过 Curl 请求运行 Gemini 批量预测会引发错误代码 13 - 内部

问题描述 投票:0回答:1

严格遵循 获取 Gemini 的批量预测说明,我尝试针对如下所示的 BigQuery 数据集执行以下

curl
请求。我尝试了多个模型(
gemini-1.5-flash-001
gemini-1.5-pro-001
gemini-1.0-pro-002
),它们都提出了相同的无信息性
Error Code 13 - INTERNAL

我是否遵循正确的规范,尤其是 BigQuery 输入和输出 URI 源?模型输入及其参数是否正确指定?

奔跑

Curl Request
(在 GCP 云终端外壳内运行)

curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://us-central1-aiplatform.googleapis.com/v1/projects/XXXXXXXXX/locations/us-central1/batchPredictionJobs"

Request JSON
(实际上是在上面的调用中运行而不是
@request.json

{
  "name": "economic_goods_batch",
  "displayName": "economic_goods_batch",
  "model": "publishers/google/models/gemini-1.5-flash-001",
  "inputConfig": {
    "instancesFormat": "bigquery",
    "bigquerySource": {
      "inputUri": "bq://XXXXXXXXX.gemini_econ_goods_batch.sample"
    }
  },
  "outputConfig": {
    "predictionsFormat": "bigquery",
    "bigqueryDestination": {
      "outputUri": "bq://XXXXXXXXX.gemini_econ_goods_batch.sample"
    }
  }
}

BigQuery Table: Sample

包含一个 JSON 类型列,Request,第一行。我尝试在包含 99 行的完整表和包含 1 行的示例表上运行。两次尝试均引发错误代码 13。

{
  "contents": [
    {
      "parts": "Which of the following types of economic goods describes the activity of playing baseball: public good, private good, common resources, and/or club good?. Please answer with a description.",
      "role": "user"
    }
  ],
  "generation_config": {
    "maxOutputTokens": 1000,
    "top_k": 5
  },
  "system_instruction": {
    "parts": [
      {
        "text": "You are an economics trained assistant. Your response must be a JSON array containing JSON objects of two elements: good_type and description."
      }
    ]
  }
}

结果

curl \
  -X GET \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1/projects/gen-lang-client-XXXXXXXXX/locations/us-central1/batchPredictionJobs
{
  "batchPredictionJobs": [
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.0-pro-002",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-12T15:40:31.753722Z",
      "startTime": "2024-06-12T15:40:31.962421Z",
      "endTime": "2024-06-12T15:42:50.600106Z",
      "updateTime": "2024-06-12T15:42:50.600106Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-flash-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.sample"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.sample"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-11T20:07:10.340485Z",
      "startTime": "2024-06-11T20:07:10.522629Z",
      "endTime": "2024-06-11T20:08:59.225966Z",
      "updateTime": "2024-06-11T20:08:59.225966Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-flash-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-10T22:44:19.973904Z",
      "startTime": "2024-06-10T22:44:20.180562Z",
      "endTime": "2024-06-10T22:46:38.819981Z",
      "updateTime": "2024-06-10T22:46:38.819981Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-pro-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_response"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-09T18:26:52.102913Z",
      "startTime": "2024-06-09T18:26:52.299451Z",
      "endTime": "2024-06-09T18:28:40.856695Z",
      "updateTime": "2024-06-09T18:28:40.856695Z",
      "modelVersionId": "1"
    }
  ]
}

GCP 审核日志在与作业请求不对应的日期时间显示奇怪的语法错误。此类日志在作业请求后不会立即可用。

enter image description here


在运行上述批量预测尝试之前,我已经使用 Gemini Python API 对相同模型进行了一次调用测试,以成功接收输出。

import os
import google.generativeai as genai

genai.configure(api_key=os.environ["GEMINIAI_API_KEY"])

model = genai.GenerativeModel(
    model_name = model_name = "gemini-1.5-flash-001", # "gemini-1.5-pro-001", #"gemini-1.5-pro-latest",
    system_instruction = (
        "You are an economics trained assistant. "
        "Your response must be a JSON array containing a list of "
        "JSON objects of two elements: good_type and description."
    )
)

prompt = (
    "Which of the following types of economic goods describes "
    "the activity of playing baseball: public good, "
    "private good, common resources, and/or club good?. "
    "Please answer with a description."
)


response = model.generate_content(
    prompt,
    generation_config=genai.GenerationConfig(
        response_mime_type = "application/json",
        max_output_tokens = 1000,
        top_k = 5
    )
)

print(response.text)
[
   {
      "good_type":"club good",
      "description":"A club good is a good that is excludable but not rivalrous. Playing baseball can be considered a club good because it is possible to exclude people from playing (e.g., requiring membership in a league or payment for access to a field). However, the enjoyment of the game by one person does not diminish the enjoyment of others. It is possible to have multiple players on the field at the same time without decreasing the enjoyment of the game for anyone."
   },
   {
      "good_type":"common resource",
      "description":"A common resource is a good that is rivalrous but not excludable.  This means that it is possible for multiple people to use the resource, but the resource is limited. Playing baseball can be considered a common resource because it can be rivalrous depending on the situation. For example, if there is only one baseball field available, then the enjoyment of the game by one group of people may diminish the enjoyment of the game for another group of people. However, it may be difficult to exclude people from playing baseball, especially if the game is played in a public park."
   }
]

请注意,尝试模型,

gemini-1.0-pro-002
,提出:

google.api_core.exceptions.NotFound:API 版本 v1beta 找不到 404 models/gemini-1.0-pro-002,或者不支持GenerateContent。调用 ListModels 查看可用模型及其支持的方法的列表。

google-cloud-platform curl google-bigquery google-gemini
1个回答
0
投票

我注意到您的 bigQuery 输入数据存在一个问题,请更新以下内容:

{
  "contents": [
    {
      "parts": {
          "text": "Which of the following types of economic goods describes the activity of playing baseball: public good, private good, common resources, and/or club good?. Please answer with a description."
      },
      "role": "user"
    }
  ],
  "generation_config": {
    "maxOutputTokens": 1000,
    "top_k": 5
  },
  "system_instruction": {
    "parts": [
      {
        "text": "You are an economics trained assistant. Your response must be a JSON array containing JSON objects of two elements: good_type and description."
      }
    ]
  }
}

parts 应该是带有

text
字段的对象。

尝试使用

publishers/google/models/gemini-1.5-flash-001
进行修复。
gemini-1.0-pro-002
应该适用于 Vertex AI 端点,我猜你的是 Google AI Studio。

© www.soinside.com 2019 - 2024. All rights reserved.