repo
stringclasses
1 value
number
int64
1
25.3k
state
stringclasses
2 values
title
stringlengths
1
487
body
stringlengths
0
234k
created_at
stringlengths
19
19
closed_at
stringlengths
19
19
comments
stringlengths
0
293k
transformers
86
closed
code in run_squad.py line 263
# Zero-pad up to the sequence length. while len(input_ids) < max_seq_length: input_ids.append(0) input_mask.append(0) segment_ids.append(0) in segment_ids array,1 indicates token from passage and 0 indicate token form query. when padding,why segment_ids filled with 0,which represents que...
12-04-2018 11:08:09
12-04-2018 11:08:09
![image](https://user-images.githubusercontent.com/11830865/49438135-61d37c00-f7f8-11e8-8b2a-a7222bd30f0e.png) <|||||>Hi, what is your question?<|||||>Strictly speaking, the zero-padding in segment_ids leads to ambiguous tensor entries, because 0 can mean both "first sentence" (or query in another task?) and "padding"...
transformers
85
closed
How to use pre-trained SQUAD model?
After training squad, I have a model file in a local folder: ``` -rw-rw-r-- 1 khashab2 cs_danr 4.7M Nov 21 19:20 dev-v1.1.json -rw-rw-r-- 1 khashab2 cs_danr 3.4K Nov 29 22:52 evaluate-v1.1.py drwxrwsr-x 2 khashab2 cs_danr 10 Nov 30 14:57 out2 -rw-rw-r-- 1 khashab2 cs_danr 29M Nov 21 19:20 train-v1.1.json...
12-04-2018 03:13:30
12-04-2018 03:13:30
Hi there are now examples on how you can save and reload the models in the examples (`run_classifier`, `run_squad` and `run_swag`)
transformers
84
closed
elementwise_mean -> mean (thinking ahead to pytorch 1.0)
under the pytorch 1.0 nightly this test generates ``` UserWarning: reduction='elementwise_mean' is deprecated, please use reduction='mean' instead. ``` so this PR fixes that.
12-03-2018 23:59:40
12-03-2018 23:59:40
oops, doesn't work under current pytorch, never mind
transformers
83
closed
Error while runing example
Hi! I have a problem when running the example, could you please give me a hint on what may I be doing wrong? I use: `PYTHONPATH=. python examples/run_classifier.py --task_name MNLI --do_train --do_eval --do_lower_case --data_dir ../GLUE-baselines/glue_data/MNLI/ --bert_model bert-base-uncased --max_seq_len 40 -...
12-03-2018 20:21:12
12-03-2018 20:21:12
Hi! In case you haven't already, modifying the source at https://github.com/huggingface/pytorch-pretrained-BERT/blob/e60e8a606837ff7f49e583de8492e55575155eb6/examples/run_classifier.py#L491 and turning it into `cache_dir=PYTORCH_PRETRAINED_BERT_CACHE / 'distributed_{}'.format(args.local_rank), num_labels = 3)` ...
transformers
82
closed
AttributeError: 'tuple' object has no attribute 'backward'
Traceback (most recent call last): | 0/11 [00:00<?, ?it/s] File "examples/run_classifier.py", line 637, in <module> main() File "examples/run_classifier.py", line 558, in main ...
12-03-2018 16:06:20
12-03-2018 16:06:20
Looks like there was a code change which changed the forward method of the model involved here from returning a tensor to returning a tuple of tensors and the example hasn't been updated yet to reflect that change. There's probably a line in run_classifier.py like ```Python loss = model(input...) ``` which now need...
transformers
81
closed
There is some problem in supporting continuously training
I change the run_classfifier.py in order to support continuously training. i save the model.state_dict() and the BertAdam optimizer.state_dict(), and I load them when start continuously training. However, After some epochs, the loss will increase little by little and finally end with a large loss value. I do not know t...
12-03-2018 12:00:09
12-03-2018 12:00:09
Hi @ZacharyWaseda, continuous training is an open-research problem. You should rather seek some solution in the papers/workshop/conference discussing researches in this field. This is not my personal field of expertise so I can only direct you to google and other search engine for more information.
transformers
80
closed
How can I apply BERT to a cloze task?
Hi, I have a dataset like : From Monday to Friday most people are busy working or studying, but in the evenings and weekends they are free and _ themselves. And there are four candidates for the missing blank area: ["love", "work", "enjoy", "play"], here "enjoy" is the correct answer, it is a cloze-style t...
12-03-2018 10:58:43
12-03-2018 10:58:43
I think that you best option would be to use the masked language modeling head and restrict the output of the softmax layer to your candidates. I think the following code does the job: ``` import torch from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM tokenizer = BertTokenizer.fro...
transformers
79
closed
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 1
hello, when I am running run_classifier.py with MRPC dataset, there seems to be an mistake. the mistake is as following: <img width="752" alt="default" src="https://user-images.githubusercontent.com/29532760/49360256-9de0e100-f713-11e8-9a5c-d9f2bc5331e6.PNG"> the mistake is happening when training is over and the mod...
12-03-2018 07:56:56
12-03-2018 07:56:56
Hi, just update the repo to the current master, this should have been fixed this weekend (re-open the issue of it's not).
transformers
78
closed
TypeError: object of type 'WindowsPath' has no len()
Hi, when I run "tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')", the error "TypeError: object of type 'WindowsPath' has no len()" occurs, what is the problem? Thank you for your excellent code!
12-02-2018 12:03:51
12-02-2018 12:03:51
Can you post a more detailed log?<|||||>I install your PyTorch pretrained bert with pip like "pip install pytorch-pretrained-bert", then I run the code in Usage section like: `import torch` `from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM` `# Load pre-trained model tokenizer (vocabu...
transformers
77
closed
Correct assignement for logits in classifier example
I tried to address https://github.com/huggingface/pytorch-pretrained-BERT/issues/76 should be correct, but there's likely a more efficient way.
12-02-2018 11:38:51
12-02-2018 11:38:51
Ok thanks, that should work for now. I simplified the output of the classes indeed (only send back loss when a label is provided) so this example broke.
transformers
76
closed
Wrong signature in model call in run_classifier.py example (?)
I think that https://github.com/huggingface/pytorch-pretrained-BERT/blob/063be09b714bf4d2fbbc3de7f52c45b8bc6817eb/examples/run_classifier.py#L608 may well have a problem, as it's not consistent with https://github.com/huggingface/pytorch-pretrained-BERT/blob/063be09b714bf4d2fbbc3de7f52c45b8bc6817eb/examples/run_cl...
12-01-2018 19:34:40
12-01-2018 19:34:40
You are right, I also encountered this small error.<|||||>Thanks for noticing, fixed in #77.
transformers
75
closed
Point typo fix
12-01-2018 00:07:09
12-01-2018 00:07:09
transformers
74
closed
Update finetuning example in README adding --do_lower_case
Should be consistent with the fact that an uncased model is used
12-01-2018 00:06:52
12-01-2018 00:06:52
Indeed
transformers
73
closed
Third release
This third release comprise the following updates: - added the two new pre-trained model from Google: `bert-large-cased` and `bert-multilingual-cased`, - added a model for token-level classification: `BertForTokenClassification`, - added tests for every model class, with and without labels, - fixed tokenizer loadin...
11-30-2018 22:10:22
11-30-2018 22:10:22
transformers
72
closed
Fix internal hyperlink typo
Fix #tup to #tpu
11-30-2018 21:13:47
11-30-2018 21:13:47
transformers
71
closed
run_squad script gets stuck
Hello, I am trying to run the squad fine tuning script, but it hangs after printing out a few predictions. I am attaching the log. Can you help take a look? I am running the script on a machine with 8 M40s. [bert_squad.log](https://github.com/huggingface/pytorch-pretrained-BERT/files/2634588/bert_squad.log) ...
11-30-2018 18:39:54
11-30-2018 18:39:54
Never mind, it just needed time to process the examples. It might be good to have the progress bar inside convert_examples_to_features.<|||||>Maybe try distributed training? I don't think PyTorch `DataParallel` will be very efficient on 8 GPUs due to the python GIL.<|||||>Thanks for the suggestion. I will try that. Cur...
transformers
70
closed
fix typo in input for masked lm loss function
Fixing #55 . There was still a typo.
11-30-2018 15:56:00
11-30-2018 15:56:00
thanks
transformers
69
closed
cannot access to pretrained vocab file on S3
Hi, thanks for develop well-made pytorch version of BERT. Unfortunately, pretrained vocab files are not reachable. error traceback is below. > File "/usr/local/lib/python3.6/dist-packages/pytorch_pretrained_bert/tokenization.py", line 124, in from_pretrained resolved_vocab_file = cached_path(vocab_file) Fi...
11-30-2018 13:57:03
11-30-2018 13:57:03
I have the same issue. > OSError: HEAD request failed for url https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese-vocab.txt with status code 404 It would be nice to be able to cache the vocab files as well as the model weights out of the box.<|||||>I found temporary solution for this issue. ...
transformers
68
closed
Accuracy on classification task is lower than the official tensorflow version
Hi, I am running the same task with the same hyper parameters as the official Google Tensorflow implementation of BERT, however, I am getting around 1.5% lower accuracy. Can you please give any hint about the possible cause? Thanks!
11-30-2018 06:30:56
11-30-2018 06:30:56
Hi! Could it be different seeds? See e.g. https://github.com/huggingface/pytorch-pretrained-BERT/issues/53#issuecomment-441565229<|||||>Hi @ejld, yes BERT has a large variance on many fine-tuning tasks (see also the discussion in #64). You should try a bunch of different seeds (like 10 seeds for example) and compare...
transformers
67
closed
`TypeError: object of type 'NoneType' has no len()` when tuning on squad
When running the following command for tuning on squad, I am getting a petty error inside logger `TypeError: object of type 'NoneType' has no len()`. Any thoughts what could be the main cause of the problem? Full log: ``` python3.6 examples/run_squad.py \ > --bert_model bert-base-uncased \ > --do_train ...
11-30-2018 05:48:04
11-30-2018 05:48:04
Oh I see, this should be fixed in `master` by 257a35134a1bd378b16aa985ee76675289ff439c just update your repo please.
transformers
66
closed
speedup by truncating unused part
11-29-2018 14:56:39
11-29-2018 14:56:39
Hi Mathis, Thanks for that. I think it's better for the user to send inputs that they truncated themselves rather than doing that hidden inside the model. Best, Thomas
transformers
65
closed
3 sentences as input for BertForSequenceClassification?
Hi there, Thanks for releasing this awesome repo, it does lots people like me a great favor. So far I've tried sentence-pair BertForSequenceClassification task, and it indeed work. I'd like to know if it is possible to use BertForSequenceClassification to model triple sentences classification problem and its inpu...
11-29-2018 09:18:21
11-29-2018 09:18:21
Technically it is possible but BERT was not pretrained to handle multiple SEP tokens between sentences and does not have a third token_type, so I think it won't be easy to make it work. You may also want to use a new token for the second separation.<|||||>> Technically it is possible but BERT was not pretrained to hand...
transformers
64
closed
Feature extraction for sequential labelling
Hi, I have a question in terms of using BERT for sequential labeling task. Please correct me if I'm wrong. My understanding is: 1. Use BertModel loaded with pretrained weights instead of MaskedBertModel. 2. In such case, take a sequence of tokens as input, BertModel would output a list of hidden states, I only use ...
11-29-2018 03:33:09
11-29-2018 03:33:09
Well that seems like a good approach. Maybe you can find some inspiration in the code of the `BertForQuestionAnswering` model? It is not exactly what you are doing but maybe it can help.<|||||>Thanks. It worked. However, a interesting issue about BERT is that it's highly sensitive to learning rate, which makes it very ...
transformers
63
closed
Unseen Vocab
Thank you so much for this well-documented and easy-to-understand implementation! I remember meeting you at WeCNLP and am so happy to see you push out usable implementations of the SOA in pytorch for the community!!!!! I have a question: The convert_tokens_to_ids method in the BertTokenizer that provides input to th...
11-28-2018 22:38:57
11-28-2018 22:38:57
If you tokenize properly the input (tokenize before convert_tokens), it automatically 'fallbacks' to subword/character-level(-like) embedding. You can add new words in the vocabulary but you'll have to train the corresponding embeddings.<|||||>Hi @siddsach, Thanks for your kind words! @artemisart is right, BPE progr...
transformers
62
closed
Specify a model from a specific directory for extract_features.py
I have downloaded the model and vocab files into a specific location, using their original file names, so my directory for bert-base-cased contains: ``` bert-base-cased-vocab.txt bert_config.json pytorch_model.bin ``` But when I try to specify the directory which contains these files for the `--bert_model` par...
11-28-2018 17:04:39
11-28-2018 17:04:39
The last update broke this, but you can fix this in tokenization.py, you have to add this after `vocab_file = pretrained_model_name`: ``` if os.path.isdir(vocab_file): vocab_file = os.path.join(vocab_file, "vocab.txt") ``` <|||||>Thank you, is it fair to assume that this will get accepted as an issue and fixed...
transformers
61
closed
BERTConfigs in example usages in `modeling.py` are not OK (?)
Hi! In the `config` definition https://github.com/huggingface/pytorch-pretrained-BERT/blob/21f0196412115876da1c38652d22d1f7a14b36ff/pytorch_pretrained_bert/modeling.py#L848 in the Example usage of `BertForSequenceClassification` in `modeling.py`, there's things I don't understand: - `vocab_size` in not an accept...
11-28-2018 14:53:01
11-28-2018 14:53:01
Hi @davidefiocco, you are right, I updated the docstrings in the new release 0.3.0.
transformers
60
closed
Updated quick-start example with `BertForMaskedLM`
As `convert_ids_to_tokens` returns a list, the code in the README currently throws an `AssertionError`, so I propose a quick fix.
11-28-2018 13:54:01
11-28-2018 13:54:01
Nice, thanks @davidefiocco
transformers
59
closed
not good when I use BERT for seq2seq model in keyphrase generation
Hi, recently, I am researching about Keyphrase generation. Usually, people use seq2seq with attention model to deal with such problem. Specifically I use the framework: https://github.com/memray/seq2seq-keyphrase-pytorch, which is implementation of http://memray.me/uploads/acl17-keyphrase-generation.pdf . Now I ...
11-28-2018 08:44:24
11-28-2018 08:44:24
have u tried transformer decoder ?instead of rnn decoder. <|||||>not yet, I will try. But I think rnn decoder should not be such bad. <|||||>> not yet, I will try. But I think rnn decoder should not be such bad. emmm,maybe u should used mean of last layer to initialize decoder, not the last token representation of...
transformers
58
closed
Bug fix in examples;correct t_total for distributed training;run pred…
Bug fix in examples; correct t_total for distributed training; run prediction for full dataset
11-27-2018 09:10:10
11-27-2018 09:10:10
Thanks @lliimsft!
transformers
57
closed
Missing function convert_to_unicode in tokenization.py
The function _convert_to_unicode_ is not in tokenization.py but used to be there in v0.1.2. When fine tuning with run_classifier.py, you get an ImportError: cannot import name 'convert_to_unicode'. https://github.com/huggingface/pytorch-pretrained-BERT/blob/ce37b8e4819142171b61558e64f7dcb0286e9937/examples/run_class...
11-26-2018 21:50:15
11-26-2018 21:50:15
Fixed in master, thanks!
transformers
56
closed
[Feature request ] Add support for the new cased version of the multilingual model
https://github.com/google-research/bert/commit/332a68723c34062b8f58e5fec3e430db4563320a
11-26-2018 10:56:18
11-26-2018 10:56:18
Hi @elyase, this model is now added in the new release 0.3.0. I also added the other new model by Google (`bert-large-cased`)
transformers
55
closed
Loss calculation error
https://github.com/huggingface/pytorch-pretrained-BERT/blob/982339d82984466fde3b1466f657a03200aa2ffb/pytorch_pretrained_bert/modeling.py#L744 Got `ValueError: Expected target size (1, 30522), got torch.Size([1, 11])` at line 744 of `modeling.py`. I think the line should be changed to `masked_lm_loss = loss_fct(predi...
11-25-2018 03:48:17
11-25-2018 03:48:17
Hi Jian, can you give me a small (self-contained) example showing how to get this error?<|||||>Hi Thomas! I modified the code in your `README.md` for an example: ```python from pytorch_pretrained_bert.modeling import BertForMaskedLM, BertConfig from pytorch_pretrained_bert import BertTokenizer import torch mod...
transformers
54
closed
example in BertForSequenceClassification() conflicts with the api
Hi, firstly, admire u for the great job. but I encounter 2 problems when i use it: **1**. `UnicodeDecodeError: 'gbk' codec can't decode byte 0x85 in position 4527: illegal multibyte sequence`, same problem as ISSUE 52 when I excute the `BertTokenizer.from_pretrained('bert-base-uncased')`, but I successfully excute `...
11-24-2018 07:27:50
11-24-2018 07:27:50
Hi, (1) is solved on master. I will release a new release soon with the fixes on pip. In the mean time you can install from sources if you want. I fixed the typo in the docstring you mention in (2), thanks, it should be a `1` instead of a `2`.
transformers
53
closed
Multi-GPU training vs Distributed training
Hi, I have a question about Multi-GPU vs Distributed training, probably unrelated to BERT itself. I have a 4-GPU server, and was trying to run `run_classifier.py` in two ways: (a) run single-node distributed training with 4 processes and minibatch of 32 each (b) run Multi-GPU training with minibatch of 128, a...
11-24-2018 00:49:45
11-24-2018 00:49:45
Hi, Thanks for the feedback, it's always interesting to compare the various possible ways to train the model indeed. The most likely cause for (2) is that MRPC is a small dataset and the model shows a high variance in the results depending on the initialization of the weights for example (see the original BERT re...
transformers
52
closed
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3920: character maps to <undefined>
Installed pytorch-pretrained-BERT from source, Python 3.7, Windows 10 When I run the following snippet: import torch from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM # Load pre-trained model tokenizer (vocabulary) tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') ...
11-22-2018 15:42:08
11-22-2018 15:42:08
I am facing the same problem. Fixed it with "with open(vocab_file, "r"**, encoding="utf-8"**) as reader:" in line 68 of tokenization.py<|||||>Thanks, it's fixed on master and will be included in the next release.
transformers
51
closed
Missing options/arguments in run_squad.py for BERT Large
Thanks for the great code..However, the `run_squad.py` for BERT Large seems to not have the `vocab_file` and `bert_config_file` (or other) options/arguments. Did you push the latest version? Also, it is looking for a pytorch model file (a bin file). Does it need to be there? I also had to add this line to the file...
11-21-2018 15:10:45
11-21-2018 15:10:45
Yes, the readme example was for an older version. I have updated them with the simplified parameters used in the current release. Thanks.
transformers
50
closed
pytorch_pretrained_bert/convert_tf_checkpoint_to_pytorch.py error
attributeError: 'BertForPreTraining' object has no attribute 'global_step'
11-21-2018 10:36:49
11-21-2018 10:36:49
Maybe some additional information could help me help you?<|||||>Initialize PyTorch weight ['cls', 'seq_relationship', 'output_weights'] Skipping cls/seq_relationship/output_weights/adam_m Skipping cls/seq_relationship/output_weights/adam_v Traceback (most recent call last): File "/home/tiandan.cxj/python/model_se...
transformers
49
closed
Multilingual Issue
Dear authors, I have two questions. First, how can I use multilingual pre-trained BERT in pytorch? Is it all download model to $BERT_BASE_DIR? Second is tokenization issue. For Chinese and Japanese, tokenizer may works, however, for Korean, it shows different result that I expected ``` import torch from p...
11-21-2018 09:32:32
11-21-2018 09:32:32
Hi, you can use the multilingual model as [indicated in the readme](https://github.com/huggingface/pytorch-pretrained-BERT#loading-google-ais-pre-trained-weigths-and-pytorch-dump) with the commands: ```python tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual') model = BertModel.from_pretrained('bert-...
transformers
48
closed
example for is next sentence
Can you make up a working example for 'is next sentence' Is this expected to work properly ? ``` # Load pre-trained model tokenizer (vocabulary) tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') # Tokenized input text = "Who was Jim Morrison ? Jim Morrison was a puppeteer" tokenized_text = tok...
11-21-2018 03:16:00
11-21-2018 03:16:00
I think it should work. You should get a [1, 2] tensor of logits where `predictions[0, 0]` is the score of Next sentence being `True` and `predictions[0, 1]` is the score of Next sentence being `False`. So just take the max of the two (or use a `SoftMax` to get probabilities). Did you try it? The model behaves better...
transformers
47
closed
Fine-Tuned BERT-base on Squad v1.
I have fine-tuned the TF model on SQuAD v1 and I've made the weights available at: https://s3.eu-west-2.amazonaws.com/nlpfiles/squad_bert_base.tgz I get 88.5 FM using these weights on SQuAD dev. (If I recall correctly I get roughly 82 EM). I think it may be beneficial to have these weights here, so that people c...
11-20-2018 17:04:09
11-20-2018 17:04:09
Thanks for the details. This PyTorch repo is starting to be used by a larger community so we would have to be a little more precise than just rough numbers if we want to include such pre-trained weights. If you want to add your weights to the repo, you should convert the weights in the PyTorch repo model and get eval...
transformers
46
closed
Assertion `srcIndex < srcSelectDimSize` failed.
Sorry to bother you I recently have used your extract_features.py to extract features of some data set but failed. The error information is as follows: `/opt/conda/conda-bld/pytorch_1532584813488/work/aten/src/THC/THCTensorIndex.cu:362: void indexSelectLargeIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, Te...
11-20-2018 12:50:41
11-20-2018 12:50:41
Your log is very hard to read. Can you format it cleanly?<|||||>I'm so sorry The first error log is as follows: ```bash /opt/conda/conda-bld/pytorch_1532584813488/work/aten/src/THC/THCTensorIndex.cu:362: void indexSelectLargeIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, ...
transformers
45
closed
Issue of `bert_model` arg in `run_classify.py`
Hi, I am trying to understand the `bert_model` arg in `run_classify.py`. In the file, I can see ``` tokenizer = BertTokenizer.from_pretrained(args.bert_model) ``` where `bert_model` is expected to be the vocab text file of the model However, I also see ``` model = BertForSequenceClassification.from_pretr...
11-20-2018 09:48:09
11-20-2018 09:48:09
Hi, please read [this section](https://github.com/huggingface/pytorch-pretrained-BERT#loading-google-ais-pre-trained-weigths-and-pytorch-dump) of the readme.
transformers
44
closed
Race condition when prepare pretrained model in distributed training
Hi, I launched two processes per node to run distributed run_classifier.py. However, I am occasionally get below error: ``` 11/20/2018 09:31:48 - INFO - pytorch_pretrained_bert.file_utils - copying /tmp/tmpa25_y4es to cache at /root/.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6...
11-20-2018 09:40:25
11-20-2018 09:40:25
My current workaround is to set the env var `PYTORCH_PRETRAINED_BERT_CACHE` to a different path per process before import `pytorch_pretrained_bert`. But I think the module itself should handle this properly<|||||>I see, thanks for the feedback. I will find a way to make that better in the next release. Not sure we need...
transformers
43
closed
grad is None in squad example
Hi, guys, I try the `run_squad` example with ``` Traceback (most recent call last): | 0/7331 [00:00<?, ?it/s] File "examples/run_squad.py", line 973, in <m...
11-20-2018 08:38:03
11-20-2018 08:38:03
Oh you're right. I've just fixed that. you can try to pull the current master and test again.<|||||>@thomwolf it works, thanks
transformers
42
closed
Fixed UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2
I encountered `UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3793: ordinal not in range(128)` when running the starter example shown under the Usage section. It turned out to be related to the `load_vocab` function in `tokenization.py`. Forcing `open` to use encoding `utf8` solved this issue on ...
11-20-2018 04:09:44
11-20-2018 04:09:44
Thanks!
transformers
41
closed
Typo in README
I think I spotted a typo in the README file under the Usage header. There is a piece of code that uses `BertTokenizer` and the typo is on this line: `tokenized_text = "Who was Jim Henson ? Jim Henson was a puppeteer"` I think `tokenized_text` should be replaced with `text`, since the next line is `tokenized_text =...
11-20-2018 03:52:35
11-20-2018 03:52:35
Yes
transformers
40
closed
update pip package name
dashes not underscores
11-19-2018 17:50:54
11-19-2018 17:50:54
transformers
39
closed
Command-line interface Document Bug
There is a bug in README.md about Command-line interface: `export BERT_BASE_DIR=chinese_L-12_H-768_A-12` **Wrong:** ``` pytorch_pretrained_bert convert_tf_checkpoint_to_pytorch \ --tf_checkpoint_path $BERT_BASE_DIR/bert_model.ckpt.index \ --bert_config_file $BERT_BASE_DIR/bert_config.json \ --pytorch_...
11-19-2018 16:42:56
11-19-2018 16:42:56
Thanks!
transformers
38
closed
truncated normal initializer
I have a reasonable truncated normal approximation. (Actually that is what tf does). https://discuss.pytorch.org/t/implementing-truncated-normal-initializer/4778/16?u=ruotianluo
11-19-2018 16:35:08
11-19-2018 16:35:08
We could try that. Not sure how important it is though. Did you try it?<|||||>Ok I think we will stick to the normal_initializer for now. Thanks for indicating this option!
transformers
37
closed
using BERT as a language Model
I was trying to use BERT as a language model to assign a score(could be PPL score) of a given sentence. Something like P("He is go to school")=0.008 P("He is going to school")=0.08 Which is indicating that the probability of second sentence is higher than first sentence. Is there a way to get a score like this? ...
11-19-2018 15:26:20
11-19-2018 15:26:20
I don't think you can do that with Bert. The masked LM loss is not a Language Modeling loss, it doesn't work nicely with the [chain rule](https://en.wikipedia.org/wiki/Chain_rule_%28probability%29) like the usual Language Modeling loss. Please see the discussion on the TensorFlow repo on that [here](https://github.com...
transformers
36
closed
How to detokenize a BertTokenizer output?
I was wondering if there's a proper way of detokenizing the output tokens, i.e., constructing the sentence back from the tokens? Considering the fact that the word-piece tokenisation introduces lots of `#`s.
11-19-2018 04:39:04
11-19-2018 04:39:04
You can remove ' ##' but you cannot know if there was a space around punctuations tokens or uppercase words.<|||||>Yes. I don't plan to include a reverse conversion of tokens in the tokenizer. For an example on how to keep track of the original characters position, please read the `run_squad.py` example.<|||||>In my c...
transformers
35
closed
issues with accents on convert_ids_to_tokens()
Hello, the BertTokenizer seems loose accents when convert_ids_to_tokens() is used : Example: - original sentence: "great breakfasts in a nice furnished cafè, slightly bohemian." - corresponding list of token produced : ['great', 'breakfast', '##s', 'in', 'a', 'nice', 'fur', '##nis', '##hed', 'cafe', ',', 'slightly...
11-18-2018 20:41:24
11-18-2018 20:41:24
This is expected behaviour and is how the multilingual and the uncased models were trained. From the [original repo](https://github.com/google-research/bert/blob/master/README.md): > We are releasing the BERT-Base and BERT-Large models from the paper. Uncased means that the text has been lowercased before WordPiece ...
transformers
34
closed
Can not find vocabulary file for Chinese model
After I convert the TF model to pytorch model, I run a classification task on a new Chinese dataset, but get this: CUDA_VISIBLE_DEVICES=3 python run_classifier.py --task_name weibo --do_eval --do_train --bert_model chinese_L-12_H-768_A-12 --max_seq_length 128 --train_batch_size 32 --learning_rate 2e-5 --num_...
11-18-2018 14:33:58
11-18-2018 14:33:58
need to specify the path of vocab.txt for: tokenizer = BertTokenizer.from_pretrained(args.bert_model)<|||||>@zlinao ,i try to load the vocab using the following code: tokenizer = BertTokenizer.from_pretrained("bert-base-chinese//vocab.txt" however,get errors 11/19/2018 15:33:13 - INFO - pytorch_pretrained_bert.to...
transformers
33
closed
[Bug report] Ineffective no_decay when using BERTAdam
https://github.com/huggingface/pytorch-pretrained-BERT/blob/master/examples/run_classifier.py#L505-L508 With this code, all parameters are decayed because the condition "parameter_name in no_decay" will never be satisfied. I've made a PR #32 to fix it.
11-18-2018 08:28:52
11-18-2018 08:28:52
You're right, thanks!
transformers
32
closed
Fix ineffective no_decay bug when using BERTAdam
With the original code, all parameters are decayed because the condition "parameter_name in no_decay" will never be satisfied.
11-18-2018 08:21:37
11-18-2018 08:21:37
thanks!<|||||>Question - wouldn't `.named_parameters()` for the model return a tuple `(name, param_tensor)`, where name looks similar to these ``` ['bert.embeddings.word_embeddings.weight', 'bert.embeddings.position_embeddings.weight', 'bert.embeddings.token_type_embeddings.weight', 'bert.embeddings.LayerNorm.w...
transformers
31
closed
BERT model for Machine Translation
Is there a way to use any of the provided pre-trained models in the repository for machine translation task? Thanks
11-18-2018 02:10:15
11-18-2018 02:10:15
Hi Kerem, I don't think so. Have a look at the fairsep repo maybe.<|||||>@thomwolf hi there, I couldn't find out anything about the fairsep repo. Could you post a link? Thanks!<|||||>Hi, I am talking about this repo: https://github.com/pytorch/fairseq. Have a look at their Transformer's models for machine translation....
transformers
30
closed
[Feature request] Add example of finetuning the pretrained models on custom corpus
11-17-2018 15:19:58
11-17-2018 15:19:58
Hi I don't plan to add that in the near future but feel free to open a PR if you would like to share an additional example.<|||||>Necrobumping this for reference, as this is addressed in https://github.com/huggingface/pytorch-pretrained-BERT/blob/master/examples/run_lm_finetuning.py
transformers
29
closed
First release
11-17-2018 11:19:41
11-17-2018 11:19:41
transformers
28
closed
speed is very slow
convert samples to features, is very slow
11-17-2018 06:51:54
11-17-2018 06:51:54
Running on a GPU, I find that dumping extracted features takes up most time. So you may optimize it yourself. <|||||>Hi, these examples are provided as starting point to write your own training scripts using the package modules. I don't plan to update them any further.
transformers
27
closed
how to load checkpoint?
i download the model from bert, it only has model.ckpt.data,model.ckpt.meta and model.ckpt.index, i donnot which to load, what is checkpoint file for convert.py?
11-17-2018 06:23:28
11-17-2018 06:23:28
Converting TensorFlow checkpoint from ../dataset/bert/uncased_L-12_H-768_A-12/bert_model Traceback (most recent call last): File "convert_tf_checkpoint_to_pytorch.py", line 111, in <module> convert() File "convert_tf_checkpoint_to_pytorch.py", line 60, in convert init_vars = tf.train.list_variables(pat...
transformers
26
closed
Checkpoints not saved
There is an option `save_checkpoints_steps` that seems to control checkpointing. However, there is no actual saving operation in the `run_*` scripts. So, should we add that functionality or remove this argument?
11-16-2018 18:50:27
11-16-2018 18:50:27
In the `run_squad.py`script, I added the following lines after the training loop: ``` logger.info(***** Saving fine-tuned model *****) output_model_file = os.path.join(args.output_dir, "pytorch_model.bin") if n_gpu > 1: torch.save(model.module.bert.state_dict(), output_model_file) else: torch.save(mode...
transformers
25
closed
can you push the run-pretraining and create_pretraining_data codes?
just want to study codes, don't need to have same pre-train performance.
11-16-2018 08:15:33
11-16-2018 08:15:33
Hi, I don't have plan for that in the near future.
transformers
24
closed
[Feature request] Port SQuAD 2.0 support
Recently the Google team added support for Squad 2.0: https://github.com/google-research/bert/commit/60454702590a6c69bd45c5d4258c7e17b8a3e1da Would be great to also have it available in the Pytorch version.
11-15-2018 23:47:04
11-15-2018 23:47:04
Hi, I don't have plan for that in the near future but feel free to open a PR.
transformers
23
closed
ValueError while using --optimize_on_cpu
> Traceback (most recent call last): | 1/87970 [00:00<8:35:35, 2.84it/s] File "./run_squad.py", line 990, in <module> main() File "./run_squad.py", line 922, in main is_nan = set_optimizer_params_grad(param_optimizer, model.named_parameters(), test_nan=True) File "./run_squad.py", line 691, in set_optimizer_params...
11-15-2018 16:53:12
11-15-2018 16:53:12
Thanks! I pushed a fix for that, you can try it again. You should be able to increase a bit the batch size. By the way, the real batch size that is used on the gpu is `train_batch_size / gradient_accumulation_steps` so `2` in your case. I think you should be able to go to `3` with `--optimize_on_cpu` The recommen...
transformers
22
closed
adding `no_cuda` flag
The `--no_cuda` flag is missing from the flagset in `extract_features.py`. On running the current code, the following error occurs. ``` (py3.5) [rahul pytorch-pretrained-BERT]$ python extract_features.py \ > --input_file=./input.txt \ > --output_file=./output.jsonl \ > --vocab_file=$BERT_BASE_DIR/vocab.txt...
11-15-2018 10:33:03
11-15-2018 10:33:03
Thanks, I've added that manually (the library organization has changed a bit with the first pip release).
transformers
21
closed
Fix some glitches in extract_features.py
Do the following fixing to make the extract_features.py runnable: 1. Add no_cuda argument 2. Fix the "not all arguments converted during string formatting" error thrown at line 230
11-15-2018 07:49:20
11-15-2018 07:49:20
Thanks, I've pushed these fixes in the first release (the organization of the library changed quite a bit).
transformers
20
closed
model loading the checkpoint error
RuntimeError: Error(s) in loading state_dict for BertModel: size mismatch for embeddings.token_type_embeddings.weight: copying a param of torch.Size([16, 768]) from checkpoint, where the shape is torch.Size([2, 768]) in current model.
11-14-2018 08:13:34
11-14-2018 08:13:34
But I print the model.embeddings.token_type_embeddings it was Embedding(16,768) .<|||||>which model are you loading?<|||||>> which model are you loading? the pre-trained model chinese_L-12_H-768_A-12<|||||>mycode: bert_config = BertConfig.from_json_file('bert_config.json') model=BertModel(bert_config) model...
transformers
19
closed
will you push the pytorch code for the pre-training process?
Can you push the pytorch code for the pre-training process,such as MLM task, please? I really want to study, but I can't understand tensorflow, it's so complex. thanks!!!
11-14-2018 06:30:59
11-14-2018 06:30:59
Hi, I don't have plan for that in the near future.
transformers
18
closed
include the output layer in the model using the pretrained weights
This is to be able to load the final output layer (bert.output_layer) from the TensorFlow pre-trained model. In particular, it is a fully connected layer that is used to map the final hidden layer to the vocabulary size, to then apply the softmax, as follows: logits = bert.output_layer(sequence_output) log_softmax...
11-13-2018 16:15:03
11-13-2018 16:15:03
Thanks for that. I've ended up taking a more modular approach in the first pip release of the library.
transformers
17
closed
activation function in BERTIntermediate
Was previously hardcoded to gelu because pretrained BERT models use gelu. Changed to make BERTIntermediate use functions and "gelu", "relu" or "swish" from `config`.
11-13-2018 15:47:46
11-13-2018 15:47:46
Looks good, thanks for that!
transformers
16
closed
Excluding AdamWeightDecayOptimizer internal variables from restoring
I tried to use convert_tf_checkpoint_to_pytorch.py script to convert my pretrained model, but in order to do so, I had to make some minor tweaks. I thought I would share in case you find it useful.
11-13-2018 15:13:18
11-13-2018 15:13:18
Is your pre-trained model a TensorFlow model?<|||||>Yes<|||||>Nice, thanks for that!
transformers
15
closed
activation function in BERTIntermediate
BERTConfig is not used for `BERTIntermediate`'s activation function. `intermediate_act_fn` is always `gelu`. Is this normal? https://github.com/huggingface/pytorch-pretrained-BERT/blob/master/modeling.py#L240
11-13-2018 15:09:33
11-13-2018 15:09:33
Yes, I hard coded that since the pre-trained models are all trained with gelu anyway.<|||||>ok. but since config is there anyway, isn't it cleaner to use it (to avoid errors for people using configs that use a different activation for some reason) ?<|||||>Yes we can, I'll change that in the coming first release (unless...
transformers
14
closed
fixed typo
When test with SQuAD
11-12-2018 01:18:24
11-12-2018 01:18:24
Hi, Thanks for the PR, we don't want to add a shell script to the repo. I will correct the typo, Best, Thom
transformers
13
closed
Bug in run_classifier.py
If I am running only evaluation and not training, there are errors as tr_loss and nb_tr_steps are undefined.
11-10-2018 17:16:01
11-10-2018 17:16:01
transformers
12
closed
py2 code
if I convert code to python2 version of code, it can't converage ; Would you present py2 code?
11-10-2018 13:23:31
11-10-2018 13:23:31
Hi, we won't provide a python 2 version but if you want to do a python 2/3 compatible version feel free to open a PR.
transformers
11
closed
Swapped to_seq_len/from_seq_len in comment
I'm pretty sure this comment: https://github.com/huggingface/pytorch-pretrained-BERT/blob/2c5d993ba48841575d9c58f0754bca00b288431c/modeling.py#L339-L343 should instead say: ``` # Sizes are [batch_size, 1, 1, to_seq_length] # So we can broadcast to [batch_size, num_heads, from_seq_length, to_seq_length] ``` ...
11-09-2018 06:13:08
11-09-2018 06:13:08
Yes! fixed the comment
transformers
10
closed
Is there a plan to have a FP16 for GPU so to have larger batch size or longer text documents support ?
Is there a plan to have an FP16 for GPU so to have a larger batch size or longer text documents support?
11-09-2018 02:23:34
11-09-2018 02:23:34
Yes probably. I am testing fp16 right now. If it works well I will push it to the repo.<|||||>Ok I've added FP16 support (see updated readme)<|||||>Thanks for this quick updates.<|||||>I'm not able to work with FP16 for pytorch BERT code. Particularly for BertForSequenceClassification, which I tried and got the issue ...
transformers
9
closed
Crash at the end of training
Hi, I tried running the Squad model this morning (on a single GPU with gradient accumulation over 3 steps) but after 3 hours of training, my job failed with the following output: I was running the code, unmodified, from commit 3bfbc21376af691b912f3b6256bbeaf8e0046ba8 Is this an issue you know about? ``` 11/08/2...
11-08-2018 22:01:57
11-08-2018 22:01:57
Here's the specific command I ran for more context: ``` python3.6 code/run_squad.py \ --bert_config_file bert/bert_config.json \ --vocab_file bert/vocab.txt \ --output_dir output \ --train_file data/original/train.json \ --predict_file data/original/dev.json \ --init_checkpoint bert-pytorch/pytorch...
transformers
8
closed
fixed small typos in the README.md
11-08-2018 18:24:27
11-08-2018 18:24:27
Many thanks!
transformers
7
closed
Develop
Fixing `run_squad.py` pre-processing bug. Various clean-ups: - the weight initialization was not optimal (tf. truncated_normal_initializer(stddev=0.02) was translated in weight.data.normal_(0.02) instead of weight.data.normal_(mean=0.0, std=0.02) which likely affected the performance of run_classifer.py also. - ...
11-07-2018 22:34:18
11-07-2018 22:34:18
transformers
6
closed
Failure during pytest (and solution for python3)
``` foo@bar:~/foo/bar/pytorch-pretrained-BERT$ pytest -sv ./tests/ ===================================================================================================================== test session starts =================================================================================================================...
11-06-2018 08:23:29
11-06-2018 08:23:29
Thanks, I update the readme.
transformers
5
closed
MRPC hyperparameters question
When describing how you reproduced the MRPC results, you say: "Our test ran on a few seeds with the original implementation hyper-parameters gave evaluation results between 82 and 87." and you link to the SQuAD hyperparameters (https://github.com/google-research/bert#squad). Is the link a mistake? Or did you use t...
11-06-2018 05:30:36
11-06-2018 05:30:36
Hi Ethan, Thanks we used the MRPC hyper-parameters indeed, I corrected the README. Regarding the dev set accuracy, I am not really surprised there is a slightly lower accuracy with the PyTorch version (even though the variance is high so it's hard to get something significant). That is something that is generally obs...
transformers
4
closed
Fix typo in subheader BertForQuestionAnswering
Should say `BertForQuestionAnswering`, but says `BertForSequenceClassification`.
11-05-2018 23:04:03
11-05-2018 23:04:03
exact thanks !
transformers
3
closed
run_squad questions
Thanks a lot for the port! I have some minor questions, for the run_squad file, I see two options for accumulating gradients, accumulate_gradients and gradient_accumulation_steps but it seems to me that it can be combined into one. The other one is for the global_step variable, seems we are only counting but not using ...
11-05-2018 21:35:51
11-05-2018 21:35:51
It also seems to me that the SQuAD 1.1 can not reproduce the google tensorflow version performance.<|||||>> It also seems to me that the SQuAD 1.1 can not reproduce the google tensorflow version performance. What batch size are you running?<|||||>I'm running on 4 GPU with a batch size of 48, the result is {"exact_ma...
transformers
2
closed
Port tokenization for the multilingual model
11-05-2018 21:35:36
11-05-2018 21:35:36
Thanks for that, sorry for the delay
transformers
1
closed
Create DataParallel model if several GPUs
11-03-2018 14:10:20
11-03-2018 14:10:20