From 523b945624232b244d2e4a4b1fd84cd0149e1749 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 17 Jul 2024 18:44:16 +0200 Subject: [PATCH] cleanup sample --- packages/sample/genaisrc/transformers-rank.genai.mts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/sample/genaisrc/transformers-rank.genai.mts b/packages/sample/genaisrc/transformers-rank.genai.mts index 3a976b0254..8665e38cae 100644 --- a/packages/sample/genaisrc/transformers-rank.genai.mts +++ b/packages/sample/genaisrc/transformers-rank.genai.mts @@ -9,19 +9,13 @@ const featureExtractor = await pipeline('feature-extraction'); // Function to rank documents async function rank(query: string, files: WorkspaceFile[]) { const documents = files.map(({ content }) => content); - // Extract features for the query const queryEmbedding = (await featureExtractor(query)).tolist()[0][0] - console.log(queryEmbedding) - // Extract features for each document and compute similarity const similarities = await Promise.all(documents.map(async (doc, i) => { const docEmbedding = (await featureExtractor(doc)).tolist()[0][0] const score = cos_sim(queryEmbedding, docEmbedding); return { file: files[i], score }; })); - - // Sort documents by similarity score in descending order similarities.sort((a, b) => b.score - a.score); - return similarities }