Skip to content

Downcase label before checking equality - #327

Merged
jonatanklosko merged 1 commit into
elixir-nx:mainfrom
preciz:main
Feb 7, 2024
Merged

Downcase label before checking equality#327
jonatanklosko merged 1 commit into
elixir-nx:mainfrom
preciz:main

Conversation

@preciz

@preciz preciz commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

Sometimes labels are in uppercase. So the library raises (ArgumentError) expected model specification to include "entailment" label in :id_to_label when building the zero shot classification.

For example here: https://huggingface.co/typeform/distilbert-base-uncased-mnli/blob/main/config.json

I tested this commit and it allows me to use the above mentioned model.

The code I used to test this commit:

Nx.default_backend({EXLA.Backend, []})

hf_model = "typeform/distilbert-base-uncased-mnli"

{:ok, model} = Bumblebee.load_model({:hf, hf_model})
{:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, "distilbert/distilbert-base-uncased"})

serving = Bumblebee.Text.zero_shot_classification(model, tokenizer, ["Is clothes", "Is food"])

Nx.Serving.run(serving, "Steak is tasty")

Thank you for reviewing.

@jonatanklosko jonatanklosko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks!

@jonatanklosko
jonatanklosko merged commit 211ca92 into elixir-nx:main Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants