Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions rust/src/embeddings/local/qwen3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,20 @@ impl Qwen3Embed for Qwen3Embedder {
for mini_text_batch in text_batch.chunks(batch_size) {
let (token_ids, attention_mask) =
tokenize_batch(&self.tokenizer, mini_text_batch, &self.device)?;

let embeddings: Tensor = {
let mut model = self.model.write().map_err(|e| anyhow::anyhow!("Lock poisoned: {}", e))?;
model.forward(&token_ids, &attention_mask, 0)?.to_dtype(DType::F32)?
let mut model = self
.model
.write()
.map_err(|e| anyhow::anyhow!("Lock poisoned: {}", e))?;
let result = model
.forward(&token_ids, &attention_mask, 0)?
.to_dtype(DType::F32)?;
model.clear_kv_cache();

result
};

self.model.write().map_err(|e| anyhow::anyhow!("Lock poisoned: {}", e))?.clear_kv_cache();
let attention_mask = PooledOutputType::from(attention_mask);
let attention_mask = Some(&attention_mask);
let model_output = ModelOutput::Tensor(embeddings.clone());
Expand Down
Loading