bert-language-model

How to test masked language model after training it?

How to test masked language model after training it? Question: I have followed this tutorial for masked language modelling from Hugging Face using BERT, but I am unsure how to actually deploy the model. Tutorial: https://github.com/huggingface/notebooks/blob/master/examples/language_modeling.ipynb I have trained the model using my own dataset, which has worked fine, but I don’t know how to …

Total answers: 2

What does 'output_dir' mean in transformers.TrainingArguments?

What does 'output_dir' mean in transformers.TrainingArguments? Question: On the huggingface site documentation, it says ‘The output directory where the model predictions and checkpoints will be written’. I don’t quite understand what it means. Do I have to create any file for that? Asked By: abhishekkuber || Source Answers: The trainer of the Huggingface models can …

Total answers: 1

Extracting Features from BertForSequenceClassification

Extracting Features from BertForSequenceClassification Question: Hello together currently I´m trying to develop a model for contradicition detection. Using and fine-tuning a BERT Model I already got quite statisfactionary result but I think with with some other features I could get a better accuracy. I oriented myself on this Tutorial. After fine-tuning, my model looks like …

Total answers: 1

How to get BioBERT embeddings

How to get BioBERT embeddings Question: I have field within a pandas dataframe with a text field for which I want to generate BioBERT embeddings. Is there a simple way with which I can generate the vector embeddings? I want to use them within another model. here is a hypothetical sample of the data frame …

Total answers: 2

How does max_length, padding and truncation arguments work in HuggingFace' BertTokenizerFast.from_pretrained('bert-base-uncased') work??

How does max_length, padding and truncation arguments work in HuggingFace' BertTokenizerFast.from_pretrained('bert-base-uncased')? Question: I am working with Text Classification problem where I want to use the BERT model as the base followed by Dense layers. I want to know how does the 3 arguments work? For example, if I have 3 sentences as: ‘My name is …

Total answers: 1

BERT-based NER model giving inconsistent prediction when deserialized

BERT-based NER model giving inconsistent prediction when deserialized Question: I am trying to train an NER model using the HuggingFace transformers library on Colab cloud GPUs, pickle it and load the model on my own CPU to make predictions. Code The model is the following: from transformers import BertForTokenClassification model = BertForTokenClassification.from_pretrained( "bert-base-cased", num_labels=NUM_LABELS, output_attentions …

Total answers: 2

Cannot import BertModel from transformers

Cannot import BertModel from transformers Question: I am trying to import BertModel from transformers, but it fails. This is code I am using from transformers import BertModel, BertForMaskedLM This is the error I get ImportError: cannot import name ‘BertModel’ from ‘transformers’ Can anyone help me fix this? Asked By: Moaz Mohammed Husain || Source Answers: …

Total answers: 4

Get probability of multi-token word in MASK position

Get probability of multi-token word in MASK position Question: It is relatively easy to get a token’s probability according to a language model, as the snippet below shows. You can get the output of a model, restrict yourself to the output of the masked token, and then find the probability of your requested token in …

Total answers: 2

BertTokenizer – when encoding and decoding sequences extra spaces appear

BertTokenizer – when encoding and decoding sequences extra spaces appear Question: When using Transformers from HuggingFace I am facing a problem with the encoding and decoding method. I have a the following string: test_string = ‘text with percentage%’ Then I am running the following code: import torch from transformers import BertTokenizer tokenizer = BertTokenizer.from_pretrained(‘bert-base-cased’) test_string …

Total answers: 3