**Full name**: projects.locations.processors.processorVersions.train

Trains a new processor version. Operation metadata is returned as `TrainProcessorVersionMetadata`.

### HTTP request

Choose a location:
<button value="global" default="">global</button> <button value="us">us</button> <button value="eu">eu</button> <button value="asia-south1">asia-south1</button> <button value="asia-southeast1">asia-southeast1</button> <button value="northamerica-northeast1">northamerica-northeast1</button> <button value="australia-southeast1">australia-southeast1</button> <button value="europe-west2">europe-west2</button> <button value="europe-west3">europe-west3</button>   
`POST https://documentai.googleapis.com/v1beta3/{parent}/processorVersions:train`

<br />

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The parent (project, location and processor) to create the new version for. Format: `projects/{project}/locations/{location}/processors/{processor}`. It takes the form `projects/{project}/locations/{location}/processors/{processor}`. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "processorVersion": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/ProcessorVersion`) }, "documentSchema": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/DocumentSchema`) }, "inputData": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#InputData`) }, "baseProcessorVersion": string, // Union field `processor_flags` can be only one of the following: "customDocumentExtractionOptions": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#CustomDocumentExtractionOptions`) }, "foundationModelTuningOptions": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#FoundationModelTuningOptions`) } // End of list of possible types for union field `processor_flags`. } ``` |

| Fields ||
|---|---|
| `processorVersion` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/ProcessorVersion`)`` Required. The processor version to be created. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `processorVersion`: - `documentai.processorVersions.create` |
| `documentSchema` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/DocumentSchema`)`` Optional. The schema the processor version will be trained with. |
| `inputData` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#InputData`)`` Optional. The input data used to train the `https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/ProcessorVersion`. |
| `baseProcessorVersion` | `string` Optional. The processor version to use as a base for training. This processor version must be a child of `parent`. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. |
| Union field `processor_flags`. `processor_flags` can be only one of the following: ||
| `customDocumentExtractionOptions` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#CustomDocumentExtractionOptions`)`` Options to control Custom Document Extraction (CDE) Processor. |
| `foundationModelTuningOptions` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#FoundationModelTuningOptions`)`` Options to control foundation model tuning of a processor. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation`.

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `parent` resource:

- `documentai.processorVersions.create`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).

## CustomDocumentExtractionOptions

Options to control the training of the Custom Document Extraction (CDE) Processor.

| JSON representation |
|---|
| ``` { "trainingMethod": enum (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#TrainingMethod`) } ``` |

| Fields ||
|---|---|
| `trainingMethod` | ``enum (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors.processorVersions/train#TrainingMethod`)`` Optional. Training method to use for CDE training. |

## TrainingMethod

Training Method for CDE. `TRAINING_METHOD_UNSPECIFIED` will fall back to `MODEL_BASED`.

| Enums ||
|---|---|
| `TRAINING_METHOD_UNSPECIFIED` |   |
| `MODEL_BASED` |   |
| `TEMPLATE_BASED` |   |

## FoundationModelTuningOptions

Options to control foundation model tuning of the processor.

| JSON representation |
|---|
| ``` { "trainSteps": integer, "learningRateMultiplier": number, "previousFineTunedProcessorVersionName": string } ``` |

| Fields ||
|---|---|
| `trainSteps` | `integer` Optional. The number of steps to run for model tuning. Valid values are between 1 and 400. If not provided, recommended steps will be used. |
| `learningRateMultiplier` | `number` Optional. The multiplier to apply to the recommended learning rate. Valid values are between 0.1 and 10. If not provided, recommended learning rate will be used. |
| `previousFineTunedProcessorVersionName` | `string` Optional. Resource name of a previously fine tuned version ID to copy the overwritten configs from. The baseProcessorVersion should be newer than the base processor version used to fine tune this provided processor version. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. |

## InputData

The input data used to train a new `https://docs.cloud.google.com/document-ai/docs/reference/rest/Shared.Types/ProcessorVersion`.

| JSON representation |
|---|
| ``` { "trainingDocuments": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/BatchDocumentsInputConfig`) }, "testDocuments": { object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/BatchDocumentsInputConfig`) } } ``` |

| Fields ||
|---|---|
| `trainingDocuments` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/BatchDocumentsInputConfig`)`` The documents used for training the new version. |
| `testDocuments` | ``object (`https://docs.cloud.google.com/document-ai/docs/reference/rest/v1beta3/BatchDocumentsInputConfig`)`` The documents used for testing the trained version. |