Skip to main content

embed_passages_serial

Function embed_passages_serial 

Source
pub fn embed_passages_serial<'a, I>(
    embedder: &Mutex<TextEmbedding>,
    texts: I,
) -> Result<Vec<Vec<f32>>, AppError>
where I: IntoIterator<Item = &'a str>,
Expand description

Embed multiple passages one-by-one (serial ONNX inference).

Serialization is intentional: ONNX batch inference can trigger pathological runtime behaviour on real-world Markdown chunks (variable token lengths cause extreme padding overhead). Callers that need parallelism should use the rayon ThreadPool in src/commands/ingest.rs::run, which partitions work across CPU threads and calls this function per shard.