Papers › TLM: Token-Level Masking for Transformers

TLM: Token-Level Masking for Transformers

28 Oct 2023arXiv:2310.18738archive 2025-07-28

Yangjun Wu, Kebin Fang, Dongxiang Zhang, Han Wang, Hao Zhang, Gang Chen

Structured dropout approaches, such as attention dropout and DropHead, have been investigated to regularize the multi-head attention mechanism in Transformers. In this paper, we propose a new regularization scheme based on token-level rather than structure-level to reduce overfitting. Specifically, we devise a novel Token-Level Masking (TLM) training strategy for Transformers to regularize the connections of self-attention, which consists of two masking techniques that are effective and easy to implement. The underlying idea is to manipulate the connections between tokens in the multi-head attention via masking, where the networks are forced to exploit partial neighbors' information to produce a meaningful representation. The generality and effectiveness of TLM are thoroughly evaluated via extensive experiments on 4 diversified NLP tasks across 18 datasets, including natural language understanding benchmark GLUE, ChineseGLUE, Chinese Grammatical Error Correction, and data-to-text generation. The results indicate that TLM can consistently outperform attention dropout and DropHead, e.g., it increases by 0.5 points relative to DropHead with BERT-large on GLUE. Moreover, TLM can establish a new record on the data-to-text benchmark Rotowire (18.93 BLEU). Our code will be publicly available at https://github.com/Young1993/tlm.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 28 code samples harvested from 2 repositories linked to this paper: 23 ran (of which 0 constructed an object rather than computing a result; 15 with no instrument failure: 1 honoured, 0 violated, 14 with no contract checked; 8 where Syntology's instrument failed) · 5 unverified. Where Syntology's instrument failed: 8 where our contract draft was wrong; failures of Syntology's instrument, not of the code.

By repository: official repository: 14 samples from 1 repository, 11 ran (5 with no instrument failure; 6 where Syntology's instrument failed); found in paper text by Syntology: 14 samples from 1 repository, 12 ran (10 with no instrument failure; 2 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-26 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.

young1993/tlm officialmentioned in paperjaxSyntology: 14 samples, 11 ran (6 instrument-failed) · 3 unverified report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

28 samples harvested: 23 ran (of which 0 constructed an object rather than computing a result; 15 with no instrument failure: 1 honoured, 0 violated, 14 with no contract checked; 8 where Syntology's instrument failed) · 5 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · honoured contract
8ran · our draft was wrong
14ran
5unverified

Licence: 28 of the 28 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; the list below is grouped by repository, each group headed by its name and what it is to the paper. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. For 1 sample that ran, the graph records a signature this page does not show: an argument's recorded type or element kind is a printout of an object in Syntology's harness (such as a mock object, a class or a pandas printout), not the type of an input, so it does not describe the call's shape. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.

young1993/tlm official repository 14 samples, 11 ran (6 instrument-failed) · 3 unverified
booleans_processing in 9 papers transformers/modeling_tf_utils.py ran · our draft was wrong no licence file found · pointer only · 743ceb9025a7955d · report fixture: signature config:MinimalConfig/0/?, output_attentions:bool/0/bool, output_hidden_states:NoneType/0/?, return_dict:bool/0/bool, use_cache:NoneType/0/? · returned dict · level recorded 2026-09-24
check_imports in 15 papers transformers/dynamic_module_utils.py ran · our draft was wrong no licence file found · pointer only · 301682fc3342590a · report fixture: signature filename:str/0/str · returned list · level recorded 2026-09-26
convert_pytorch_state_dict_to_flax in 21 papers transformers/modeling_flax_pytorch_utils.py ran no licence file found · pointer only · db0c9b6ddfd01ae5 · report fixture: signature pt_state_dict:dict/0/?, flax_model:MockFlaxModel/0/? · returned dict · level recorded 2026-09-24
dummy_loss in 11 papers transformers/modeling_tf_utils.py ran no licence file found · pointer only · 3c1eb64dde6b86af · report fixture: signature y_true:EagerTensor/3/float, y_pred:EagerTensor/3/float · returned EagerTensor · level recorded 2026-09-24
get_relative_import_files in 28 papers transformers/dynamic_module_utils.py ran · our draft was wrong no licence file found · pointer only · 00cc853a73f3aeb6 · report fixture: signature module_file:str/0/str · returned list · level recorded 2026-09-26
get_relative_imports in 28 papers transformers/dynamic_module_utils.py ran · our draft was wrong no licence file found · pointer only · 450aeffe7f80f917 · report fixture: signature module_file:str/0/str · returned list · level recorded 2026-09-26
infer_metric_tags_from_eval_results in 20 papers transformers/modelcard.py ran · our draft was wrong no licence file found · pointer only · dd8f7751ef859581 · report fixture: signature eval_results:dict/0/? · returned dict · level recorded 2026-09-24
keras_serializable in 11 papers transformers/modeling_tf_utils.py ran · our draft was wrong no licence file found · pointer only · 6a3959a0ffd36577 · report fixture: signature cls:callable/0/? · returned type · level recorded 2026-09-24
parse_keras_history in 19 papers transformers/modelcard.py ran no licence file found · pointer only · 18450df3733a6e7e · report fixture: returned tuple · level recorded 2026-09-24
quick_gelu in 43 papers transformers/modeling_flax_utils.py ran · honoured contract fingerprinted no licence file found · pointer only · a66d2b78670c85e1 · report fixture: signature x:ArrayImpl/2/float · returned ArrayImpl · level recorded 2026-09-24
rename_key_and_reshape_tensor in 22 papers transformers/modeling_flax_pytorch_utils.py ran no licence file found · pointer only · 1236c8c8ab59ff20 · report fixture: signature pt_tuple_key:tuple/1/str, pt_tensor:ndarray/2/float, random_flax_state_dict:dict/0/?, model_prefix:str/0/str · returned tuple · level recorded 2026-09-24
dtype_byte_size in 15 papers transformers/modeling_flax_utils.py unverified no licence file found · pointer only · 9d98806acb3144b7 · report
flax_shard_checkpoint in 15 papers transformers/modeling_flax_utils.py unverified no licence file found · pointer only · e3ce70ca9258800e · report
is_hf_dataset in 20 papers transformers/modelcard.py unverified no licence file found · pointer only · 569927b3efc92b80 · report
blcuicall/CCL2022-CLTC found in paper text by Syntology 14 samples, 12 ran (2 instrument-failed) · 2 unverified
construct_parallel_data_lbl baselines/track1/data_preprocess.py ran no licence file found · pointer only · 5967acfb31566dce · report fixture: signature src_path:str/0/str, trg_path:str/0/str · returned list · level recorded 2026-09-24
construct_parallel_data_para baselines/track1/data_preprocess.py ran no licence file found · pointer only · 37070b4bd77f89f1 · report fixture: signature src_path:str/0/str, trg_path:str/0/str · returned list · level recorded 2026-09-24
convert_to_unicode in 40 papers baselines/track2/tokenization.py ran · our draft was wrong fingerprinted no licence file found · pointer only · 1923fc05163d207d · report fixture: signature text:str/0/str · returned str · level recorded 2026-09-22
encode_parallel_data baselines/track1/data_preprocess.py ran no licence file found · pointer only · f02b7d24b3c3ecb3 · report fixture: signature config:Config/0/?, parallel_data:list/1/tuple, normalizer:Normalizer/0/?, tokenizer:Tokenizer/0/?, max_len:int/0/int · returned list · level recorded 2026-09-24
get_correction_map baselines/track1/eval_char_level.py ran no licence file found · pointer only · bec43ad3f12fba68 · report fixture: signature path:str/0/str · returned OrderedDict · level recorded 2026-09-24
get_eval_metrics baselines/track1/eval_char_level.py ran no licence file found · pointer only · befde8a6e72b2fa6 · report fixture: signature conf_set:dict/0/?, total:int/0/int · returned OrderedDict · level recorded 2026-09-24
get_weights_name baselines/track2/gector/gec_model.py ran fingerprinted no licence file found · pointer only · 1e8d0a0db7a3947f · report fixture: signature transformer_name:str/0/str, lowercase:bool/0/bool · returned str · level recorded 2026-09-24
load_vocab in 107 papers baselines/track2/tokenization.py ran no licence file found · pointer only · deb4d1793cf3ba73 · report fixture: signature vocab_file:str/0/str · returned OrderedDict · level recorded 2026-09-24
metric_file baselines/track1/eval_sent_level.py ran no licence file found · pointer only · 7b3c30e644fc5e5e · report fixture: signature pred_path:str/0/str, targ_path:str/0/str · returned OrderedDict · level recorded 2026-09-24
printable_text in 36 papers baselines/track2/tokenization.py ran · our draft was wrong no licence file found · pointer only · 0e5615f8994003cf · report fixture: signature text:str/0/str · returned str · level recorded 2026-09-26
read_file in 112 papers baselines/track1/eval_sent_level.py ran no licence file found · pointer only · 40a3d4e153df98ef · report fixture: signature path:str/0/str · returned list · level recorded 2026-09-24
sent_metric_detect baselines/track1/eval_sent_level.py ran no licence file found · pointer only · 2384075fc45a1f65 · report fixture: signature preds:list/1/list, targs:list/1/list · returned OrderedDict · level recorded 2026-09-24
get_best_score baselines/track1/utils.py unverified no licence file found · pointer only · 23c9c8f028972e4e · report
get_char_metrics baselines/track1/eval_char_level.py unverified no licence file found · pointer only · 9b9e456240811606 · report

Tasks

Data-to-Text GenerationGrammatical Error CorrectionNatural Language UnderstandingText Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Attention DropoutDropoutLinear LayerSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections