Template-based extraction

You can train a high-performing model with as little as three training and three test documents for fixed-layout use cases. Accelerate development and reduce time to production for templated document types like W9, 1040, ACORD, surveys, and questionnaires.

Dataset configuration

A document dataset is required to train, up-train, or evaluate a processor version. Document AI processors learn from examples, just like humans. Dataset fuels processor stability in terms of performance.

Train dataset

To improve the model and its accuracy, train a dataset on your documents. The model is made up of documents with ground-truth. You need a minimum of three documents to train a new model.

Test dataset

The test dataset is what the model uses to generate an F1 score (accuracy). It is made up of documents with ground-truth. To see how often the model is right, the ground truth is used to compare the model's predictions (extracted fields from the model) with the correct answers. The test dataset should have at least three documents.

Before you begin

If not already done, enable:

Template-mode labeling best practices

Proper labeling is one of the most important steps to achieving high accuracy. Template mode has some unique labeling methodology that differs from other training modes:

  • Draw bounding boxes around the entire area you expect data to be in (per label) within a document, even if the label is empty in the training document you're labeling.
  • You may label empty fields for template-based training. Don't label empty fields for model-based training.

Build and evaluate a custom extractor with template mode

  1. Create a custom extractor. Create a processor and define fields you want to extract following best practices, which is important because it impacts extraction quality.

  2. Set dataset location. Select the default option folder (Google-managed). This might be done automatically shortly after creating the processor.

  3. Navigate to the Build tab and select Import documents with auto-labeling enabled. Adding more documents than the minimum of three needed typically doesn't improve quality for template-based training. Instead of adding more, focus on labeling a small set very accurately.

  4. Extend bounding boxes. These boxes for template mode should look like the preceding examples. Extend the bounding boxes, following the best practices for the optimal result.

  5. Train model.

    1. Select Train new version.
    2. Name the processor version.
    3. Go to Show advanced options and select the template-based model approach.

    template-based-extraction-3

  6. Evaluation.

    1. Go to Evaluate & test.
    2. Select the version you just trained, then select View Full Evaluation.

    template-based-extraction-4

    You now see metrics such as F1, precision, and recall for the entire document and each field. 1. Decide if performance meets your production goals, and if not, reevaluate training and testing sets.

  7. Set a new version as the default.

    1. Navigate to Manage versions.
    2. Select to see the settings menu, then mark Set as default.