Commit Graph
77 Commits
Author SHA1 Message Date
Rémi Louf 2a64107e44 improve device usage 2019-12-09 20:37:55 -05:00
Rémi Louf c0707a85d2 add README 2019-12-09 20:37:55 -05:00
Rémi Louf ade3cdf5ad integrate ROUGE 2019-12-09 20:37:55 -05:00
Rémi Louf 076602bdc4 prevent BERT weights from being downloaded twice 2019-12-09 20:37:55 -05:00
Rémi Louf 5909f71028 add py-rouge dependency 2019-12-09 20:37:55 -05:00
Rémi Louf a1994a71ee simplified model and configuration 2019-12-09 20:37:55 -05:00
Rémi Louf 3a9a9f7861 default output dir to documents dir 2019-12-09 20:37:55 -05:00
Rémi Louf 693606a75c update the docs 2019-12-09 20:37:55 -05:00
Rémi Louf c0443df593 remove beam search 2019-12-09 20:37:55 -05:00
Rémi Louf 2403a66598 give transformers API to BertAbs 2019-12-09 20:37:55 -05:00
Rémi Louf 4d18199902 cast bool tensor to long for pytorch < 1.3 2019-12-09 20:37:55 -05:00
Rémi Louf 9f75565ea8 setup training 2019-12-09 20:37:55 -05:00
Rémi Louf 4735c2af07 tweaks to the BeamSearch API 2019-12-09 20:37:55 -05:00
Rémi Louf ba089c780b share pretrained embeddings 2019-12-09 20:37:55 -05:00
Rémi Louf 9660ba1cbd Add beam search 2019-12-09 20:37:55 -05:00
Rémi Louf 1c71ecc880 load the pretrained weights for encoder-decoder
We currently save the pretrained_weights of the encoder and decoder in
two separate directories `encoder` and `decoder`. However, for the
`from_pretrained` function to operate with automodels we need to
specify the type of model in the path to the weights.

The path to the encoder/decoder weights is handled by the
`PreTrainedEncoderDecoder` class in the `save_pretrained` function. Sice
there is no easy way to infer the type of model that was initialized for
the encoder and decoder we add a parameter `model_type` to the function.
This is not an ideal solution as it is error prone, and the model type
should be carried by the Model classes somehow.

This is a temporary fix that should be changed before merging.
2019-12-09 20:37:55 -05:00
Rémi Louf 07f4cd73f6 update function to add special tokens
Since I started my PR the `add_special_token_single_sequence` function
has been deprecated for another; I replaced it with the new function.
2019-12-09 20:37:55 -05:00
Rémi Louf de2696f68e suggest to track repo w/ https rather than ssh 2019-11-27 11:02:28 -05:00
Rémi Louf 26db31e0c0 update the documentation 2019-11-21 14:41:19 -05:00
Rémi Louf 6f70bb8c69 add instructions to run the examples 2019-11-21 14:41:19 -05:00
Rémi Louf 2276bf69b7 update the examples, docs and template 2019-11-14 20:38:02 +01:00
Rémi Louf 022525b003 replace LambdaLR scheduler wrappers by function
Custom schedulers are currently initiated by wrapping Pytorch's LambdaLR
class and passing a method of the wrapping class to the __init__
function of LambdaLR. This approach is not appropriate for several
reasons:

1. one does not need to define a class when it only defines a
__init__() method;
2. instantiating the parent class by passing a method of the child class
creates a cyclical reference which leads to memory leaks. See issues #1742 and #1134.

In this commit we replace the wrapper classes with functions that
instantiate `LambdaLR` with a custom learning rate function. We use a
closure to specify the parameter of the latter. We also do a bit of
renaming within the function to explicit the behaviour and removed
docstrings that were subsequently not necessary.
2019-11-14 15:39:08 +01:00
Rémi Louf cd286c2145 add condition around mask transformation 2019-11-08 11:31:16 +01:00
Rémi Louf 28d0ba35d7 only init encoder_attention_mask if stack is decoder
We currently initialize `encoder_attention_mask` when it is `None`,
whether the stack is that of an encoder or a decoder. Since this
may lead to bugs that are difficult to tracks down, I added a condition
that assesses whether the current stack is a decoder.
2019-11-08 11:22:19 +01:00
Rémi Louf 3cf2020c6b change kwargs processing 2019-10-30 16:27:51 +01:00
Rémi Louf a88a0e4413 add tests to encoder-decoder model 2019-10-30 16:06:29 +01:00
Rémi Louf 3f07cd419c update test on Bert to include decoder mode 2019-10-30 15:09:53 +01:00
Rémi Louf 070507df1f format utils for summarization 2019-10-30 11:24:12 +01:00
Rémi Louf da10de8466 fix bug with padding mask + add corresponding test 2019-10-30 11:19:58 +01:00
Rémi Louf 3b0d2fa30e rename seq2seq to encoder_decoder 2019-10-30 10:54:46 +01:00
Rémi Louf 9c1bdb5b61 revert renaming of lm_labels to ltr_lm_labels 2019-10-30 10:43:13 +01:00
Rémi Louf 098a89f312 update docstrings; rename lm_labels to more explicit ltr_lm_labels 2019-10-29 20:08:03 +01:00
Rémi Louf dfce409691 resolve PR comments 2019-10-29 17:10:20 +01:00
Rémi Louf 4c3ac4a7d8 here's one big commit 2019-10-28 10:49:50 +01:00
Rémi Louf 932543f77e fix test of truncation function 2019-10-28 10:49:49 +01:00
Rémi Louf a67413ccc8 extend works in-place 2019-10-28 10:49:49 +01:00
Rémi Louf cb26b035c6 remove potential UndefinedError 2019-10-28 10:49:49 +01:00
Rémi Louf b915ba9dfe pad sequence with 0, mask with -1 2019-10-28 10:49:49 +01:00
Rémi Louf dc580dd4c7 add lm_labels for the LM cross-entropy 2019-10-28 10:49:49 +01:00
Rémi Louf f873a3edb2 the decoder attends to the output of the encoder stack (last layer) 2019-10-28 10:49:00 +01:00
Rémi Louf 578d23e061 add training pipeline (formatting temporary) 2019-10-17 14:02:27 +02:00
Rémi Louf 47a06d88a0 use two different tokenizers for storyand summary 2019-10-17 13:04:26 +02:00
Rémi Louf bfb9b540d4 add Model2Model to __init__ 2019-10-17 12:59:51 +02:00
Rémi Louf c1bc709c35 correct the truncation and padding of dataset 2019-10-17 10:41:53 +02:00
Rémi Louf 87d60b6e19 reword explanation of encoder_attention_mask 2019-10-17 10:18:19 +02:00
Rémi Louf 638fe7f5a4 correct composition of padding and causal masks 2019-10-17 10:13:07 +02:00
Rémi Louf 4e0f24348f document the MLM modification + raise exception on MLM training with encoder-decoder 2019-10-17 09:41:53 +02:00
Rémi Louf 624a5644cc revert black formatting to conform with lib style 2019-10-17 09:27:56 +02:00
Rémi Louf 9b71fc9a18 tying weights is going to be a clusterfuck 2019-10-16 21:31:38 +02:00
Rémi Louf 95ec1d08be separate inputs into encoder & decoder inputs 2019-10-16 20:55:42 +02:00
Rémi Louf e4e0ee14bd add separator between data import and train 2019-10-16 20:05:32 +02:00
Rémi Louf a424892fab correct syntax error: dim() and not dims() 2019-10-16 18:24:32 +02:00
Rémi Louf 33c01368b1 remove Bert2Rnd test 2019-10-16 18:13:05 +02:00
Rémi Louf 260ac7d9a8 wip commit, switching computers 2019-10-15 12:24:35 +02:00
Rémi Louf fe25eefc15 add instructions to fetch the dataset 2019-10-14 20:45:39 +02:00
Rémi Louf 412793275d delegate the padding with special tokens to the tokenizer 2019-10-14 20:45:16 +02:00
Rémi Louf 447fffb21f process the raw CNN/Daily Mail dataset
the data provided by Li Dong et al. were already tokenized, which means
that they are not compatible with  all the models in the library. We
thus process the raw data directly and tokenize them using the models'
tokenizers.
2019-10-14 18:12:20 +02:00
Rémi Louf 67d10960ae load and prepare CNN/Daily Mail data
We write a function to load an preprocess the CNN/Daily Mail dataset as
provided by Li Dong et al. The issue is that this dataset has already
been tokenized by the authors, so we actually need to find the original,
plain-text dataset if we want to apply it to all models.
2019-10-14 14:11:20 +02:00
Rémi Louf b3261e7ace read parameters from CLI, load model & tokenizer 2019-10-11 18:40:38 +02:00
Rémi Louf d889e0b71b add base for seq2seq finetuning 2019-10-11 17:36:12 +02:00
Rémi Louf f8e98d6779 load pretrained embeddings in Bert decoder
In Rothe et al.'s "Leveraging Pre-trained Checkpoints for Sequence
Generation Tasks", Bert2Bert is initialized with pre-trained weights for
the encoder, and only pre-trained embeddings for the decoder. The
current version of the code completely randomizes the weights of the
decoder.

We write a custom function to initiliaze the weights of the decoder; we
first initialize the decoder with the weights and then randomize
everything but the embeddings.
2019-10-11 16:48:11 +02:00
Rémi Louf 1e68c28670 add test for initialization of Bert2Rnd 2019-10-10 18:07:11 +02:00
Rémi Louf fa218e648a fix syntax errors 2019-10-10 15:16:07 +02:00
Rémi Louf 3e1cd8241e fix stupid (re)naming issue 2019-10-10 14:18:20 +02:00
Rémi Louf 81ee29ee8d remove the staticmethod used to load the config 2019-10-10 14:13:37 +02:00
Rémi Louf d7092d592c rename the attributes in the Bert Layer
Since the preloading of weights relies on the name of the class's
attributes changing the namespace breaks loading pretrained weights on
Bert and all related models. I reverted `self_attention` to `attention`
and us `crossattention` for the decoder instead.
2019-10-10 12:51:14 +02:00
Rémi Louf 51261167b4 prune both attention and self-attention heads 2019-10-10 12:17:22 +02:00
Rémi Louf 17177e7379 add is_decoder as an attribute to Config class 2019-10-10 12:03:58 +02:00
Rémi Louf df85a0ff0b replace double quotes with simple quotes 2019-10-10 11:38:26 +02:00
Rémi Louf 9ca788b2e8 merge the two Bert layers classes 2019-10-10 11:33:28 +02:00
Rémi Louf edfc8f8225 Remove and do the branching in 2019-10-10 10:17:27 +02:00
Rémi Louf 09cfd12235 remove and do the branching in 2019-10-10 10:15:27 +02:00
Rémi Louf 877ef2c6ca override from_pretrained in Bert2Rnd
In the seq2seq model we need to both load pretrained weights in the
encoder and initialize the decoder randomly. Because the
`from_pretrained` method defined in the base class relies on module
names to assign weights, it would also initialize the decoder with
pretrained weights. To avoid this we override the method to only
initialize the encoder with pretrained weights.
2019-10-10 10:02:18 +02:00
Rémi Louf 851ef592c5 add comment on recursive weights loading 2019-10-10 10:02:03 +02:00
Rémi Louf 770b15b58c rename class in __init__ 2019-10-08 17:32:28 +02:00
Rémi Louf f4d41fe33e Merge pull request #1448 from huggingface/contributing
add contribution guidelines
2019-10-08 16:55:34 +02:00
Rémi Louf 6e3e1c959e Merge pull request #1447 from huggingface/dev-requirements
Provide requirements.txt for development dependencies
2019-10-07 18:49:26 +02:00