{"id":18330179,"url":"https://github.com/qznan/spankl","last_synced_at":"2025-04-06T01:33:00.823Z","repository":{"id":155926194,"uuid":"571600318","full_name":"Qznan/SpanKL","owner":"Qznan","description":"Code for paper: A Neural Span-Based Continual Named Entity Recognition Model","archived":false,"fork":false,"pushed_at":"2023-12-11T07:24:16.000Z","size":76182,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T15:12:37.156Z","etag":null,"topics":["continual-learning","named-entity-recognition","natural-language-processing"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2302.12200","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Qznan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-28T13:36:32.000Z","updated_at":"2025-03-09T10:36:43.000Z","dependencies_parsed_at":"2023-12-11T08:40:45.752Z","dependency_job_id":null,"html_url":"https://github.com/Qznan/SpanKL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qznan%2FSpanKL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qznan%2FSpanKL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qznan%2FSpanKL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qznan%2FSpanKL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qznan","download_url":"https://codeload.github.com/Qznan/SpanKL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423463,"owners_count":20936621,"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","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":["continual-learning","named-entity-recognition","natural-language-processing"],"created_at":"2024-11-05T19:20:53.444Z","updated_at":"2025-04-06T01:32:55.814Z","avatar_url":"https://github.com/Qznan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eSpanKL\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Qznan/SpanKL\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/Qznan/SpanKL.svg?colorA=orange\u0026colorB=orange\u0026logo=github\" alt=\"GitHub stars\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Qznan/SpanKL/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/issues/Qznan/SpanKL.svg\"\n             alt=\"GitHub issues\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Qznan/SpanKL/\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/last-commit/Qznan/SpanKL.svg\"\u003e\n  \u003c/a\u003e\n   \u003ca href=\"https://github.com/Qznan/SpanKL/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/Qznan/SpanKL.svg\"\u003e\n  \u003c/a\u003e\n  \n\u003c/p\u003e\n\n# A Neural Span-Based Continual Named Entity Recognition Model\n\nSource code for AAAI 2023 paper: A Neural Span-Based Continual Named Entity Recognition Model [[arxiv](https://arxiv.org/pdf/2302.12200.pdf)]  \n[[Appendix for AAAI paper](Paper_Appendix.pdf)]\n\n## 1. Prerequisites\n\n```\n# Environment\n- python \u003e= 3.6\n\n# Dependencies\n- torch \u003e= 1.8\n- transformers == 4.3.0\n- rich\n- prettytable\n- paramiko  # [Option] if need to remotely open file.\n```\n\n\n## 2. Dataset\n- [OntoNotes 5.0](https://catalog.ldc.upenn.edu/LDC2013T19)\n- [Few-NERD](https://ningding97.github.io/fewnerd)\n\n\nWe provide the pre-processed datasets in `data/` DIR, which keep the same sample-task allocation for split setup experimented in the paper for reproduction.\n\n[Update 20230525🔥] We provide the zip file of `data/` as `data.zip` for convenient, since the original `data/` used LFS and need Github quota 😑. Please unzip it before running the code.😊\n## 3. Training\n\n```shell\npython train_clner.py \\\n      --gpu 0 \\\n      --m spankl \\\n      --corpus onto \\\n      --setup split \\\n      --perm perm0\n      \n# gpu: which gpu to use. (-2: auto allocate gpu -1: use cpu)\n# m: types of model (spankl|add|ext)\n# corpus: (onto|fewnerd)\n# setup: (split|filter)\n# perm: task learning order, default perm0 (perm0|perm1|...)\n```\n**Note** that this yields results regarding **one of** the Task Permutation (e.g., --perm0), while Tab.1 and Tab.2 in the paper are the results averaged over all the Task Permutations.  \n\n**Update 0305! #1** For convenience, we log the final metric used in the paper at each incremental step (Task) during training, as belows:\n```angular2html\n...\nINFO     Test All Final MacroF1 over Task-Level:{metric}\n...\nINFO     Test Filter Final MacroF1 over Task-Level:{metric}\n...\n```\nand also provide an overivew of the performance learned so far:\n```angular2html\n# Logging example when the running finishs (All tasks have been learned on OntoNotes).\n======onto======\n\nonto-0-2022-07-21_10-02-57-1824-spankl_split_perm0\n\n***Test All***\n[[87.9   0.    0.    0.    0.    0.   87.9  87.9 ]\n [87.18 93.33  0.    0.    0.    0.   90.43 90.25]\n [88.13 93.41 95.47  0.    0.    0.   92.61 92.34]\n [87.4  93.26 95.16 85.02  0.    0.   90.71 90.21]\n [87.13 92.65 95.05 84.71 81.37  0.   89.38 88.18]\n [87.88 93.02 95.08 85.93 83.04 93.01 90.3  89.66]\n [-0.26 -0.39 -0.39  0.    0.    0.   -0.17  0.  ]]\n```\nThe table is organized as (Table Format):\n```angular2html\n                Task1_metric Task2_metric ... MicroF1 MacroF1\nLearn to Task1\nLearn to Task2\n...\nBI (backward interference / forgetting)\n```\nThe **last columns** are the metrics of each step used in the paper.\n\n##### More ways to print the above CL metrics:\nAfter and during training, an `overview_metric.json` file will be generated in `model_ckpt/[MODEL_INFO]/` recording the required details, and you can:\n- refer to `__main__` in `print_cl_metric.py` to use `print_cl_metric()` func to **remotely** print results.\n- or refer to the end of `train_clner.py` to use a wrapped `simply_print_cl_metric()` func to **locally** print results.\n\nFor any questions please notice the comments in the code or contact me.  \nWelcome to star or raise issues and PR! :)\n## 4. License\n\nThis project is licensed under the Apache License - see the [LICENSE](LICENSE) file for details.\n\n## 5. Citation\n\nIf you use this work or code, please kindly cite this paper:\n\n```\n@inproceedings{zhang2023spankl,\n  title={A Neural Span-Based Continual Named Entity Recognition Model},\n  author={Zhang, Yunan and Chen, Qingcai},\n  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},\n  year={2023}\n}\nor\n@article{Zhang_Chen_2023,\n title={A Neural Span-Based Continual Named Entity Recognition Model},\n volume={37},\n url={https://ojs.aaai.org/index.php/AAAI/article/view/26638},\n DOI={10.1609/aaai.v37i11.26638},\n number={11},\n journal={Proceedings of the AAAI Conference on Artificial Intelligence},\n author={Zhang, Yunan and Chen, Qingcai},\n year={2023},\n month={Jun.},\n pages={13993-14001}\n }\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqznan%2Fspankl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqznan%2Fspankl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqznan%2Fspankl/lists"}