Views
No views yet
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4# Load model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("LemkinAI/roberta-joint-ner-re")
6model = AutoModelForTokenClassification.from_pretrained("LemkinAI/roberta-joint-ner-re")
7
8# Example text
9text = "The International Criminal Court issued a warrant for the general's arrest."
10
11# Tokenize and predict
12inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
13with torch.no_grad():
14 outputs = model(**inputs)
15 predictions = torch.argmax(outputs.logits, dim=-1)
16
17# Process results
18tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
19predicted_labels = [model.config.id2label[pred.item()] for pred in predictions[0]]
20
21for token, label in zip(tokens, predicted_labels):
22 if label != "O":
23 print(f"{token}: {label}")1@misc{lemkin-roberta-ner-re-2025,
2 title={RoBERTa Joint NER+RE Model for Legal Text Analysis},
3 author={Lemkin AI Team},
4 year={2025},
5 url={https://huggingface.co/LemkinAI/roberta-joint-ner-re}
6}