Diligently following the Get batch predictions for Gemini instructions, I attempted the following curl
request against a BigQuery dataset shown below. I have attempted multiple models (gemini-1.5-flash-001
, gemini-1.5-pro-001
, gemini-1.0-pro-002
) that all raise the same uninformative Error Code 13 - INTERNAL
.
Am I following the correct specifications, especially the BigQuery input and output URI sources? Is the model input with its parameters correctly specified?
Run
Curl Request
(ran inside GCP cloud terminal shell)
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
(ran literally inside above call in place of @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
Contains one JSON type column, Request, with first row. I attempted to run on full table containing 99 rows and sample table containing 1 row. Both attemptes raised the Error code 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."
}
]
}
}
Result
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 audit Logs shows strange syntax errors at datetimes that do not correspond to job request. Such logs are not immediately available after job request.
Before running above batch predictions attempt, I have tested a single call with the Gemini Python API against same models to successfully receive output.
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."
}
]
Do note, attempting model, gemini-1.0-pro-002
, raised:
google.api_core.exceptions.NotFound: 404 models/gemini-1.0-pro-002 is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.