π TalbankenΒΆ
Universal Named Entity Recognition (UNER) aims to fill a gap in multilingual NLP: high quality NER datasets in many languages with a shared tagset. UNER is modeled after the Universal Dependencies project, in that it is intended to be a large community annotation effort with language-universal guidelines. Further, we use the same text corpora as Universal Dependencies⦠See the full description on the dataset page: https://huggingface.co/datasets/universalner/universal_ner
Tags: arxiv:2311.09122, language:['ceb', 'da', 'de', 'en', 'hr', 'pt', 'ru', 'sk', 'sr', 'sv', 'tl', 'zh'], license:cc-by-sa-4.0, region:us, task_categories:token-classification, category:dataset
cards.universal_ner.sv.talbanken
type: TaskCard
loader:
type: LoadHF
path: universalner/universal_ner
name: sv_talbanken
requirements_list:
- conllu
preprocess_steps:
- type: Shuffle
page_size: 9223372036854775807
- type: Rename
field_to_field:
ner_tags: labels
- type: GetItemByIndex
field: labels
items_list:
- O
- B-PER
- I-PER
- B-ORG
- I-ORG
- B-LOC
- I-LOC
process_every_value: True
- type: IobExtractor
labels:
- Person
- Organization
- Location
begin_labels:
- B-PER
- B-ORG
- B-LOC
inside_labels:
- I-PER
- I-ORG
- I-LOC
outside_label: O
- type: Copy
field_to_field:
spans/*/start: spans_starts
spans/*/end: spans_ends
spans/*/label: labels
get_default: []
not_exist_ok: True
- type: Set
fields:
entity_types:
- Person
- Organization
- Location
task: tasks.span_labeling.extraction
templates: templates.span_labeling.extraction.all
[source]Explanation about TaskCardΒΆ
TaskCard delineates the phases in transforming the source dataset into model input, and specifies the metrics for evaluation of model output.
- Args:
- loader:
specifies the source address and the loading operator that can access that source and transform it into a unitxt multistream.
- preprocess_steps:
list of unitxt operators to process the data source into model input.
- task:
specifies the fields (of the already (pre)processed instance) making the inputs, the fields making the outputs, and the metrics to be used for evaluating the model output.
- templates:
format strings to be applied on the input fields (specified by the task) and the output fields. The template also carries the instructions and the list of postprocessing steps, to be applied to the model output.
- default_template:
a default template for tasks with very specific task dataset specific template
Explanation about CopyΒΆ
Copies values from specified fields to specified fields.
- Args (of parent class):
field_to_field (Union[List[List], Dict[str, str]]): A list of lists, where each sublist contains the source field and the destination field, or a dictionary mapping source fields to destination fields.
- Examples:
An input instance {βaβ: 2, βbβ: 3}, when processed by
Copy(field_to_field={"a": "b"})would yield {βaβ: 2, βbβ: 2}, and when processed byCopy(field_to_field={"a": "c"})would yield {βaβ: 2, βbβ: 3, βcβ: 2}with field names containing / , we can also copy inside the field:
Copy(field="a/0",to_field="a")would process instance {βaβ: [1, 3]} into {βaβ: 1}
Explanation about ShuffleΒΆ
Shuffles the order of instances in each page of a stream.
- Args (of superclass):
page_size (int): The size of each page in the stream. Defaults to 1000.
Explanation about IobExtractorΒΆ
A class designed to extract entities from sequences of text using the Inside-Outside-Beginning (IOB) tagging convention. It identifies entities based on IOB tags and categorizes them into predefined labels such as Person, Organization, and Location.
- Args:
- labels (List[str]):
A list of entity type labels, e.g., [βPersonβ, βOrganizationβ, βLocationβ].
- begin_labels (List[str]):
A list of labels indicating the beginning of an entity, e.g., [βB-PERβ, βB-ORGβ, βB-LOCβ].
- inside_labels (List[str]):
A list of labels indicating the continuation of an entity, e.g., [βI-PERβ, βI-ORGβ, βI-LOCβ].
- outside_label (str):
The label indicating tokens outside of any entity, typically βOβ.
The extraction process identifies spans of text corresponding to entities and labels them according to their entity type. Each span is annotated with a start and end character offset, the entity text, and the corresponding label.
Example of instantiation and usage:
operator = IobExtractor( labels=["Person", "Organization", "Location"], begin_labels=["B-PER", "B-ORG", "B-LOC"], inside_labels=["I-PER", "I-ORG", "I-LOC"], outside_label="O", ) instance = { "labels": ["B-PER", "I-PER", "O", "B-ORG", "I-ORG"], "tokens": ["John", "Doe", "works", "at", "OpenAI"] } processed_instance = operator.process(instance) print(processed_instance["spans"]) # Output: [{'start': 0, 'end': 8, 'text': 'John Doe', 'label': 'Person'}, ...]For more details on the IOB tagging convention, see: https://en.wikipedia.org/wiki/Inside-outside-beginning_(tagging)
Explanation about SetΒΆ
Sets specified fields in each instance, in a given stream or all streams (default), with specified values. If fields exist, updates them, if do not exist β adds them.
- Args:
fields (Dict[str, object]): The fields to add to each instance. Use β/β to access inner fields
use_deepcopy (bool) : Deep copy the input value to avoid later modifications
- Examples:
# Set a value of a list consisting of βpositiveβ and βnegativeβ do field βclassesβ to each and every instance of all streams
Set(fields={"classes": ["positive","negatives"]})# In each and every instance of all streams, field βspanβ is to become a dictionary containing a field βstartβ, in which the value 0 is to be set
Set(fields={"span/start": 0}# In all instances of stream βtrainβ only, Set field βclassesβ to have the value of a list consisting of βpositiveβ and βnegativeβ
Set(fields={"classes": ["positive","negatives"], apply_to_stream=["train"]})# Set field βclassesβ to have the value of a given list, preventing modification of original list from changing the instance.
Set(fields={"classes": alist}), use_deepcopy=True)if now alist is modified, still the instances remain intact.
Explanation about RenameΒΆ
Renames fields.
Move value from one field to another, potentially, if field name contains a /, from one branch into another. Remove the from field, potentially part of it in case of / in from_field.
- Examples:
Rename(field_to_field={βbβ: βcβ}) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βcβ: 2}, {βaβ: 2, βcβ: 3}]
Rename(field_to_field={βbβ: βc/dβ}) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βcβ: {βdβ: 2}}, {βaβ: 2, βcβ: {βdβ: 3}}]
Rename(field_to_field={βbβ: βb/dβ}) will change inputs [{βaβ: 1, βbβ: 2}, {βaβ: 2, βbβ: 3}] to [{βaβ: 1, βbβ: {βdβ: 2}}, {βaβ: 2, βbβ: {βdβ: 3}}]
Rename(field_to_field={βb/c/eβ: βb/dβ}) will change inputs [{βaβ: 1, βbβ: {βcβ: {βeβ: 2, βfβ: 20}}}] to [{βaβ: 1, βbβ: {βcβ: {βfβ: 20}, βdβ: 2}}]
Explanation about GetItemByIndexΒΆ
Get from the item list by the index in the field.
Explanation about LoadHFΒΆ
Loads datasets from the HuggingFace Hub.
It supports loading with or without streaming, and it can filter datasets upon loading.
- Args:
- path:
The path or identifier of the dataset on the HuggingFace Hub.
- name:
An optional dataset name.
- data_dir:
Optional directory to store downloaded data.
- split:
Optional specification of which split to load.
- data_files:
Optional specification of particular data files to load.
- revision:
Optional. The revision of the dataset. Often the commit id. Use in case you want to set the dataset version.
- streaming (bool):
indicating if streaming should be used.
- filtering_lambda (str, optional):
A lambda function for filtering the data after loading.
- num_proc (int, optional):
Specifies the number of processes to use for parallel dataset loading.
- Example:
Loading glueβs mrpc dataset
load_hf = LoadHF(path='glue', name='mrpc')
References: templates.span_labeling.extraction.all, tasks.span_labeling.extraction
Read more about catalog usage here.