pub enum EmbeddingsSource {
Hdf5(H5Dataset),
Zarr {
store: ReadableListableStorage,
path: String,
},
Memory(Array2<f32>),
}Expand description
The embeddings a build reads, from an .h5 or .zarr file or an
Array2<f32> already in memory. Files may store f32, f16, uint8 or int8,
but read_vecs always returns f32 and only reads the rows asked for.
Variants§
Implementations§
Source§impl EmbeddingsSource
impl EmbeddingsSource
Sourcepub fn open(path: &Path, name: &str) -> Result<Self>
pub fn open(path: &Path, name: &str) -> Result<Self>
Opens the dataset (.h5) or array (.zarr) called name in the file
at path, picking the format from path’s extension.
Sourcepub fn from_zarr(store: ReadableListableStorage, path: String) -> Self
pub fn from_zarr(store: ReadableListableStorage, path: String) -> Self
Creates an embeddings source from the zarr array at path in store.
Sourcepub fn natural_chunk_vecs(&self, fallback: usize) -> Result<usize>
pub fn natural_chunk_vecs(&self, fallback: usize) -> Result<usize>
Returns how many vectors one on-disk chunk holds, or fallback if the
source isn’t chunked.
Sourcepub fn chunk_aligned_batch_vecs(
&self,
memory_floor_vecs: usize,
fallback: usize,
) -> Result<usize>
pub fn chunk_aligned_batch_vecs( &self, memory_floor_vecs: usize, fallback: usize, ) -> Result<usize>
Picks a read batch size that covers whole chunks. Rounds memory_floor_vecs,
the batch size the memory budget allows, up to whole chunks, so no chunk is
split and decoded twice. fallback works as in natural_chunk_vecs.
Sourcepub fn native_dtype(&self) -> Result<EmbeddingDtype>
pub fn native_dtype(&self) -> Result<EmbeddingDtype>
Returns the dtype the embeddings are stored as, always F32 for Memory.
Auto Trait Implementations§
impl !RefUnwindSafe for EmbeddingsSource
impl !Send for EmbeddingsSource
impl !Sync for EmbeddingsSource
impl !UnwindSafe for EmbeddingsSource
impl Freeze for EmbeddingsSource
impl Unpin for EmbeddingsSource
impl UnsafeUnpin for EmbeddingsSource
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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