mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
RuntimeEmbedder and RuntimeFragments
This commit is contained in:
parent
836ae19bec
commit
422a786ffd
1 changed files with 24 additions and 13 deletions
|
@ -584,6 +584,7 @@ pub struct ArroyStats {
|
||||||
pub documents: RoaringBitmap,
|
pub documents: RoaringBitmap,
|
||||||
}
|
}
|
||||||
/// One or multiple embeddings stored consecutively in a flat vector.
|
/// One or multiple embeddings stored consecutively in a flat vector.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Embeddings<F> {
|
pub struct Embeddings<F> {
|
||||||
data: Vec<F>,
|
data: Vec<F>,
|
||||||
dimension: usize,
|
dimension: usize,
|
||||||
|
@ -734,15 +735,26 @@ impl EmbeddingConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map of embedder configurations.
|
/// Map of runtime embedder data.
|
||||||
///
|
|
||||||
/// Each configuration is mapped to a name.
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct EmbeddingConfigs(HashMap<String, (Arc<Embedder>, Arc<Prompt>, bool)>);
|
pub struct RuntimeEmbedders(HashMap<String, Arc<RuntimeEmbedder>>);
|
||||||
|
|
||||||
impl EmbeddingConfigs {
|
pub struct RuntimeEmbedder {
|
||||||
|
pub embedder: Arc<Embedder>,
|
||||||
|
pub document_template: Prompt,
|
||||||
|
pub fragments: Vec<RuntimeFragment>,
|
||||||
|
pub is_quantized: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct RuntimeFragment {
|
||||||
|
pub name: String,
|
||||||
|
pub id: u8,
|
||||||
|
pub template: JsonTemplate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RuntimeEmbedders {
|
||||||
/// Create the map from its internal component.s
|
/// Create the map from its internal component.s
|
||||||
pub fn new(data: HashMap<String, (Arc<Embedder>, Arc<Prompt>, bool)>) -> Self {
|
pub fn new(data: HashMap<String, Arc<RuntimeEmbedder>>) -> Self {
|
||||||
Self(data)
|
Self(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,24 +763,23 @@ impl EmbeddingConfigs {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an embedder configuration and template from its name.
|
/// Get an embedder configuration and template from its name.
|
||||||
pub fn get(&self, name: &str) -> Option<(Arc<Embedder>, Arc<Prompt>, bool)> {
|
pub fn get(&self, name: &str) -> Option<Arc<RuntimeEmbedder>> {
|
||||||
self.0.get(name).cloned()
|
self.0.get(name).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_as_ref(&self) -> &HashMap<String, (Arc<Embedder>, Arc<Prompt>, bool)> {
|
pub fn inner_as_ref(&self) -> &HashMap<String, Arc<RuntimeEmbedder>> {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_inner(self) -> HashMap<String, (Arc<Embedder>, Arc<Prompt>, bool)> {
|
pub fn into_inner(self) -> HashMap<String, Arc<RuntimeEmbedder>> {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoIterator for EmbeddingConfigs {
|
impl IntoIterator for RuntimeEmbedders {
|
||||||
type Item = (String, (Arc<Embedder>, Arc<Prompt>, bool));
|
type Item = (String, Arc<RuntimeEmbedder>);
|
||||||
|
|
||||||
type IntoIter =
|
type IntoIter = std::collections::hash_map::IntoIter<String, Arc<RuntimeEmbedder>>;
|
||||||
std::collections::hash_map::IntoIter<String, (Arc<Embedder>, Arc<Prompt>, bool)>;
|
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.0.into_iter()
|
self.0.into_iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue