pub struct Embeddings {
pub vectors: Vec<(String, Vec<f64>)>,
/* private fields */
}Expand description
Lightweight semantic embeddings for repo memory. §3.8: “optional embeddings (per project)”
Fields§
§vectors: Vec<(String, Vec<f64>)>Stored text + normalized hashing-vector embedding.
Implementations§
Source§impl Embeddings
impl Embeddings
pub const DEFAULT_DIMENSIONS: usize = 512
pub fn new() -> Self
pub fn with_dimensions(dimensions: usize) -> Self
Sourcepub fn embed(&self, text: &str) -> Vec<f64>
pub fn embed(&self, text: &str) -> Vec<f64>
Build a deterministic hashing-vector embedding from text.
This is intentionally local-first: no model/API key required, fixed dimensions across documents, stable across sessions, and good enough for lexical semantic recall in memory. It uses signed feature hashing with unigram + adjacent bigram features, sublinear term frequency, and L2 normalization.
pub fn add(&mut self, text: &str)
pub fn add_many<I, S>(&mut self, texts: I)
Sourcepub fn search(&self, query: &str, k: usize) -> Vec<String>
pub fn search(&self, query: &str, k: usize) -> Vec<String>
Find the most similar stored text to the query
pub fn search_scored(&self, query: &str, k: usize) -> Vec<(f64, String)>
pub fn save_to_path(&self, path: impl AsRef<Path>) -> Result<()>
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self>
Trait Implementations§
Source§impl Clone for Embeddings
impl Clone for Embeddings
Source§fn clone(&self) -> Embeddings
fn clone(&self) -> Embeddings
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Embeddings
impl Debug for Embeddings
Auto Trait Implementations§
impl Freeze for Embeddings
impl RefUnwindSafe for Embeddings
impl Send for Embeddings
impl Sync for Embeddings
impl Unpin for Embeddings
impl UnsafeUnpin for Embeddings
impl UnwindSafe for Embeddings
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more