Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Different embedding vectors results than with Python version #30

Description

@rklf

Hi!
First, thank you for your work. However, I'm getting different vector results when embedding a exact same query with the exact same model (and same max_length : default to 512 on both) than when using FastEmbed Python version. Is it intended? Am I doing something wrong?

For example for hello query using fast-multilingual-e5-large (EmbeddingModel.MLE5Large) :

fastembed-js (Node-JS) :

import { EmbeddingModel, FlagEmbedding } from "fastembed";
...
this._embedder = await FlagEmbedding.init({
  model: EmbeddingModel.MLE5Large,
  maxLength: 512,
  cacheDir: "./local_cache",
  showDownloadProgress: false,
});
results = await this.embedder.queryEmbed("hello");

// results
{
    "0": 0.04752354323863983,
    "1": -0.0058815134689211845,
    "2": 0.0006205342360772192,
    "3": -0.03057778812944889,
    "4": 0.038045115768909454,
    "5": -0.02664419822394848,
    "6": -0.018038146197795868,
    "7": 0.03404559567570686,
    ...
}

(also not related but queryEmbed() doesn't return number[] as TS types says, but structure like above, so I use Object.values() to get number[])

fastembed (Python):

from langchain_community.embeddings import FastEmbedEmbeddings
...
embedding_function = FastEmbedEmbeddings(
  model_name="intfloat/multilingual-e5-large",
  cache_dir=".cache",
)
results = embedding_function.embed_query("hello")

# results
[
  0.6659826636314392,
  -0.13676010817289352,
  -0.41865870729088783,
  -1.7572288811206818,
  0.4101845696568489,
  -1.075161725282669,
  -0.4985295459628105,
  0.9173809438943863,
  ...
]

This results to a lower score when searching through .search() using QdrantClient (@qdrant/js-client-rest). Also, I'm using a micro-service that add documents to Qdrant vector database, which use embed_query() on Python-side. Output would be currently more accurate when embedding query from Python-side (since it would use same function), but I'd like to be free from Python-side and embed user queries on JS-side (unfortunately, rn embedded vectors differ for an exact same query).

export class QdrantService extends QdrantClient implements OnModuleInit {
  constructor() {
    super({
      url: process.env.QDRANT_CLUSTER_URL,
      apiKey: process.env.QDRANT_API_KEY,
    });
  }
  ...

  async searchQdrant(...) {
    ...
    return await this.search(collectionName, {
      vector: {
        name: vectorName,
        vector: embedding,
      },
      limit: limit,
      filter: filter,
      with_payload: true,
      with_vector: false,
    })
  }

Python left | JS right
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions