Lesson 3 of 3 Document Extraction with Content Understanding

Building Custom Analyzers for Structured and Markdown Output

This lesson explains how a custom analyzer defines the output when prebuilt analyzers do not return exactly what downstream systems need: the analyzer definition, the field schema and the analysis lifecycle.

Learning outcomes

After completing this lesson, you will be able to:

  • Create a custom analyzer definition.
  • Design fields with descriptions, types and methods.
  • Run an asynchronous analysis and read the results.

Analyzer definition

Prebuilt analyzers return what most applications need from a type of content, such as the Markdown and summary of a document or the standard fields of an invoice. A custom analyzer is needed when downstream systems require specific fields in a specific shape: a claims system that expects a policy number, an incident date and a claim category, or a contract register that expects renewal terms and liability caps. The analyzer is a reusable, named configuration, so every document is processed with the same schema and the results remain consistent over time.

A custom analyzer usually starts from a base analyzer, which supplies the content processing (OCR, layout and Markdown for documents), and adds a field schema on top. Its lifecycle has three steps: the analyzer is created once, documents are analyzed against it many times, and it is replaced with a new version when the schema changes. Because analyzer IDs are referenced by applications, a changed schema is typically created under a new ID, tested on sample documents and then switched in.

A custom analyzer is created with a PUT request to {endpoint}/contentunderstanding/analyzers/{analyzerId}. The definition includes a description, a base analyzer (such as prebuilt-document), a config section with options such as returning Markdown, layout details and figure descriptions, the models to use for completion and embeddings, and a field schema. Creation is a long-running operation, after which the analyzer can be used by its ID.

PUT {endpoint}/contentunderstanding/analyzers/claim-form?api-version=2025-11-01
{
  "description": "Motor insurance claim forms",
  "baseAnalyzerId": "prebuilt-document",
  "models": {"completion": "gpt-5.2"},
  "fieldSchema": {
    "fields": {
      "PolicyNumber":  {"type": "string", "method": "extract",  "description": "Policy number, format MTR-0000000"},
      "IncidentDate":  {"type": "date",   "method": "extract",  "description": "Date the incident happened"},
      "DamageSummary": {"type": "string", "method": "generate", "description": "One-sentence summary of the damage described"},
      "ClaimType":     {"type": "string", "method": "classify", "description": "Type of claim",
                        "enum": ["collision", "theft", "weather", "vandalism", "other"]}
    }
  }
}

Field design

Field descriptions guide the model, so they state the meaning, format and where the value usually appears. Types (string, number, integer, date, time, boolean, array, object) let downstream code consume values without parsing. Arrays of objects capture repeated items such as line items. The method is chosen per field: extract for values printed in the document, generate for values that require interpretation or summarization, and classify with an enum for categories.

The choice of method changes what the result means. An extracted value is a copy of text in the document and carries grounding that points to where it was found, so a reviewer can verify it. A generated value is the model's interpretation, such as a one-sentence damage summary, and should be treated as a judgement rather than a quotation. A classified value is restricted to the listed categories, which lets code branch on it safely. A field that should be copied must therefore not be defined as generated, or the model may paraphrase a policy number or a date.

Sort into groups

Choose the field method

Exam skills 5.2.3

Choose extract, generate or classify for each field.

Log in to try this activity Interactive activities are free with an account.

Analysis and results

Analysis is asynchronous. A POST to /analyzers/{analyzerId}:analyze with the input (a URL or binary content) returns 202 Accepted and an Operation-Location header. The client polls that URL until status is Succeeded (or Failed). The result's contents array has one item per input, with markdown and fields; each field has a type, a typed value such as valueString or valueDate, a confidence and grounding information. Structured fields drive rules and database writes; Markdown drives retrieval and summarization.

Put in order

Create and run an analyzer

Exam skills 5.2.3

Put the steps of creating and running a custom analyzer in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Improving a field

A claim analyzer returns the policy number correctly for most forms, but on forms that also show a vehicle registration number it sometimes returns the registration instead.

Refine the field description to distinguish the two ("Policy number printed after 'Policy no.', format MTR-0000000; not the vehicle registration"), optionally add a VehicleRegistration field so the model has somewhere to put it, and validate the format in code. Re-test on the labelled sample set before replacing the analyzer in production.

Check yourself

What is the main lever for improving the accuracy of a custom analyzer's field?

Show answer

A clear field description, which tells the analyzer exactly what to extract.

Exam Tips

Remember for the exam

  • Create analyzers with PUT; analyze with POST and poll Operation-Location.
  • Field methods: extract printed values, generate interpretations, classify into an enum.
  • Clear field descriptions are the main lever for extraction accuracy.