{"card_data"=>nil} |
---|
This is a SpanMarker model{% if dataset_id %} trained on the [{{ dataset_name if dataset_name else dataset_id }}](https://huggingface.co/datasets/{{ dataset_id }}) dataset{% endif %} that can be used for {{ task_name | default("Named Entity Recognition", true) }}.{% if encoder_id %} This SpanMarker model uses [{{ encoder_name if encoder_name else encoder_id }}](https://huggingface.co/{{ encoder_id }}) as the underlying encoder.{% endif %}
- Model Type: SpanMarker
{% if encoder_id -%}
- Encoder: [{{ encoder_name if encoder_name else encoder_id }}](https://huggingface.co/{{ encoder_id }}) {%- else -%}
{%- endif %}
- Maximum Sequence Length: {{ model_max_length }} tokens
- Maximum Entity Length: {{ entity_max_length }} words
{% if dataset_id -%}
- Training Dataset: [{{ dataset_name if dataset_name else dataset_id }}](https://huggingface.co/datasets/{{ dataset_id }}) {%- else -%}
{%- endif %} {% if language -%} - Language{{"s" if language is not string and language | length > 1 else ""}}: {%- if language is string %} {{ language }} {%- else %} {% for lang in language -%} {{ lang }}{{ ", " if not loop.last else "" }} {%- endfor %} {%- endif %} {%- else -%} {%- endif %} {% if license -%} - License: {{ license }} {%- else -%} {%- endif %}
- Repository: SpanMarker on GitHub
- Thesis: SpanMarker For Named Entity Recognition {% if label_examples %}
{{ label_examples }}{% endif -%} {% if metrics_table %}
{{ metrics_table }}{% endif %}
from span_marker import SpanMarkerModel
# Download from the {{ hf_emoji }} Hub
model = SpanMarkerModel.from_pretrained("{{ model_id | default('span_marker_model_id', true) }}")
# Run inference
entities = model.predict("{{ predict_example | replace('"', '\\"') | default("Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.", true)}}")
You can finetune this model on your own dataset.
Click to expand
from span_marker import SpanMarkerModel, Trainer
# Download from the {{ hf_emoji }} Hub
model = SpanMarkerModel.from_pretrained("{{ model_id | default('span_marker_model_id', true) }}")
# Specify a Dataset with "tokens" and "ner_tag" columns
dataset = load_dataset("conll2003") # For example CoNLL2003
# Initialize a Trainer using the pretrained model & dataset
trainer = Trainer(
model=model,
train_dataset=dataset["train"],
eval_dataset=dataset["validation"],
)
trainer.train()
trainer.save_model("{{ model_id | default('span_marker_model_id', true) }}-finetuned")
{% if train_set_metrics %}
{{ train_set_metrics }}{% endif %}{% if hyperparameters %}
{% for name, value in hyperparameters.items() %}- {{ name }}: {{ value }} {% endfor %}{% endif %}{% if eval_lines %}
{{ eval_lines }}{% endif %}{% if co2_eq_emissions %}
Carbon emissions were measured using CodeCarbon.
- Carbon Emitted: {{ "%.3f"|format(co2_eq_emissions["emissions"] / 1000) }} kg of CO2
- Hours Used: {{ co2_eq_emissions["hours_used"] }} hours
- On Cloud: {{ "Yes" if co2_eq_emissions["on_cloud"] else "No" }}
- GPU Model: {{ co2_eq_emissions["hardware_used"] or "No GPU used" }}
- CPU Model: {{ co2_eq_emissions["cpu_model"] }}
- RAM Size: {{ "%.2f"|format(co2_eq_emissions["ram_total_size"]) }} GB {% endif %}
- Python: {{ version["python"] }}
- SpanMarker: {{ version["span_marker"] }}
- Transformers: {{ version["transformers"] }}
- PyTorch: {{ version["torch"] }}
- Datasets: {{ version["datasets"] }}
- Tokenizers: {{ version["tokenizers"] }}
@software{Aarsen_SpanMarker,
author = {Aarsen, Tom},
license = {Apache-2.0},
title = {{"{{SpanMarker for Named Entity Recognition}}"}},
url = {https://github.com/tomaarsen/SpanMarkerNER}
}