{"id":18010953,"url":"https://github.com/liyucheng09/metaphorframe","last_synced_at":"2025-03-26T14:32:21.229Z","repository":{"id":129612128,"uuid":"422244192","full_name":"liyucheng09/MetaphorFrame","owner":"liyucheng09","description":"FrameBERT: Conceptual Metaphor Detection with Frame Embedding Learning. Presented at EACL 2023.","archived":false,"fork":false,"pushed_at":"2023-11-25T23:58:21.000Z","size":19065,"stargazers_count":27,"open_issues_count":6,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T23:34:02.702Z","etag":null,"topics":["deep-learning","machine-learning","metaphor-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liyucheng09.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-28T14:49:46.000Z","updated_at":"2025-03-07T19:15:48.000Z","dependencies_parsed_at":"2023-04-08T11:35:16.239Z","dependency_job_id":null,"html_url":"https://github.com/liyucheng09/MetaphorFrame","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/liyucheng09%2FMetaphorFrame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyucheng09%2FMetaphorFrame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyucheng09%2FMetaphorFrame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyucheng09%2FMetaphorFrame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyucheng09","download_url":"https://codeload.github.com/liyucheng09/MetaphorFrame/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245670938,"owners_count":20653455,"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":["deep-learning","machine-learning","metaphor-detection"],"created_at":"2024-10-30T02:15:57.699Z","updated_at":"2025-03-26T14:32:19.800Z","avatar_url":"https://github.com/liyucheng09.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FrameBERT: Conceptual Metaphor Detection with Frame Embedding Learning\n\nThis repository contains the implementation of our EACL 2023 paper \"FrameBERT: Conceptual Metaphor Detection with Frame Embedding Learning\" (https://arxiv.org/abs/2302.04834). FrameBERT is a BERT-based model that leverages FrameNet embeddings for improved metaphor detection and model explainability. Our extensive experiments demonstrate the effectiveness of FrameBERT on four public benchmark datasets (VUA, MOH-X, TroFi) compared to the base model and state-of-the-art models.\n\n**Important updates**: I have just added a `inference.py` to enable quick metaphor and frame detection on your customized data. I plan to add more features in the future. So please star our project to get posted.\n\n## 0. To Start:\n\n1. Clone the repository:\n\n```\ngit clone https://github.com/liyucheng09/MetaphorFrame.git\ncd MetaphorFrame\n```\n\n2. Install the required packages:\n\n```\npip install -r requirements.txt\n```\n\n## 1. Run FrameBERT on Your data:\n\n3. If you just want to **run FrameBERT directly on your own data**, just run:\n\n```\npython inference.py example_articles.json\n```\n\nPut your own data in `example_articles.json`. Check out `example_articles.json` and `inference.py`, you can easily edit them to run the program on large amount of articles.\n\nThis will produce the results to a `predictions.tsv`, which look like this:\n| Tokens         | Borderline_metaphor | Real_metaphors | Frame_label     |\n|----------------|---------------------|----------------|-----------------|\n| The            | 0                   | 0              | _               |\n| Frozen         | 1                   | 1              | _               |\n| Political      | 0                   | 0              | _               |\n| Battlefield    | 1                   | 1              | _               |\n| In             | 1                   | 0              | _               |\n| fact           | 0                   | 0              | _               |\n| ,              | 0                   | 0              | _               |\n| in             | 1                   | 0              | _               |\n| normal         | 0                   | 0              | Typicality      |\n| circumstances  | 0                   | 0              | _               |\n| ,              | 0                   | 0              | _               |\n| the            | 0                   | 0              | _               |\n| incumbent      | 0                   | 0              | _               |\n| would          | 0                   | 0              | _               |\n| look           | 1                   | 0              | Give_impression |\n\nThe column `Borderline_metaphor` indicates a wide range of metaphor which can be very conventional, but `Real_metaphor` represents more interesting and novel metaphors. The `Frame_label` represents the identified Frame labels.\n\n## Citation\n\nIf you find this repository helpful for your research, please cite our paper:\n\n```\n@misc{li2023framebert,\n      title={FrameBERT: Conceptual Metaphor Detection with Frame Embedding Learning}, \n      author={Yucheng Li and Shun Wang and Chenghua Lin and Frank Guerin and Loïc Barrault},\n      year={2023},\n      eprint={2302.04834},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\nFor any questions or issues, please feel free to open an issue on GitHub or contact the authors directly.\n\n## Reproduce the paper (optional)\n\nYou don't have to reproduce the results in the paper, if you just want to use a metaphor detection tool.\n\nBut if you want to **reproduce FrameBERT from scratch**:\n\n3. Unzip the data:\n\n```\nunzip data_all.zip\n```\n\nAfter unzipping, the frame data can be found at `data_all/open_sesame_v1_data`, and other data such as VUA, MOH, and TroFi datasets can be found in their respective directories.\n\n4. Prepare the `frame_finder` model first before we run the entire framewrok. Traning the frame model will take around 2 hours.\n\n```\n./scripts/ff.sh\n```\n\n5. config data path and `frame_finder` path in `main_config.cfg`\n\n6. Run the main script, training on `VUA18` will take about 5 hours:\n\n```\n./scripts/run.sh\n```\n\nTo see the meaning of all variables, check the explaination in the config file `main_config.cfg`.\n\n## Repository Structure\n\nThe repository is organized as follows:\n\n- `scripts/`: Contains all bash scripts with relevant code execution and arguments for each script.\n    - `scripts/run.sh`: The main script for running FrameBERT.\n- `main_config.cfg`: Configuration file for `main.py`.\n- `data_all.zip`: Compressed file containing all the data needed for the project.\n- `frame_finder/`: Directory containing the frame embedding model.\n- `requirements.txt`: Lists the required packages for the project.\n\n## Configuration\n\nYou can modify the configuration of the FrameBERT model by editing the `main_config.cfg` file. This file contains various settings and hyperparameters for the model.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyucheng09%2Fmetaphorframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyucheng09%2Fmetaphorframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyucheng09%2Fmetaphorframe/lists"}