Telerik.Documents.AI.Core
Represents a text embedding consisting of the original text and its associated vector representation.
Initializes a new instance of the Embedding class with the specified text and vector representation.
The source fragment to associate with the embedding. Cannot be null.
The vector representation of the text. Cannot be null.
Gets the fragment content associated with this instance.
Gets the vector representation as an array of single-precision floating-point values.
Provides methods for splitting text into context fragments and joining them.
Splits the specified text into fragments suitable for processing, based on the model and encoding.
The input text to split.
The maximum token size for a single embedding.
An array of text fragments.
Provides methods for retrieving relevant context from embeddings and managing text fragments.
Gets the text representation of the relevant embeddings for the provided question.
The user prompt to get relevant context for.
The text representations of the relevant embeddings.
Asynchronously splits the specified text into fragments based on the provided embedding token size.
The text to be divided into fragments. Cannot be null.
The maximum number of tokens allowed in each fragment. Must be a positive integer.
A task that represents the asynchronous operation of fragmenting the text.
Defines a contract for generating vector embeddings from a collection of text fragments asynchronously.
Implementations of this interface typically interact with machine learning models or external
services to produce embeddings. The returned embeddings correspond to the input fragments in order.
Generates embeddings for the specified collection of text fragments asynchronously.
A list of text fragments for which to generate embeddings. Each fragment represents a separate input to be
embedded. Cannot be null or contain null elements.
A task that represents the asynchronous operation. The task result contains an array of Embedding objects
corresponding to each input fragment, in the same order as provided.
Represents configuration settings for generating embeddings using an AI model.
Gets the maximum input token limit the model allows.
Gets the size in tokens of each embedding that will be generated.
Gets the tokenization encoding.
Gets the ID of the model.
Defines a fragment which can be converted to text representations suitable for context or embedding scenarios.
Returns a string representation of the object's context suitable for display or logging.
A string containing text suitable for adding to an LLM context.
Converts the current object to a plain text representation suitable for use in embedding models.
A string containing the embedding-compatible text representation of the object.
Provides access to a collection of string fragments.
Gets the collection of fragments associated with the current instance.
Defines methods for calculating similarity scores between a query and a set of text fragments, enabling
retrieval of the most relevant fragments based on semantic similarity.
Implementations of this interface typically use vector embeddings to measure semantic
similarity between the input question and provided fragments. Methods return an array of similarity scores,
ordered by relevance, which can be used to identify the closest matches. This interface is intended for use in
scenarios such as search, question answering, or recommendation systems where ranking by semantic similarity is
required.
The input prompt to compare against the provided fragments. Cannot be null.
A list of embeddings representing the fragments to be compared. Cannot be null or empty.
A task that represents the asynchronous operation. The task result contains an array of SimilarityScore objects,
each representing a fragment and its similarity score. The array will be empty if no fragments are similar.
Defines behavior for settings working with embedding of json.
Determines whether the context sent to the model is in JSON or plain text format, if json format is applicable.
Plain text might consume more tokens but should lead to better results when asking the LLM.
Gets the maximum number of tokens allowed in the context to be sent to the model.
Defines behavior for settings working with embedding of plain text.
Gets or sets the maximum number of embeddings to be sent to the model.
Defines a contract for counting tokens in a given input.
Implementations of this interface are responsible for analyzing input data and determining
the number of tokens it contains. The definition of a "token" may vary depending on the specific implementation
(e.g., words, characters, or other units of text).
Counts the number of tokens in the specified input.
The input data to analyze.
The number of tokens in the input.
Represents a score indicating the similarity of an item to a reference point.
This structure is used to encapsulate the similarity score of an item, along with the item
itself. It is particularly useful in scenarios where items need to be ranked or sorted based on their similarity
to a reference point. The ensures that items with the same similarity score are
distinguished by a unique index, which is useful for operations that require distinct results.
The type of the item being compared.
The similarity score indicating how closely the item matches the comparison criteria. Higher values represent
greater similarity.
The item of type T that is associated with the similarity score.
Represents a score indicating the similarity of an item to a reference point.
This structure is used to encapsulate the similarity score of an item, along with the item
itself. It is particularly useful in scenarios where items need to be ranked or sorted based on their similarity
to a reference point. The ensures that items with the same similarity score are
distinguished by a unique index, which is useful for operations that require distinct results.
The type of the item being compared.
The similarity score indicating how closely the item matches the comparison criteria. Higher values represent
greater similarity.
The item of type T that is associated with the similarity score.
Gets the similarity score between two compared entities.
Gets the item of type .
Gets a comparer that orders instances by descending similarity, using the
unique index as a tiebreaker.
This comparer is useful for sorting collections of
so that items with higher similarity values appear first. If two items have the same similarity, the one
with the lower unique index is considered less than the other.
Returns a string that represents the current object, including its similarity value and item.
A string containing the similarity value and item of this instance, formatted for readability.