# Generative activities - Good practices

> This page provides good practices for using the [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#extract-document-data) and [Classify Document](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-classify-document#classify-document) activities using a Generative Predefined project, as well as the [Data Extraction Scope](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) and the [Classify Document Scope](https://docs.uipath.com/activities/other/latest/document-understanding/classify-document-scope) activities with [Data Extraction](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) and [Generative Classifier](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-ml-generative-classifier#generative-classifier) activities respectively.

This page provides good practices for using the [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#extract-document-data) and [Classify Document](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-classify-document#classify-document) activities using a Generative Predefined project, as well as the [Data Extraction Scope](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) and the [Classify Document Scope](https://docs.uipath.com/activities/other/latest/document-understanding/classify-document-scope) activities with [Data Extraction](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) and [Generative Classifier](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-ml-generative-classifier#generative-classifier) activities respectively.

## Timeouts

It is strongly recommended to leave the timeout at its default value of 1 hour. If you want to change it, we recommend not lowering it below 10 minutes.
:::note
If you set a lower timeout value, you may encounter errors. For example:
* `[...] A task was canceled [...]` for [Data Extraction Scope](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) with [Generative Extractor](https://docs.uipath.com/activities/other/latest/document-understanding/generative-extractor#generative-extractor) or [Classify Document Scope](https://docs.uipath.com/activities/other/latest/document-understanding/classify-document-scope) with [Generative Classifier](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-ml-generative-classifier#generative-classifier) activities.
* `[...] The processing took too long and the timeout value configured on the activity has been reached [...]` for [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#extract-document-data), [Classify Document](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-classify-document#classify-document) activities.
:::

## Rate limiting handling

You may encounter an error such as:

`[...] Rate limit exceeded. Please try again later. Error code: [GptRateLimitError] [...]`.

**Possible cause**

Document Understanding Generative Services are currently under high load in your region. Please retry your request after a short while.

**Possible solution**

A recommended approach is to implement a retry mechanism for such errors, allowing the workflow to automatically attempt the operation again after a short delay (we recommend at least **1 minute**) instead of failing immediately.

At a high level, the workflows follow the retry logic outlined in the following code block:

```
+--------------------------------------------------+
| Initialize retry parameters                      |
|                                                  |
| numberOfAttempts = 3                             |
| delayBetweenRetriesInSeconds = 60                |
+--------------------------------------------------+
                    |
                    v
+--------------------------------------------------+
| Do While (success == false)                      |
+--------------------------------------------------+
                    |
                    v
        +-----------------------------+
        | Try                         |
        |-----------------------------|
        | Run Generative              |
        | Classify / Extract Activity |
        |                             |
        | success = true              |
        +-----------------------------+
                    |
        +-----------------------------+
        | Catch Exception             |
        |-----------------------------|
        | If exception contains       |
        | "[GptRateLimitError]"       |
        |                             |
        |   If attempt < max retries  |
        |      Delay                  |
        |   Else                      |
        |      Rethrow exception      |
        |                             |
        | Else                        |
        |   Rethrow exception         |
        +-----------------------------+
                    |
                    v
            (Exit Do While)
```

The following workflows demonstrate how to handle this scenario effectively.

## Workflow: Using Extract Document Data

This section shows an example workflow for using the [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#extract-document-data) activity.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-640311-4a8b9095-0ef1d0b8.webp)

## Workflow: Using Classify Document

This section shows an example workflow for using the [Classify Document](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-classify-document#classify-document) activity.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-640317-d94f3a16-207beb43.webp)

## Workflow: Using Data Extraction Scope with Generative Extractor

This section shows an example workflow for using the [Data Extraction Scope](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) activity with [Generative Extractor](https://docs.uipath.com/activities/other/latest/document-understanding/generative-extractor#generative-extractor).

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-640324-e9b56caf-10af9a40.webp)

## Workflow: Using Classify Document Scope with Generative Classifier

This section shows an example workflow for using the [Classify Document Scope](https://docs.uipath.com/activities/other/latest/document-understanding/classify-document-scope) activity with [Generative Classifier](https://docs.uipath.com/activities/other/latest/document-understanding/document-understanding-ml-generative-classifier#generative-classifier).

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-640333-df663f96-c743e6db.webp)
