UReader<T>

Models & Types · AiDotNet.VisionLanguage.Document

UReader: universal OCR-free visually-situated language model.

Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → UReader<T>

Implements: IDocumentUnderstandingModel<T>

For Beginners

UReader is a universal OCR-free model for understanding text in documents, web pages, and natural scenes. Default values follow the original paper settings.

How It Works

UReader (2024) is a universal OCR-free model for visually-situated language understanding. It handles diverse document types including scanned documents, web pages, slides, and natural scene text through adaptive resolution processing and shape-adaptive cropping, unifying document understanding across different visual text formats without requiring OCR preprocessing.

References:

  • Paper: “UReader: Universal OCR-free Visually-situated Language Understanding” (2024)

Example

// Create a UReader model for universal OCR-free document understanding
// handling documents, web pages, slides, and scene text
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.TwoDimensional,
    taskType: NeuralNetworkTaskType.ImageClassification,
    inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
            
// ONNX inference mode with pre-trained model
var model = new UReader<double>(architecture, "ureader.onnx");
            
// Training mode with native layers
var trainModel = new UReader<double>(architecture, new UReaderOptions());

Constructors

Constructor Summary
UReader(NeuralNetworkArchitecture<T> architecture, UReaderOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
UReader(NeuralNetworkArchitecture<T> architecture, string modelPath, UReaderOptions options)

Properties

Property Summary
bool IsOcrFree { get; }
int DecoderEmbeddingDim { get; }
int EmbeddingDimension { get; }
int MaxGenerationLength { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> AnswerDocumentQuestion(Tensor<T> documentImage, string question)
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> ExtractText(Tensor<T> documentImage)
Tensor<T> GenerateFromImage(Tensor<T> image, string prompt) Generates text from a document image using UReader’s shape-adaptive cropping pipeline.