pub struct Embedding {
pub model: String,
pub dtype: Dtype,
pub dim: u32,
pub vector: Bytes,
}Expand description
A dense vector embedding produced by a named model.
Embeddings live in the per-commit sidecar (Commit.embeddings
Prolly tree, keyed by NodeCid) rather than inline on Node. This
keeps dense bytes out of the canonical Node hash so nondeterministic
producers (e.g. ORT thread-count drift) cannot perturb NodeCid.
Fields§
§model: StringFree-form model identifier ("text-embedding-3-small",
"nomic-embed-text-v1.5", etc.).
dtype: DtypeElement type of the vector. Defaults to f32 on encode when absent.
dim: u32Vector dimension.
vector: BytesVector bytes. Length MUST equal dim * dtype.byte_width() per
SPEC §4.1; validate with Embedding::validate after decoding.
Implementations§
Source§impl Embedding
impl Embedding
Sourcepub const fn validate(&self) -> Result<(), ObjectError>
pub const fn validate(&self) -> Result<(), ObjectError>
Validate the vector.len() == dim × byte_width invariant.
§Errors
Returns ObjectError::EmbeddingSizeMismatch if the invariant is
violated.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Embedding
impl<'de> Deserialize<'de> for Embedding
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Embedding
impl StructuralPartialEq for Embedding
Auto Trait Implementations§
impl !Freeze for Embedding
impl RefUnwindSafe for Embedding
impl Send for Embedding
impl Sync for Embedding
impl Unpin for Embedding
impl UnsafeUnpin for Embedding
impl UnwindSafe for Embedding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more