Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understanding Label Meanings in FLANG-BERT Model #4

Open
JY251 opened this issue Jul 26, 2024 · 0 comments
Open

Understanding Label Meanings in FLANG-BERT Model #4

JY251 opened this issue Jul 26, 2024 · 0 comments

Comments

@JY251
Copy link

JY251 commented Jul 26, 2024

Code:

I have been working with the FLANG-BERT model and have encountered an issue with understanding the labels returned by the model. Here is the code I am using:

from transformers import BertTokenizer, BertForSequenceClassification, pipeline

model_path = "FLANG-BERT"
# model_path = "FLANG-ELECTRA"

flang_bert = BertForSequenceClassification.from_pretrained(model_path, num_labels=3) # Adjust num_labels as needed
tokenizer = BertTokenizer.from_pretrained(model_path)

nlp = pipeline('text-classification', model=flang_bert, tokenizer=tokenizer)
results1 = nlp("I am happy")
results2 = nlp("I am angry")
results3 = nlp("I am sleepy")

print(results1)
print(results2)
print(results3)

Output:

The output I receive is as follows:

[{'label': 'LABEL_1', 'score': 0.3824489414691925}]
[{'label': 'LABEL_1', 'score': 0.38688215613365173}]
[{'label': 'LABEL_1', 'score': 0.3874432444572449}]

When I run the same code again multiple times, I obtain different outputs:

[{'label': 'LABEL_2', 'score': 0.33723291754722595}]
[{'label': 'LABEL_2', 'score': 0.3374021649360657}]
[{'label': 'LABEL_2', 'score': 0.33843377232551575}]
[{'label': 'LABEL_0', 'score': 0.3722850978374481}]
[{'label': 'LABEL_0', 'score': 0.37265387177467346}]
[{'label': 'LABEL_0', 'score': 0.3684918284416199}]

Issue:

I am unsure what the labels (e.g., 'LABEL_1') represent in the FLANG-BERT model. I have looked at the documentation for the model, such as the Hugging Face documentation, but I could not find any notes about the meaning of the labels.

As there are only 3 labels in this case (maybe due to the num_labels=3 parameter), I suspect these 3 correspond to 'Positive', 'Negative', and 'Neutral' sentiments. However, I am still uncertain about if "LABEL_1" corresponds to 'Positive' or 'Negative' sentiment.

Could you please provide information on what the labels correspond to or direct me to where I can find this information in the documentation?

Thank you for your assistance.

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

No branches or pull requests

1 participant