Table of Contents

Constructor VlmOcr

Namespace
LMKit.Extraction.Ocr
Assembly
LM-Kit.NET.dll

VlmOcr(LM)

Initializes a new instance of the VlmOcr class using the specified model with a default intent selected automatically based on the model family.

public VlmOcr(LM model)

Parameters

model LM

The LM instance that will perform OCR. The model must support text generation, accept visual inputs, and be loaded with tensor weights.

Examples

var model = LM.LoadFromModelID("gemma3:12b");
var ocr = new VlmOcr(model);
Console.WriteLine($"Default intent: {ocr.Intent}");

Remarks

The default intent is determined by the model family: for models with native OCR support (for example, PaddleOCR-VL), the default is PlainText; for general-purpose vision-language models, the default is Markdown.

Exceptions

ArgumentNullException

Thrown if model is null.

InvalidModelException

Thrown if model does not support text generation, does not support vision, or has been loaded without tensor weights.

VlmOcr(LM, VlmOcrIntent)

Initializes a new instance of the VlmOcr class using the specified model and an explicit OCR intent.

public VlmOcr(LM model, VlmOcrIntent intent)

Parameters

model LM

The LM instance that will perform OCR. The model must support text generation, accept visual inputs, and be loaded with tensor weights.

intent VlmOcrIntent

The desired outcome of the OCR operation. Pass Undefined to let the engine select a default intent based on the model family. Not every model natively supports every intent; the engine applies the best available instruction and post-processing strategy for the loaded model.

Examples

var model = LM.LoadFromModelID("gemma3:12b");
var ocr = new VlmOcr(model, VlmOcrIntent.TableRecognition);

Exceptions

ArgumentNullException

Thrown if model is null.

InvalidModelException

Thrown if model does not support text generation, does not support vision, or has been loaded without tensor weights.

Share