Views
No views yet
pip install transformers torch1
2from transformers import RobertaTokenizerFast, RobertaForSequenceClassification, Trainer, TrainingArguments
3import torch
4
5
6
7# Load tokenizer
8
9tokenizer = RobertaTokenizerFast.from_pretrained("roberta-base")
10
11# Create NER pipeline
12ner_pipeline = pipeline(
13 "ner",
14 model=model,
15 tokenizer=tokenizer,
16 aggregation_strategy="simple"
17)
18
19# Sample news headline
20text = "Apple Inc. is planning to open a new campus in London by the end of 2025."
21
22# Inference
23entities = ner_pipeline(text)
24
25# Display results
26for ent in entities:
27 print(f"{ent['word']}: {ent['entity_group']} ({ent['score']:.2f})")
28
.
├── config.json
├── tokenizer_config.json
├── sepcial_tokens_map.json
├── tokenizer.json
├── model.safetensors # Fine Tuned Model
├── README.md # Model documentation