Views
No views yet
|1from span_marker import SpanMarkerModel
2from span_marker.tokenizer import SpanMarkerTokenizer
3
4
5# Download from the 🤗 Hub
6model = SpanMarkerModel.from_pretrained("lambdavi/span-marker-luke-legal")
7tokenizer = SpanMarkerTokenizer.from_pretrained("roberta-base", config=model.config)
8model.set_tokenizer(tokenizer)
9
10# Run inference
11entities = model.predict("The petition was filed through Sh. Vijay Pahwa, General Power of Attorney and it was asserted in the petition under Section 13-B of the Rent Act that 1 of 23 50% share of the demised premises had been purchased by the landlord from Sh. Vinod Malhotra vide sale deed No.4226 registered on 20.12.2007 with Sub Registrar, Chandigarh.")1from span_marker import SpanMarkerModel, Trainer
2from span_marker.tokenizer import SpanMarkerTokenizer
3
4
5# Download from the 🤗 Hub
6model = SpanMarkerModel.from_pretrained("lambdavi/span-marker-luke-legal")
7tokenizer = SpanMarkerTokenizer.from_pretrained("roberta-base", config=model.config)
8model.set_tokenizer(tokenizer)
9
10# Specify a Dataset with "tokens" and "ner_tag" columns
11dataset = load_dataset("conll2003") # For example CoNLL2003
12
13# Initialize a Trainer using the pretrained model & dataset
14trainer = Trainer(
15 model=model,
16 train_dataset=dataset["train"],
17 eval_dataset=dataset["validation"],
18)
19trainer.train()
20trainer.save_model("lambdavi/span-marker-luke-legal-finetuned")| Training set | Min | Median | Max |
|---|---|---|---|
| Sentence length | 3 | 44.5113 | 2795 |
| Entities per sentence | 0 | 2.7232 | 68 |
| Epoch | Step | Validation Loss | Validation Precision | Validation Recall | Validation F1 | Validation Accuracy |
|---|---|---|---|---|---|---|
| 0.9997 | 1837 | 0.0137 | 0.7773 | 0.7994 | 0.7882 | 0.9577 |
| 2.0 | 3675 | 0.0090 | 0.8751 | 0.8348 | 0.8545 | 0.9697 |
| 2.9997 | 5512 | 0.0077 | 0.8777 | 0.8959 | 0.8867 | 0.9770 |
| 4.0 | 7350 | 0.0061 | 0.8941 | 0.9083 | 0.9011 | 0.9811 |
| 4.9986 | 9185 | 0.0064 | 0.9090 | 0.9110 | 0.9100 | 0.9824 |
| Metric | Value |
|---|---|
| f1-exact | 0.9237 |
| f1-strict | 0.9100 |
| f1-partial | 0.9365 |
| f1-type-match | 0.9277 |
@software{Aarsen_SpanMarker,
author = {Aarsen, Tom},
license = {Apache-2.0},
title = {{SpanMarker for Named Entity Recognition}},
url = {https://github.com/tomaarsen/SpanMarkerNER}
}