{"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/optimizing-bi-encoder-for-named-entity","title":"Optimizing Bi-Encoder for Named Entity Recognition via Contrastive Learning","arxiv_id":"2208.14565","date":"2022-08-30","proceeding":null,"authors":["Sheng Zhang","Hao Cheng","Jianfeng Gao","Hoifung Poon"],"abstract":"We present a bi-encoder framework for named entity recognition (NER), which applies contrastive learning to map candidate text spans and entity types into the same vector representation space. Prior work predominantly approaches NER as sequence labeling or span classification. We instead frame NER as a representation learning problem that maximizes the similarity between the vector representations of an entity mention and its type. This makes it easy to handle nested and flat NER alike, and can better leverage noisy self-supervision signals. A major challenge to this bi-encoder formulation for NER lies in separating non-entity spans from entity mentions. Instead of explicitly labeling all non-entity spans as the same class $\\texttt{Outside}$ ($\\texttt{O}$) as in most prior methods, we introduce a novel dynamic thresholding loss. Experiments show that our method performs well in both supervised and distantly supervised settings, for nested and flat NER alike, establishing new state of the art across standard datasets in the general domain (e.g., ACE2004, ACE2005) and high-value verticals such as biomedicine (e.g., GENIA, NCBI, BC5CDR, JNLPBA). We release the code at github.com/microsoft/binder.","url_abs":"https://arxiv.org/abs/2208.14565v2","url_pdf":"https://arxiv.org/pdf/2208.14565v2.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":"optimizing-bi-encoder-for-named-entity","repo_url":"https://github.com/microsoft/binder","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"metric-learning","task_name":"Metric Learning"},{"task_slug":"cg","task_name":"NER"},{"task_slug":"named-entity-recognition-1","task_name":"Named Entity Recognition"},{"task_slug":"named-entity-recognition-ner","task_name":"Named Entity Recognition (NER)"},{"task_slug":"nested-named-entity-recognition","task_name":"Nested Named Entity Recognition"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"named-entity-recognition","task_name":"named-entity-recognition"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/named-entity-recognition-ner-on-bc5cdr","task":"Named Entity Recognition (NER)","dataset":"BC5CDR","model":"BINDER","rank_in_archive_order":1,"of":16,"metrics":{"F1":"91.9"},"uses_additional_data":false},{"leaderboard":"/sota/named-entity-recognition-ner-on-jnlpba","task":"Named Entity Recognition (NER)","dataset":"JNLPBA","model":"BINDER","rank_in_archive_order":4,"of":17,"metrics":{"F1":"80.3"},"uses_additional_data":false},{"leaderboard":"/sota/nested-named-entity-recognition-on-ace-2004","task":"Nested Named Entity Recognition","dataset":"ACE 2004","model":"BINDER","rank_in_archive_order":2,"of":24,"metrics":{"F1":"88.7"},"uses_additional_data":false},{"leaderboard":"/sota/nested-named-entity-recognition-on-ace-2005","task":"Nested Named Entity Recognition","dataset":"ACE 2005","model":"BINDER","rank_in_archive_order":1,"of":25,"metrics":{"F1":"89.5"},"uses_additional_data":false},{"leaderboard":"/sota/nested-named-entity-recognition-on-genia","task":"Nested Named Entity Recognition","dataset":"GENIA","model":"BINDER","rank_in_archive_order":8,"of":26,"metrics":{"F1":"80.5"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2208.14565","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2208.14565"}},"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":"deterministic:regex_extraction","url":"https://github.com/microsoft/binder","reach":null}],"summary":{"ran_draft_wrong":3,"ran_honours":1},"by_repo_kind":{"official":{"samples":4,"ran":4,"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":"f7b4bc846f7c354c","entry":"contrastive_loss","repo":"microsoft/binder","repo_kind":"official","path":"src/model.py","file_url":"https://github.com/microsoft/binder/blob/HEAD/src/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f7b4bc846f7c354c"}},{"code_sha256_prefix":"73ac50d5341bf380","entry":"contrastive_loss","repo":"microsoft/binder","repo_kind":"official","path":"src/model.py","file_url":"https://github.com/microsoft/binder/blob/HEAD/src/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"73ac50d5341bf380"}},{"code_sha256_prefix":"1609cd13cd5232f1","entry":"masked_log_softmax","repo":"microsoft/binder","repo_kind":"official","path":"src/model.py","file_url":"https://github.com/microsoft/binder/blob/HEAD/src/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1609cd13cd5232f1"}},{"code_sha256_prefix":"9552b6c058655062","entry":"tiny_value_of_dtype","repo":"microsoft/binder","repo_kind":"official","path":"src/model.py","file_url":"https://github.com/microsoft/binder/blob/HEAD/src/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9552b6c058655062"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}