> [!NOTE]
> **Private beta:** This product is in private preview. You need to be on the allowlist to use this product. To be added to the allowlist, contact your [account team](https://cloud.google.com/tam) or the [sales team](https://cloud.google.com/contact).

> [!WARNING]
>
> **Preview**
>
>
> This product is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

You can configure a Document AI custom extractor to modify the type of
*grounding* that a processor version uses. In generative AI, grounding is the
ability to connect model output to verifiable sources of information. Grounding
helps ensure that the model extracts information only from the provided
document rather than relying solely on its internal training weights.

Two types of grounding are available:

- **Hard:** Requires an exact match with OCR text (default).
- **OCR Relaxed:** Allows minor discrepancies between LLM output and OCR text.

For more information on grounding, see [Grounding
overview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/grounding/overview).

## Configure grounding using the API

Before using any of the request data, make the following replacements:

       DISPLAY_NAME: The display name of the new processor version.
       GROUNDING_TYPE: The grounding type, either "OCR_RELAXED" or "HARD."
       LOCATION: Your processor location
       PROJECT_ID: Your Google Cloud project ID
       PROCESSOR_ID: The ID of your custom processor
       SOURCE_PROCESSOR_VERSION: The source processor version.

### CURL

```console
   curl -X POST -v -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
         -H "Content-Type: application/json" \
         "https://documentai.googleapis.com/v1beta3/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions:train" \
         -d '{
         "processor_version": {
            "display_name": "DISPLAY_NAME"
         },
         "processor_version_overrides": {
            "grounding_settings": {
               "grounding_type": "GROUNDING_TYPE"
            }
         },
         "base_processor_version": "projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/SOURCE_PROCESSOR_VERSION",
         "foundation_model_tuning_options": {
            "train_steps": 4,
            "learning_rate_multiplier": 1,
         }
      }'
```

> [!NOTE]
> **Note:** The grounding overrides API is available in preview for `v1beta3` only.

## Configure processor grounding in the Google Cloud console

Before configuring grounding, you must have a processor with at least one
processor version. For more information, see [Create a
processor](https://docs.cloud.google.com/document-ai/docs/create-processor).

### Check current grounding settings

1. In the Google Cloud console for an existing processor, select the
   **Evaluate \& Test** entry.

2. Click **Settings**, and then go to the next page of the dialog.

3. You can view the current grounding type from the **Grounding type** list.

   ![Grounding type list in the Label & Build section of the Settings
   page.](https://docs.cloud.google.com/static/document-ai/docs/images/manage/cde-grounding-1.png)

### Enable grounding through fine-tuning

To enable grounding when you fine-tune a processor, do the following:

1. In the Google Cloud console for an existing processor, click
   **Label \& Build**.

2. In the **Fine tuning** section, click **Fine tune**.

3. In the **Version name** field, enter a name for the version.

4. Optional: If the advanced options are collapsed, click **Show advanced
   options** , and in the **Tuning settings** section, modify the **Train step**
   or **Learning rate multiplier** values.

5. In the **Overrides** section, select an option from the **Grounding type** list.

   ![Grounding type list in the Overrides section of the Create new version
   pane.](https://docs.cloud.google.com/static/document-ai/docs/images/manage/cde-grounding-2.png)
6. Select **Create** to create a new version with the selected grounding.

## What's next

- Learn about [validation and correction](https://docs.cloud.google.com/document-ai/docs/ce-validation.md.txt).