Documents AI training failure

Hi,
I’m trying to fine tune a processor in documentsAI. When hitting the create new version button, the process starts and ends with an error. I’m encountering the following infamous error :
“error”: {

“code”: 13,
“message”: “Internal error encountered.”,
“details”:
}
After digging into the Log Explorer it seems that my training file is too large and makes the process fail (see error below)

{
“protoPayload”: {
“@type”: “type.googleapis.com/google.cloud.audit.AuditLog”,
“status”: {
“code”: 3,
“message”: “Media file size cannot exceed 20971520 bytes. Actual size is 21608688 bytes. File: gs://xx-training/xx/xx/scratch/image_uris/xx/chunk_1”
},
“authenticationInfo”: {
“principalEmail”: “myemail@mail.fr”
},
“requestMetadata”: {
“requestAttributes”: {},
“destinationAttributes”: {}
},
“serviceName”: “documentai.googleapis.com”,
“methodName”: “google.cloud.documentai.uiv1beta3.DocumentProcessorService.TrainProcessorVersion”,
“resourceName”: “projects/xx/locations/eu/processors/xx/processorVersions/xx”
},
“insertId”: “hhbldtc1gd”,
“resource”: {
“type”: “audited_resource”,
“labels”: {
“project_id”: “xx”,
“service”: “documentai.googleapis.com”,
“method”: “google.cloud.documentai.uiv1beta3.DocumentProcessorService.TrainProcessorVersion”
}
},
“timestamp”: “2025-04-22T13:41:35.890474349Z”,
“severity”: “ERROR”,
“logName”: “projects/xx/logs/cloudaudit.googleapis.com%2Factivity”,
“operation”: {
“id”: “projects/xx/locations/eu/operations/xx”,
“producer”: “documentai.googleapis.com”,
“last”: true
},
“receiveTimestamp”: “2025-04-22T13:41:37.059774963Z”
}

I have two issues with that :
1/ None of my training files have such a size, the max image size is 5Mo not 20Mo. I guess documents AI is adding some data to process it, but it’d be nice to automatically reject files that are too big right after labeling in the dataset management view instead of when training a new version.
2/ There’s no way for me to identify which file in my dataset is causing the training failure, because there’s no match between the documentId that caused the error and the documentId in my dataset. I tried to play with those two endpoints dataset.listDocuments and dataset.getDocument to see if I could match those, but unfortunately no.

Any help know how to identify which file I should remove from my dataset, so I can train a new processor version, would be highly appreciated.

Regards,
Laurent

I’ve found a workaround to remove files > 20Mo:

1/ Go to Manage Dataset and click the Export dataset button. This will export the dataset directory, managed by Google, on which you have no rights.
2/ Choose a location in your cloud storage
3/ With the following command line identify files > 20Mo in both train and test directories. Those are json files (not image files), but the name is the same as the image you uploaded. These are the files that are blocking the training.

gcloud storage ls --long --recursive gs://myexport/ | awk ‘{mo = $1 / (1024 * 1024); if (mo > 20) printf “%.2f Mo\t%s\n”, mo, $NF}’

4/ Finally, in the documents AI dataset view, remove the files you listed in the previous step, manually …

Then you can train again successfully! Very long, very cumbersome but at least this solution exists. Hope it helps someone.

Laurent