IDocumentModel<T>

Interfaces · AiDotNet.Document.Interfaces

Base interface for all document AI models in AiDotNet.

Implements: IFullModel<T, Tensor<T>, Tensor<T>>

Known implementations: IDocumentClassifier<T>, IDocumentQA<T>, IFormUnderstanding<T>, ILayoutDetector<T>, IOCRModel<T>, IPageSegmenter<T>, IReadingOrderDetector<T>, ITableExtractor<T>, ITextDetector<T>, ITextRecognizer<T>

For Beginners

A document AI model processes document images (scanned pages, PDFs, photos of text) to extract information, understand layout, or answer questions.

Key concepts:

  • Document images have shape [batch, channels, height, width]
  • Models can run in Native mode (pure C#) or ONNX mode (optimized runtime)
  • All models support both training and inference
  • Many document models combine vision and language understanding

Example usage:

How It Works

This interface extends IFullModel to provide the core contract for document AI models, inheriting standard methods for training, inference, model persistence, and gradient computation.

Properties

Property Summary
DocumentType SupportedDocumentTypes { get; } Gets the supported document types for this model.
bool IsOnnxMode { get; } Gets whether this model is running in ONNX inference mode.
bool RequiresOCR { get; } Gets whether this model requires OCR preprocessing.
int ExpectedImageSize { get; } Gets the expected input image size (assumes square images).
int MaxSequenceLength { get; } Gets the maximum sequence length for text processing.

Methods

Method Summary
Tensor<T> EncodeDocument(Tensor<T> documentImage) Processes a document image and returns encoded features.
string GetModelSummary() Gets a summary of the model architecture.
void ValidateInputShape(Tensor<T> documentImage) Validates that an input tensor has the correct shape for this model.