Skip to content

Dense Vector Field Support  #356

Closed
Closed
@YakPort

Description

@YakPort

I note the closed issue
https://github.com/elastic/elasticsearch-dsl-py/issues/1278

I created a densevector field as mentioned above
I have a method on my model the calculates the embedding called get_embedding

I am trying to create a Field that will access the attribute on my model and store the calculated embedding similar to

class DenseVector(DEDField, Field):
    name = 'dense_vector'

    def __init__(self):
        dims = 1024
        super(DenseVector, self).__init__(dims=dims)

in documents.py

@registry.register_document
class ItemDocument(Document):
    title_vector = DenseVector(attr='get_embedding')

    class Index:
        name = "products"
        settings = {
            "number_of_shards": 1,
            "number_of_replicas": 0,
            "analysis": {"analyzer": {"standard": {"type": "standard"}}},
        }

    class Django:
        model = Item

I am getting TypeError: init() got an unexpected keyword argument 'attr'
where is attr being initialised, or am I going down the wrong path?

Many thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions