{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/charbert-character-aware-pre-trained-language","title":"CharBERT: Character-aware Pre-trained Language Model","arxiv_id":"2011.01513","date":"2020-11-03","proceeding":"COLING 2020 8","authors":["Wentao Ma","Yiming Cui","Chenglei Si","Ting Liu","Shijin Wang","Guoping Hu"],"abstract":"Most pre-trained language models (PLMs) construct word representations at subword level with Byte-Pair Encoding (BPE) or its variations, by which OOV (out-of-vocab) words are almost avoidable. However, those methods split a word into subword units and make the representation incomplete and fragile. In this paper, we propose a character-aware pre-trained language model named CharBERT improving on the previous methods (such as BERT, RoBERTa) to tackle these problems. We first construct the contextual word embedding for each token from the sequential character representations, then fuse the representations of characters and the subword representations by a novel heterogeneous interaction module. We also propose a new pre-training task named NLM (Noisy LM) for unsupervised character representation learning. We evaluate our method on question answering, sequence labeling, and text classification tasks, both on the original datasets and adversarial misspelling test sets. The experimental results show that our method can significantly improve the performance and robustness of PLMs simultaneously. Pretrained models, evaluation sets, and code are available at https://github.com/wtma/CharBERT","url_abs":"https://arxiv.org/abs/2011.01513v1","url_pdf":"https://arxiv.org/pdf/2011.01513v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"charbert-character-aware-pre-trained-language","repo_url":"https://github.com/wtma/CharBERT","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"text-classification","task_name":"Text Classification"},{"task_slug":"model","task_name":"model"},{"task_slug":"text-classification-1","task_name":"text-classification"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2011.01513","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2011.01513"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wtma/CharBERT","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_honours":2,"ran_draft_wrong":2,"ran":1,"unverified":8},"by_repo_kind":{"official":{"samples":13,"ran":5,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"211753ba29188d4e","entry":"gelu","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_bert.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_bert.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"211753ba29188d4e"}},{"code_sha256_prefix":"77601724cad03f95","entry":"gelu_new","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_bert.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_bert.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"77601724cad03f95"}},{"code_sha256_prefix":"0c145728a35789fa","entry":"load_tf_weights_in_bert","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_bert.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_bert.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0c145728a35789fa"}},{"code_sha256_prefix":"d30d6c3098df2c42","entry":"prune_linear_layer","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d30d6c3098df2c42"}},{"code_sha256_prefix":"e827d94caab33f59","entry":"url_to_filename","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/file_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/file_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e827d94caab33f59"}},{"code_sha256_prefix":"ff19dbac9350f154","entry":"eval_hit_metrics","repo":"wtma/CharBERT","repo_kind":"official","path":"run_lm_finetuning.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/run_lm_finetuning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ff19dbac9350f154"}},{"code_sha256_prefix":"b2be6c932ce41084","entry":"hf_bucket_url","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/file_utils_roberta.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/file_utils_roberta.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b2be6c932ce41084"}},{"code_sha256_prefix":"9a10ade1f3205dc9","entry":"hf_bucket_url","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/file_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/file_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9a10ade1f3205dc9"}},{"code_sha256_prefix":"4381d1f588a7f42a","entry":"is_remote_url","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/file_utils_roberta.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/file_utils_roberta.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4381d1f588a7f42a"}},{"code_sha256_prefix":"2d4e91b11d029045","entry":"is_remote_url","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/file_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/file_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2d4e91b11d029045"}},{"code_sha256_prefix":"9db820e8f7a8258b","entry":"load_and_cache_examples","repo":"wtma/CharBERT","repo_kind":"official","path":"run_lm_finetuning.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/run_lm_finetuning.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9db820e8f7a8258b"}},{"code_sha256_prefix":"7183a17dd79327a8","entry":"prune_conv1d_layer","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7183a17dd79327a8"}},{"code_sha256_prefix":"e31093ffc8275cff","entry":"prune_layer","repo":"wtma/CharBERT","repo_kind":"official","path":"modeling/modeling_utils.py","file_url":"https://github.com/wtma/CharBERT/blob/HEAD/modeling/modeling_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e31093ffc8275cff"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}