Struct Embedding
- Namespace
- FoundationaLLM.Common.Models.Vectorization
- Assembly
- FoundationaLLM.Common.dll
Stores a vector embedding. This type should be serialized using Emedding.JsonConverter.
public struct Embedding : IEquatable<Embedding>
- Implements
- Inherited Members
- Extension Methods
Constructors
Embedding(int)
Creates an embedding with a zero-initialzed vector of a specified size.
public Embedding(int size)
Parameters
size
intThe size of the vector representing the embedding.
Embedding(ReadOnlyMemory<float>)
Creates an embedding from a vector represents as a ReadOnlyMemory<T> object.
public Embedding(ReadOnlyMemory<float> vector)
Parameters
vector
ReadOnlyMemory<float>
Embedding(float[])
Creates an embedding from a vector represented as an array of real numbers.
public Embedding(float[] vector)
Parameters
vector
float[]The array containing the vector values.
Properties
Length
Length of the vector representing the embedding. This property is only serialized when Embedding.JsonConverter is used.
[JsonIgnore]
public readonly int Length { get; }
Property Value
Vector
The vector that represents the embedding. This property is only serialized when Embedding.JsonConverter is used.
[JsonIgnore]
public ReadOnlyMemory<float> Vector { readonly get; set; }
Property Value
Methods
Equals(Embedding)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Embedding other)
Parameters
other
EmbeddingAn object to compare with this object.
Returns
Equals(object?)
Inidicates whether the current object is equal to another object.
public override readonly bool Equals(object? obj)
Parameters
obj
objectAn object to compare with this object.
Returns
- bool
True if the object is equal to the obj param and False otherwise.
GetHashCode()
Calculated the hashcode for this Embedding.
public override readonly int GetHashCode()
Returns
- int
The hash value represented by an integer.
Operators
operator ==(Embedding, Embedding)
Checks if two Embedding values are equal.
public static bool operator ==(Embedding v1, Embedding v2)
Parameters
v1
EmbeddingThe first Embedding value to be cheched.
v2
EmbeddingThe second Embedding value to be checked.
Returns
- bool
True if the two values are equal, False otherwise.
operator !=(Embedding, Embedding)
Checks if two Embedding values are different.
public static bool operator !=(Embedding v1, Embedding v2)
Parameters
v1
EmbeddingThe first Embedding value to be cheched.
v2
EmbeddingThe second Embedding value to be checked.
Returns
- bool
True if the two values are different, False otherwise.