From 74d91d52e51efd1afbcd7be29efa7b67696124b4 Mon Sep 17 00:00:00 2001 From: osmarks Date: Wed, 29 May 2024 21:25:50 +0100 Subject: [PATCH] probably I should do better testing --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index bb92f1e..1a6b740 100644 --- a/src/main.rs +++ b/src/main.rs @@ -734,23 +734,23 @@ async fn handle_request(config: Arc, client: Arc, index: &IInde if !image_batch.is_empty() { batches.push( - EmbeddingRequest::Images { + (EmbeddingRequest::Images { images: image_batch - } + }, image_weights) ); } if !text_batch.is_empty() { batches.push( - EmbeddingRequest::Text { + (EmbeddingRequest::Text { text: text_batch, - } + }, text_weights) ); } - for batch in batches { + for (batch, weights) in batches { let embs: Vec> = query_clip_server(&client, &config.service.clip_server, "/", batch).await?; - for emb in embs { - total_embedding += &ndarray::Array::from_vec(decode_fp16_buffer(&emb)); + for (emb, weight) in embs.into_iter().zip(weights) { + total_embedding += &(ndarray::Array::from_vec(decode_fp16_buffer(&emb)) * weight); } }