Remove options

This commit is contained in:
Mubelotix 2025-06-24 15:10:15 +02:00
parent 695877043a
commit d08e89ea3d
9 changed files with 31 additions and 33 deletions

View file

@ -196,7 +196,7 @@ impl SubEmbedder {
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> std::result::Result<Vec<Vec<Embedding>>, EmbedError> {
match self {
SubEmbedder::HuggingFace(embedder) => embedder.embed_index(text_chunks),
@ -218,7 +218,7 @@ impl SubEmbedder {
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> std::result::Result<Vec<Embedding>, EmbedError> {
match self {
SubEmbedder::HuggingFace(embedder) => embedder.embed_index_ref(texts),

View file

@ -749,7 +749,7 @@ impl Embedder {
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> std::result::Result<Vec<Vec<Embedding>>, EmbedError> {
match self {
Embedder::HuggingFace(embedder) => embedder.embed_index(text_chunks),
@ -772,7 +772,7 @@ impl Embedder {
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> std::result::Result<Vec<Embedding>, EmbedError> {
match self {
Embedder::HuggingFace(embedder) => embedder.embed_index_ref(texts),

View file

@ -121,21 +121,21 @@ impl Embedder {
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Vec<Embedding>>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
text_chunks
.into_iter()
.map(move |chunk| self.embed(&chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(&chunk, None, Some(embedder_stats.clone())))
.collect()
} else {
threads
.install(move || {
text_chunks
.into_par_iter()
.map(move |chunk| self.embed(&chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(&chunk, None, Some(embedder_stats.clone())))
.collect()
})
.map_err(|error| EmbedError {
@ -149,14 +149,14 @@ impl Embedder {
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Vec<f32>>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;
@ -166,7 +166,7 @@ impl Embedder {
.install(move || {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.par_chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;

View file

@ -262,21 +262,21 @@ impl Embedder {
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Vec<Embedding>>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
text_chunks
.into_iter()
.map(move |chunk| self.embed(&chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(&chunk, None, Some(embedder_stats.clone())))
.collect()
} else {
threads
.install(move || {
text_chunks
.into_par_iter()
.map(move |chunk| self.embed(&chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(&chunk, None, Some(embedder_stats.clone())))
.collect()
})
.map_err(|error| EmbedError {
@ -290,14 +290,14 @@ impl Embedder {
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Vec<f32>>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;
Ok(embeddings.into_iter().flatten().collect())
@ -306,7 +306,7 @@ impl Embedder {
.install(move || {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.par_chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;

View file

@ -208,21 +208,21 @@ impl Embedder {
&self,
text_chunks: Vec<Vec<String>>,
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Vec<Embedding>>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
text_chunks
.into_iter()
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect()
} else {
threads
.install(move || {
text_chunks
.into_par_iter()
.map(move |chunk| self.embed(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed(chunk, None, Some(embedder_stats.clone())))
.collect()
})
.map_err(|error| EmbedError {
@ -236,14 +236,14 @@ impl Embedder {
&self,
texts: &[&str],
threads: &ThreadPoolNoAbort,
embedder_stats: Option<Arc<EmbedderStats>>,
embedder_stats: Arc<EmbedderStats>,
) -> Result<Vec<Embedding>, EmbedError> {
// This condition helps reduce the number of active rayon jobs
// so that we avoid consuming all the LMDB rtxns and avoid stack overflows.
if threads.active_operations() >= REQUEST_PARALLELISM {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed_ref(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed_ref(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;
@ -253,7 +253,7 @@ impl Embedder {
.install(move || {
let embeddings: Result<Vec<Vec<Embedding>>, _> = texts
.par_chunks(self.prompt_count_in_chunk_hint())
.map(move |chunk| self.embed_ref(chunk, None, embedder_stats.clone()))
.map(move |chunk| self.embed_ref(chunk, None, Some(embedder_stats.clone())))
.collect();
let embeddings = embeddings?;