Why is the Custom Extraction Model combining two fields that are no where near each other?

Becky Burgess 40 Reputation points
2025-06-30T14:25:33.97+00:00

We currently use our custom extraction model to read purchase orders in our live production environment. We routinely train and test the model with various purchase order formats. Lately, we've consistently seen Azure trying to combine customer material codes into one string when only one is needed AND we have trained it this way. Azure grabs the customer's material number twice even though the numbers are not close to each other anywhere on PO. And sometimes they are close to each other but there is clearly a space or two separating them. This has caused significant errors on our end and manual intervention is becoming the norm. Is there anything we can do to limit this issue? Anyone else having a similar issue?

Azure Document Intelligence in Foundry Tools
0 comments No comments

Answer accepted by question author
Jerald Felix 18,760 Reputation points Volunteer Moderator
2025-06-30T15:35:41.78+00:00

Hi Becky,

What you’re running into is a known behaviour of the current custom-neural extraction engine: if two tokens that look alike sit on the same OCR text line (or their labelled regions overlap by even a pixel or two), the model may treat them as one “long” value. Microsoft has acknowledged that field / cell merging can still happen when character spacing is tight even in v4 GA and there’s no official fix date yet.

Why it happens

Tight reading-order grouping – internally the model builds “chunks” from the OCR line. If both material codes are caught in the same chunk, they are emitted as one string.

Over-lapping or generous labels – if, during labelling, a bounding box touches any part of the neighbour code, the model learns they belong together.

Lack of negative examples – when most training docs only show a single code per line, the model generalises that pattern and struggles when a second code appears elsewhere.

Practical mitigations

Action Details & tips
Tighten your labels In Document Intelligence Studio, switch to Draw region (or Bounding-box) and zoom in – the box should hug only the digits you need. Avoid Shift-selecting a whole line. Microsoft moderators call this out as the first thing to try (learn.microsoft.com).
Tighten your labels In Document Intelligence Studio, switch to Draw region (or Bounding-box) and zoom in – the box should hug only the digits you need. Avoid Shift-selecting a whole line. Microsoft moderators call this out as the first thing to try ([learn.microsoft.com](https://learn.microsoft.com/en-us/answers/questions/2180762/azure-document-intelligence-custom-model-fails-to"Azure Document Intelligence: Custom Model Fails to Separate Adjacent Document Number and Date - Microsoft Q&A")).
Add “difficult” samples Retrain with 10-20 extra POs where the two codes are close together and separately label each instance. Variety helps the model learn the separator.
Use the right schema If the material code appears repeatedly in a line-items grid, label the whole table as a dynamic table and let each code be its own cell instead of a top-level field.
Try a Template model If your PO layout is stable, train a custom template model (anchor on the “Material #” key). Template models use positional anchors and rarely merge distant fields ([learn.microsoft.com](https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/train/custom-model?view=doc-intel-4.0.0&utm_source=chatgpt.com"Custom document models - Document Intelligence - Azure AI services")).
Regex post-processing As a safety net, split strings downstream: re.findall(r'[A-Z0-9]{5,12}', value) will usually separate two concatenated codes.
Upgrade & re-test Make sure you’re on the latest GA API 2024-11-30 and re-publish the model; a few token-splitting tweaks shipped in April 2025.
Raise a support ticket If merging still blocks production, open a ticket with a redacted sample document. Support can forward it to the DI product team, who track these edge cases.

Until Microsoft rolls out a model change, the best defence is precise labelling plus a light post-processing rule that splits any accidental concatenations. In most projects we see the error rate drop to near-zero once the bounding boxes are tightened and a regex fallback is in place.

Hope this gets your POs flowing again—let me know if you’d like example code or have any follow-up questions!

Best Regards,

Jerald Felix

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.