{"id":19381573,"url":"https://github.com/megagonlabs/zett","last_synced_at":"2025-04-23T20:31:57.097Z","repository":{"id":196104801,"uuid":"693828928","full_name":"megagonlabs/zett","owner":"megagonlabs","description":":see_no_evil: Code for Zero-shot Triplet Extraction by Template Infilling (Kim et al; IJCNLP-AACL 2023)","archived":false,"fork":false,"pushed_at":"2024-02-17T04:56:57.000Z","size":977,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-16T17:12:53.932Z","etag":null,"topics":["ijcnlp-aacl-2023","information-extraction","nlp","zero-shot-learning","zero-shot-triplet-extraction"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2212.10708","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/megagonlabs.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}},"created_at":"2023-09-19T19:50:09.000Z","updated_at":"2024-11-23T13:21:27.000Z","dependencies_parsed_at":"2023-12-22T09:02:11.273Z","dependency_job_id":"50e2d9de-4460-43cb-bb03-dbcff03191a7","html_url":"https://github.com/megagonlabs/zett","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"801c00daac584753d16ae3e2b013df44b67741c8"},"previous_names":["megagonlabs/zett"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megagonlabs%2Fzett","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megagonlabs%2Fzett/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megagonlabs%2Fzett/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megagonlabs%2Fzett/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megagonlabs","download_url":"https://codeload.github.com/megagonlabs/zett/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250509698,"owners_count":21442482,"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":["ijcnlp-aacl-2023","information-extraction","nlp","zero-shot-learning","zero-shot-triplet-extraction"],"created_at":"2024-11-10T09:17:36.000Z","updated_at":"2025-04-23T20:31:56.634Z","avatar_url":"https://github.com/megagonlabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zero-shot Triplet Extraction by Template Infilling\n\n[![Conference](https://img.shields.io/badge/ijcnlp--aacl-2023-red)]()\n[![arXiv](https://img.shields.io/badge/arxiv-2212.10708-success)](https://arxiv.org/abs/2212.10708)\n[![blog](https://img.shields.io/badge/blog-link-blue)](https://megagon.ai/zett-aacl-2023-paper-based/)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/zero-shot-triplet-extraction-by-template/zero-shot-relation-triplet-extraction-on)](https://paperswithcode.com/sota/zero-shot-relation-triplet-extraction-on?p=zero-shot-triplet-extraction-by-template)\n\n\nThis repository contains the code and data for the paper [Zero-shot Triplet Extraction by Template Infilling](https://arxiv.org/abs/2212.10708), accepted in IJCNLP-AACL 2023.\n\n![ZETT](./img/zett.png)\n\n## Citations\n\n```bibtex\n@inproceedings{kim23zett,\n    title = {{Z}ero-shot {T}riplet {E}xtraction by {T}emplate {I}nfilling},\n    author = {Bosung Kim and\n              Hayate Iso and\n              Nikita Bhutani and\n              Estevam Hruschka and\n              Ndapa Nakashole and\n              Tom Mitchell},\n    booktitle = \"IJCNLP-AACL\",\n    month = {November},\n    year = {2023}\n}\n```\n\n## Setup\nTo install requirements\n```\npip install -r requirements.txt\n```\n\n## Data\nDownload: https://drive.google.com/drive/folders/1heVF8flYGfrxEnBqNvjYcgTzpSBke6IV?usp=share_link\n\nPut data folder under the *outputs* directory. e.g., ZETT/outputs/data/fewrel/unseen_10_seed_0/train.jsonl\n\n\n## Train\nFor each dataset, we have 30 different setups for 5/10/15 unseen relations and 5 different data folds. To train with a specific setting:\n\ne.g. on FewRel dataset with the setting of 10 unseen relations and data fold #0:\n```\npython run_zett.py train --data_name ['fewrel'] --n_unseen_rel [10] --rd_fold [0] --model_name {model_name}\n```\n\ne.g. on wiki-ZSL dataset with the setting of 15 unseen relations and data fold #1, 2, 3:\n```\npython run_zett.py train --data_name ['wiki'] --n_unseen_rel [15] --rd_fold [1, 2, 3] --model_name {model_name}\n```\n\nTo train for all settings at once:  \n```\npython run_zett.py train --model_name {model_name}\n```\n\n\n## Evaluate triplet extraction\n\n### Test on the single-triplet test set\n\nTo test with a specific setting:\n\ne.g. on FewRel dataset with the setting of 10 unseen relations and data fold #0:\n```\npython run_zett.py test --data_name ['fewrel'] --n_unseen_rel [10] --rd_fold [0] --model_name {model_name}\n```\n\nTest all setting: \n```\npython run_zett.py test --model_name {model_name}\n```\n\n### Test on the multi-triplet test set\nSet **eval_mode** option to *multi*\n```\npython run_zett.py test --model_name {model_name} --eval_mode 'multi'\n```\n\n### Inference *without* relation constraint\nSet **use_label_constraint** option to *False*\n```\npython run_zett.py test --model_name {model_name} --use_label_constraint False\n```\n\n\n\n### Evaluate relation extraction (or relation classification)\n\nUse **task_type** option to set the target task.\n\n```\npython run_zett.py test --model_name {model_name} --task_type RC\n```\n\n### Choice of templates\n\nTrain/test with the paraphrased templates from the back-translation (English-German) machine translation model.\n```\npython run_zett.py train --model_name {model_name} --templ_file templates/templates_paraphrased_top1.tsv\n\npython run_zett.py test --model_name {model_name} --templ_file templates/templates_paraphrased_top1.tsv\n```\n\n---\n\n### Disclosure \nEmbedded in, or bundled with, this product are open source software (OSS) components, datasets and other third party components identified below. The license terms respectively governing the datasets and third-party components continue to govern those portions, and you agree to those license terms, which, when applicable, specifically limit any distribution. You may receive a copy of, distribute and/or modify any open source code for the OSS component under the terms of their respective licenses, which may be BSD 3 clause license and Apache 2.0 license. In the event of conflicts between Megagon Labs, Inc., license conditions and the Open Source Software license conditions, the Open Source Software conditions shall prevail with respect to the Open Source Software portions of the software. \n\nYou agree not to, and are not permitted to, distribute actual datasets used with the OSS components listed below. You agree and are limited to distribute only links to datasets from known sources by listing them in the datasets overview table below. You are permitted to distribute derived datasets of data sets from known sources by including links to original dataset source in the datasets overview table below. You agree that any right to modify datasets originating from parties other than Megagon Labs, Inc. are governed by the respective third party’s license conditions. \n\nAll OSS components and datasets are distributed WITHOUT ANY WARRANTY, without even implied warranty such as for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, and without any liability to or claim against any Megagon Labs, Inc. entity other than as explicitly documented in this README document. You agree to cease using any part of the provided materials if you do not agree with the terms or the lack of any warranty herein.\n\nWhile Megagon Labs, Inc., makes commercially reasonable efforts to ensure that citations in this document are complete and accurate, errors may occur. If you see any error or omission, please help us improve this document by sending information to contact_oss@megagon.ai.\n\n\n#### Datasets\nAll datasets used within the product are listed below (including their copyright holders and the license conditions).\n\nFor Datasets having different portions released under different licenses, please refer to the included source link specified for each of the respective datasets for identifications of dataset files released under the identified licenses.\n\n\n| ID  | Dataset | Modified | Copyright Holder       | Source Link                                                       | License            | \n|-----|---------|----------|------------------------|-------------------------------------------------------------------|--------------------|\n| 1   | WikiZSL | Yes      | University of Virginia | [source](https://github.com/UKPLab/emnlp2017-relation-extraction) | Apache-2.0 license |\n\n#### Open Source Software (OSS) Components \nAll open source software components used within the product are listed below (including their copyright holders and the license conditions).\nFor OSS components having different portions released under different licenses, please refer to the included Upstream link(s) specified for each of the respective OSS components for identifications of code files released under the identified licenses.\n\n| ID  | OSS Component Name   | Modified | Copyright Holder | Upstream Link                                                                                                       | License            | \n|-----|----------------------|----------|------------------|---------------------------------------------------------------------------------------------------------------------|--------------------|\n| 1   | run_summarization.py | Yes      | Hugging Face     | [link](https://github.com/huggingface/transformers/blob/v4.7.0/examples/pytorch/summarization/run_summarization.py) | Apache License 2.0 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegagonlabs%2Fzett","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegagonlabs%2Fzett","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegagonlabs%2Fzett/lists"}