Views
No views yet
NeoBERTForTokenClassification class can occur.NeoBERTForTokenClassification class was implemented to conduct experiments with Transformers.4.50.0.dev0 is currently used including a recent built of xFormers, as NeoBERT depends on that for the SwiGLU implementation.1python3 run_ner.py \
2 --model_name_or_path /home/stefan/Repositories/NeoBERT \
3 --dataset_name conll2003 \
4 --output_dir ./neobert-conll2003-lr1e-05-e10-bs16-1 \
5 --seed 1 \
6 --do_train \
7 --do_eval \
8 --per_device_train_batch_size 16 \
9 --num_train_epochs 10 \
10 --learning_rate 1e-05 \
11 --eval_strategy epoch \
12 --save_strategy epoch \
13 --overwrite_output_dir \
14 --trust_remote_code True \
15 --load_best_model_at_end \
16 --metric_for_best_model "eval_f1" \
17 --greater_is_better True| Configuration | Run 1 | Run 2 | Run 3 | Run 4 | Run 5 | Avg. |
|---|---|---|---|---|---|---|
bs=16,e=10,lr=1e-05 | 95.71 | 95.42 | 95.53 | 95.56 | 95.43 | 95.53 |
bs=16,e=10,lr=2e-05 | 95.25 | 95.33 | 95.28 | 95.35 | 95.26 | 95.29 |
bs=16,e=10,lr=3e-05 | 94.98 | 95.22 | 94.86 | 94.72 | 94.93 | 94.94 |
bs=16,e=10,lr=4e-05 | 94.61 | 94.39 | 94.57 | 94.65 | 94.87 | 94.61 |
bs=16,e=10,lr=5e-05 | 93.82 | 93.94 | 94.36 | 91.14 | 94.38 | 94.15 |
1from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
2
3model_name = "stefan-it/neobert-ner-conll03"
4
5
6model = AutoModelForTokenClassification.from_pretrained(model_name, trust_remote_code=True)
7tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
8
9ner = pipeline(task="ner",
10 model=model,
11 tokenizer=tokenizer,
12 trust_remote_code=True)
13
14print(ner("George Washington went to Washington in the US."))1[
2 {'entity': 'B-PER', 'score': 0.99981505, 'index': 1, 'word': 'george', 'start': 0, 'end': 6},
3 {'entity': 'I-PER', 'score': 0.9997435, 'index': 2, 'word': 'washington', 'start': 7, 'end': 17},
4 {'entity': 'B-LOC', 'score': 0.99955124, 'index': 5, 'word': 'washington', 'start': 26, 'end': 36},
5 {'entity': 'B-LOC', 'score': 0.99958867, 'index': 8, 'word': 'us', 'start': 44, 'end': 46}
6]