Truncate HuggingFace vectors that are too long

This commit is contained in:
Louis Dureuil 2024-01-29 11:22:24 +01:00
parent 9f8f3105d5
commit 1555870088
No known key found for this signature in database

View File

@ -151,7 +151,8 @@ impl Embedder {
let token_ids = tokens
.iter()
.map(|tokens| {
let tokens = tokens.get_ids().to_vec();
let mut tokens = tokens.get_ids().to_vec();
tokens.truncate(512);
Tensor::new(tokens.as_slice(), &self.model.device).map_err(EmbedError::tensor_shape)
})
.collect::<Result<Vec<_>, EmbedError>>()?;