SmartExtensions
Wisej.AI.SmartExtensions
Last updated
Wisej.AI.SmartExtensions
Last updated
Namespace: Wisej.AI
Assembly: Wisej.AI (3.5.0.0)
Provides extension methods for various operations such as calculating cosine similarity, computing clusters, converting strings to camel case, and managing services in a service provider.
Adds or replaces a service in the service provider with the specified implementation type.
TService
The type of service to add or replace.
TImplementation
The type of the implementation to use.
services
The service provider to modify.
The lifetime of the service.
Returns: . The modified service provider.
Adds or replaces a service in the service provider with the specified implementation instance.
TService
The type of service to add or replace.
services
The service provider to modify.
implementation
The implementation instance to use.
The lifetime of the service.
Adds or replaces a service in the service provider using a factory method.
TService
The type of service to add or replace.
services
The service provider to modify.
factory
The factory method to create the service instance.
The lifetime of the service.
Computes clusters from the given embeddings using the K-Means clustering algorithm.
embeddings
The embeddings to cluster.
count
The number of clusters to create.
The maximum divergence allowed for convergence.
K-Means clustering is a method of vector quantization, originally from signal processing, that is popular for cluster analysis in data mining. This method partitions the embeddings into count clusters.
Calculates the cosine similarity between two vectors.
vectorA
The first vector.
vectorB
The second vector.
Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space. It is defined as the cosine of the angle between the two vectors.
Calculates the cosine similarity between a vector and an array of vectors.
vectorA
The vector to compare.
vectorB
The array of vectors to compare against.
This method extends the single vector cosine similarity calculation to handle multiple vectors, returning an array of similarity scores.
Converts the first character of the string to lowercase, making it camel case.
text
The string to convert.
This method is useful for converting PascalCase strings to camelCase, which is often used in JSON serialization and other contexts.
lifetime
lifetime
Returns: . The modified service provider.
lifetime
Returns: . The modified service provider.
maxDivergence
Returns: . An array of tuples containing the centroid and vectors of each cluster.
Returns: . The cosine similarity between the two vectors.
Returns: . An array of cosine similarity values for each vector in the array.
Returns: . The camel case version of the string.