Table of Contents

Class Categorization

Namespace
LMKit.TextAnalysis
Assembly
LM-Kit.NET.dll

Provides functionality to classify content into predefined categories using a language model. This engine supports categorization tasks for both plain text and image attachments.

public sealed class Categorization
Inheritance
Categorization
Inherited Members

Constructors

Categorization(LM)

Initializes a new instance of the Categorization class using the specified language model. This categorization engine supports both plain text and image attachments.

Properties

AllowUnknownCategory

Gets or sets a value indicating whether the categorization engine can identify when content does not match any of the predefined categories. If set to true, the engine returns -1 (for single-category methods) or an empty list (for multi-category methods) when no suitable category is identified. If set to false, the engine always assigns the content to the nearest matching category, even if confidence is low.

Confidence

Gets the confidence level of the most recent categorization process.

Guidance

Gets or sets optional guidance text that can influence the categorization process. This can be used to steer the model towards certain themes or constraints.

Model

Gets the underlying language model instance associated with this categorization object.

UseEmbeddingClassifier

Gets or sets a value indicating whether the classifier should utilize an embedding-based classification strategy. When set to true, the engine is forced to classify using embeddings instead of a completion-based approach.

Methods

CreateTrainingObject(IList<string>, IList<(string, string)>, int)

Creates a training object for fine-tuning the categorization model using the provided training data.

GetBestCategory(IList<string>, Attachment, bool, CancellationToken)

Classifies the content provided as an attachment into one of the predefined categories. The attachment can represent plain text or an image. If the attachment is an image requiring vision processing, the underlying language model must support vision input.

GetBestCategory(IList<string>, string, bool, CancellationToken)

Classifies the specified plain text into one of the predefined categories.

GetBestCategoryAsync(IList<string>, Attachment, bool, CancellationToken)

Asynchronously classifies the content provided as an attachment into one of the predefined categories. The attachment may contain either plain text or image data. For image attachments that require vision processing, ensure that the underlying language model supports vision input.

GetBestCategoryAsync(IList<string>, string, bool, CancellationToken)

Asynchronously classifies the specified plain text into one of the predefined categories.

GetTopCategories(IList<string>, Attachment, int, bool, CancellationToken)

Classifies the content provided as an attachment into up to a specified maximum number of categories. The attachment can contain either plain text or image data. If the attachment is an image requiring vision processing, the underlying language model must support vision input.

GetTopCategories(IList<string>, string, int, bool, CancellationToken)

Classifies the specified plain text into up to a specified maximum number of categories.

GetTopCategoriesAsync(IList<string>, Attachment, int, bool, CancellationToken)

Asynchronously classifies the content provided as an attachment into up to a specified maximum number of categories. The attachment may contain either plain text or image data. For image attachments that require vision processing, the underlying language model must support vision input.

GetTopCategoriesAsync(IList<string>, string, int, bool, CancellationToken)

Asynchronously classifies the specified plain text into up to a specified maximum number of categories.