Share via

InternalServerError: An unexpected error occurred when trying to train a model

Richard Bennett 0 Reputation points
2026-03-16T14:19:20.98+00:00

Attempting to create a custom classification model with 5 small documents of two classes in Word and/or PDF.

Training fails every time with "InternalServerError: An unexpected error occurred".

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

2 answers

Sort by: Most helpful
  1. SAI JAGADEESH KUDIPUDI 2,625 Reputation points Microsoft External Staff Moderator
    2026-04-28T17:18:54.37+00:00

    Hi Richard Bennett,

    Thanks for reaching out and for sharing the details.

    The InternalServerError (HTTP 500) you’re seeing during model training in Azure Document Intelligence is a generic service-side error. In scenarios like yours (very small dataset across classes), this is most commonly linked to training data limitations or transient backend conditions, rather than a configuration issue.

    1. Increase your training dataset (most impactful step) You’re currently using about 5 documents across two classes. While this may meet the minimum requirement, it’s often not sufficient for stable training.
    • Try adding more samples per class (ideally 10+ if possible)

    Keep the dataset balanced across classes

    Include some variation in document formats/content

    1. Validate document quality Make sure the files are suitable for training:

    Use PDF or DOCX formats

    Avoid scanned/image-only PDFs (text must be extractable)

    Ensure documents are clear and not noisy

    1. Verify storage access (if using Blob Storage) If your training data is in Azure Storage:

    Confirm the container is accessible

    If the storage is behind a firewall or private endpoint, ensure the service can reach it

    Managed identity is only needed in restricted access scenarios, not by default

    1. Retry the training Since HTTP 500 can also be transient:

    Wait a few minutes and retry

    If possible, try triggering training via a different method (Portal vs API/SDK)

    Please share the following so we can investigate further:

    • x-ms-correlation-request-id
    • Timestamp of the failure

    How you initiated training (Portal, REST API, or SDK)
    In your case, the issue is most likely due to the very small training dataset or document quality, and expanding the dataset typically resolves this kind of error.

    Microsoft documentation

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
    Please do not forget to "Accept Answer" and "up-vote" wherever the information provided helps you, as this can be beneficial to other community members.


  2. Q&A Assist
    2026-03-16T14:19:35.7866667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The error is most likely caused by a missing prerequisite for training a custom classification model rather than by document size or count.

    For custom classification in Azure Document Intelligence v4.0, each training document must have corresponding layout model results stored alongside it. When training via Studio, if layout results are not present, Studio will try to run the layout model for every document. That background layout run can be throttled and fail, which surfaces as generic internal errors.

    To unblock training:

    1. Ensure minimum dataset requirements
      • At least two classes.
      • At least five documents per class.
      • Word, PowerPoint, Excel, PDF, or image formats are supported; having at least one sample of each format used per class is recommended.
    2. Pre‑generate layout results for all training documents
      • In Document Intelligence Studio, open the Layout model.
      • Run the layout model on each training document.
      • Download or save the layout results and upload them to the same location as the original document (same folder, same storage container) so that each document has its corresponding layout JSON.
    3. Verify layout result format
      • Layout results must be the raw layout API response, not the SDK object model.
      • When training via SDK/API, place these layout JSON files in the folders that contain the individual documents.
    4. Retry training the classifier
      • After all documents have layout results in place, start training the custom classification model again (via Studio or API).

    If training still fails with the same internal error after layout results are correctly added, check for regional service issues (Service Health) and, if needed, try training in another region or open a support case, as the remaining cause is likely service-side.


    References:

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.