Datasets:

Modalities:
Text
Formats:
parquet
Languages:
English
Libraries:
Datasets
pandas
License:

Remove 'O-MATE', 'O-MANP', etc.

#1
by tomaarsen HF staff - opened

Hello!

Pull Request overview

  • Remove 'O-MATE', 'O-MANP', etc. from the fabner subset.
  • Increment version to 1.2.0

Details

Before

Currently, labels like 'O-MATE' get created, which obviously don't make much sense. I analyzed the dataset and determined how frequently each of the labels were used:

from datasets import load_dataset
import matplotlib.pyplot as plt
from collections import Counter

dataset = load_dataset("DFKI-SLT/fabner", "fabner")
labels = dataset["train"].features["ner_tags"].feature.names
num_labels = len(labels)
print(f"A total of {num_labels} labels found.")

label_counter = Counter(sum(dataset["train"]["ner_tags"], []))
print(label_counter)

unused_labels = set()
for i in range(num_labels):
    if label_counter[i] == 0:
        unused_labels.add(labels[i])

print(f"These labels are not used whatsoever: {unused_labels}")

fig, ax = plt.subplots()
ax.set_yscale("log")
ax.bar(list(label_counter.keys()), list(label_counter.values()))
plt.show()

Which outputs:

A total of 61 labels found.
Counter({0: 184499, 50: 12349, 5: 7539, 10: 4374, 46: 3085, 49: 3085, 6: 3043, 9: 3043, 30: 2272, 1: 1516, 4: 1516, 26: 1464, 29: 1464, 7: 1459, 40: 1454, 15: 1329, 20: 1200, 36: 1122, 39: 1122, 35: 955, 25: 928, 31: 783, 34: 783, 45: 679, 11: 432, 14: 432, 21: 428, 24: 428, 47: 345, 2: 257, 32: 193, 41: 179, 44: 179, 16: 156, 19: 156, 27: 96, 37: 87, 60: 75, 12: 64, 42: 47, 55: 32, 17: 32, 22: 22, 56: 16, 59: 16, 51: 6, 54: 6, 52: 1})
These labels are not used whatsoever: {'O-PRO', 'O-PARA', 'O-CHAR', 'O-CONPRI', 'O-MACEQ', 'O-MANP', 'I-BIOP', 'O-APPL', 'O-MATE', 'O-BIOP', 'O-ENAT', 'O-MANS', 'O-FEAT'}

as well as:
image.png

Certainly not ideal! A lot of "O-..." labels that we don't want. The problem is this line, which unintuitively adds "O-..." labels:
https://huggingface.co./datasets/DFKI-SLT/fabner/blob/main/fabner.py#L136

After

After removing this line (and updating the version), running this same script gives:

A total of 49 labels found.
Counter({0: 184499, 40: 12349, 4: 7539, 8: 4374, 37: 3085, 39: 3085, 5: 3043, 7: 3043, 24: 2272, 1: 1516, 3: 1516, 21: 1464, 23: 1464, 6: 1459, 32: 1454, 12: 1329, 16: 1200, 29: 1122, 31: 1122, 28: 955, 20: 928, 25: 783, 27: 783, 36: 679, 9: 432, 11: 432, 17: 428, 19: 428, 38: 345, 2: 257, 26: 193, 33: 179, 35: 179, 13: 156, 15: 156, 22: 96, 30: 87, 48: 75, 10: 64, 34: 47, 44: 32, 14: 32, 18: 22, 45: 16, 47: 16, 41: 6, 43: 6, 42: 1})
These labels are not used whatsoever: {'I-BIOP'}

as well as:
image.png

As you can see, I-BIOP is not represented in this dataset, but that is fine. After all, in the BIOES tagging scheme, the I-... is only used for entities of 3 or more words.


Let me know if you need anything from me at this point.

  • Tom Aarsen
tomaarsen changed pull request status to open
Speech and Language Technology, DFKI org

Oh yeah good catch. I forgot to take out that line when defining the BIOES label set. Thanks, Tom!

phucdev changed pull request status to merged

Thanks for getting to this so swiftly!

Sign up or log in to comment