{"id":13763973,"url":"https://github.com/UKPLab/emnlp2017-relation-extraction","last_synced_at":"2025-05-10T17:31:22.307Z","repository":{"id":25230082,"uuid":"101305146","full_name":"UKPLab/emnlp2017-relation-extraction","owner":"UKPLab","description":"Context-Aware Representations for Knowledge Base Relation Extraction","archived":false,"fork":false,"pushed_at":"2022-11-21T22:17:56.000Z","size":570,"stargazers_count":289,"open_issues_count":8,"forks_count":71,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-11-16T23:32:27.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/UKPLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-24T14:39:29.000Z","updated_at":"2024-07-26T23:21:23.000Z","dependencies_parsed_at":"2023-01-14T02:22:06.426Z","dependency_job_id":null,"html_url":"https://github.com/UKPLab/emnlp2017-relation-extraction","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UKPLab%2Femnlp2017-relation-extraction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UKPLab%2Femnlp2017-relation-extraction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UKPLab%2Femnlp2017-relation-extraction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UKPLab%2Femnlp2017-relation-extraction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UKPLab","download_url":"https://codeload.github.com/UKPLab/emnlp2017-relation-extraction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253453272,"owners_count":21911067,"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":[],"created_at":"2024-08-03T15:01:02.892Z","updated_at":"2025-05-10T17:31:18.575Z","avatar_url":"https://github.com/UKPLab.png","language":"Python","funding_links":[],"categories":["Text content NER/Topic/Subject/Context"],"sub_categories":[],"readme":"# Context-Aware Representations for Knowledge Base Relation Extraction\n\n## Relation extraction on an open-domain knowledge base\n\n\nAccompanying repository for our **EMNLP 2017 paper** ([full paper](http://aclweb.org/anthology/D17-1188)). It contains the code to replicate the experiments and the pre-trained models for sentence-level relation extraction. \nSee [below](#ukp-labs-work-on-knowledge-bases) for links to other work on knowledge bases, question answering and graph neural networks.\n\n\u003e This repository contains experimental software and is published for the sole purpose of giving additional background details on the respective publication.\n \nPlease use the following citation:\n\n```\n@inproceedings{TUD-CS-2017-0119,\n\ttitle = {{Context-Aware Representations for Knowledge Base Relation Extraction}},\n\tauthor = {Sorokin, Daniil and Gurevych, Iryna},\n\tbooktitle = {Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing (EMNLP)},\n\tpages = {1784-1789},\n\tyear = {2017},\n\tlocation = {Copenhagen, Denmark},\n\tpublisher = {Association for Computational Linguistics},\n\tdoi = {10.18653/v1/D17-1188}\n}\n```\n\n### Paper abstract:\n\u003e We demonstrate that for sentence-level relation extraction it is beneficial to consider other relations in the sentential context while predicting the target relation. Our architecture uses an LSTM-based encoder to jointly learn representations for all relations in a single sentence. \nWe combine the context representations with an attention mechanism to make the final prediction. \n\u003e We use the Wikidata knowledge base to construct a dataset of multiple relations per sentence and to evaluate our approach. Compared to a baseline system, our method results in an average error reduction of 24\\% on a held-out set of relations.\n\nPlease, refer to the paper for more details.\n\nThe dataset described in the paper can be found here:\n * https://www.informatik.tu-darmstadt.de/ukp/research_6/data/lexical_resources/wikipedia_wikidata_relations/\n\n \n### Contacts:\nIf you have any questions regarding the code, please, don't hesitate to contact the authors or best report an issue here.\n  * Daniil Sorokin, [personal page](https://daniilsorokin.github.io)\n  * https://www.informatik.tu-darmstadt.de/ukp/\n  * https://www.tu-darmstadt.de\n\n### Demo:\n\nYou can try out the relation extraction model on single sentences in our demo: \n\nhttp://semanticparsing.ukp.informatik.tu-darmstadt.de:5000/relation-extraction/\n\n  \n### UKP Lab's work on knowledge bases:\nIf you came here looking for our other work on linking text to Wikidata you can also find useful the following links\n\n* Wikidata Entity Linking: https://github.com/UKPLab/starsem2018-entity-linking\n* Graph Neural Networks for Knowledge Base Question Answering: https://github.com/UKPLab/coling2018-graph-neural-networks-question-answering\n* Question Answering Demo UI: https://github.com/UKPLab/emnlp2018-question-answering-interface\n\n\n### Wikipedia-Wikidata sentence-level relation data set\n\n*  Download the data set from the paper [here](https://www.informatik.tu-darmstadt.de/ukp/research_6/data/lexical_resources/wikipedia_wikidata_relations/). See the data set ReadMe for more information on the format and see the [paper](http://aclweb.org/anthology/D17-1188) on data set construction.\n\n### Project structure:\n```\nrelation_extraction/\n├── eval.py\n├── model-train-and-test.py\n├── notebooks\n├── optimization_space.py\n├── core\n│   ├── parser.py\n│   ├── embeddings.py\n│   ├── entity_extraction.py\n│   └── keras_models.py\n├── relextserver\n│   └── server.py\n├── graph\n│   ├── graph_utils.py\n│   ├── io.py\n│   └── vis_utils.py\n├── stanford_tag_dataset.py\n└── evaluation\n    └── metrics.py\nresources/\n├── properties-with-labels.txt\n└── property_blacklist.txt\n```\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eFile\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003erelation_extraction/\u003c/td\u003e\u003ctd\u003eMain Python module\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003erelation_extraction/core\u003c/td\u003e\u003ctd\u003eModels for joint relation extraction\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003erelation_extraction/relextserver\u003c/td\u003e\u003ctd\u003eThe code for the web demo.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003erelation_extraction/graph\u003c/td\u003e\u003ctd\u003eIO and processing for relation graphs\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003erelation_extraction/evaluation\u003c/td\u003e\u003ctd\u003eEvaluation metrics\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eresources/\u003c/td\u003e\u003ctd\u003eNecessary resources\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003edata/curves/\u003c/td\u003e\u003ctd\u003eThe precision-recall curves for each model on the held out data\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n### Setup:\n\n1. We recommend that you setup a new pip environment first: http://docs.python-guide.org/en/latest/dev/virtualenvs/\n\n2. Check out the repository and run:\n```\npip3 install -r requirements.txt\n```\n\n3. Set the Keras (deep learning library) backend to TensorFlow  with the following command:\n```\nexport KERAS_BACKEND=tensorflow\n```\n   You can also permanently change Keras backend (read more: https://keras.io/backend/). \n   Note that in order to reproduce the experiments in the paper you have to use Theano as a backend instead.\n\n4. Download the [data](https://www.informatik.tu-darmstadt.de/ukp/research_6/data/lexical_resources/wikipedia_wikidata_relations/), if you want to replicate the experiments from the paper.\nExtract the archive inside `emnlp2017-relation-extraction/data/wikipedia-wikidata/`. The data was preprocessed using Stanford Core NLP 3.7.0 models. See `stanford_tag_dataset.py` for more information.\n\n5. Download the [GloVe embeddings, glove.6B.zip](https://nlp.stanford.edu/projects/glove/)\nand put them into the folder `emnlp2017-relation-extraction/resources/glove/`. You can change the path to word embeddings in the `model_params.json` file if needed.\n\n### Pre-trained models:\n* You can download the models that were used in the experiments [here](https://fileserver.ukp.informatik.tu-darmstadt.de/emnlp2017-relation-extraction/EMNLP2017_DS_IG_relation_extraction_trained_models.zip)\n* See `Using pre-trained models.ipynb` for a detailed example on how to use the pre-trained models in your code\n\n#### Reproducing the experiments from the paper\nTo reproduce the experiments please refer to the version of the code that was published with the paper:\n[tag emnlp17](https://github.com/UKPLab/emnlp2017-relation-extraction/tree/emnlp17)\n\nIn any other case, we recommend using the most recent version.\n\n1. Complete the setup above \n\n2. Run `python model_train.py` in `emnlp2017-relation-extraction/relation_extraction/` to see the list of parameters\n\n3. If you put the data into the default folders you can train the `ContextWeighted` model with the following command:\n```\npython model_train.py model_ContextWeighted train ../data/wikipedia-wikidata/enwiki-20160501/semantic-graphs-filtered-training.02_06.json ../data/wikipedia-wikidata/enwiki-20160501/semantic-graphs-filtered-validation.02_06.json\n```\n\n4. Run the following command to compute the precision-recall curves:\n```\npython precision_recall_curves.py model_ContextWeighted ../data/wikipedia-wikidata/enwiki-20160501/semantic-graphs-filtered-held-out.02_06.json\n```\n\n#### Notes\n\n- The web demo code is provided for information only. It is not meant to be run elsewhere.\n\n#### Requirements:\n* Python 3.6\n* Keras 2.1.5\n* TensorFlow 1.6.0\n* See requirements.txt for library requirements. \n\n### License:\n* Apache License Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUKPLab%2Femnlp2017-relation-extraction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUKPLab%2Femnlp2017-relation-extraction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUKPLab%2Femnlp2017-relation-extraction/lists"}