{"id":13753255,"url":"https://github.com/hiyouga/dual-contrastive-learning","last_synced_at":"2025-10-17T01:12:16.635Z","repository":{"id":43088142,"uuid":"448803521","full_name":"hiyouga/Dual-Contrastive-Learning","owner":"hiyouga","description":"Code for our paper \"Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation\"","archived":false,"fork":false,"pushed_at":"2022-09-16T11:35:19.000Z","size":6095,"stargazers_count":157,"open_issues_count":10,"forks_count":31,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-01T21:48:09.383Z","etag":null,"topics":["bert","contrastive-learning","deep-learning","natural-language-processing","neural-networks","text-classification","transformers"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2201.08702","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiyouga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-17T08:03:38.000Z","updated_at":"2025-03-25T12:58:53.000Z","dependencies_parsed_at":"2023-01-18T10:17:00.198Z","dependency_job_id":null,"html_url":"https://github.com/hiyouga/Dual-Contrastive-Learning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hiyouga/Dual-Contrastive-Learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FDual-Contrastive-Learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FDual-Contrastive-Learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FDual-Contrastive-Learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FDual-Contrastive-Learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiyouga","download_url":"https://codeload.github.com/hiyouga/Dual-Contrastive-Learning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FDual-Contrastive-Learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273549306,"owners_count":25125275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bert","contrastive-learning","deep-learning","natural-language-processing","neural-networks","text-classification","transformers"],"created_at":"2024-08-03T09:01:19.179Z","updated_at":"2025-10-17T01:12:11.577Z","avatar_url":"https://github.com/hiyouga.png","language":"Python","funding_links":[],"categories":["文本分类"],"sub_categories":[],"readme":"# Dual-Contrastive-Learning\n \n![GitHub](https://img.shields.io/github/license/hiyouga/dual-contrastive-learning)\n\n![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/dual-contrastive-learning-text-classification/sentiment-analysis-on-cr)\n\n![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/dual-contrastive-learning-text-classification/subjectivity-analysis-on-subj)\n\n![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/dual-contrastive-learning-text-classification/text-classification-on-trec-6)\n\nA PyTorch implementation for our paper \"Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation\".\n\nYou can download the paper via: [[ArXiv]](https://arxiv.org/abs/2201.08702) [[PapersWithCode]](https://paperswithcode.com/paper/dual-contrastive-learning-text-classification).\n\n## One-Sentence Summary\n\nThis paper proposes a novel contrastive learning framework for supervised classification tasks by simultaneously learning the features of input samples and the parameters of classifiers in the same space. \n\n![method](assets/method.png)\n\n## Abstract\n\nContrastive learning has achieved remarkable success in representation learning via self-supervision in unsupervised settings. However, effectively adapting contrastive learning to supervised learning tasks remains as a challenge in practice. In this work, we introduce a dual contrastive learning (DualCL) framework that simultaneously learns the features of input samples and the parameters of classifiers in the same space. Specifically, DualCL regards the parameters of the classifiers as augmented samples associating to different labels and then exploits the contrastive learning between the input samples and the augmented samples. Empirical studies on five benchmark text classification datasets and their low-resource version demonstrate the improvement in classification accuracy and confirm the capability of learning discriminative representations of DualCL.\n\n## Requirement\n\n- Python = 3.7\n- torch = 1.11.0\n- numpy = 1.17.2\n- transformers = 4.19.2\n\n## Preparation\n\n### Clone\n\n```bash\ngit clone https://github.com/hiyouga/Dual-Contrastive-Learning.git\n```\n\n### Create an anaconda environment:\n\n```bash\nconda create -n dualcl python=3.7\nconda activate dualcl\npip install -r requirements.txt\n```\n\n## Usage\n\n```sh\npython main.py --method dualcl\n```\n\n## Citation\n\nIf this work is helpful, please cite as:\n\n```bibtex\n@article{chen2022dual,\n  title={Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation},\n  author={Qianben Chen and Richong Zhang and Yaowei Zheng and Yongyi Mao},\n  journal={arXiv preprint},\n  year={2022}\n}\n```\n\n## Contact\n\nhiyouga [AT] buaa [DOT] edu [DOT] cn\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiyouga%2Fdual-contrastive-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiyouga%2Fdual-contrastive-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiyouga%2Fdual-contrastive-learning/lists"}