Comments (3)
Hi Jian, can you give me a small (self-contained) example showing how to get this error?
from transformers.
Hi Thomas! I modified the code in your README.md
for an example:
from pytorch_pretrained_bert.modeling import BertForMaskedLM, BertConfig
from pytorch_pretrained_bert import BertTokenizer
import torch
model = BertForMaskedLM.from_pretrained('bert-base-uncased')
# Tokenized input
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
text = "Who was Jim Henson ? Jim Henson was a puppeteer"
tokenized_text = tokenizer.tokenize(text)
# Mask a token that we will try to predict back with `BertForMaskedLM`
masked_index = 6
tokenized_text[masked_index] = '[MASK]'
# Convert token to vocabulary indices
indexed_truths = tokenizer.convert_tokens_to_ids(tokenized_text)
indexed_tokens = tokenizer.convert_tokens_to_ids(tokenized_text)
# Convert inputs to PyTorch tensors
tokens_tensor = torch.tensor([indexed_tokens])
indexed_truths_tensor = torch.tensor([indexed_truths])
# Evaluate loss
model.eval()
masked_lm_logits_scores = model(tokens_tensor, masked_lm_labels=indexed_truths_tensor)
print(masked_lm_logits_scores)
from transformers.
Thank you, you are right, I fixed that on master. It will be in the next release.
from transformers.
Related Issues (20)
- Minor difference in rouge scores for BART evaluation on summarization task HOT 4
- Inconsistency between torch_dtype in model.config and torch_dtype of model parameters HOT 1
- Inconsistency with transformer pipeline results HOT 1
- Replacing the LlamaDecoderLayer Class hugging Face With New LongNet
- Improve/simplify object detection task guide HOT 3
- name 'tokenized_val_dataset' is not defined but it is defined HOT 6
- Generating text with Llama 2 doesn't work when num_beams > 1 and only inputs_embeds is provided HOT 5
- Enhance Generality of Trainer Class HOT 6
- Discrepancies between whisper training script and notebook HOT 2
- [VitMatte] Cannot export VitMatte model to ONNX HOT 2
- RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn HOT 1
- Nested Tensor support HOT 4
- Add support for walltime-based saving/logging/evaluating HOT 4
- Suddenly the process is killed HOT 1
- bug in save_pretrained of transformers/generation/configuration_utils.py HOT 5
- Unable to load starcoder2 finetuned version getting quantization errors HOT 3
- Why AttentionMaskConverter to_casual_4d needs input_shape[-1] > 1? HOT 1
- Missing [existing] default config for accelerator in trainer module HOT 5
- Flash Attention 2 support for Wav2Vec2ForCTC
- Suddenly 'FileNotFoundError: [Errno 2] No such file or directory' error came, the other issues were of no help HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.