Why vector is null in Qdrant which is created with langchain?

339 Views Asked by At

I create a collection with langchain V0.0.335 with code below

from langchain.vectorstores import Qdrant
...
qdrant= Qdrant.from_documents(
    documents = docs,
    embedding = embeddings,
    collection_name = "book_1"
)

And I got a result from Qdrant UI as below

{
  "result": {
    "points": [
      {
        "id": "003af5c5-4a3e-4d80-a257-46bda8628908",
        "payload": {
          "metadata": {
            "source": "./simple_qdrant/Mr_Spaceship.txt",
            "start_index": 8875
          },
          "page_content": "\"I don't like the idea,\" Kramer said. In his mind an image had appeared, the image of an old man sitting behind a desk, his bright gentle eyes moving about the classroom. The old man leaning forward, a thin hand raised—\n\n\"Keep him out of this,\" Kramer said.\n\n\"What's wrong?\" Gross looked at him curiously.\n\n\"It's because I suggested it,\" Dolores said."
        },
        "vector": null
      },
    "next_page_offset": "05dd3eb3-6ee3-4d42-be86-7c387c35dc16"
  },
  "status": "ok",
  "time": 0.001733464
}

I expected the vector is a list of number, like [0.1,0.2,...]

I checked the source code of qdrant.py in /langchain/vectorstores/ and didn't find method from_documents, which is defined in vectorstore.py in /langchain/schema/. Is it the reason that vector is null?

2

There are 2 best solutions below

1
On

By default, Qdrant tries to minimize network traffic and doesn’t return vectors in search results. But you can force Qdrant to do so by setting the with_vector parameter of the Search/Scroll to true.

If you’re still seeing "vector": null in your results, it might be that the vector you’re passing is not in the correct format, or there’s an issue with how you’re calling the upsert method.

Source: https://qdrant.tech/documentation/faq/qdrant-fundamentals/#my-search-results-contain-vectors-with-null-values-why

0
On

UPDATE The parameter has been updated to with_vectors. Simply set with_vectors = True in your search method.