Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed_batch does not use parallel computation #1

Open
EricLBuehler opened this issue Jul 6, 2024 · 0 comments
Open

embed_batch does not use parallel computation #1

EricLBuehler opened this issue Jul 6, 2024 · 0 comments

Comments

@EricLBuehler
Copy link

Hi @ShelbyJenkins!

I was taking a look at this great crate, and I noticed that embed_batch does not use batching.

candle_embed/src/lib.rs

Lines 261 to 273 in 3036c6f

pub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> {
if texts.is_empty() {
return Err(Error::msg(
"CandleEmbed error: embed_batch called with empty texts",
));
}
let mut embeddings = vec![];
for text in texts {
let embedding = self.embed_one(text)?;
embeddings.push(embedding);
}
Ok(embeddings)
}

Perhaps you can add this feature by padding the texts and then unpadding the embeddings? It is just a thought, but I think it would improve performance significantly for real-world use cases!

@ShelbyJenkins ShelbyJenkins pinned this issue Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant