"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "68ab9599ce3aefbd25d1c81e3315d1968849b628"
Commit bfb9b540 authored by Rémi Louf's avatar Rémi Louf
Browse files

add Model2Model to __init__

parent c1bc709c
...@@ -13,22 +13,7 @@ ...@@ -13,22 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" Finetuning seq2seq models for sequence generation. """ Finetuning seq2seq models for sequence generation."""
We use the procedure described in [1] to finetune models for sequence
generation. Let S1 and S2 be the source and target sequence respectively; we
pack them using the start of sequence [EOS] and end of sequence [EOS] token:
[CLS] S1 [EOS] S2 [EOS]
We then mask a fixed percentage of token from S2 at random and learn to predict
the masked words. [EOS] can be masked during finetuning so the model learns to
terminate the generation process.
[1] Dong Li, Nan Yang, Wenhui Wang, Furu Wei, Xiaodong Liu, Yu Wang, Jianfeng
Gao, Ming Zhou, and Hsiao-Wuen Hon. “Unified Language Model Pre-Training for
Natural Language Understanding and Generation.” (May 2019) ArXiv:1905.03197
"""
import argparse import argparse
from collections import deque from collections import deque
...@@ -56,6 +41,7 @@ def set_seed(args): ...@@ -56,6 +41,7 @@ def set_seed(args):
# Load dataset # Load dataset
# ------------ # ------------
class TextDataset(Dataset): class TextDataset(Dataset):
""" Abstracts the dataset used to train seq2seq models. """ Abstracts the dataset used to train seq2seq models.
......
...@@ -87,6 +87,7 @@ if is_torch_available(): ...@@ -87,6 +87,7 @@ if is_torch_available():
from .modeling_distilbert import (DistilBertForMaskedLM, DistilBertModel, from .modeling_distilbert import (DistilBertForMaskedLM, DistilBertModel,
DistilBertForSequenceClassification, DistilBertForQuestionAnswering, DistilBertForSequenceClassification, DistilBertForQuestionAnswering,
DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP) DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP)
from .modeling_seq2seq import Model2Model
# Optimization # Optimization
from .optimization import (AdamW, ConstantLRSchedule, WarmupConstantSchedule, WarmupCosineSchedule, from .optimization import (AdamW, ConstantLRSchedule, WarmupConstantSchedule, WarmupCosineSchedule,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment