All Questions

Filter by
Sorted by
Tagged with
4 votes
1 answer
3k views

Tensorflow BERT for token-classification - exclude pad-tokens from accuracy while training and testing

I'm doing token-based classification using the pre-trained BERT-model for tensorflow to automatically label cause and effects in sentences. To access BERT, I'm using the TFBertForTokenClassification-...
user3228384's user avatar
4 votes
0 answers
199 views

How to create iob tags for a sentence?

I have a dataset for NER in which I have to do POS tagging and IOB tagging, but I don't understand the concept or method of how iob tags are created. Even CoNLL is pretagged.
Umang Bhalani's user avatar
3 votes
2 answers
2k views

Company name extraction with bert-base-ner: easy way to know which words relate to which?

Hi I'm trying to extract the full company name from a string description about the company with bert-base-ner. I am also open to trying other methods but I couldn't really find one. The issue is that ...
Dana 's user avatar
  • 41
3 votes
2 answers
2k views

AttributeError: 'TokenClassifierOutput' object has no attribute 'detach'

Could you please assist me in solving the following error: 'TokenClassifierOutput' object has no attribute 'detach' The error persists even when modifying the code like output = model(input_ids, ...
Haneen Alahmadi's user avatar
3 votes
0 answers
233 views

Name of training and test data files in NLP (BioBERT GitHub repo)

I'm reading the README.md file of the BioBERT GitHub repo: Let $NER_DIR indicate a folder for a single NER dataset which contains train_dev.tsv, train.tsv, devel.tsv and test.tsv. Also, set $...
Contestosis's user avatar
3 votes
1 answer
902 views

CUDA Runtime Error: Which Cuda version is compatible to run NER task using BERT-NER

I have setup all the requirement packages installed on my VM and i found no nvidia GPU driver installed, In the requirements doesn't have nvidia GPU driver installation instructions, I want to know ...
veilupearl's user avatar
3 votes
0 answers
906 views

Load bert model in java

I have bert model for named entity recognition.(config.json, model.bin, vocab.txt). I can load model and get named entities from text with model in python input_text = "I live in London" model_dir = "...
Bekzhan's user avatar
  • 175
2 votes
4 answers
5k views

Could not find function 'spacy-transformers.TransformerModel.v3' in function registry 'architectures'

I was trying to create a custom NER model. I used spacy library to create the model. And this line of code is to create the config file from the base.config file. My code is : !python -m spacy ...
RITHIK ALIAS's user avatar
2 votes
2 answers
4k views

How to load BertforSequenceClassification models weights into BertforTokenClassification model?

Initially, I have a fine-tuned BERT base cased model using a text classification dataset and I have used BertforSequenceClassification class for this. from transformers import ...
Mr. NLP's user avatar
  • 971
2 votes
1 answer
3k views

How do I use my trained BERT NER (named entity recognition) model to predict a new example?

I trained my own BERT NER following this Medium post: https://medium.com/@yingbiao/ner-with-bert-in-action-936ff275bc73 I saved my model to the disc and successfully loaded it. model = ...
quisi's user avatar
  • 21
2 votes
2 answers
3k views

Getting the input text from transformers pipeline

I am following the tutorial on https://huggingface.co/docs/transformers/pipeline_tutorial to use transformers pipeline for inference. For example, the following code snippet works for getting the NER ...
Jing's user avatar
  • 935
2 votes
1 answer
2k views

Cannot add CRF layer on top of BERT in keras for NER

I am facing an unknown issue while training my BERT-CRF model for NER. I am using keras.contrib for the CRF model. Here are the imported libraries. !pip install transformers !pip install git+https://...
thenocturnalguy's user avatar
2 votes
1 answer
979 views

How to mask [PAD] and [SEP] tokens to prevent their prediction and loss calculation for NER task on BERT models?

I am trying to fine-tune BERT model for NER tagging task using tensorflow official nlp toolkit. I found there's already a bert token classifier class which i wanted to use. Looking at the code inside, ...
Mani Rai's user avatar
  • 665
2 votes
0 answers
1k views

huggingface pipeline: bert NER task throws RuntimeError: The size of tensor a (921) must match the size of tensor b (512) at non-singleton dimension 1

I try to set up a german ner, pretrained with bert via the huggingface pipeline. For some texts the following code throws an error "RuntimeError: The size of tensor a (921) must match the size of ...
Michael Göggelmann's user avatar
2 votes
0 answers
101 views

How to classify same entity based on the context of sentence?

I am working on a conversational AI that used to understand customer requests and make necessary responses. I have used BERT to train my dataset for NLU tasks intent classification and entity ...
Bipin's user avatar
  • 21
2 votes
2 answers
2k views

Python RuntimeError: input sequence

I try to run NER in Indonesian Language I've read some resources, they said that the BERT model has positional embeddings only for first 512 subtokens. So, the model can't work with longer sequences. ...
winnie's user avatar
  • 135
2 votes
0 answers
337 views

BERT weight calculation

I am trying to understand the BERT weight calculation. Please suggest me some article which can help me to understand the internal workings of BERT. I have read articles from Medium. https://...
Faseela Thayattuchira's user avatar
1 vote
1 answer
423 views

How to create a training pipeline for huggingface bert base uncased clinical NER

Current BERT base uncased clinical NER predict clinical entities( Problem, Test, Treatment) I want to train on different clinical dataset to get entity like ( Disease, Medicine, Problem) How to ...
krrish's user avatar
  • 11
1 vote
1 answer
610 views

Classification report in NER models ? seqeval vs sickit learn

I'm building a NER model to identify some medical entities. In order to evaluate my model, I used the classification report from seqeval and compared it to sklearn's classification report. as for ...
Akram HECINI's user avatar
1 vote
1 answer
330 views

Bert NER model start and end position None after fine-tuning

I have fine-tuned a BERT NER model to my dataset. The base model that I am fine-tuning is “dslim/bert-base-NER”. I have been successfully able to train the model using the following script as refrence:...
Amit Singh's user avatar
1 vote
1 answer
525 views

How to add simple custom pytorch-crf layer on top of TokenClassification model using pytorch and Trainer

I followed this link, but its implemented in Keras. Cannot add CRF layer on top of BERT in keras for NER Model description Is it possible to add simple custom pytorch-crf layer on top of ...
MAC's user avatar
  • 1,455
1 vote
1 answer
535 views

NER Classification Deberta Tokenizer error : You need to instantiate DebertaTokenizerFast

I'm trying to perform a NER Classification task using Deberta, but I'm stacked with a Tokenizer error. This is my code (my input sentence must be splitted word by word by ",:): from transformers ...
Chiara's user avatar
  • 380
1 vote
1 answer
1k views

Using Pretrained BERT model to add additional words that are not recognized by the model

I want some help regarding adding additional words in the existing BERT model. I have two quires kindly guide me: I am working on NER task for a domain: There are few words (not sure the exact numbers)...
muzamil's user avatar
  • 306
1 vote
1 answer
2k views

Are special tokens [CLS] [SEP] absolutely necessary while fine tuning BERT?

I am following the tutorial https://www.depends-on-the-definition.com/named-entity-recognition-with-bert/ to do Named Entity Recognition with BERT. While fine-tuning, before feeding the tokens to the ...
N G's user avatar
  • 13
1 vote
1 answer
704 views

Using BERT for extracting Product Features

How can I use BERT to extract product features from text? For example, how to extract the ids from the next emails - WSK30015675, KTXFFC156, 4569TT11DRE Hello John, Please order 15 dresses ID ...
Sahar Millis's user avatar
1 vote
0 answers
17 views

Issue with 'ValueError' when computing metrics in NER using transformers library (Tuple is empty)

Description: I am encountering issues while trying to compute metrics for Named Entity Recognition (NER) using the Hugging Face transformers library. The specific errors are 'ValueError' and I've been ...
Alwan Rahmana Subian's user avatar
1 vote
1 answer
94 views

my IndoBERT model got ValueError: The model did not return a loss from the inputs , only the following keys: last_hidden_state

I was trying to fine-tuned my IndoBERT model with my dataset. It was worked when i was using BERT base-uncased. But when I was gonna do it with IndoBERT, it returned -----------------------------------...
Alwan Rahmana Subian's user avatar
1 vote
0 answers
75 views

Cannot reduce overfitting on BERT+BiGRU+Softmax network for named entity recognition

I am currently attempting to build a named entity recognition system for the Moroccan Dialect using BERT+ BiGRU+Softmax architecture. I am encountering overfitting (F1 score on validation set around ...
hananour's user avatar
1 vote
1 answer
515 views

mask entities with Spacy NER?

I am working on some topic modeling and my data is heavy on locations. I want to mask them so the model doesn't see them as unique words. I can find them with Spacy using NER, and this is how I'm ...
steadynappin's user avatar
1 vote
1 answer
362 views

PyTorch, Bert model: optimizer zero_grad() error

I am relatively new to Python, and I am following a tutorial(https://towardsdatascience.com/named-entity-recognition-with-bert-in-pytorch-a454405e0b6a) regarding bert training for a task that I need. ...
Stathis G.'s user avatar
1 vote
1 answer
152 views

Bert Tokenizer punctuation for named entity recognition task

I'm working on a named entity recognition task, where I need to identify person names, books etc. I am using Huggingface Transformer package and BERT with PyTorch. Generally it works very good, ...
Questioner's user avatar
1 vote
1 answer
483 views

Pytorch based Bert NER for transfer learning/retraining

I trained an Bert-based NER model using Pytorch framework by referring the below article. https://www.depends-on-the-definition.com/named-entity-recognition-with-bert/. After training the model using ...
IronMan's user avatar
  • 23
1 vote
1 answer
198 views

How to build 'ner_ontonotes_bert_mult' model from scratch

How can I custom train the model "ner_ontonotes_bert_mult". I want to train the model with my own dataset which have some different tags. How to train the model and use it? When I am ...
Sayak Ghanta's user avatar
1 vote
0 answers
288 views

How to extract noun phrases from a sentence using pre-trained BERT?

I want to extract noun phrases from sentence using BERT. There are some available libraries like TextBlob that allows us to extract noun phrases like this: from textblob import TextBlob line = "...
Ruchit Vithani's user avatar
1 vote
0 answers
2k views

size mismatch for classifier.weight: copying a param with shape torch.Size([9, 768]) from checkpoint. Current model is torch.Size([2, 768])

tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER") model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER") RuntimeError ...
Raktim Nath's user avatar
1 vote
1 answer
938 views

BERT NER: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first

I want to train my BERT NER model on colab. But following error occurs Code: tr_logits = tr_logits.detach().cpu().numpy() tr_label_ids = torch.masked_select(b_labels, (preds_mask == 1)) tr_batch_preds ...
Wayne's user avatar
  • 11
1 vote
0 answers
134 views

Spacy - What does blank models contain?

Hy everyone, I am trying to create a new NER model which labels custom entities. As part of that I am using a new blank model for Italian with spacy.blank('it') I'm creating a new NER pipeline with ...
Sergio's user avatar
  • 187
1 vote
1 answer
397 views

How to feed my own data to BERT by getting the right placeholder from the tensorflow graph

I am trying to fine tune BERT for NER. I have downloaded a checkpoint from here (https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip) I have loaded the session and graph ...
user3347259's user avatar
0 votes
3 answers
152 views

How to Handle Imbalance Dataset in NER?

I'm now doing information extraction using NER. My dataset domain (mostly) in computer science. It contains label/tag: "TUJUAN", "METODE", and "TEMUAN". The problem is ...
Alwan Rahmana Subian's user avatar
0 votes
1 answer
356 views

How to visualize entities predicted by NER model?

How do I visualize entities predicted by a Bert-like model that's built using Pytorch? I built a NER model using Bert. My model works fine. It returns a list of predicted entities: example : ...
Akram H's user avatar
  • 53
0 votes
1 answer
257 views

AttributeError: 'list' object has no attribute 'ents' in building NER using BERT

I'm trying to build a NER model using Bert-base-NER for a tweets dataset and ending up getting this error . Please help This is what I have done from transformers import AutoTokenizer, ...
d_stupido_02's user avatar
0 votes
1 answer
176 views

BertForTokenClassification Has Extra Output

I am using PyTorch's BertForTokenClassification pretrained model to do custom word tagging (not NER or POS, but essentially the same). There are 20 different possible tags (using BIO scheme): 9 B's, 9 ...
Clayton C.'s user avatar
0 votes
1 answer
341 views

BERT NER Python

I am using BERT model for Named Entity Recognition task. I have torch version - 1.2.0+cu9.2 torch vision version - 0.4.0+cu9.2 Nvidia drivers compatible with cuda 9.2 when i am trying to train my ...
Hitesh's user avatar
  • 24
0 votes
2 answers
524 views

how to use ktrain for NER Offline?

I have trained my English model following this notebook (https://nbviewer.jupyter.org/github/amaiya/ktrain/blob/master/tutorials/tutorial-06-sequence-tagging.ipynb). I am able to save my pretrained ...
Leidy E. Molina's user avatar
0 votes
0 answers
12 views

Mismatched batch size error when calculating cross-entropy loss in PyTorch using BERT Token Classification

I'm currently working on a project where I'm training a neural network model for word classification using PyTorch. However, I'm encountering an error related to mismatched batch sizes when ...
Alwan Rahmana Subian's user avatar
0 votes
0 answers
13 views

Problem with running trainer.train() function while fine tuning BERT

When i run trainer.train() it says the following --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ...
NEERAJ GHATE's user avatar
0 votes
0 answers
20 views

How to get ClassLabel for the ai4privacy/pii-masking-200k dataset?

I am working on fine tuning of the NER Model. For this, I have downloaded the dataset as shown in the below image: If you take a look at features of this dataset, there isn't "ner_tags" ...
Manish Shegokar's user avatar
0 votes
0 answers
28 views

How to chunk large documents and realign the labels for entity extraction task using BERT models using python

I have a need to extract entities from pdf documents. Documents can be in the range of 1 to 5 pages. After doing OCR on these documents we pass it through When doing tokenization using Deep learning ...
MAC's user avatar
  • 1,455
0 votes
0 answers
27 views

Fine tuning BERT(for phone and card) not accurate

This is my code for FT BERT for credit card and Phone number identification. I have a dataset that has sentences and each word has its tag(o, PHN, CRD). I am not able to get the required results. The ...
develop's user avatar
  • 65
0 votes
0 answers
34 views

BERT fine-tuning for NER(specifically for Phone number and credit card)

!pip install simpletransformers import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score from ...
develop's user avatar
  • 65