Skip to content

Commit

Permalink
Merge pull request #1926 from flairNLP/GH-1925-TARS
Browse files Browse the repository at this point in the history
GH-1925: fixed a bug, added TARS on homepage
  • Loading branch information
alanakbik authored Oct 30, 2020
2 parents 6653340 + 876d561 commit c83d771
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ We provide a set of quick tutorials to get you started with the library:
* [Tutorial 6: Loading a Dataset](/resources/docs/TUTORIAL_6_CORPUS.md)
* [Tutorial 7: Training a Model](/resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md)
* [Tutorial 8: Training your own Flair Embeddings](/resources/docs/TUTORIAL_9_TRAINING_LM_EMBEDDINGS.md)
* [Tutorial 9: Training a Zero Shot Text Classifier](/resources/docs/TUTORIAL_10_TRAINING_ZERO_SHOT_MODEL.md)
* [Tutorial 9: Training a Zero Shot Text Classifier (TARS)](/resources/docs/TUTORIAL_10_TRAINING_ZERO_SHOT_MODEL.md)

The tutorials explain how the base NLP classes work, how you can load pre-trained models to tag your
text, how you can embed your text with different word or document embeddings, and how you can train your own
Expand Down
8 changes: 7 additions & 1 deletion flair/models/text_classification_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,13 @@ def _get_nearest_labels_for(self, labels):
plausible_labels.append(plausible_label)
plausible_label_probabilities.append( \
self.label_nearest_map[label][plausible_label])
plausible_label_probabilities /= np.sum(plausible_label_probabilities) + 1e-08

# make sure the probabilities always sum up to 1
plausible_label_probabilities = np.array(plausible_label_probabilities, dtype='float64')
plausible_label_probabilities += 1e-08
plausible_label_probabilities /= np.sum(plausible_label_probabilities)


if len(plausible_labels) > 0:
num_samples = min(self.num_negative_labels_to_sample, len(plausible_labels))
sampled_negative_labels = np.random.choice(plausible_labels,
Expand Down

0 comments on commit c83d771

Please sign in to comment.