Git Product home page Git Product logo

Comments (9)

fitzgeraldja avatar fitzgeraldja commented on June 25, 2024 1

yep - at bottom of batch update section of points docs it says

To batch many points with a single operation type, please use batching functionality in that operation directly.

which from earlier in the same page (under upload points) would suggest to me that client.update_vectors should accept a models.Batch set of points.

Not a major issue if just clarified that instead it requires the record-oriented equivalent using PointVectors, like

client.update_vectors(
    collection_name="test",
    points=[
        models.PointVectors(
            id="test-point", vector={"test-vec": [np.random.rand() for _ in range(768)]},
        )
    ],
)

which works

from qdrant-client.

joein avatar joein commented on June 25, 2024

Hi @fitzgeraldja

Could you please provide an example?

I tried running this code and there is no error for me

from qdrant_client import QdrantClient, models
client = QdrantClient()
client.recreate_collection('test', vectors_config=models.VectorParams(size=2, distance=models.Distance.COSINE))
client.upsert('test', points=models.Batch(ids=[1,2], vectors=[[0.0, 0.2], [0.1, 0.2]]), wait=True)

My dependencies:

python3.10.12
qdrant-client==1.7.0
pydantic==2.5.3
pydantic_core==2.14.6

from qdrant-client.

fitzgeraldja avatar fitzgeraldja commented on June 25, 2024

I have same dependencies other than python3.10.13 - issue is specifically for client.update_vectors rather than client.upsert, which in the source code has specific handling for models.Batch type points argument. Have tested with

client.update_vectors(
    collection_name="test",
    points=models.Batch(
        ids=["test-point"],
        vectors={"test-vec": [[np.random.rand() for _ in range(768)]]},
    ),
)

for an existing collection

from qdrant-client.

joein avatar joein commented on June 25, 2024

Some versions of pydantic used to convert numpy arrays to lists implicitly, however it is no longer the case.
Batch structure does not accept numpy arrays on its own, you need to convert it to a list

from qdrant-client.

fitzgeraldja avatar fitzgeraldja commented on June 25, 2024

in example given, np.random.rand() just returns a float, so that shouldn't be the issue (i.e. vectors is of type Dict[StrictStr, List[List[StrictFloat]]] as required for models.Batch) - it's not models.Batch(...) that throws the error, but client.update_vectors itself

from qdrant-client.

joein avatar joein commented on June 25, 2024

I checked the documentation at qdrant.tech

https://qdrant.tech/documentation/concepts/points/#update-vectors

Example here is indeed incorrect, we will fix it!

It should be a sequence of PointVectors. Batch or PointStruct models contain payload field, which is not relevant for update_vectors operation.

from qdrant-client.

joein avatar joein commented on June 25, 2024

A correct example may look like this:

client.update_vectors(
    collection_name=collection_name,
    points=[
        models.PointVectors(
            id=1,
            vector={
                [0.1, 0.1,],
            },
        ),
        models.PointVectors(
            id=2,
            vector={
            [0.2, 0.2],
            },
        ),
    ],
)

from qdrant-client.

joein avatar joein commented on June 25, 2024

qdrant/landing_page#541

from qdrant-client.

joein avatar joein commented on June 25, 2024

the documentation has been updated

from qdrant-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.