Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.

[Improvement] Add support for batches #78

@KennethEnevoldsen

Description

@KennethEnevoldsen

Currently, the framework does not seem to allow for batching inputs, which reduce its usability on larger datasets.

The intuitive approach would be:

from danlp.models import load_bert_tone_model
classifier = load_bert_tone_model()
classifier.predict(["I am very happy", "I am very very happy"])
# {'analytic': 'objective', 'polarity': 'positive'}

While you would expect:

from danlp.models import load_bert_tone_model
classifier = load_bert_tone_model()
classifier.predict(["I am very happy", "I am very very happy"], batch_size=2)
#[{'analytic': 'objective', 'polarity': 'positive'},
# {'analytic': 'objective', 'polarity': 'positive'}]

The reason why you would add the batch_size=2 is to distinguish between looping through each text and batching them for faster computation on GPUs

Interestingly the first approach does not throw an error

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