Revert "Update embedding model for WebSearch (#437)"
Browse filesThis reverts commit f88542b1121903c1df34b20bd7b8213148e85ca0.
5 unmodified lines6789101112131415161718195 unmodified linesreturn 1.0 - dot(tensor1.data, tensor2.data);}const extractor = await pipeline("feature-extraction", "Xenova/gte-small");export async function findSimilarSentences(query: string,sentences: string[],{ topK = 5 }: { topK: number }) {const input = [query, ...sentences];const output: Tensor = await extractor(input, { pooling: "mean", normalize: true });const queryTensor: Tensor = output[0];5 unmodified lines67891011121314151617181920215 unmodified linesreturn 1.0 - dot(tensor1.data, tensor2.data);}const extractor = await pipeline("feature-extraction", "Xenova/e5-small-v2");export async function findSimilarSentences(query: string,sentences: string[],{ topK = 5 }: { topK: number }) {// this preprocessing step is suggested for e5-small-v2 model// see more: https://huggingface.co/intfloat/e5-small-v2/blob/main/README.md?code=true#L2631const input = [`query: ${query}`, ...sentences.map((s) => `passage: ${s}`)];const output: Tensor = await extractor(input, { pooling: "mean", normalize: true });const queryTensor: Tensor = output[0];
src/lib/server/websearch/sentenceSimilarity.ts+4-2