{"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/incorporating-hierarchy-into-text-encoder-a","title":"Incorporating Hierarchy into Text Encoder: a Contrastive Learning Approach for Hierarchical Text Classification","arxiv_id":"2203.03825","date":"2022-03-08","proceeding":"ACL 2022 5","authors":["Zihan Wang","Peiyi Wang","Lianzhe Huang","Xin Sun","Houfeng Wang"],"abstract":"Hierarchical text classification is a challenging subtask of multi-label classification due to its complex label hierarchy. Existing methods encode text and label hierarchy separately and mix their representations for classification, where the hierarchy remains unchanged for all input text. Instead of modeling them separately, in this work, we propose Hierarchy-guided Contrastive Learning (HGCLR) to directly embed the hierarchy into a text encoder. During training, HGCLR constructs positive samples for input text under the guidance of the label hierarchy. By pulling together the input text and its positive sample, the text encoder can learn to generate the hierarchy-aware text representation independently. Therefore, after training, the HGCLR enhanced text encoder can dispense with the redundant hierarchy. Extensive experiments on three benchmark datasets verify the effectiveness of HGCLR.","url_abs":"https://arxiv.org/abs/2203.03825v2","url_pdf":"https://arxiv.org/pdf/2203.03825v2.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":"incorporating-hierarchy-into-text-encoder-a","repo_url":"https://github.com/wzh9969/contrastive-htc","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"classification-1","task_name":"Classification"},{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"multi-label-classification-2","task_name":"MUlTI-LABEL-ClASSIFICATION"},{"task_slug":"multi-label-classification","task_name":"Multi-Label Classification"},{"task_slug":"text-classification","task_name":"Text Classification"},{"task_slug":"text-classification-1","task_name":"text-classification"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2203.03825","atlas_url":"https://app.syntology.ai/?focus=2203.03825","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2203.03825"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/wzh9969/contrastive-htc","reach":null}],"summary":{"ran":5,"unverified":6},"by_repo_kind":{"official":{"samples":11,"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":"9c1eae0a3959807d","entry":"BartAttention","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9c1eae0a3959807d"}},{"code_sha256_prefix":"dcc09c5532200722","entry":"BertEmbeddings","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dcc09c5532200722"}},{"code_sha256_prefix":"ddb657076af7cea8","entry":"BertOutputLayer","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ddb657076af7cea8"}},{"code_sha256_prefix":"ad00a3061aa7bdc2","entry":"BertPoolingLayer","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ad00a3061aa7bdc2"}},{"code_sha256_prefix":"8e41bc17f38b83ea","entry":"NTXent","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8e41bc17f38b83ea"}},{"code_sha256_prefix":"b13db2a9f4af0aa0","entry":"BaseModelOutputWithPoolingAndCrossAttentions","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b13db2a9f4af0aa0"}},{"code_sha256_prefix":"1b18fd412b5eaf7b","entry":"BertModel","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1b18fd412b5eaf7b"}},{"code_sha256_prefix":"b93b85c4d9138224","entry":"ContrastModel","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b93b85c4d9138224"}},{"code_sha256_prefix":"aa93cb13fe01f92c","entry":"GraphEncoder","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aa93cb13fe01f92c"}},{"code_sha256_prefix":"da6ef7283c459235","entry":"GraphLayer","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"da6ef7283c459235"}},{"code_sha256_prefix":"985ecde4944a60ab","entry":"SelfAttention","repo":"wzh9969/contrastive-htc","repo_kind":"official","path":"model/contrast.py","file_url":"https://github.com/wzh9969/contrastive-htc/blob/HEAD/model/contrast.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"985ecde4944a60ab"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}