├── .gitignore ├── LICENSE ├── README.md ├── conf ├── countries.conf ├── countries_S1_complex.conf ├── countries_S1_ntp.conf ├── countries_S1_ntp_complex_reg.conf ├── countries_S2_complex.conf ├── countries_S2_ntp.conf ├── countries_S2_ntp_complex_reg.conf ├── countries_S3_complex.conf ├── countries_S3_ntp.conf ├── countries_S3_ntp_complex_reg.conf ├── countries_ntp.conf ├── default.conf ├── kinship.conf ├── kinship_complex.conf ├── kinship_ntp.conf ├── kinship_ntp_complex_reg.conf ├── nations.conf ├── nations_complex.conf ├── nations_ntp.conf ├── nations_ntp_complex_reg.conf ├── synth │ ├── synth_three.conf │ └── synth_two.conf ├── umls.conf ├── umls_complex.conf ├── umls_ntp.conf ├── umls_ntp_complex.conf └── umls_ntp_complex_reg.conf ├── data ├── .DS_Store ├── countries │ ├── countries.csv │ ├── countries.nl │ ├── countries.nlt │ ├── countries_S1.nl │ ├── countries_S1.nlt │ ├── countries_S2.nl │ ├── countries_S2.nlt │ ├── countries_S3.nl │ ├── countries_S3.nlt │ ├── dev.txt │ ├── download.sh │ ├── regions.txt │ ├── subregions.txt │ └── test.txt ├── kinship │ ├── dev.nl │ ├── download.sh │ ├── entities.txt │ ├── kinship.nl │ ├── kinship.nlt │ ├── test.nl │ └── train.nl ├── nations │ ├── dev.nl │ ├── download.sh │ ├── entities.txt │ ├── nat.db │ ├── nations.nl │ ├── nations.nlt │ ├── test.nl │ └── train.nl ├── ntp │ ├── simpsons.nl │ └── simpsons.nlt ├── synth │ ├── go.sh │ ├── one.nl │ ├── three.nl │ ├── three.nlt │ ├── two.nl │ └── two.nlt └── umls │ ├── dev.nl │ ├── download.sh │ ├── entities.txt │ ├── test.nl │ ├── train.nl │ ├── uml.db │ ├── umls.nl │ └── umls.nlt ├── docs ├── README.md └── ntp_graph.png ├── models ├── kinship_complex │ ├── checkpoint │ ├── events.out.tfevents.1494941798.brooks.local │ ├── kinship_complex_alt.conf │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ └── tmp.conf ├── kinship_ntp │ ├── checkpoint │ ├── events.out.tfevents.1494927548.brooks.local │ ├── kinship_ntp.conf │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ └── tmp.conf-e ├── kinship_ntpl │ ├── checkpoint │ ├── events.out.tfevents.1494498458.korman.local │ ├── kinship_ntp_complex_reg.conf │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ └── tmp.conf-e ├── nations_complex │ ├── checkpoint │ ├── events.out.tfevents.1495140729.tesla5.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── nations_complex.conf │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ └── tmp.conf-e ├── nations_ntp │ ├── checkpoint │ ├── events.out.tfevents.1495140821.tesla4.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── nations_ntp.conf │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ └── tmp.conf-e ├── nations_ntpl │ ├── checkpoint │ ├── events.out.tfevents.1495140751.tesla5.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── nations_ntp_complex_reg.conf │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ └── tmp.conf-e ├── umls_complex │ ├── checkpoint │ ├── events.out.tfevents.1494941070.brooks.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ ├── tmp.conf-e │ └── umls_complex_alt.conf ├── umls_ntp │ ├── checkpoint │ ├── events.out.tfevents.1494927512.tesla1.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ ├── tmp.conf-e │ └── umls_ntp.conf └── umls_ntpl │ ├── checkpoint │ ├── events.out.tfevents.1494923910.tesla2.local │ ├── metadata.tsv │ ├── model.ckpt-0.data-00000-of-00001 │ ├── model.ckpt-0.index │ ├── model.ckpt-0.meta │ ├── projector_config.pbtxt │ ├── rules.nl │ ├── tmp.conf │ ├── tmp.conf-e │ └── umls_ntp_complex_reg_alt3.conf ├── ntp ├── __init__.py ├── data │ ├── countries.py │ ├── countries2nkb.py │ ├── db2nkb.py │ ├── sample.py │ └── umls2nkb.py ├── experiments │ ├── __init__.py │ ├── eval.py │ ├── learn.py │ ├── recover.py │ └── util.py ├── jtr │ ├── __init__.py │ ├── nn │ │ ├── __init__.py │ │ └── models.py │ ├── preprocess │ │ ├── __init__.py │ │ ├── batch.py │ │ ├── map.py │ │ └── vocab.py │ ├── train.py │ └── util │ │ ├── __init__.py │ │ ├── hooks.py │ │ ├── rs.py │ │ ├── tfutil.py │ │ └── util.py ├── kb.py ├── kmax.py ├── nkb.py ├── nunify.py ├── prover.py ├── tp.py └── util.py ├── requirements.txt └── tests ├── conftest.py └── ntp ├── test_kb.py └── test_learn.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | # intellij 60 | .idea 61 | .idea/* 62 | .idea_modules 63 | !.idea/codeStyleSettings.xml 64 | *.iml 65 | 66 | out/ 67 | data/wikihop/wikihop.tar.gz 68 | data/wikihop/wikihop/*.json 69 | 70 | *.swp 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # End-to-End Differentiable Proving 2 | This is an implementation of the paper [End-to-End Differentiable Proving](http://papers.nips.cc/paper/6969-end-to-end-differentiable-proving.pdf). For a high-level introduction, see the [NIPS oral](https://www.youtube.com/watch?v=WWWQXTb_69c&t=1700s), [slides](https://rockt.github.io/pdf/rocktaschel2017end-slides.pdf) and [poster](https://rockt.github.io/pdf/rocktaschel2017end-poster.pdf). 3 | 4 | 5 | ## Disclaimer 6 | Please note that this software is not maintained. It is highly-experimental research code, not well documented and we provide no warranty of any kind. Use at your own risk! 7 | 8 | ## Data Format 9 | 10 | Data for the NTP is in `nl` format - basically Prolog syntax: 11 | 12 | ```shell 13 | ntp$ head data/countries/countries.nl 14 | locatedIn(palau,micronesia). 15 | locatedIn(palau,oceania). 16 | locatedIn(maldives,southern_asia). 17 | locatedIn(maldives,asia). 18 | locatedIn(brunei,south-eastern_asia). 19 | locatedIn(brunei,asia). 20 | neighborOf(brunei,malaysia). 21 | locatedIn(japan,eastern_asia). 22 | locatedIn(japan,asia). 23 | locatedIn(netherlands,western_europe). 24 | ``` 25 | 26 | - `*.nl` files represent *facts and rules* (example of a rule: `isa(X,Y) :- isa(X,Z), isa(Z,Y)`) 27 | 28 | - `*.nlt` files represent *rule templates* (example of a rule template: `#1(X,Y) :- #2(X,Z), #3(Z,Y)`) 29 | 30 | ```shell 31 | ntp$ cat data/ntp/simpsons.nlt 32 | 5 #1(X, Y) :- #2(X, Y). 33 | 34 | 5 #1(X, Y) :- #1(Y, X). 35 | 36 | 5 #1(X, Y) :- 37 | #2(X, Z), 38 | #2(Z, Y). 39 | ``` 40 | 41 | ## Running 42 | 43 | The main file for running NTP is `ntp/experiments/learn.py` which takes the path to a configuration file as argument. 44 | 45 | ## Code Structure 46 | 47 | The core implementation of the NTP can be found [here](https://github.com/uclmr/ntp/blob/master/ntp/prover.py). 48 | 49 | The base models (neural link predictors) are implemented [here](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L253). 50 | 51 | Imortant "modules" are [unify](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L195), 52 | [this one](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L195) 53 | and [this one](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L470). 54 | It should pretty much reflect the pseudocode in the paper. 55 | 56 | The tricky part is the tiling of batched representations for batch proving - 57 | check out [this](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L160). 58 | 59 | However, this *tiling* needs to happen at various points in the code, 60 | e.g. [here](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L492) 61 | 62 | Implementation of tiling (and multiplexing) 63 | [here](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L319) and 64 | [here](https://github.com/uclmr/ntp/blob/master/ntp/prover.py#L346). 65 | 66 | An important trick in NTP for proving in larger KBs and usin complex rules, is the Kmax heuristic, 67 | implemented [here](https://github.com/uclmr/ntp/blob/master/ntp/kmax.py). 68 | 69 | There is a *symbolic prover implementation* [here](https://github.com/uclmr/ntp/blob/master/ntp/tp.py) 70 | - it is probably worthwile to look at it first, and compare to NTP. 71 | 72 | ## Test 73 | 74 | ```shell 75 | nosetests 76 | ``` 77 | 78 | ## Contributors 79 | - [Tim Rocktäschel](https://rockt.github.com) 80 | - [Sebastian Riedel](http://www.riedelcastro.org/) 81 | - [Pasquale Minervini](http://www.neuralnoise.com/) 82 | - [Matko Bosnjak](http://matko.info/) 83 | - [Johannes Welbl](https://jowel.gitlab.io/welbl/) 84 | 85 | ## Citation 86 | ``` 87 | @inproceedings{rocktaschel2017end, 88 | author = {Tim Rockt{\"{a}}schel and 89 | Sebastian Riedel}, 90 | title = {End-to-end Differentiable Proving}, 91 | booktitle = {Advances in Neural Information Processing Systems 30: Annual Conference 92 | on Neural Information Processing Systems 2017, 4-9 December 2017, 93 | Long Beach, CA, {USA}}, 94 | pages = {3791--3803}, 95 | year = {2017}, 96 | url = {http://papers.nips.cc/paper/6969-end-to-end-differentiable-proving}, 97 | } 98 | ``` 99 | -------------------------------------------------------------------------------- /conf/countries.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries.nl", 4 | "templates": "./data/countries/countries.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "countries", 10 | "test_set": "test", 11 | "result_file": "./out/countries/results.tsv", 12 | "debug": False 13 | }, 14 | "training": { 15 | "num_epochs": 100, 16 | "report_interval": 10, 17 | "pos_per_batch": 50, 18 | "neg_per_pos": 1, 19 | "optimizer": "Adam", 20 | "learning_rate": 0.001, 21 | "sampling_scheme": "all", 22 | "init": None, # xavier initialization 23 | "clip": (-1.0, 1.0) 24 | }, 25 | "model": { 26 | "input_size": 100, 27 | "k_max": 10, 28 | "name": "???", 29 | "neural_link_predictor": "ComplEx", 30 | "l2": 0.01, # 0.01 # 0.0001 31 | "keep_prob": 0.7 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /conf/countries_S1_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S1.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries.conf", 8 | }, 9 | "model": { 10 | "name": "ComplEx", 11 | "neural_link_predictor": "ComplEx" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S1_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S1.nl", 4 | "templates": "./data/countries/countries_S1.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | }, 9 | "model": { 10 | "name": "NTP", 11 | "neural_link_predictor": None, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S1_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S1.nl", 4 | "templates": "./data/countries/countries_S1.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | "test_time_neural_link_prediction": False 9 | }, 10 | "model": { 11 | "name": "NTP ComplEx Reg", 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S2_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S2.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries.conf", 8 | }, 9 | "model": { 10 | "name": "ComplEx", 11 | "neural_link_predictor": "ComplEx" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S2_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S2.nl", 4 | "templates": "./data/countries/countries_S2.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | }, 9 | "model": { 10 | "name": "NTP", 11 | "neural_link_predictor": None, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S2_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S2.nl", 4 | "templates": "./data/countries/countries_S2.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | "test_time_neural_link_prediction": False 9 | }, 10 | "model": { 11 | "name": "NTP ComplEx Reg", 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S3_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S3.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries.conf", 8 | }, 9 | "model": { 10 | "name": "ComplEx", 11 | "neural_link_predictor": "ComplEx" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S3_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S3.nl", 4 | "templates": "./data/countries/countries_S3.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | }, 9 | "model": { 10 | "name": "NTP", 11 | "neural_link_predictor": None, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_S3_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries_S3.nl", 4 | "templates": "./data/countries/countries_S3.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries_ntp.conf", 8 | "test_time_neural_link_prediction": False 9 | }, 10 | "model": { 11 | "name": "NTP ComplEx Reg", 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /conf/countries_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/countries/countries.nl", 4 | "templates": "./data/countries/countries.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/countries.conf", 8 | }, 9 | "model": { 10 | "name": "NTP ComplEx Reg", 11 | "neural_link_predictor": "ComplEx", 12 | "train_0ntp": True, 13 | "l2": 0.001, # 0.01 # 0.0001 14 | "keep_prob": 1.0 15 | }, 16 | "training": { 17 | "init": (-1.0, 1.0) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /conf/default.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/ntp/debug.nl", 4 | "templates": "./data/ntp/default.nlt" 5 | }, 6 | "model": { 7 | "input_size": 100, 8 | "aggregate_fun": "Max", # "LogSumExp" 9 | "unit_normalize": False, 10 | "unification": "cos", 11 | "l2": 0.001, 12 | "k_max": None, 13 | "train_0ntp": False, 14 | "keep_prob": 1.0, 15 | "max_depth": 1 16 | }, 17 | "training": { 18 | "num_epochs": 10, 19 | "report_interval": 10, 20 | "clip": (-5, 5), 21 | "init": (-0.1, 0.1), 22 | "learning_rate": 0.001, 23 | "optimizer": "Adam", # "SGD" 24 | "epsilon": 1e-10, 25 | "pos_per_batch": 2, # batch_size = pos_per_batch * (1 + neg_per_batch) 26 | "neg_per_pos": 1, 27 | "sampling_scheme": "all", 28 | "mean_loss": False 29 | }, 30 | "meta": { 31 | "parent": None, 32 | "debug": False, 33 | "output_predictions": False, 34 | "check_numerics": False, 35 | "tfdbg": False, 36 | "experiment_prefix": "experiments", 37 | "test_graph_creation": False, 38 | "train": True, 39 | "test_time_neural_link_prediction": True, 40 | "test_time_batching": False, 41 | "ensemble": False 42 | }, 43 | } 44 | -------------------------------------------------------------------------------- /conf/kinship.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "kinship", 10 | "test_set": "test", 11 | "result_file": "./out/kinship/results.tsv", 12 | "debug": False 13 | }, 14 | "training": { 15 | "num_epochs": 100, 16 | "report_interval": 10, 17 | "pos_per_batch": 10, 18 | "neg_per_pos": 1, 19 | "optimizer": "Adam", 20 | "learning_rate": 0.001, 21 | "sampling_scheme": "all", 22 | "init": None, # xavier initialization 23 | "clip": (-1.0, 1.0) 24 | }, 25 | "model": { 26 | "input_size": 100, 27 | "k_max": 10, 28 | "name": "???", 29 | "neural_link_predictor": "ComplEx", 30 | "l2": 0.01, # 0.01 # 0.0001 31 | "keep_prob": 0.7 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /conf/kinship_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "templates": None 4 | }, 5 | "meta": { 6 | "parent": "./conf/kinship.conf", 7 | }, 8 | "model": { 9 | "name": "ComplEx", 10 | "neural_link_predictor": "ComplEx" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /conf/kinship_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/kinship.conf", 4 | "test_time_neural_link_prediction": False 5 | }, 6 | "model": { 7 | "name": "NTP", 8 | "neural_link_predictor": None, 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/kinship_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/kinship.conf", 4 | "test_time_neural_link_prediction": False 5 | }, 6 | "model": { 7 | "name": "NTP ComplEx Reg", 8 | "neural_link_predictor": "ComplEx", 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/nations.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "nations", 10 | "test_set": "test", 11 | "result_file": "./out/nations/results.tsv", 12 | "debug": False 13 | }, 14 | "training": { 15 | "num_epochs": 100, 16 | "report_interval": 10, 17 | "pos_per_batch": 10, 18 | "neg_per_pos": 1, 19 | "optimizer": "Adam", 20 | "learning_rate": 0.001, 21 | "sampling_scheme": "all", 22 | "init": None, # xavier initialization 23 | "clip": (-1.0, 1.0) 24 | }, 25 | "model": { 26 | "input_size": 100, 27 | "k_max": 10, 28 | "name": "???", 29 | "neural_link_predictor": "ComplEx", 30 | "l2": 0.01, # 0.01 # 0.0001 31 | "keep_prob": 0.7 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /conf/nations_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "templates": None 4 | }, 5 | "meta": { 6 | "parent": "./conf/nations.conf", 7 | }, 8 | "model": { 9 | "name": "ComplEx", 10 | "neural_link_predictor": "ComplEx" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /conf/nations_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/nations.conf", 4 | "test_time_neural_link_prediction": False 5 | }, 6 | "model": { 7 | "name": "NTP", 8 | "neural_link_predictor": None, 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/nations_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/nations.conf", 4 | "test_time_neural_link_prediction": False 5 | }, 6 | "model": { 7 | "name": "NTP ComplEx Reg", 8 | "neural_link_predictor": "ComplEx", 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/synth/synth_three.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/synth/three.nl", 4 | "templates": "./data/synth/three.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "synth_two", 10 | "test_time_neural_link_prediction": False 11 | }, 12 | "training": { 13 | "num_epochs": 50, 14 | "report_interval": 10, 15 | "pos_per_batch": 2, 16 | "neg_per_pos": 1, 17 | "sampling_scheme": "all" 18 | }, 19 | "model": { 20 | "neural_link_predictor": "ComplEx", 21 | "train_0ntp": True 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /conf/synth/synth_two.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/synth/two.nl", 4 | "templates": "./data/synth/two.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "synth_two", 10 | "test_time_neural_link_prediction": False 11 | }, 12 | "training": { 13 | "num_epochs": 200, 14 | "report_interval": 10, 15 | "pos_per_batch": 2, 16 | "neg_per_pos": 1, 17 | "sampling_scheme": "all" 18 | }, 19 | "model": { 20 | "neural_link_predictor": "ComplEx", 21 | "train_0ntp": True 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /conf/umls.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls.nlt" 5 | }, 6 | "meta": { 7 | "parent": "./conf/default.conf", 8 | "test_graph_creation": False, 9 | "experiment_prefix": "umls", 10 | "test_set": "test", 11 | "result_file": "./out/umls/results.tsv", 12 | "debug": False 13 | }, 14 | "training": { 15 | "num_epochs": 100, 16 | "report_interval": 10, 17 | "pos_per_batch": 10, 18 | "neg_per_pos": 1, 19 | "optimizer": "Adam", 20 | "learning_rate": 0.001, 21 | "sampling_scheme": "all", 22 | "init": None, # xavier initialization 23 | "clip": (-1.0, 1.0) 24 | }, 25 | "model": { 26 | "input_size": 100, 27 | "k_max": 10, 28 | "name": "???", 29 | "neural_link_predictor": "ComplEx", 30 | "l2": 0.01, # 0.01 # 0.0001 31 | "keep_prob": 0.7 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /conf/umls_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "templates": None 4 | }, 5 | "meta": { 6 | "parent": "./conf/umls.conf", 7 | }, 8 | "model": { 9 | "name": "ComplEx", 10 | "neural_link_predictor": "ComplEx" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /conf/umls_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/umls.conf", 4 | "test_time_neural_link_prediction": True 5 | }, 6 | "model": { 7 | "name": "NTP", 8 | "neural_link_predictor": None, 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/umls_ntp_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/umls.conf", 4 | "test_time_neural_link_prediction": True 5 | }, 6 | "model": { 7 | "name": "NTP ComplEx Reg", 8 | "neural_link_predictor": "ComplEx", 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/umls_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "parent": "./conf/umls.conf", 4 | "test_time_neural_link_prediction": False 5 | }, 6 | "model": { 7 | "name": "NTP ComplEx Reg", 8 | "neural_link_predictor": "ComplEx", 9 | "train_0ntp": True, 10 | "l2": 0.001, # 0.01 # 0.0001 11 | "keep_prob": 1.0 12 | }, 13 | "training": { 14 | "init": (-1.0, 1.0) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/data/.DS_Store -------------------------------------------------------------------------------- /data/countries/countries.nlt: -------------------------------------------------------------------------------- 1 | 3 #1(X, Y) :- #2(X, Z), #2(Z, Y). 2 | 3 #1(X, Y) :- #2(X, Z), #3(Z, Y). 3 | 3 #1(X, Y) :- #2(X, Z), #3(Z, W), #4(W, Y). 4 | 3 #1(X, Y) :- #1(Y, X). -------------------------------------------------------------------------------- /data/countries/countries_S1.nlt: -------------------------------------------------------------------------------- 1 | 3 #1(X, Y) :- #1(Y, X). 2 | 3 #1(X, Y) :- #2(X, Z), #2(Z, Y). 3 | -------------------------------------------------------------------------------- /data/countries/countries_S2.nlt: -------------------------------------------------------------------------------- 1 | 3 #1(X, Y) :- #1(Y, X). 2 | 3 #1(X, Y) :- #2(X, Z), #2(Z, Y). 3 | 3 #1(X, Y) :- #2(X, Z), #3(Z, Y). 4 | -------------------------------------------------------------------------------- /data/countries/countries_S3.nlt: -------------------------------------------------------------------------------- 1 | 3 #1(X, Y) :- #1(Y, X). 2 | 3 #1(X, Y) :- #2(X, Z), #2(Z, Y). 3 | 3 #1(X, Y) :- #2(X, Z), #3(Z, Y). 4 | 3 #1(X, Y) :- #2(X, Z), #3(Z, W), #4(W, Y). 5 | -------------------------------------------------------------------------------- /data/countries/dev.txt: -------------------------------------------------------------------------------- 1 | kazakhstan 2 | thailand 3 | mongolia 4 | suriname 5 | botswana 6 | syria 7 | panama 8 | norway 9 | sudan 10 | spain 11 | french_guiana 12 | myanmar 13 | czechia 14 | guinea-bissau 15 | denmark 16 | iraq 17 | nicaragua 18 | bhutan 19 | zambia 20 | djibouti 21 | hungary 22 | saint_martin 23 | kosovo 24 | macau 25 | -------------------------------------------------------------------------------- /data/countries/download.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | wget https://github.com/mledoze/countries/raw/master/dist/countries.csv -------------------------------------------------------------------------------- /data/countries/regions.txt: -------------------------------------------------------------------------------- 1 | oceania 2 | asia 3 | europe 4 | africa 5 | americas 6 | -------------------------------------------------------------------------------- /data/countries/subregions.txt: -------------------------------------------------------------------------------- 1 | northern_america 2 | eastern_europe 3 | australia_and_new_zealand 4 | melanesia 5 | micronesia 6 | eastern_africa 7 | southern_asia 8 | eastern_asia 9 | south_america 10 | central_europe 11 | western_asia 12 | northern_africa 13 | western_africa 14 | northern_europe 15 | middle_africa 16 | caribbean 17 | polynesia 18 | western_europe 19 | southern_europe 20 | central_america 21 | southern_africa 22 | central_asia 23 | south-eastern_asia 24 | -------------------------------------------------------------------------------- /data/countries/test.txt: -------------------------------------------------------------------------------- 1 | eritrea 2 | ghana 3 | saudi_arabia 4 | bulgaria 5 | french_guiana 6 | monaco 7 | djibouti 8 | venezuela 9 | guyana 10 | indonesia 11 | thailand 12 | sudan 13 | germany 14 | burkina_faso 15 | united_states 16 | tanzania 17 | ecuador 18 | norway 19 | zimbabwe 20 | jordan 21 | timor-leste 22 | spain 23 | egypt 24 | iraq 25 | -------------------------------------------------------------------------------- /data/kinship/download.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | wget https://archive.ics.uci.edu/ml/machine-learning-databases/kinship/kinship.data 3 | wget https://archive.ics.uci.edu/ml/machine-learning-databases/kinship/kinship.names 4 | wget https://alchemy.cs.washington.edu/data/kinships/kin.db -------------------------------------------------------------------------------- /data/kinship/entities.txt: -------------------------------------------------------------------------------- 1 | person26 2 | person14 3 | person44 4 | person91 5 | person80 6 | person85 7 | person8 8 | person48 9 | person32 10 | person20 11 | person79 12 | person102 13 | person57 14 | person92 15 | person13 16 | person78 17 | person97 18 | person0 19 | person84 20 | person16 21 | person30 22 | person59 23 | person42 24 | person27 25 | person56 26 | person41 27 | person83 28 | person68 29 | person73 30 | person6 31 | person101 32 | person87 33 | person47 34 | person21 35 | person24 36 | person38 37 | person99 38 | person22 39 | person88 40 | person100 41 | person95 42 | person40 43 | person96 44 | person2 45 | person49 46 | person90 47 | person86 48 | person63 49 | person50 50 | person81 51 | person74 52 | person7 53 | person29 54 | person10 55 | person46 56 | person53 57 | person28 58 | person51 59 | person77 60 | person71 61 | person19 62 | person45 63 | person58 64 | person103 65 | person89 66 | person67 67 | person52 68 | person93 69 | person15 70 | person72 71 | person18 72 | person12 73 | person98 74 | person54 75 | person61 76 | person33 77 | person25 78 | person60 79 | person4 80 | person66 81 | person65 82 | person82 83 | person36 84 | person1 85 | person23 86 | person94 87 | person35 88 | person9 89 | person39 90 | person62 91 | person31 92 | person34 93 | person70 94 | person55 95 | person43 96 | person3 97 | person17 98 | person11 99 | person75 100 | person64 101 | person37 102 | person76 103 | person5 104 | person69 105 | -------------------------------------------------------------------------------- /data/kinship/kinship.nlt: -------------------------------------------------------------------------------- 1 | 20 #1(X, Y) :- #2(X, Y). 2 | 3 | 20 #1(X, Y) :- #2(Y, X). 4 | 5 | 20 #1(X, Y) :- 6 | #2(X, Z), 7 | #3(Z, Y). -------------------------------------------------------------------------------- /data/nations/dev.nl: -------------------------------------------------------------------------------- 1 | timesinceally(cuba,india). 2 | reltreaties(brazil,egypt). 3 | exports3(egypt,uk). 4 | ngo(netherlands,uk). 5 | reltourism(china,ussr). 6 | intergovorgs(uk,israel). 7 | releconomicaid(ussr,cuba). 8 | embassy(ussr,indonesia). 9 | violentactions(israel,jordan). 10 | unweightedunvote(uk,usa). 11 | intergovorgs3(india,brazil). 12 | commonbloc1(cuba,brazil). 13 | unweightedunvote(poland,israel). 14 | intergovorgs(israel,brazil). 15 | embassy(cuba,uk). 16 | exportbooks(uk,netherlands). 17 | blockpositionindex(netherlands,cuba). 18 | blockpositionindex(cuba,uk). 19 | reltreaties(poland,uk). 20 | weightedunvote(israel,ussr). 21 | embassy(netherlands,poland). 22 | economicaid(china,egypt). 23 | treaties(ussr,china). 24 | independence(usa,poland). 25 | commonbloc0(usa,cuba). 26 | unweightedunvote(israel,netherlands). 27 | relexports(ussr,uk). 28 | militaryalliance(israel,usa). 29 | embassy(india,uk). 30 | embassy(cuba,indonesia). 31 | officialvisits(cuba,egypt). 32 | timesinceally(ussr,uk). 33 | officialvisits(ussr,poland). 34 | negativecomm(cuba,usa). 35 | reldiplomacy(ussr,israel). 36 | ngo(egypt,brazil). 37 | relintergovorgs(ussr,india). 38 | intergovorgs3(china,brazil). 39 | independence(uk,brazil). 40 | intergovorgs(uk,ussr). 41 | timesinceally(poland,ussr). 42 | embassy(netherlands,usa). 43 | nonviolentbehavior(china,ussr). 44 | relintergovorgs(china,india). 45 | commonbloc1(brazil,indonesia). 46 | weightedunvote(israel,usa). 47 | ngoorgs3(burma,uk). 48 | commonbloc1(ussr,burma). 49 | intergovorgs(netherlands,poland). 50 | embassy(burma,ussr). 51 | intergovorgs3(burma,netherlands). 52 | militaryactions(indonesia,china). 53 | commonbloc1(cuba,india). 54 | conferences(uk,usa). 55 | commonbloc1(jordan,usa). 56 | embassy(poland,israel). 57 | violentactions(uk,indonesia). 58 | negativecomm(china,usa). 59 | embassy(india,egypt). 60 | independence(brazil,poland). 61 | tourism(usa,uk). 62 | treaties(china,ussr). 63 | blockpositionindex(uk,cuba). 64 | conferences(brazil,uk). 65 | negativebehavior(cuba,indonesia). 66 | timesinceally(netherlands,usa). 67 | conferences(ussr,usa). 68 | ngoorgs3(uk,india). 69 | timesinceally(ussr,netherlands). 70 | commonbloc2(burma,israel). 71 | relintergovorgs(burma,indonesia). 72 | embassy(ussr,poland). 73 | treaties(poland,china). 74 | tourism3(netherlands,egypt). 75 | commonbloc1(china,indonesia). 76 | blockpositionindex(china,netherlands). 77 | independence(ussr,jordan). 78 | intergovorgs(netherlands,usa). 79 | dependent(cuba,usa). 80 | reldiplomacy(china,burma). 81 | blockpositionindex(usa,poland). 82 | relintergovorgs(india,indonesia). 83 | timesinceally(usa,brazil). 84 | ngoorgs3(usa,brazil). 85 | reldiplomacy(burma,poland). 86 | reltreaties(brazil,usa). 87 | embassy(china,uk). 88 | pprotests(usa,poland). 89 | timesincewar(israel,egypt). 90 | weightedunvote(cuba,israel). 91 | duration(china,india). 92 | negativecomm(china,ussr). 93 | independence(uk,netherlands). 94 | negativebehavior(indonesia,ussr). 95 | treaties(indonesia,china). 96 | reldiplomacy(egypt,burma). 97 | reldiplomacy(poland,brazil). 98 | relintergovorgs(poland,brazil). 99 | ngo(poland,ussr). 100 | ngoorgs3(israel,usa). 101 | reldiplomacy(jordan,india). 102 | embassy(cuba,india). 103 | conferences(brazil,poland). 104 | relintergovorgs(usa,india). 105 | relbooktranslations(poland,ussr). 106 | relbooktranslations(poland,uk). 107 | treaties(cuba,china). 108 | tourism(usa,egypt). 109 | ngo(usa,brazil). 110 | intergovorgs3(egypt,israel). 111 | embassy(burma,indonesia). 112 | reltreaties(china,indonesia). 113 | embassy(china,cuba). 114 | embassy(israel,usa). 115 | ngoorgs3(brazil,israel). 116 | timesinceally(egypt,brazil). 117 | commonbloc2(india,egypt). 118 | warning(jordan,israel). 119 | embassy(jordan,ussr). 120 | embassy(poland,brazil). 121 | conferences(uk,brazil). 122 | intergovorgs3(ussr,brazil). 123 | unweightedunvote(netherlands,poland). 124 | emigrants3(jordan,usa). 125 | relngo(poland,brazil). 126 | relexports(israel,netherlands). 127 | accusation(uk,ussr). 128 | militaryalliance(jordan,egypt). 129 | timesinceally(ussr,cuba). 130 | ngo(ussr,uk). 131 | reltreaties(india,netherlands). 132 | reltourism(poland,ussr). 133 | weightedunvote(israel,egypt). 134 | embassy(indonesia,uk). 135 | exportbooks(uk,china). 136 | relintergovorgs(indonesia,cuba). 137 | embassy(burma,china). 138 | negativecomm(india,china). 139 | exports3(poland,uk). 140 | intergovorgs3(ussr,israel). 141 | relngo(burma,egypt). 142 | treaties(usa,poland). 143 | relbooktranslations(burma,uk). 144 | intergovorgs(egypt,israel). 145 | ngoorgs3(burma,india). 146 | independence(cuba,uk). 147 | relngo(israel,netherlands). 148 | ngo(ussr,usa). 149 | unweightedunvote(israel,usa). 150 | independence(uk,ussr). 151 | commonbloc0(netherlands,ussr). 152 | relstudents(uk,usa). 153 | economicaid(uk,india). 154 | embassy(uk,cuba). 155 | commonbloc2(burma,egypt). 156 | conferences(cuba,poland). 157 | reldiplomacy(burma,china). 158 | independence(china,egypt). 159 | intergovorgs(cuba,brazil). 160 | weightedunvote(burma,usa). 161 | commonbloc1(egypt,cuba). 162 | timesinceally(china,egypt). 163 | unweightedunvote(jordan,uk). 164 | commonbloc2(indonesia,egypt). 165 | ngoorgs3(poland,netherlands). 166 | relbooktranslations(indonesia,usa). 167 | exports3(uk,usa). 168 | embassy(brazil,indonesia). 169 | exports3(uk,india). 170 | intergovorgs3(ussr,egypt). 171 | relintergovorgs(india,egypt). 172 | reltourism(uk,netherlands). 173 | unoffialacts(indonesia,india). 174 | relexports(poland,ussr). 175 | intergovorgs(netherlands,egypt). 176 | timesinceally(netherlands,brazil). 177 | tourism3(poland,ussr). 178 | intergovorgs3(brazil,israel). 179 | timesinceally(china,netherlands). 180 | reltourism(usa,brazil). 181 | relintergovorgs(egypt,indonesia). 182 | embassy(burma,israel). 183 | negativecomm(china,indonesia). 184 | ngoorgs3(cuba,brazil). 185 | relngo(ussr,netherlands). 186 | treaties(uk,cuba). 187 | reltreaties(brazil,india). 188 | eemigrants(israel,usa). 189 | ngoorgs3(ussr,usa). 190 | embassy(uk,poland). 191 | ngoorgs3(netherlands,usa). 192 | ngo(brazil,israel). 193 | reldiplomacy(cuba,india). 194 | militaryactions(india,china). 195 | intergovorgs(usa,egypt). 196 | ngoorgs3(poland,uk). 197 | timesinceally(china,india). 198 | timesinceally(usa,poland). 199 | negativecomm(egypt,israel). 200 | -------------------------------------------------------------------------------- /data/nations/download.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | wget https://alchemy.cs.washington.edu/data/nations/nat.db 3 | -------------------------------------------------------------------------------- /data/nations/entities.txt: -------------------------------------------------------------------------------- 1 | china 2 | cuba 3 | ussr 4 | burma 5 | india 6 | poland 7 | brazil 8 | netherlands 9 | uk 10 | indonesia 11 | usa 12 | egypt 13 | jordan 14 | israel 15 | -------------------------------------------------------------------------------- /data/nations/nations.nlt: -------------------------------------------------------------------------------- 1 | 20 #1(X, Y) :- #2(X, Y). 2 | 3 | 20 #1(X, Y) :- #2(Y, X). 4 | 5 | 20 #1(X, Y) :- 6 | #2(X, Z), 7 | #3(Z, Y). -------------------------------------------------------------------------------- /data/nations/test.nl: -------------------------------------------------------------------------------- 1 | ngoorgs3(poland,ussr). 2 | intergovorgs(india,israel). 3 | commonbloc1(israel,cuba). 4 | independence(usa,china). 5 | reldiplomacy(burma,ussr). 6 | pprotests(uk,ussr). 7 | militaryactions(indonesia,uk). 8 | weightedunvote(poland,netherlands). 9 | intergovorgs3(china,india). 10 | relintergovorgs(burma,usa). 11 | ngoorgs3(israel,brazil). 12 | intergovorgs(india,egypt). 13 | ngo(netherlands,india). 14 | booktranslations(ussr,usa). 15 | militaryalliance(usa,netherlands). 16 | commonbloc1(india,poland). 17 | reldiplomacy(cuba,egypt). 18 | weightedunvote(usa,israel). 19 | ngoorgs3(cuba,israel). 20 | embassy(china,burma). 21 | embassy(netherlands,india). 22 | embassy(egypt,uk). 23 | relexports(india,ussr). 24 | accusation(indonesia,uk). 25 | officialvisits(egypt,ussr). 26 | intergovorgs(brazil,cuba). 27 | relexports(china,cuba). 28 | relintergovorgs(ussr,brazil). 29 | ngoorgs3(usa,netherlands). 30 | reltreaties(jordan,indonesia). 31 | violentactions(indonesia,uk). 32 | reldiplomacy(poland,usa). 33 | unweightedunvote(usa,israel). 34 | relintergovorgs(china,brazil). 35 | reltreaties(burma,china). 36 | blockpositionindex(ussr,uk). 37 | reldiplomacy(cuba,china). 38 | ngoorgs3(egypt,usa). 39 | relexports(cuba,ussr). 40 | relintergovorgs(burma,israel). 41 | relbooktranslations(ussr,usa). 42 | intergovorgs3(china,ussr). 43 | reltreaties(india,usa). 44 | blockpositionindex(ussr,burma). 45 | weightedunvote(poland,uk). 46 | independence(ussr,china). 47 | relngo(ussr,poland). 48 | relintergovorgs(india,brazil). 49 | negativecomm(china,india). 50 | officialvisits(usa,indonesia). 51 | independence(cuba,usa). 52 | tourism3(uk,egypt). 53 | negativebehavior(cuba,uk). 54 | reltreaties(poland,ussr). 55 | booktranslations(israel,ussr). 56 | reldiplomacy(burma,egypt). 57 | officialvisits(china,indonesia). 58 | weightedunvote(usa,cuba). 59 | weightedunvote(uk,cuba). 60 | embassy(china,egypt). 61 | intergovorgs3(israel,egypt). 62 | timesinceally(uk,usa). 63 | intergovorgs3(cuba,uk). 64 | reldiplomacy(jordan,usa). 65 | relexports(india,uk). 66 | reldiplomacy(indonesia,egypt). 67 | embassy(egypt,cuba). 68 | timesincewar(israel,jordan). 69 | relngo(uk,usa). 70 | ngo(poland,india). 71 | relngo(indonesia,cuba). 72 | dependent(burma,uk). 73 | treaties(netherlands,usa). 74 | militaryalliance(usa,uk). 75 | relintergovorgs(jordan,poland). 76 | intergovorgs3(uk,brazil). 77 | reldiplomacy(poland,cuba). 78 | embassy(usa,uk). 79 | ngo(uk,poland). 80 | reldiplomacy(ussr,usa). 81 | reltreaties(egypt,poland). 82 | embassy(indonesia,burma). 83 | commonbloc2(poland,ussr). 84 | expeldiplomats(indonesia,cuba). 85 | relngo(israel,usa). 86 | relngo(israel,india). 87 | relngo(jordan,brazil). 88 | negativebehavior(usa,egypt). 89 | ngoorgs3(indonesia,netherlands). 90 | accusation(usa,cuba). 91 | militaryalliance(indonesia,usa). 92 | commonbloc0(china,brazil). 93 | reltourism(usa,egypt). 94 | embassy(china,indonesia). 95 | reldiplomacy(egypt,usa). 96 | intergovorgs3(china,usa). 97 | timesinceally(india,cuba). 98 | reltreaties(cuba,uk). 99 | intergovorgs3(burma,indonesia). 100 | nonviolentbehavior(india,china). 101 | timesinceally(ussr,china). 102 | intergovorgs3(jordan,israel). 103 | relintergovorgs(cuba,egypt). 104 | students(indonesia,usa). 105 | ngoorgs3(indonesia,india). 106 | timesinceally(uk,cuba). 107 | treaties(burma,china). 108 | tourism3(netherlands,uk). 109 | intergovorgs3(israel,brazil). 110 | timesinceally(uk,ussr). 111 | commonbloc1(india,china). 112 | timesincewar(cuba,usa). 113 | relintergovorgs(jordan,cuba). 114 | negativecomm(indonesia,china). 115 | unweightedunvote(uk,jordan). 116 | conferences(uk,indonesia). 117 | commonbloc1(netherlands,burma). 118 | negativecomm(indonesia,uk). 119 | commonbloc2(indonesia,burma). 120 | treaties(egypt,china). 121 | embassy(netherlands,china). 122 | reltreaties(indonesia,china). 123 | ngoorgs3(netherlands,india). 124 | commonbloc1(burma,brazil). 125 | embassy(egypt,burma). 126 | intergovorgs(poland,israel). 127 | officialvisits(jordan,egypt). 128 | reltreaties(cuba,china). 129 | timesinceally(egypt,ussr). 130 | intergovorgs3(poland,israel). 131 | ngoorgs3(jordan,usa). 132 | relngo(indonesia,usa). 133 | embassy(brazil,uk). 134 | officialvisits(cuba,china). 135 | intergovorgs3(brazil,usa). 136 | negativecomm(usa,brazil). 137 | lostterritory(netherlands,indonesia). 138 | weightedunvote(usa,ussr). 139 | ngoorgs3(egypt,brazil). 140 | relintergovorgs(netherlands,uk). 141 | ngoorgs3(egypt,netherlands). 142 | commonbloc1(egypt,uk). 143 | commonbloc2(jordan,indonesia). 144 | embassy(ussr,netherlands). 145 | embassy(netherlands,ussr). 146 | tourism3(netherlands,ussr). 147 | commonbloc0(netherlands,china). 148 | timesinceally(uk,egypt). 149 | negativebehavior(egypt,israel). 150 | weightedunvote(jordan,uk). 151 | relintergovorgs(poland,usa). 152 | relexportbooks(netherlands,uk). 153 | ngoorgs3(burma,israel). 154 | relexports(india,usa). 155 | independence(poland,uk). 156 | treaties(egypt,indonesia). 157 | embassy(indonesia,cuba). 158 | tourism3(cuba,ussr). 159 | timesinceally(usa,cuba). 160 | reldiplomacy(poland,india). 161 | timesinceally(usa,netherlands). 162 | commonbloc2(egypt,india). 163 | intergovorgs(netherlands,indonesia). 164 | blockpositionindex(usa,ussr). 165 | relexports(china,ussr). 166 | embassy(israel,brazil). 167 | embassy(usa,brazil). 168 | relngo(burma,israel). 169 | officialvisits(china,burma). 170 | commonbloc1(brazil,india). 171 | intergovorgs(israel,egypt). 172 | commonbloc2(netherlands,uk). 173 | independence(egypt,brazil). 174 | relintergovorgs(burma,egypt). 175 | conferences(usa,indonesia). 176 | exports3(brazil,usa). 177 | commonbloc1(egypt,brazil). 178 | blockpositionindex(burma,usa). 179 | embassy(egypt,ussr). 180 | timesinceally(china,brazil). 181 | accusation(china,uk). 182 | embassy(uk,netherlands). 183 | intergovorgs(india,burma). 184 | reltourism(usa,india). 185 | commonbloc1(indonesia,netherlands). 186 | relexports(poland,usa). 187 | timesinceally(ussr,brazil). 188 | ngoorgs3(usa,uk). 189 | intergovorgs(brazil,poland). 190 | students(india,usa). 191 | independence(egypt,usa). 192 | timesinceally(india,brazil). 193 | duration(uk,indonesia). 194 | reldiplomacy(indonesia,uk). 195 | intergovorgs3(uk,netherlands). 196 | intergovorgs3(israel,usa). 197 | exports3(burma,india). 198 | reldiplomacy(burma,indonesia). 199 | relngo(jordan,usa). 200 | commonbloc1(israel,netherlands). 201 | ngoorgs3(jordan,netherlands). 202 | -------------------------------------------------------------------------------- /data/ntp/simpsons.nl: -------------------------------------------------------------------------------- 1 | fatherOf(abe, homer). 2 | 3 | parentOf(homer, lisa). 4 | 5 | parentOf(homer, bart). 6 | 7 | grandpaOf(abe, lisa). 8 | 9 | grandfatherOf(abe, maggie). 10 | 11 | grandparentOf(X, Y) :- 12 | grandfatherOf(X, Y). 13 | 14 | parentOf(X, Y) :- 15 | fatherOf(X, Y). 16 | 17 | grandfatherOf(X, Y) :- 18 | fatherOf(X, Z), 19 | parentOf(Z, Y). 20 | 21 | grandchildOf(X, Y) :- 22 | grandparentOf(Y, X). -------------------------------------------------------------------------------- /data/ntp/simpsons.nlt: -------------------------------------------------------------------------------- 1 | 5 #1(X, Y) :- #2(X, Y). 2 | 3 | 5 #1(X, Y) :- #1(Y, X). 4 | 5 | 5 #1(X, Y) :- 6 | #2(X, Z), 7 | #2(Z, Y). -------------------------------------------------------------------------------- /data/synth/go.sh: -------------------------------------------------------------------------------- 1 | seq 0 32 | awk '{ print "p(e" $1 ", e" $1 ")." }' > one.nl 2 | seq 0 32 | awk '{ print "p(e" $1 ").\nq(e" $1 ")." }' > two.nl 3 | seq 0 32 | awk '{ print "p(e" $1 ", e" $1 ").\nq(e" $1 ", e" $1 ").\nr(f" $1 ", f" $1 ")." }' > three.nl 4 | -------------------------------------------------------------------------------- /data/synth/one.nl: -------------------------------------------------------------------------------- 1 | p(e0, e0). 2 | p(e1, e1). 3 | p(e2, e2). 4 | p(e3, e3). 5 | p(e4, e4). 6 | p(e5, e5). 7 | p(e6, e6). 8 | p(e7, e7). 9 | p(e8, e8). 10 | p(e9, e9). 11 | p(e10, e10). 12 | p(e11, e11). 13 | p(e12, e12). 14 | p(e13, e13). 15 | p(e14, e14). 16 | p(e15, e15). 17 | p(e16, e16). 18 | p(e17, e17). 19 | p(e18, e18). 20 | p(e19, e19). 21 | p(e20, e20). 22 | p(e21, e21). 23 | p(e22, e22). 24 | p(e23, e23). 25 | p(e24, e24). 26 | p(e25, e25). 27 | p(e26, e26). 28 | p(e27, e27). 29 | p(e28, e28). 30 | p(e29, e29). 31 | p(e30, e30). 32 | p(e31, e31). 33 | p(e32, e32). 34 | -------------------------------------------------------------------------------- /data/synth/three.nl: -------------------------------------------------------------------------------- 1 | p(e0, e0). 2 | q(e0, e0). 3 | r(f0, f0). 4 | p(e1, e1). 5 | q(e1, e1). 6 | r(f1, f1). 7 | p(e2, e2). 8 | q(e2, e2). 9 | r(f2, f2). 10 | p(e3, e3). 11 | q(e3, e3). 12 | r(f3, f3). 13 | p(e4, e4). 14 | q(e4, e4). 15 | r(f4, f4). 16 | p(e5, e5). 17 | q(e5, e5). 18 | r(f5, f5). 19 | p(e6, e6). 20 | q(e6, e6). 21 | r(f6, f6). 22 | p(e7, e7). 23 | q(e7, e7). 24 | r(f7, f7). 25 | p(e8, e8). 26 | q(e8, e8). 27 | r(f8, f8). 28 | p(e9, e9). 29 | q(e9, e9). 30 | r(f9, f9). 31 | p(e10, e10). 32 | q(e10, e10). 33 | r(f10, f10). 34 | p(e11, e11). 35 | q(e11, e11). 36 | r(f11, f11). 37 | p(e12, e12). 38 | q(e12, e12). 39 | r(f12, f12). 40 | p(e13, e13). 41 | q(e13, e13). 42 | r(f13, f13). 43 | p(e14, e14). 44 | q(e14, e14). 45 | r(f14, f14). 46 | p(e15, e15). 47 | q(e15, e15). 48 | r(f15, f15). 49 | p(e16, e16). 50 | q(e16, e16). 51 | r(f16, f16). 52 | p(e17, e17). 53 | q(e17, e17). 54 | r(f17, f17). 55 | p(e18, e18). 56 | q(e18, e18). 57 | r(f18, f18). 58 | p(e19, e19). 59 | q(e19, e19). 60 | r(f19, f19). 61 | p(e20, e20). 62 | q(e20, e20). 63 | r(f20, f20). 64 | p(e21, e21). 65 | q(e21, e21). 66 | r(f21, f21). 67 | p(e22, e22). 68 | q(e22, e22). 69 | r(f22, f22). 70 | p(e23, e23). 71 | q(e23, e23). 72 | r(f23, f23). 73 | p(e24, e24). 74 | q(e24, e24). 75 | r(f24, f24). 76 | p(e25, e25). 77 | q(e25, e25). 78 | r(f25, f25). 79 | p(e26, e26). 80 | q(e26, e26). 81 | r(f26, f26). 82 | p(e27, e27). 83 | q(e27, e27). 84 | r(f27, f27). 85 | p(e28, e28). 86 | q(e28, e28). 87 | r(f28, f28). 88 | p(e29, e29). 89 | q(e29, e29). 90 | r(f29, f29). 91 | p(e30, e30). 92 | q(e30, e30). 93 | r(f30, f30). 94 | p(e31, e31). 95 | q(e31, e31). 96 | r(f31, f31). 97 | p(e32, e32). 98 | q(e32, e32). 99 | r(f32, f32). 100 | -------------------------------------------------------------------------------- /data/synth/three.nlt: -------------------------------------------------------------------------------- 1 | 5 #1(X, Y) :- #2(X, Y). 2 | -------------------------------------------------------------------------------- /data/synth/two.nl: -------------------------------------------------------------------------------- 1 | p(e0). 2 | q(e0). 3 | p(e1). 4 | q(e1). 5 | p(e2). 6 | q(e2). 7 | p(e3). 8 | q(e3). 9 | p(e4). 10 | q(e4). 11 | p(e5). 12 | q(e5). 13 | p(e6). 14 | q(e6). 15 | p(e7). 16 | q(e7). 17 | p(e8). 18 | q(e8). 19 | p(e9). 20 | q(e9). 21 | p(e10). 22 | q(e10). 23 | p(e11). 24 | q(e11). 25 | p(e12). 26 | q(e12). 27 | p(e13). 28 | q(e13). 29 | p(e14). 30 | q(e14). 31 | p(e15). 32 | q(e15). 33 | p(e16). 34 | q(e16). 35 | p(e17). 36 | q(e17). 37 | p(e18). 38 | q(e18). 39 | p(e19). 40 | q(e19). 41 | p(e20). 42 | q(e20). 43 | p(e21). 44 | q(e21). 45 | p(e22). 46 | q(e22). 47 | p(e23). 48 | q(e23). 49 | p(e24). 50 | q(e24). 51 | p(e25). 52 | q(e25). 53 | p(e26). 54 | q(e26). 55 | p(e27). 56 | q(e27). 57 | p(e28). 58 | q(e28). 59 | p(e29). 60 | q(e29). 61 | p(e30). 62 | q(e30). 63 | p(e31). 64 | q(e31). 65 | p(e32). 66 | q(e32). 67 | -------------------------------------------------------------------------------- /data/synth/two.nlt: -------------------------------------------------------------------------------- 1 | 5 #1(X) :- #2(X). 2 | -------------------------------------------------------------------------------- /data/umls/download.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | wget https://alchemy.cs.washington.edu/data/umls/uml.db 3 | -------------------------------------------------------------------------------- /data/umls/entities.txt: -------------------------------------------------------------------------------- 1 | organ_or_tissue_function 2 | human_caused_phenomenon_or_process 3 | drug_delivery_device 4 | alga 5 | organization 6 | antibiotic 7 | organism 8 | neoplastic_process 9 | regulation_or_law 10 | medical_device 11 | therapeutic_or_preventive_procedure 12 | physiologic_function 13 | natural_phenomenon_or_process 14 | social_behavior 15 | hormone 16 | molecular_sequence 17 | neuroreactive_substance_or_biogenic_amine 18 | lipid 19 | invertebrate 20 | organism_function 21 | behavior 22 | research_device 23 | experimental_model_of_disease 24 | inorganic_chemical 25 | idea_or_concept 26 | cell_component 27 | occupational_activity 28 | conceptual_entity 29 | disease_or_syndrome 30 | patient_or_disabled_group 31 | genetic_function 32 | professional_or_occupational_group 33 | plant 34 | diagnostic_procedure 35 | archaeon 36 | body_space_or_junction 37 | group_attribute 38 | pathologic_function 39 | reptile 40 | age_group 41 | tissue 42 | organic_chemical 43 | gene_or_genome 44 | fully_formed_anatomical_structure 45 | bacterium 46 | daily_or_recreational_activity 47 | mammal 48 | molecular_function 49 | temporal_concept 50 | amphibian 51 | amino_acid_peptide_or_protein 52 | classification 53 | human 54 | acquired_abnormality 55 | laboratory_or_test_result 56 | organism_attribute 57 | chemical_viewed_functionally 58 | chemical 59 | individual_behavior 60 | nucleotide_sequence 61 | steroid 62 | amino_acid_sequence 63 | body_system 64 | injury_or_poisoning 65 | cell_function 66 | food 67 | immunologic_factor 68 | laboratory_procedure 69 | animal 70 | pharmacologic_substance 71 | cell 72 | physical_object 73 | bird 74 | mental_or_behavioral_dysfunction 75 | nucleic_acid_nucleoside_or_nucleotide 76 | biomedical_occupation_or_discipline 77 | receptor 78 | manufactured_object 79 | family_group 80 | anatomical_structure 81 | population_group 82 | element_ion_or_isotope 83 | spatial_concept 84 | vertebrate 85 | phenomenon_or_process 86 | substance 87 | body_substance 88 | fungus 89 | finding 90 | health_care_activity 91 | anatomical_abnormality 92 | qualitative_concept 93 | cell_or_molecular_dysfunction 94 | geographic_area 95 | group 96 | enzyme 97 | health_care_related_organization 98 | rickettsia_or_chlamydia 99 | fish 100 | clinical_attribute 101 | machine_activity 102 | entity 103 | intellectual_product 104 | organophosphorus_compound 105 | biologic_function 106 | body_part_organ_or_organ_component 107 | carbohydrate 108 | sign_or_symptom 109 | eicosanoid 110 | hazardous_or_poisonous_substance 111 | research_activity 112 | indicator_reagent_or_diagnostic_aid 113 | molecular_biology_research_technique 114 | clinical_drug 115 | activity 116 | quantitative_concept 117 | carbohydrate_sequence 118 | educational_activity 119 | event 120 | biomedical_or_dental_material 121 | biologically_active_substance 122 | environmental_effect_of_humans 123 | embryonic_structure 124 | vitamin 125 | virus 126 | chemical_viewed_structurally 127 | functional_concept 128 | professional_society 129 | mental_process 130 | self_help_or_relief_organization 131 | governmental_or_regulatory_activity 132 | language 133 | occupation_or_discipline 134 | congenital_abnormality 135 | body_location_or_region 136 | -------------------------------------------------------------------------------- /data/umls/umls.nlt: -------------------------------------------------------------------------------- 1 | 20 #1(X, Y) :- 2 | #2(X, Z), 3 | #3(Z, Y). 4 | 5 | 20 #1(X, Y) :- 6 | #2(X, Z), 7 | #2(Z, Y). 8 | 9 | 20 #1(X, Y) :- #2(X, Y). -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Interpreting the Computation Graph 2 | 3 | The Ts with the numbers informs you about the tensor dimensions 4 | 5 | The first T50 in the goal means we have 50 predicate representations (each k dimensional) 6 | 7 | The first rule (with T8544) tells us we are unifying the 50 goals with all 8544 facts in the KB 8 | 9 | The result is a tensor with 8544x50 proof success scores 10 | 11 | The next unification is more interesting… now we are unifying with 20 rules that have all the same structure 12 | 13 | We get 20x50 unification success scores 14 | 15 | Note the new variable bindings X1/T50… means we bound X1 to the 50 representations of the first arguments (entities) in the goal 16 | 17 | Next, we need to prove the body of the rule T20(Y1, X1) 18 | 19 | since we have 50 different success scores for each of the 20 body atoms, we need to construct 20*50=1000 goals -- this is where the tiling craziness begins. 20 | 21 | Note the difference between inner and outer tiling to make sure we keep the correct reference to the unification success scores 22 | 23 | Using the new goal (of 1000 atoms) we now unify with all facts in the KB — yielding 8544x1000 proof success scores 24 | 25 | The next one is a slightly more complicated rule (a transitivity) 26 | 27 | The mechanism is similar to the simple implication before… however now we are only keeping the 10max unifications after proving the first atom in the body of the rule 28 | 29 | Note how under the TF Warning we instead of 8544x1000 keep only 10x1000 successes (and correspondingly only 10x1000 variable bindings for Z2) 30 | -------------------------------------------------------------------------------- /docs/ntp_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/docs/ntp_graph.png -------------------------------------------------------------------------------- /models/kinship_complex/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/kinship_complex/events.out.tfevents.1494941798.brooks.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_complex/events.out.tfevents.1494941798.brooks.local -------------------------------------------------------------------------------- /models/kinship_complex/kinship_complex_alt.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": null 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/kinship_complex_alt.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/kinship/17-05-16/13-36-35/", 12 | "experiment_prefix": "kinship", 13 | "file_name": "kinship_complex_alt.conf", 14 | "name": "kinship_complex_alt", 15 | "output_predictions": false, 16 | "parent": "./conf/kinship.conf", 17 | "result_file": "./out/kinship/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": true, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/kinship_complex/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | term6 Predicate 4 | person100 Constant 5 | person80 Constant 6 | term10 Predicate 7 | person37 Constant 8 | person72 Constant 9 | term12 Predicate 10 | person49 Constant 11 | person39 Constant 12 | term4 Predicate 13 | person12 Constant 14 | person87 Constant 15 | term20 Predicate 16 | person10 Constant 17 | person48 Constant 18 | term11 Predicate 19 | person63 Constant 20 | term8 Predicate 21 | person36 Constant 22 | person45 Constant 23 | person68 Constant 24 | person40 Constant 25 | person82 Constant 26 | term5 Predicate 27 | person90 Constant 28 | person13 Constant 29 | term17 Predicate 30 | person17 Constant 31 | person69 Constant 32 | person103 Constant 33 | person0 Constant 34 | term15 Predicate 35 | term9 Predicate 36 | person65 Constant 37 | person11 Constant 38 | person9 Constant 39 | person92 Constant 40 | person62 Constant 41 | person102 Constant 42 | person66 Constant 43 | person70 Constant 44 | term1 Predicate 45 | person73 Constant 46 | person18 Constant 47 | person60 Constant 48 | term18 Predicate 49 | person26 Constant 50 | person50 Constant 51 | person89 Constant 52 | person38 Constant 53 | term13 Predicate 54 | person81 Constant 55 | person14 Constant 56 | term7 Predicate 57 | person21 Constant 58 | person53 Constant 59 | person67 Constant 60 | person28 Constant 61 | person24 Constant 62 | person95 Constant 63 | person51 Constant 64 | person3 Constant 65 | person41 Constant 66 | person99 Constant 67 | term0 Predicate 68 | person96 Constant 69 | person7 Constant 70 | term16 Predicate 71 | person54 Constant 72 | person15 Constant 73 | person1 Constant 74 | person29 Constant 75 | term2 Predicate 76 | person78 Constant 77 | person31 Constant 78 | person83 Constant 79 | person33 Constant 80 | term3 Predicate 81 | person2 Constant 82 | person58 Constant 83 | person52 Constant 84 | person79 Constant 85 | person27 Constant 86 | person32 Constant 87 | person76 Constant 88 | person85 Constant 89 | person101 Constant 90 | person8 Constant 91 | person35 Constant 92 | person23 Constant 93 | person5 Constant 94 | person64 Constant 95 | person77 Constant 96 | term22 Predicate 97 | person86 Constant 98 | person93 Constant 99 | person91 Constant 100 | person4 Constant 101 | person42 Constant 102 | person22 Constant 103 | person19 Constant 104 | person47 Constant 105 | person20 Constant 106 | person46 Constant 107 | person25 Constant 108 | person75 Constant 109 | person71 Constant 110 | person56 Constant 111 | term21 Predicate 112 | person43 Constant 113 | person88 Constant 114 | person6 Constant 115 | person57 Constant 116 | person94 Constant 117 | person61 Constant 118 | person16 Constant 119 | person98 Constant 120 | person55 Constant 121 | term14 Predicate 122 | person97 Constant 123 | person74 Constant 124 | person84 Constant 125 | person30 Constant 126 | person34 Constant 127 | person59 Constant 128 | person44 Constant 129 | term19 Predicate 130 | term25 Predicate 131 | term24 Predicate 132 | -------------------------------------------------------------------------------- /models/kinship_complex/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_complex/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/kinship_complex/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_complex/model.ckpt-0.index -------------------------------------------------------------------------------- /models/kinship_complex/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_complex/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/kinship_complex/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/kinship_complex/rules.nl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_complex/rules.nl -------------------------------------------------------------------------------- /models/kinship_complex/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/kinship_complex_alt.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/kinship/17-05-16/13-36-35/", 12 | "experiment_prefix": "kinship", 13 | "file_name": "kinship_complex_alt.conf", 14 | "name": "kinship_complex_alt", 15 | "output_predictions": False, 16 | "parent": "./conf/kinship.conf", 17 | "result_file": "./out/kinship/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": False, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": False 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": False, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/kinship_ntp/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/kinship_ntp/events.out.tfevents.1494927548.brooks.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntp/events.out.tfevents.1494927548.brooks.local -------------------------------------------------------------------------------- /models/kinship_ntp/kinship_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/kinship_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/kinship/17-05-16/09-38-44/", 12 | "experiment_prefix": "kinship", 13 | "file_name": "kinship_ntp.conf", 14 | "name": "kinship_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/kinship.conf", 17 | "result_file": "./out/kinship/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": null, 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/kinship_ntp/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | term6 Predicate 4 | person100 Constant 5 | person80 Constant 6 | term10 Predicate 7 | person37 Constant 8 | person72 Constant 9 | term12 Predicate 10 | person49 Constant 11 | person39 Constant 12 | term4 Predicate 13 | person12 Constant 14 | person87 Constant 15 | term20 Predicate 16 | person10 Constant 17 | person48 Constant 18 | term11 Predicate 19 | person63 Constant 20 | term8 Predicate 21 | person36 Constant 22 | person45 Constant 23 | person68 Constant 24 | person40 Constant 25 | person82 Constant 26 | term5 Predicate 27 | person90 Constant 28 | person13 Constant 29 | term17 Predicate 30 | person17 Constant 31 | person69 Constant 32 | person103 Constant 33 | person0 Constant 34 | term15 Predicate 35 | term9 Predicate 36 | person65 Constant 37 | person11 Constant 38 | person9 Constant 39 | person92 Constant 40 | person62 Constant 41 | person102 Constant 42 | person66 Constant 43 | person70 Constant 44 | term1 Predicate 45 | person73 Constant 46 | person18 Constant 47 | person60 Constant 48 | term18 Predicate 49 | person26 Constant 50 | person50 Constant 51 | person89 Constant 52 | person38 Constant 53 | term13 Predicate 54 | person81 Constant 55 | person14 Constant 56 | term7 Predicate 57 | person21 Constant 58 | person53 Constant 59 | person67 Constant 60 | person28 Constant 61 | person24 Constant 62 | person95 Constant 63 | person51 Constant 64 | person3 Constant 65 | person41 Constant 66 | person99 Constant 67 | term0 Predicate 68 | person96 Constant 69 | person7 Constant 70 | term16 Predicate 71 | person54 Constant 72 | person15 Constant 73 | person1 Constant 74 | person29 Constant 75 | term2 Predicate 76 | person78 Constant 77 | person31 Constant 78 | person83 Constant 79 | person33 Constant 80 | term3 Predicate 81 | person2 Constant 82 | person58 Constant 83 | person52 Constant 84 | person79 Constant 85 | person27 Constant 86 | person32 Constant 87 | person76 Constant 88 | person85 Constant 89 | person101 Constant 90 | person8 Constant 91 | person35 Constant 92 | person23 Constant 93 | person5 Constant 94 | person64 Constant 95 | person77 Constant 96 | term22 Predicate 97 | person86 Constant 98 | person93 Constant 99 | person91 Constant 100 | person4 Constant 101 | person42 Constant 102 | person22 Constant 103 | person19 Constant 104 | person47 Constant 105 | person20 Constant 106 | person46 Constant 107 | person25 Constant 108 | person75 Constant 109 | person71 Constant 110 | person56 Constant 111 | term21 Predicate 112 | person43 Constant 113 | person88 Constant 114 | person6 Constant 115 | person57 Constant 116 | person94 Constant 117 | person61 Constant 118 | person16 Constant 119 | person98 Constant 120 | person55 Constant 121 | term14 Predicate 122 | person97 Constant 123 | person74 Constant 124 | person84 Constant 125 | person30 Constant 126 | person34 Constant 127 | person59 Constant 128 | person44 Constant 129 | term19 Predicate 130 | term25 Predicate 131 | term24 Predicate 132 | #1_2_0 Param 133 | #2_2_0 Param 134 | #3_2_0 Param 135 | #1_2_1 Param 136 | #2_2_1 Param 137 | #3_2_1 Param 138 | #1_2_2 Param 139 | #2_2_2 Param 140 | #3_2_2 Param 141 | #1_2_3 Param 142 | #2_2_3 Param 143 | #3_2_3 Param 144 | #1_2_4 Param 145 | #2_2_4 Param 146 | #3_2_4 Param 147 | #1_2_5 Param 148 | #2_2_5 Param 149 | #3_2_5 Param 150 | #1_2_6 Param 151 | #2_2_6 Param 152 | #3_2_6 Param 153 | #1_2_7 Param 154 | #2_2_7 Param 155 | #3_2_7 Param 156 | #1_2_8 Param 157 | #2_2_8 Param 158 | #3_2_8 Param 159 | #1_2_9 Param 160 | #2_2_9 Param 161 | #3_2_9 Param 162 | #1_2_10 Param 163 | #2_2_10 Param 164 | #3_2_10 Param 165 | #1_2_11 Param 166 | #2_2_11 Param 167 | #3_2_11 Param 168 | #1_2_12 Param 169 | #2_2_12 Param 170 | #3_2_12 Param 171 | #1_2_13 Param 172 | #2_2_13 Param 173 | #3_2_13 Param 174 | #1_2_14 Param 175 | #2_2_14 Param 176 | #3_2_14 Param 177 | #1_2_15 Param 178 | #2_2_15 Param 179 | #3_2_15 Param 180 | #1_2_16 Param 181 | #2_2_16 Param 182 | #3_2_16 Param 183 | #1_2_17 Param 184 | #2_2_17 Param 185 | #3_2_17 Param 186 | #1_2_18 Param 187 | #2_2_18 Param 188 | #3_2_18 Param 189 | #1_2_19 Param 190 | #2_2_19 Param 191 | #3_2_19 Param 192 | #1_0_0 Param 193 | #2_0_0 Param 194 | #1_0_1 Param 195 | #2_0_1 Param 196 | #1_0_2 Param 197 | #2_0_2 Param 198 | #1_0_3 Param 199 | #2_0_3 Param 200 | #1_0_4 Param 201 | #2_0_4 Param 202 | #1_0_5 Param 203 | #2_0_5 Param 204 | #1_0_6 Param 205 | #2_0_6 Param 206 | #1_0_7 Param 207 | #2_0_7 Param 208 | #1_0_8 Param 209 | #2_0_8 Param 210 | #1_0_9 Param 211 | #2_0_9 Param 212 | #1_0_10 Param 213 | #2_0_10 Param 214 | #1_0_11 Param 215 | #2_0_11 Param 216 | #1_0_12 Param 217 | #2_0_12 Param 218 | #1_0_13 Param 219 | #2_0_13 Param 220 | #1_0_14 Param 221 | #2_0_14 Param 222 | #1_0_15 Param 223 | #2_0_15 Param 224 | #1_0_16 Param 225 | #2_0_16 Param 226 | #1_0_17 Param 227 | #2_0_17 Param 228 | #1_0_18 Param 229 | #2_0_18 Param 230 | #1_0_19 Param 231 | #2_0_19 Param 232 | #1_1_0 Param 233 | #2_1_0 Param 234 | #1_1_1 Param 235 | #2_1_1 Param 236 | #1_1_2 Param 237 | #2_1_2 Param 238 | #1_1_3 Param 239 | #2_1_3 Param 240 | #1_1_4 Param 241 | #2_1_4 Param 242 | #1_1_5 Param 243 | #2_1_5 Param 244 | #1_1_6 Param 245 | #2_1_6 Param 246 | #1_1_7 Param 247 | #2_1_7 Param 248 | #1_1_8 Param 249 | #2_1_8 Param 250 | #1_1_9 Param 251 | #2_1_9 Param 252 | #1_1_10 Param 253 | #2_1_10 Param 254 | #1_1_11 Param 255 | #2_1_11 Param 256 | #1_1_12 Param 257 | #2_1_12 Param 258 | #1_1_13 Param 259 | #2_1_13 Param 260 | #1_1_14 Param 261 | #2_1_14 Param 262 | #1_1_15 Param 263 | #2_1_15 Param 264 | #1_1_16 Param 265 | #2_1_16 Param 266 | #1_1_17 Param 267 | #2_1_17 Param 268 | #1_1_18 Param 269 | #2_1_18 Param 270 | #1_1_19 Param 271 | #2_1_19 Param 272 | -------------------------------------------------------------------------------- /models/kinship_ntp/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntp/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/kinship_ntp/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntp/model.ckpt-0.index -------------------------------------------------------------------------------- /models/kinship_ntp/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntp/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/kinship_ntp/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/kinship_ntp/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p2', 'X2', 'X1')) 2 | 0.612706 term11(X,Y) :- term11(X,Z), term11(Z,Y). 3 | 0.579304 term16(X,Y) :- term16(X,Z), term11(Z,Y). 4 | 0.0477242 term25(X,Y) :- term24(X,Z), term24(Z,Y). 5 | 0.0398933 term25(X,Y) :- term24(X,Z), term24(Z,Y). 6 | 0.0397091 term25(X,Y) :- term24(X,Z), term24(Z,Y). 7 | 0.039663 term25(X,Y) :- term24(X,Z), term24(Z,Y). 8 | 0.0396415 term25(X,Y) :- term24(X,Z), term24(Z,Y). 9 | 0.0395722 term25(X,Y) :- term24(X,Z), term24(Z,Y). 10 | 0.0394746 term25(X,Y) :- term24(X,Z), term24(Z,Y). 11 | 0.0391767 term25(X,Y) :- term24(X,Z), term24(Z,Y). 12 | 0.0390129 term25(X,Y) :- term24(X,Z), term24(Z,Y). 13 | 0.0389618 term25(X,Y) :- term24(X,Z), term24(Z,Y). 14 | 0.0176708 term24(X,Y) :- term24(X,Z), term24(Z,Y). 15 | 0.0175768 term24(X,Y) :- term24(X,Z), term24(Z,Y). 16 | 0.0175594 term24(X,Y) :- term24(X,Z), term24(Z,Y). 17 | 0.0175291 term24(X,Y) :- term24(X,Z), term24(Z,Y). 18 | 0.0173265 term24(X,Y) :- term24(X,Z), term24(Z,Y). 19 | 0.016085 term24(X,Y) :- term24(X,Z), term24(Z,Y). 20 | 0.0160308 term24(X,Y) :- term24(X,Z), term24(Z,Y). 21 | 0.0158281 term24(X,Y) :- term22(X,Z), term24(Z,Y). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 24 | 0.0485452 term24(X,Y) :- term25(X,Y). 25 | 0.0438157 term24(X,Y) :- term24(X,Y). 26 | 0.0430116 term25(X,Y) :- term25(X,Y). 27 | 0.0427952 term25(X,Y) :- term25(X,Y). 28 | 0.0426511 term25(X,Y) :- term25(X,Y). 29 | 0.0397399 term25(X,Y) :- term24(X,Y). 30 | 0.0396426 term25(X,Y) :- term24(X,Y). 31 | 0.0396241 term25(X,Y) :- term24(X,Y). 32 | 0.0396068 term25(X,Y) :- term24(X,Y). 33 | 0.0395567 term25(X,Y) :- term24(X,Y). 34 | 0.0395553 term25(X,Y) :- term24(X,Y). 35 | 0.0394815 term25(X,Y) :- term24(X,Y). 36 | 0.0394701 term25(X,Y) :- term24(X,Y). 37 | 0.039295 term25(X,Y) :- term24(X,Y). 38 | 0.0380241 term25(X,Y) :- term24(X,Y). 39 | 0.0369799 term25(X,Y) :- term24(X,Y). 40 | 0.0367271 term24(X,Y) :- term25(X,Y). 41 | 0.0365823 term24(X,Y) :- term25(X,Y). 42 | 0.0363483 term24(X,Y) :- term25(X,Y). 43 | 0.0358342 term24(X,Y) :- term25(X,Y). 44 | 45 | (('p0', 'X0', 'X1'), ('p1', 'X1', 'X0')) 46 | 0.721879 term22(X,Y) :- term22(Y,X). 47 | 0.679513 term25(X,Y) :- term20(Y,X). 48 | 0.0399259 term25(X,Y) :- term24(Y,X). 49 | 0.0398381 term25(X,Y) :- term24(Y,X). 50 | 0.0398027 term25(X,Y) :- term24(Y,X). 51 | 0.0397957 term25(X,Y) :- term24(Y,X). 52 | 0.0397676 term25(X,Y) :- term24(Y,X). 53 | 0.0397323 term25(X,Y) :- term24(Y,X). 54 | 0.0397031 term25(X,Y) :- term24(Y,X). 55 | 0.0397029 term25(X,Y) :- term24(Y,X). 56 | 0.039682 term25(X,Y) :- term24(Y,X). 57 | 0.0396311 term25(X,Y) :- term24(Y,X). 58 | 0.0393499 term25(X,Y) :- term24(Y,X). 59 | 0.0388464 term25(X,Y) :- term24(Y,X). 60 | 0.0387782 term25(X,Y) :- term24(Y,X). 61 | 0.0385092 term25(X,Y) :- term24(Y,X). 62 | 0.0383409 term25(X,Y) :- term24(Y,X). 63 | 0.0312516 term24(X,Y) :- term25(Y,X). 64 | 0.0311613 term24(X,Y) :- term25(Y,X). 65 | 0.0310667 term24(X,Y) :- term25(Y,X). 66 | 67 | -------------------------------------------------------------------------------- /models/kinship_ntp/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/kinship_ntp.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/kinship/17-05-16/09-38-44/", 12 | "experiment_prefix": "kinship", 13 | "file_name": "kinship_ntp.conf", 14 | "name": "kinship_ntp", 15 | "output_predictions": False, 16 | "parent": "./conf/kinship.conf", 17 | "result_file": "./out/kinship/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": False, 22 | "tfdbg": False, 23 | "train": True, 24 | "permutation": [2, 1, 3, 0] 25 | }, 26 | "model": { 27 | "aggregate_fun": "Max", 28 | "input_size": 100, 29 | "k_max": 10, 30 | "keep_prob": 1.0, 31 | "l2": 0.001, 32 | "max_depth": 1, 33 | "name": "NTP", 34 | "neural_link_predictor": None, 35 | "train_0ntp": True, 36 | "unification": "cos", 37 | "unit_normalize": False 38 | }, 39 | "training": { 40 | "clip": [ 41 | -1.0, 42 | 1.0 43 | ], 44 | "epsilon": 1e-10, 45 | "init": [ 46 | -1.0, 47 | 1.0 48 | ], 49 | "learning_rate": 0.001, 50 | "mean_loss": False, 51 | "neg_per_pos": 1, 52 | "num_epochs": 100, 53 | "optimizer": "Adam", 54 | "pos_per_batch": 10, 55 | "report_interval": 10, 56 | "sampling_scheme": "all" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /models/kinship_ntp/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/kinship_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/kinship/17-05-16/09-38-44/", 12 | "experiment_prefix": "kinship", 13 | "file_name": "kinship_ntp.conf", 14 | "name": "kinship_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/kinship.conf", 17 | "result_file": "./out/kinship/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": None, 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/kinship_ntpl/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/kinship_ntpl/events.out.tfevents.1494498458.korman.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntpl/events.out.tfevents.1494498458.korman.local -------------------------------------------------------------------------------- /models/kinship_ntpl/kinship_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/kinship_ntp_complex_reg.conf", 9 | "debug": false, 10 | "experiment_dir": "./out/kinship/17-05-11/10-27-10/", 11 | "experiment_prefix": "kinship", 12 | "file_name": "kinship_ntp_complex_reg.conf", 13 | "name": "kinship_ntp_complex_reg", 14 | "output_predictions": false, 15 | "parent": "./conf/kinship.conf", 16 | "result_file": "./out/kinship/results.tsv", 17 | "test_graph_creation": false, 18 | "test_set": "test", 19 | "test_time_batching": false, 20 | "test_time_neural_link_prediction": false, 21 | "tfdbg": false, 22 | "train": true 23 | }, 24 | "model": { 25 | "aggregate_fun": "Max", 26 | "input_size": 100, 27 | "k_max": 10, 28 | "keep_prob": 1.0, 29 | "l2": 0.001, 30 | "name": "NTP ComplEx Reg", 31 | "neural_link_predictor": "ComplEx", 32 | "train_0ntp": true, 33 | "unification": "cos", 34 | "unit_normalize": false 35 | }, 36 | "training": { 37 | "clip": [ 38 | -1.0, 39 | 1.0 40 | ], 41 | "epsilon": 1e-10, 42 | "init": [ 43 | -1.0, 44 | 1.0 45 | ], 46 | "learning_rate": 0.001, 47 | "mean_loss": false, 48 | "neg_per_pos": 1, 49 | "num_epochs": 100, 50 | "optimizer": "Adam", 51 | "pos_per_batch": 10, 52 | "report_interval": 10, 53 | "sampling_scheme": "all" 54 | } 55 | } -------------------------------------------------------------------------------- /models/kinship_ntpl/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | term6 Predicate 4 | person100 Constant 5 | person80 Constant 6 | term10 Predicate 7 | person37 Constant 8 | person72 Constant 9 | term12 Predicate 10 | person49 Constant 11 | person39 Constant 12 | term4 Predicate 13 | person12 Constant 14 | person87 Constant 15 | term20 Predicate 16 | person10 Constant 17 | person48 Constant 18 | term11 Predicate 19 | person63 Constant 20 | term8 Predicate 21 | person36 Constant 22 | person45 Constant 23 | person68 Constant 24 | person40 Constant 25 | person82 Constant 26 | term5 Predicate 27 | person90 Constant 28 | person13 Constant 29 | term17 Predicate 30 | person17 Constant 31 | person69 Constant 32 | person103 Constant 33 | person0 Constant 34 | term15 Predicate 35 | term9 Predicate 36 | person65 Constant 37 | person11 Constant 38 | person9 Constant 39 | person92 Constant 40 | person62 Constant 41 | person102 Constant 42 | person66 Constant 43 | person70 Constant 44 | term1 Predicate 45 | person73 Constant 46 | person18 Constant 47 | person60 Constant 48 | term18 Predicate 49 | person26 Constant 50 | person50 Constant 51 | person89 Constant 52 | person38 Constant 53 | term13 Predicate 54 | person81 Constant 55 | person14 Constant 56 | term7 Predicate 57 | person21 Constant 58 | person53 Constant 59 | person67 Constant 60 | person28 Constant 61 | person24 Constant 62 | person95 Constant 63 | person51 Constant 64 | person3 Constant 65 | person41 Constant 66 | person99 Constant 67 | term0 Predicate 68 | person96 Constant 69 | person7 Constant 70 | term16 Predicate 71 | person54 Constant 72 | person15 Constant 73 | person1 Constant 74 | person29 Constant 75 | term2 Predicate 76 | person78 Constant 77 | person31 Constant 78 | person83 Constant 79 | person33 Constant 80 | term3 Predicate 81 | person2 Constant 82 | person58 Constant 83 | person52 Constant 84 | person79 Constant 85 | person27 Constant 86 | person32 Constant 87 | person76 Constant 88 | person85 Constant 89 | person101 Constant 90 | person8 Constant 91 | person35 Constant 92 | person23 Constant 93 | person5 Constant 94 | person64 Constant 95 | person77 Constant 96 | term22 Predicate 97 | person86 Constant 98 | person93 Constant 99 | person91 Constant 100 | person4 Constant 101 | person42 Constant 102 | person22 Constant 103 | person19 Constant 104 | person47 Constant 105 | person20 Constant 106 | person46 Constant 107 | person25 Constant 108 | person75 Constant 109 | person71 Constant 110 | person56 Constant 111 | term21 Predicate 112 | person43 Constant 113 | person88 Constant 114 | person6 Constant 115 | person57 Constant 116 | person94 Constant 117 | person61 Constant 118 | person16 Constant 119 | person98 Constant 120 | person55 Constant 121 | term14 Predicate 122 | person97 Constant 123 | person74 Constant 124 | person84 Constant 125 | person30 Constant 126 | person34 Constant 127 | person59 Constant 128 | person44 Constant 129 | term19 Predicate 130 | term25 Predicate 131 | term24 Predicate 132 | #1_2_0 Param 133 | #2_2_0 Param 134 | #3_2_0 Param 135 | #1_2_1 Param 136 | #2_2_1 Param 137 | #3_2_1 Param 138 | #1_2_2 Param 139 | #2_2_2 Param 140 | #3_2_2 Param 141 | #1_2_3 Param 142 | #2_2_3 Param 143 | #3_2_3 Param 144 | #1_2_4 Param 145 | #2_2_4 Param 146 | #3_2_4 Param 147 | #1_2_5 Param 148 | #2_2_5 Param 149 | #3_2_5 Param 150 | #1_2_6 Param 151 | #2_2_6 Param 152 | #3_2_6 Param 153 | #1_2_7 Param 154 | #2_2_7 Param 155 | #3_2_7 Param 156 | #1_2_8 Param 157 | #2_2_8 Param 158 | #3_2_8 Param 159 | #1_2_9 Param 160 | #2_2_9 Param 161 | #3_2_9 Param 162 | #1_2_10 Param 163 | #2_2_10 Param 164 | #3_2_10 Param 165 | #1_2_11 Param 166 | #2_2_11 Param 167 | #3_2_11 Param 168 | #1_2_12 Param 169 | #2_2_12 Param 170 | #3_2_12 Param 171 | #1_2_13 Param 172 | #2_2_13 Param 173 | #3_2_13 Param 174 | #1_2_14 Param 175 | #2_2_14 Param 176 | #3_2_14 Param 177 | #1_2_15 Param 178 | #2_2_15 Param 179 | #3_2_15 Param 180 | #1_2_16 Param 181 | #2_2_16 Param 182 | #3_2_16 Param 183 | #1_2_17 Param 184 | #2_2_17 Param 185 | #3_2_17 Param 186 | #1_2_18 Param 187 | #2_2_18 Param 188 | #3_2_18 Param 189 | #1_2_19 Param 190 | #2_2_19 Param 191 | #3_2_19 Param 192 | #1_1_0 Param 193 | #2_1_0 Param 194 | #1_1_1 Param 195 | #2_1_1 Param 196 | #1_1_2 Param 197 | #2_1_2 Param 198 | #1_1_3 Param 199 | #2_1_3 Param 200 | #1_1_4 Param 201 | #2_1_4 Param 202 | #1_1_5 Param 203 | #2_1_5 Param 204 | #1_1_6 Param 205 | #2_1_6 Param 206 | #1_1_7 Param 207 | #2_1_7 Param 208 | #1_1_8 Param 209 | #2_1_8 Param 210 | #1_1_9 Param 211 | #2_1_9 Param 212 | #1_1_10 Param 213 | #2_1_10 Param 214 | #1_1_11 Param 215 | #2_1_11 Param 216 | #1_1_12 Param 217 | #2_1_12 Param 218 | #1_1_13 Param 219 | #2_1_13 Param 220 | #1_1_14 Param 221 | #2_1_14 Param 222 | #1_1_15 Param 223 | #2_1_15 Param 224 | #1_1_16 Param 225 | #2_1_16 Param 226 | #1_1_17 Param 227 | #2_1_17 Param 228 | #1_1_18 Param 229 | #2_1_18 Param 230 | #1_1_19 Param 231 | #2_1_19 Param 232 | #1_0_0 Param 233 | #2_0_0 Param 234 | #1_0_1 Param 235 | #2_0_1 Param 236 | #1_0_2 Param 237 | #2_0_2 Param 238 | #1_0_3 Param 239 | #2_0_3 Param 240 | #1_0_4 Param 241 | #2_0_4 Param 242 | #1_0_5 Param 243 | #2_0_5 Param 244 | #1_0_6 Param 245 | #2_0_6 Param 246 | #1_0_7 Param 247 | #2_0_7 Param 248 | #1_0_8 Param 249 | #2_0_8 Param 250 | #1_0_9 Param 251 | #2_0_9 Param 252 | #1_0_10 Param 253 | #2_0_10 Param 254 | #1_0_11 Param 255 | #2_0_11 Param 256 | #1_0_12 Param 257 | #2_0_12 Param 258 | #1_0_13 Param 259 | #2_0_13 Param 260 | #1_0_14 Param 261 | #2_0_14 Param 262 | #1_0_15 Param 263 | #2_0_15 Param 264 | #1_0_16 Param 265 | #2_0_16 Param 266 | #1_0_17 Param 267 | #2_0_17 Param 268 | #1_0_18 Param 269 | #2_0_18 Param 270 | #1_0_19 Param 271 | #2_0_19 Param 272 | -------------------------------------------------------------------------------- /models/kinship_ntpl/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntpl/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/kinship_ntpl/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntpl/model.ckpt-0.index -------------------------------------------------------------------------------- /models/kinship_ntpl/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/kinship_ntpl/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/kinship_ntpl/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/kinship_ntpl/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p2', 'X2', 'X1')) 2 | 0.727643 term12(X,Y) :- term10(X,Z), term12(Z,Y). 3 | 0.523665 term21(X,Y) :- term16(X,Z), term6(Z,Y). 4 | 0.511183 term1(X,Y) :- term16(X,Z), term16(Z,Y). 5 | 0.485173 term9(X,Y) :- term16(X,Z), term8(Z,Y). 6 | 0.390947 term11(X,Y) :- term7(X,Z), term16(Z,Y). 7 | 0.313335 term13(X,Y) :- term7(X,Z), term6(Z,Y). 8 | 0.13633 term25(X,Y) :- term16(X,Z), term15(Z,Y). 9 | 0.030528 term24(X,Y) :- term24(X,Z), term24(Z,Y). 10 | 0.0304016 term24(X,Y) :- term24(X,Z), term24(Z,Y). 11 | 0.0302747 term24(X,Y) :- term24(X,Z), term24(Z,Y). 12 | 0.0301015 term24(X,Y) :- term24(X,Z), term24(Z,Y). 13 | 0.0293984 term24(X,Y) :- term24(X,Z), term24(Z,Y). 14 | 0.015644 term24(X,Y) :- term24(X,Z), term24(Z,Y). 15 | 0.0155818 term24(X,Y) :- term24(X,Z), term24(Z,Y). 16 | 0.0155679 term24(X,Y) :- term24(X,Z), term24(Z,Y). 17 | 0.0152711 term24(X,Y) :- term24(X,Z), term24(Z,Y). 18 | 0.0151357 term24(X,Y) :- term24(X,Z), term24(Z,Y). 19 | 0.00863563 term24(X,Y) :- term24(X,Z), term24(Z,Y). 20 | 0.0086311 term24(X,Y) :- term24(X,Z), term24(Z,Y). 21 | 0.00858056 term24(X,Y) :- term24(X,Z), term24(Z,Y). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X1', 'X0')) 24 | 0.977399 term15(X,Y) :- term5(Y,X). 25 | 0.971542 term18(X,Y) :- term18(Y,X). 26 | 0.861957 term4(X,Y) :- term4(Y,X). 27 | 0.830567 term15(X,Y) :- term6(Y,X). 28 | 0.614535 term16(X,Y) :- term8(Y,X). 29 | 0.613399 term7(X,Y) :- term16(Y,X). 30 | 0.28321 term19(X,Y) :- term8(Y,X). 31 | 0.0513783 term24(X,Y) :- term24(Y,X). 32 | 0.0498855 term24(X,Y) :- term24(Y,X). 33 | 0.0311305 term24(X,Y) :- term24(Y,X). 34 | 0.0310689 term24(X,Y) :- term24(Y,X). 35 | 0.0310119 term24(X,Y) :- term24(Y,X). 36 | 0.0307208 term24(X,Y) :- term24(Y,X). 37 | 0.0304906 term24(X,Y) :- term24(Y,X). 38 | 0.0303 term24(X,Y) :- term24(Y,X). 39 | 0.0302771 term24(X,Y) :- term19(Y,X). 40 | 0.030032 term24(X,Y) :- term24(Y,X). 41 | 0.0300076 term24(X,Y) :- term24(Y,X). 42 | 0.029767 term24(X,Y) :- term19(Y,X). 43 | 0.0296001 term24(X,Y) :- term24(Y,X). 44 | 45 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 46 | 0.0515215 term24(X,Y) :- term24(X,Y). 47 | 0.0514744 term24(X,Y) :- term24(X,Y). 48 | 0.0315999 term24(X,Y) :- term24(X,Y). 49 | 0.0315819 term24(X,Y) :- term24(X,Y). 50 | 0.0315799 term24(X,Y) :- term24(X,Y). 51 | 0.0315623 term24(X,Y) :- term24(X,Y). 52 | 0.0315365 term24(X,Y) :- term24(X,Y). 53 | 0.0315348 term24(X,Y) :- term24(X,Y). 54 | 0.0315074 term24(X,Y) :- term24(X,Y). 55 | 0.0314439 term24(X,Y) :- term24(X,Y). 56 | 0.0314383 term24(X,Y) :- term24(X,Y). 57 | 0.0314138 term24(X,Y) :- term24(X,Y). 58 | 0.0313414 term24(X,Y) :- term24(X,Y). 59 | 0.0313305 term24(X,Y) :- term24(X,Y). 60 | 0.0307665 term24(X,Y) :- term19(X,Y). 61 | 0.0306403 term24(X,Y) :- term19(X,Y). 62 | 0.0306219 term24(X,Y) :- term19(X,Y). 63 | 0.0302528 term24(X,Y) :- term19(X,Y). 64 | 0.0300563 term24(X,Y) :- term24(X,Y). 65 | 0.029975 term24(X,Y) :- term24(X,Y). 66 | 67 | -------------------------------------------------------------------------------- /models/kinship_ntpl/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/kinship_ntp_complex_reg.conf", 9 | "debug": False, 10 | "experiment_dir": "./out/kinship/17-05-11/10-27-10/", 11 | "experiment_prefix": "kinship", 12 | "file_name": "kinship_ntp_complex_reg.conf", 13 | "name": "kinship_ntp_complex_reg", 14 | "output_predictions": False, 15 | "parent": "./conf/kinship.conf", 16 | "result_file": "./out/kinship/results.tsv", 17 | "test_graph_creation": False, 18 | "test_set": "test", 19 | "test_time_batching": False, 20 | "test_time_neural_link_prediction": False, 21 | "tfdbg": False, 22 | "train": True, 23 | "permutation": [3, 1, 2, 0] 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "name": "NTP ComplEx Reg", 32 | "neural_link_predictor": "ComplEx", 33 | "train_0ntp": True, 34 | "unification": "cos", 35 | "unit_normalize": False 36 | }, 37 | "training": { 38 | "clip": [ 39 | -1.0, 40 | 1.0 41 | ], 42 | "epsilon": 1e-10, 43 | "init": [ 44 | -1.0, 45 | 1.0 46 | ], 47 | "learning_rate": 0.001, 48 | "mean_loss": False, 49 | "neg_per_pos": 1, 50 | "num_epochs": 100, 51 | "optimizer": "Adam", 52 | "pos_per_batch": 10, 53 | "report_interval": 10, 54 | "sampling_scheme": "all" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /models/kinship_ntpl/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/kinship/train.nl", 4 | "templates": "./data/kinship/kinship.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/kinship_ntp_complex_reg.conf", 9 | "debug": false, 10 | "experiment_dir": "./out/kinship/17-05-11/10-27-10/", 11 | "experiment_prefix": "kinship", 12 | "file_name": "kinship_ntp_complex_reg.conf", 13 | "name": "kinship_ntp_complex_reg", 14 | "output_predictions": false, 15 | "parent": "./conf/kinship.conf", 16 | "result_file": "./out/kinship/results.tsv", 17 | "test_graph_creation": false, 18 | "test_set": "test", 19 | "test_time_batching": false, 20 | "test_time_neural_link_prediction": false, 21 | "tfdbg": false, 22 | "train": True 23 | }, 24 | "model": { 25 | "aggregate_fun": "Max", 26 | "input_size": 100, 27 | "k_max": 10, 28 | "keep_prob": 1.0, 29 | "l2": 0.001, 30 | "name": "NTP ComplEx Reg", 31 | "neural_link_predictor": "ComplEx", 32 | "train_0ntp": True, 33 | "unification": "cos", 34 | "unit_normalize": false 35 | }, 36 | "training": { 37 | "clip": [ 38 | -1.0, 39 | 1.0 40 | ], 41 | "epsilon": 1e-10, 42 | "init": [ 43 | -1.0, 44 | 1.0 45 | ], 46 | "learning_rate": 0.001, 47 | "mean_loss": false, 48 | "neg_per_pos": 1, 49 | "num_epochs": 100, 50 | "optimizer": "Adam", 51 | "pos_per_batch": 10, 52 | "report_interval": 10, 53 | "sampling_scheme": "all" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /models/nations_complex/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/nations_complex/events.out.tfevents.1495140729.tesla5.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_complex/events.out.tfevents.1495140729.tesla5.local -------------------------------------------------------------------------------- /models/nations_complex/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | militaryalliance Predicate 4 | netherlands Constant 5 | uk Constant 6 | intergovorgs3 Predicate 7 | egypt Constant 8 | usa Constant 9 | relbooktranslations Predicate 10 | jordan Constant 11 | timesincewar Predicate 12 | poland Constant 13 | ussr Constant 14 | negativebehavior Predicate 15 | relintergovorgs Predicate 16 | weightedunvote Predicate 17 | india Constant 18 | accusation Predicate 19 | china Constant 20 | unweightedunvote Predicate 21 | embassy Predicate 22 | commonbloc1 Predicate 23 | cuba Constant 24 | indonesia Constant 25 | commonbloc2 Predicate 26 | israel Constant 27 | ngoorgs3 Predicate 28 | brazil Constant 29 | exports3 Predicate 30 | economicaid Predicate 31 | booktranslations Predicate 32 | relexports Predicate 33 | intergovorgs Predicate 34 | independence Predicate 35 | reltreaties Predicate 36 | ngo Predicate 37 | blockpositionindex Predicate 38 | burma Constant 39 | relstudents Predicate 40 | aidenemy Predicate 41 | eemigrants Predicate 42 | officialvisits Predicate 43 | unoffialacts Predicate 44 | releconomicaid Predicate 45 | commonbloc0 Predicate 46 | expeldiplomats Predicate 47 | relngo Predicate 48 | students Predicate 49 | nonviolentbehavior Predicate 50 | reldiplomacy Predicate 51 | tourism Predicate 52 | timesinceally Predicate 53 | conferences Predicate 54 | relexportbooks Predicate 55 | treaties Predicate 56 | militaryactions Predicate 57 | exportbooks Predicate 58 | boycottembargo Predicate 59 | negativecomm Predicate 60 | tourism3 Predicate 61 | reltourism Predicate 62 | pprotests Predicate 63 | emigrants3 Predicate 64 | duration Predicate 65 | attackembassy Predicate 66 | dependent Predicate 67 | violentactions Predicate 68 | relemigrants Predicate 69 | warning Predicate 70 | lostterritory Predicate 71 | severdiplomatic Predicate 72 | -------------------------------------------------------------------------------- /models/nations_complex/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_complex/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/nations_complex/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_complex/model.ckpt-0.index -------------------------------------------------------------------------------- /models/nations_complex/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_complex/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/nations_complex/nations_complex.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": null 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_complex.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-51-41/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_complex.conf", 14 | "name": "nations_complex", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": true, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 0.7, 30 | "l2": 0.01, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": false, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": null, 45 | "learning_rate": 0.001, 46 | "mean_loss": false, 47 | "neg_per_pos": 1, 48 | "num_epochs": 100, 49 | "optimizer": "Adam", 50 | "pos_per_batch": 10, 51 | "report_interval": 10, 52 | "sampling_scheme": "all" 53 | } 54 | } -------------------------------------------------------------------------------- /models/nations_complex/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/nations_complex/rules.nl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_complex/rules.nl -------------------------------------------------------------------------------- /models/nations_complex/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/nations_complex.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/nations/17-05-18/20-51-41/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_complex.conf", 14 | "name": "nations_complex", 15 | "output_predictions": False, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": False, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 0.7, 30 | "l2": 0.01, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": False, 35 | "unification": "cos", 36 | "unit_normalize": False 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": None, 45 | "learning_rate": 0.001, 46 | "mean_loss": False, 47 | "neg_per_pos": 1, 48 | "num_epochs": 100, 49 | "optimizer": "Adam", 50 | "pos_per_batch": 10, 51 | "report_interval": 10, 52 | "sampling_scheme": "all" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /models/nations_complex/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_complex.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-51-41/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_complex.conf", 14 | "name": "nations_complex", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 0.7, 30 | "l2": 0.01, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": false, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": None, 45 | "learning_rate": 0.001, 46 | "mean_loss": false, 47 | "neg_per_pos": 1, 48 | "num_epochs": 100, 49 | "optimizer": "Adam", 50 | "pos_per_batch": 10, 51 | "report_interval": 10, 52 | "sampling_scheme": "all" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /models/nations_ntp/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/nations_ntp/events.out.tfevents.1495140821.tesla4.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntp/events.out.tfevents.1495140821.tesla4.local -------------------------------------------------------------------------------- /models/nations_ntp/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | #1_1_0 Param 4 | #2_1_0 Param 5 | #1_1_1 Param 6 | #2_1_1 Param 7 | #1_1_2 Param 8 | #2_1_2 Param 9 | #1_1_3 Param 10 | #2_1_3 Param 11 | #1_1_4 Param 12 | #2_1_4 Param 13 | #1_1_5 Param 14 | #2_1_5 Param 15 | #1_1_6 Param 16 | #2_1_6 Param 17 | #1_1_7 Param 18 | #2_1_7 Param 19 | #1_1_8 Param 20 | #2_1_8 Param 21 | #1_1_9 Param 22 | #2_1_9 Param 23 | #1_1_10 Param 24 | #2_1_10 Param 25 | #1_1_11 Param 26 | #2_1_11 Param 27 | #1_1_12 Param 28 | #2_1_12 Param 29 | #1_1_13 Param 30 | #2_1_13 Param 31 | #1_1_14 Param 32 | #2_1_14 Param 33 | #1_1_15 Param 34 | #2_1_15 Param 35 | #1_1_16 Param 36 | #2_1_16 Param 37 | #1_1_17 Param 38 | #2_1_17 Param 39 | #1_1_18 Param 40 | #2_1_18 Param 41 | #1_1_19 Param 42 | #2_1_19 Param 43 | #1_2_0 Param 44 | #2_2_0 Param 45 | #3_2_0 Param 46 | #1_2_1 Param 47 | #2_2_1 Param 48 | #3_2_1 Param 49 | #1_2_2 Param 50 | #2_2_2 Param 51 | #3_2_2 Param 52 | #1_2_3 Param 53 | #2_2_3 Param 54 | #3_2_3 Param 55 | #1_2_4 Param 56 | #2_2_4 Param 57 | #3_2_4 Param 58 | #1_2_5 Param 59 | #2_2_5 Param 60 | #3_2_5 Param 61 | #1_2_6 Param 62 | #2_2_6 Param 63 | #3_2_6 Param 64 | #1_2_7 Param 65 | #2_2_7 Param 66 | #3_2_7 Param 67 | #1_2_8 Param 68 | #2_2_8 Param 69 | #3_2_8 Param 70 | #1_2_9 Param 71 | #2_2_9 Param 72 | #3_2_9 Param 73 | #1_2_10 Param 74 | #2_2_10 Param 75 | #3_2_10 Param 76 | #1_2_11 Param 77 | #2_2_11 Param 78 | #3_2_11 Param 79 | #1_2_12 Param 80 | #2_2_12 Param 81 | #3_2_12 Param 82 | #1_2_13 Param 83 | #2_2_13 Param 84 | #3_2_13 Param 85 | #1_2_14 Param 86 | #2_2_14 Param 87 | #3_2_14 Param 88 | #1_2_15 Param 89 | #2_2_15 Param 90 | #3_2_15 Param 91 | #1_2_16 Param 92 | #2_2_16 Param 93 | #3_2_16 Param 94 | #1_2_17 Param 95 | #2_2_17 Param 96 | #3_2_17 Param 97 | #1_2_18 Param 98 | #2_2_18 Param 99 | #3_2_18 Param 100 | #1_2_19 Param 101 | #2_2_19 Param 102 | #3_2_19 Param 103 | #1_0_0 Param 104 | #2_0_0 Param 105 | #1_0_1 Param 106 | #2_0_1 Param 107 | #1_0_2 Param 108 | #2_0_2 Param 109 | #1_0_3 Param 110 | #2_0_3 Param 111 | #1_0_4 Param 112 | #2_0_4 Param 113 | #1_0_5 Param 114 | #2_0_5 Param 115 | #1_0_6 Param 116 | #2_0_6 Param 117 | #1_0_7 Param 118 | #2_0_7 Param 119 | #1_0_8 Param 120 | #2_0_8 Param 121 | #1_0_9 Param 122 | #2_0_9 Param 123 | #1_0_10 Param 124 | #2_0_10 Param 125 | #1_0_11 Param 126 | #2_0_11 Param 127 | #1_0_12 Param 128 | #2_0_12 Param 129 | #1_0_13 Param 130 | #2_0_13 Param 131 | #1_0_14 Param 132 | #2_0_14 Param 133 | #1_0_15 Param 134 | #2_0_15 Param 135 | #1_0_16 Param 136 | #2_0_16 Param 137 | #1_0_17 Param 138 | #2_0_17 Param 139 | #1_0_18 Param 140 | #2_0_18 Param 141 | #1_0_19 Param 142 | #2_0_19 Param 143 | militaryalliance Predicate 144 | netherlands Constant 145 | uk Constant 146 | intergovorgs3 Predicate 147 | egypt Constant 148 | usa Constant 149 | relbooktranslations Predicate 150 | jordan Constant 151 | timesincewar Predicate 152 | poland Constant 153 | ussr Constant 154 | negativebehavior Predicate 155 | relintergovorgs Predicate 156 | weightedunvote Predicate 157 | india Constant 158 | accusation Predicate 159 | china Constant 160 | unweightedunvote Predicate 161 | embassy Predicate 162 | commonbloc1 Predicate 163 | cuba Constant 164 | indonesia Constant 165 | commonbloc2 Predicate 166 | israel Constant 167 | ngoorgs3 Predicate 168 | brazil Constant 169 | exports3 Predicate 170 | economicaid Predicate 171 | booktranslations Predicate 172 | relexports Predicate 173 | intergovorgs Predicate 174 | independence Predicate 175 | reltreaties Predicate 176 | ngo Predicate 177 | blockpositionindex Predicate 178 | burma Constant 179 | relstudents Predicate 180 | aidenemy Predicate 181 | eemigrants Predicate 182 | officialvisits Predicate 183 | unoffialacts Predicate 184 | releconomicaid Predicate 185 | commonbloc0 Predicate 186 | expeldiplomats Predicate 187 | relngo Predicate 188 | students Predicate 189 | nonviolentbehavior Predicate 190 | reldiplomacy Predicate 191 | tourism Predicate 192 | timesinceally Predicate 193 | conferences Predicate 194 | relexportbooks Predicate 195 | treaties Predicate 196 | militaryactions Predicate 197 | exportbooks Predicate 198 | boycottembargo Predicate 199 | negativecomm Predicate 200 | tourism3 Predicate 201 | reltourism Predicate 202 | pprotests Predicate 203 | emigrants3 Predicate 204 | duration Predicate 205 | attackembassy Predicate 206 | dependent Predicate 207 | violentactions Predicate 208 | relemigrants Predicate 209 | warning Predicate 210 | lostterritory Predicate 211 | severdiplomatic Predicate 212 | -------------------------------------------------------------------------------- /models/nations_ntp/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntp/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/nations_ntp/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntp/model.ckpt-0.index -------------------------------------------------------------------------------- /models/nations_ntp/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntp/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/nations_ntp/nations_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-53-20/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp.conf", 14 | "name": "nations_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": null, 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/nations_ntp/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/nations_ntp/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X1', 'X0')) 2 | 0.947337 militaryactions(X,Y) :- duration(Y,X). 3 | 0.939915 duration(X,Y) :- militaryactions(Y,X). 4 | 0.886806 accusation(X,Y) :- duration(Y,X). 5 | 0.725322 violentactions(X,Y) :- duration(Y,X). 6 | 0.661134 blockpositionindex(X,Y) :- blockpositionindex(Y,X). 7 | 0.169211 duration(X,Y) :- duration(Y,X). 8 | 0.165436 duration(X,Y) :- duration(Y,X). 9 | 0.165032 duration(X,Y) :- duration(Y,X). 10 | 0.142308 aidenemy(X,Y) :- militaryactions(Y,X). 11 | 0.138 aidenemy(X,Y) :- militaryactions(Y,X). 12 | 0.136307 aidenemy(X,Y) :- militaryactions(Y,X). 13 | 0.13594 aidenemy(X,Y) :- duration(Y,X). 14 | 0.134607 aidenemy(X,Y) :- militaryactions(Y,X). 15 | 0.133663 aidenemy(X,Y) :- militaryactions(Y,X). 16 | 0.132718 aidenemy(X,Y) :- militaryactions(Y,X). 17 | 0.131585 aidenemy(X,Y) :- militaryactions(Y,X). 18 | 0.130054 aidenemy(X,Y) :- duration(Y,X). 19 | 0.128682 aidenemy(X,Y) :- militaryactions(Y,X). 20 | 0.124813 aidenemy(X,Y) :- militaryactions(Y,X). 21 | 0.124 aidenemy(X,Y) :- militaryactions(Y,X). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p2', 'X2', 'X1')) 24 | 0.381881 relemigrants(X,Y) :- lostterritory(X,Z), dependent(Z,Y). 25 | 0.332213 attackembassy(X,Y) :- dependent(X,Z), relemigrants(Z,Y). 26 | 0.217517 severdiplomatic(X,Y) :- duration(X,Z), duration(Z,Y). 27 | 0.213556 officialvisits(X,Y) :- aidenemy(X,Z), duration(Z,Y). 28 | 0.187817 severdiplomatic(X,Y) :- duration(X,Z), militaryactions(Z,Y). 29 | 0.12898 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 30 | 0.12869 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 31 | 0.125319 duration(X,Y) :- militaryactions(X,Z), aidenemy(Z,Y). 32 | 0.124278 severdiplomatic(X,Y) :- militaryactions(X,Z), duration(Z,Y). 33 | 0.123778 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 34 | 0.123119 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 35 | 0.122876 duration(X,Y) :- militaryactions(X,Z), relemigrants(Z,Y). 36 | 0.121096 duration(X,Y) :- militaryactions(X,Z), aidenemy(Z,Y). 37 | 0.120756 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 38 | 0.118933 severdiplomatic(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 39 | 0.118619 aidenemy(X,Y) :- militaryactions(X,Z), militaryactions(Z,Y). 40 | 0.118078 severdiplomatic(X,Y) :- militaryactions(X,Z), duration(Z,Y). 41 | 0.105824 duration(X,Y) :- aidenemy(X,Z), militaryactions(Z,Y). 42 | 0.104914 duration(X,Y) :- aidenemy(X,Z), militaryactions(Z,Y). 43 | 0.0772926 duration(X,Y) :- attackembassy(X,Z), militaryactions(Z,Y). 44 | 45 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 46 | 0.937188 warning(X,Y) :- militaryactions(X,Y). 47 | 0.884529 dependent(X,Y) :- lostterritory(X,Y). 48 | 0.715856 relstudents(X,Y) :- students(X,Y). 49 | 0.552091 aidenemy(X,Y) :- warning(X,Y). 50 | 0.512543 pprotests(X,Y) :- boycottembargo(X,Y). 51 | 0.365957 students(X,Y) :- relemigrants(X,Y). 52 | 0.337928 aidenemy(X,Y) :- relemigrants(X,Y). 53 | 0.311478 lostterritory(X,Y) :- militaryactions(X,Y). 54 | 0.248008 expeldiplomats(X,Y) :- dependent(X,Y). 55 | 0.166303 duration(X,Y) :- duration(X,Y). 56 | 0.165555 duration(X,Y) :- duration(X,Y). 57 | 0.162268 duration(X,Y) :- duration(X,Y). 58 | 0.142869 lostterritory(X,Y) :- militaryactions(X,Y). 59 | 0.140903 aidenemy(X,Y) :- militaryactions(X,Y). 60 | 0.140711 lostterritory(X,Y) :- duration(X,Y). 61 | 0.139853 aidenemy(X,Y) :- militaryactions(X,Y). 62 | 0.13797 aidenemy(X,Y) :- militaryactions(X,Y). 63 | 0.134495 lostterritory(X,Y) :- militaryactions(X,Y). 64 | 0.131653 aidenemy(X,Y) :- militaryactions(X,Y). 65 | 0.109617 militaryalliance(X,Y) :- dependent(X,Y). 66 | 67 | -------------------------------------------------------------------------------- /models/nations_ntp/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/nations_ntp.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/nations/17-05-18/20-53-20/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp.conf", 14 | "name": "nations_ntp", 15 | "output_predictions": False, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": False, 22 | "tfdbg": False, 23 | "train": True, 24 | "permutation": [2, 1, 0, 3] 25 | }, 26 | "model": { 27 | "aggregate_fun": "Max", 28 | "input_size": 100, 29 | "k_max": 10, 30 | "keep_prob": 1.0, 31 | "l2": 0.001, 32 | "max_depth": 1, 33 | "name": "NTP", 34 | "neural_link_predictor": None, 35 | "train_0ntp": True, 36 | "unification": "cos", 37 | "unit_normalize": False 38 | }, 39 | "training": { 40 | "clip": [ 41 | -1.0, 42 | 1.0 43 | ], 44 | "epsilon": 1e-10, 45 | "init": [ 46 | -1.0, 47 | 1.0 48 | ], 49 | "learning_rate": 0.001, 50 | "mean_loss": False, 51 | "neg_per_pos": 1, 52 | "num_epochs": 100, 53 | "optimizer": "Adam", 54 | "pos_per_batch": 10, 55 | "report_interval": 10, 56 | "sampling_scheme": "all" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /models/nations_ntp/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-53-20/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp.conf", 14 | "name": "nations_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": None, 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/nations_ntpl/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/nations_ntpl/events.out.tfevents.1495140751.tesla5.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntpl/events.out.tfevents.1495140751.tesla5.local -------------------------------------------------------------------------------- /models/nations_ntpl/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | #1_0_0 Param 4 | #2_0_0 Param 5 | #1_0_1 Param 6 | #2_0_1 Param 7 | #1_0_2 Param 8 | #2_0_2 Param 9 | #1_0_3 Param 10 | #2_0_3 Param 11 | #1_0_4 Param 12 | #2_0_4 Param 13 | #1_0_5 Param 14 | #2_0_5 Param 15 | #1_0_6 Param 16 | #2_0_6 Param 17 | #1_0_7 Param 18 | #2_0_7 Param 19 | #1_0_8 Param 20 | #2_0_8 Param 21 | #1_0_9 Param 22 | #2_0_9 Param 23 | #1_0_10 Param 24 | #2_0_10 Param 25 | #1_0_11 Param 26 | #2_0_11 Param 27 | #1_0_12 Param 28 | #2_0_12 Param 29 | #1_0_13 Param 30 | #2_0_13 Param 31 | #1_0_14 Param 32 | #2_0_14 Param 33 | #1_0_15 Param 34 | #2_0_15 Param 35 | #1_0_16 Param 36 | #2_0_16 Param 37 | #1_0_17 Param 38 | #2_0_17 Param 39 | #1_0_18 Param 40 | #2_0_18 Param 41 | #1_0_19 Param 42 | #2_0_19 Param 43 | #1_2_0 Param 44 | #2_2_0 Param 45 | #3_2_0 Param 46 | #1_2_1 Param 47 | #2_2_1 Param 48 | #3_2_1 Param 49 | #1_2_2 Param 50 | #2_2_2 Param 51 | #3_2_2 Param 52 | #1_2_3 Param 53 | #2_2_3 Param 54 | #3_2_3 Param 55 | #1_2_4 Param 56 | #2_2_4 Param 57 | #3_2_4 Param 58 | #1_2_5 Param 59 | #2_2_5 Param 60 | #3_2_5 Param 61 | #1_2_6 Param 62 | #2_2_6 Param 63 | #3_2_6 Param 64 | #1_2_7 Param 65 | #2_2_7 Param 66 | #3_2_7 Param 67 | #1_2_8 Param 68 | #2_2_8 Param 69 | #3_2_8 Param 70 | #1_2_9 Param 71 | #2_2_9 Param 72 | #3_2_9 Param 73 | #1_2_10 Param 74 | #2_2_10 Param 75 | #3_2_10 Param 76 | #1_2_11 Param 77 | #2_2_11 Param 78 | #3_2_11 Param 79 | #1_2_12 Param 80 | #2_2_12 Param 81 | #3_2_12 Param 82 | #1_2_13 Param 83 | #2_2_13 Param 84 | #3_2_13 Param 85 | #1_2_14 Param 86 | #2_2_14 Param 87 | #3_2_14 Param 88 | #1_2_15 Param 89 | #2_2_15 Param 90 | #3_2_15 Param 91 | #1_2_16 Param 92 | #2_2_16 Param 93 | #3_2_16 Param 94 | #1_2_17 Param 95 | #2_2_17 Param 96 | #3_2_17 Param 97 | #1_2_18 Param 98 | #2_2_18 Param 99 | #3_2_18 Param 100 | #1_2_19 Param 101 | #2_2_19 Param 102 | #3_2_19 Param 103 | #1_1_0 Param 104 | #2_1_0 Param 105 | #1_1_1 Param 106 | #2_1_1 Param 107 | #1_1_2 Param 108 | #2_1_2 Param 109 | #1_1_3 Param 110 | #2_1_3 Param 111 | #1_1_4 Param 112 | #2_1_4 Param 113 | #1_1_5 Param 114 | #2_1_5 Param 115 | #1_1_6 Param 116 | #2_1_6 Param 117 | #1_1_7 Param 118 | #2_1_7 Param 119 | #1_1_8 Param 120 | #2_1_8 Param 121 | #1_1_9 Param 122 | #2_1_9 Param 123 | #1_1_10 Param 124 | #2_1_10 Param 125 | #1_1_11 Param 126 | #2_1_11 Param 127 | #1_1_12 Param 128 | #2_1_12 Param 129 | #1_1_13 Param 130 | #2_1_13 Param 131 | #1_1_14 Param 132 | #2_1_14 Param 133 | #1_1_15 Param 134 | #2_1_15 Param 135 | #1_1_16 Param 136 | #2_1_16 Param 137 | #1_1_17 Param 138 | #2_1_17 Param 139 | #1_1_18 Param 140 | #2_1_18 Param 141 | #1_1_19 Param 142 | #2_1_19 Param 143 | militaryalliance Predicate 144 | netherlands Constant 145 | uk Constant 146 | intergovorgs3 Predicate 147 | egypt Constant 148 | usa Constant 149 | relbooktranslations Predicate 150 | jordan Constant 151 | timesincewar Predicate 152 | poland Constant 153 | ussr Constant 154 | negativebehavior Predicate 155 | relintergovorgs Predicate 156 | weightedunvote Predicate 157 | india Constant 158 | accusation Predicate 159 | china Constant 160 | unweightedunvote Predicate 161 | embassy Predicate 162 | commonbloc1 Predicate 163 | cuba Constant 164 | indonesia Constant 165 | commonbloc2 Predicate 166 | israel Constant 167 | ngoorgs3 Predicate 168 | brazil Constant 169 | exports3 Predicate 170 | economicaid Predicate 171 | booktranslations Predicate 172 | relexports Predicate 173 | intergovorgs Predicate 174 | independence Predicate 175 | reltreaties Predicate 176 | ngo Predicate 177 | blockpositionindex Predicate 178 | burma Constant 179 | relstudents Predicate 180 | aidenemy Predicate 181 | eemigrants Predicate 182 | officialvisits Predicate 183 | unoffialacts Predicate 184 | releconomicaid Predicate 185 | commonbloc0 Predicate 186 | expeldiplomats Predicate 187 | relngo Predicate 188 | students Predicate 189 | nonviolentbehavior Predicate 190 | reldiplomacy Predicate 191 | tourism Predicate 192 | timesinceally Predicate 193 | conferences Predicate 194 | relexportbooks Predicate 195 | treaties Predicate 196 | militaryactions Predicate 197 | exportbooks Predicate 198 | boycottembargo Predicate 199 | negativecomm Predicate 200 | tourism3 Predicate 201 | reltourism Predicate 202 | pprotests Predicate 203 | emigrants3 Predicate 204 | duration Predicate 205 | attackembassy Predicate 206 | dependent Predicate 207 | violentactions Predicate 208 | relemigrants Predicate 209 | warning Predicate 210 | lostterritory Predicate 211 | severdiplomatic Predicate 212 | -------------------------------------------------------------------------------- /models/nations_ntpl/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntpl/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/nations_ntpl/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntpl/model.ckpt-0.index -------------------------------------------------------------------------------- /models/nations_ntpl/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/nations_ntpl/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/nations_ntpl/nations_ntp_complex_reg.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_ntp_complex_reg.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-52-19/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp_complex_reg.conf", 14 | "name": "nations_ntp_complex_reg", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP ComplEx Reg", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/nations_ntpl/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/nations_ntpl/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 2 | 0.460194 expeldiplomats(X,Y) :- negativebehavior(X,Y). 3 | 0.379498 negativecomm(X,Y) :- commonbloc0(X,Y). 4 | 0.349342 attackembassy(X,Y) :- commonbloc2(X,Y). 5 | 0.239083 intergovorgs(X,Y) :- weightedunvote(X,Y). 6 | 0.199181 reltourism(X,Y) :- conferences(X,Y). 7 | 0.0894692 lostterritory(X,Y) :- lostterritory(X,Y). 8 | 0.0892686 lostterritory(X,Y) :- lostterritory(X,Y). 9 | 0.0751098 lostterritory(X,Y) :- warning(X,Y). 10 | 0.0737614 lostterritory(X,Y) :- warning(X,Y). 11 | 0.0685182 lostterritory(X,Y) :- warning(X,Y). 12 | 0.068448 lostterritory(X,Y) :- warning(X,Y). 13 | 0.0682459 lostterritory(X,Y) :- warning(X,Y). 14 | 0.0675454 lostterritory(X,Y) :- warning(X,Y). 15 | 0.0674517 lostterritory(X,Y) :- warning(X,Y). 16 | 0.0669826 lostterritory(X,Y) :- warning(X,Y). 17 | 0.0660652 lostterritory(X,Y) :- warning(X,Y). 18 | 0.0660024 lostterritory(X,Y) :- warning(X,Y). 19 | 0.0653558 lostterritory(X,Y) :- warning(X,Y). 20 | 0.0651576 lostterritory(X,Y) :- warning(X,Y). 21 | 0.0578526 lostterritory(X,Y) :- warning(X,Y). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p2', 'X2', 'X1')) 24 | 0.240598 officialvisits(X,Y) :- warning(X,Z), embassy(Z,Y). 25 | 0.172574 relexports(X,Y) :- relngo(X,Z), embassy(Z,Y). 26 | 0.135489 timesinceally(X,Y) :- blockpositionindex(X,Z), commonbloc2(Z,Y). 27 | 0.0915509 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 28 | 0.0908797 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 29 | 0.0907331 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 30 | 0.0907314 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 31 | 0.0907175 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 32 | 0.0906109 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 33 | 0.0903951 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 34 | 0.090202 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 35 | 0.0899867 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 36 | 0.0899775 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 37 | 0.0897394 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 38 | 0.0896368 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 39 | 0.0894852 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 40 | 0.0894494 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 41 | 0.0892622 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 42 | 0.0876731 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 43 | 0.0865361 lostterritory(X,Y) :- lostterritory(X,Z), lostterritory(Z,Y). 44 | 45 | (('p0', 'X0', 'X1'), ('p1', 'X1', 'X0')) 46 | 0.680509 blockpositionindex(X,Y) :- blockpositionindex(Y,X). 47 | 0.382743 intergovorgs3(X,Y) :- intergovorgs(Y,X). 48 | 0.275524 severdiplomatic(X,Y) :- commonbloc1(Y,X). 49 | 0.120425 dependent(X,Y) :- timesincewar(Y,X). 50 | 0.106226 aidenemy(X,Y) :- warning(Y,X). 51 | 0.0930151 lostterritory(X,Y) :- lostterritory(Y,X). 52 | 0.0923801 lostterritory(X,Y) :- lostterritory(Y,X). 53 | 0.0915094 lostterritory(X,Y) :- lostterritory(Y,X). 54 | 0.0914438 lostterritory(X,Y) :- lostterritory(Y,X). 55 | 0.0901195 lostterritory(X,Y) :- lostterritory(Y,X). 56 | 0.0900138 lostterritory(X,Y) :- lostterritory(Y,X). 57 | 0.0898399 lostterritory(X,Y) :- lostterritory(Y,X). 58 | 0.0878116 lostterritory(X,Y) :- lostterritory(Y,X). 59 | 0.0769658 relintergovorgs(X,Y) :- lostterritory(Y,X). 60 | 0.0722672 lostterritory(X,Y) :- warning(Y,X). 61 | 0.0721357 lostterritory(X,Y) :- warning(Y,X). 62 | 0.0721076 lostterritory(X,Y) :- warning(Y,X). 63 | 0.0705857 lostterritory(X,Y) :- warning(Y,X). 64 | 0.0703469 lostterritory(X,Y) :- warning(Y,X). 65 | 0.0671455 lostterritory(X,Y) :- warning(Y,X). 66 | 67 | -------------------------------------------------------------------------------- /models/nations_ntpl/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/nations_ntp_complex_reg.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/nations/17-05-18/20-52-19/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp_complex_reg.conf", 14 | "name": "nations_ntp_complex_reg", 15 | "output_predictions": False, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": False, 22 | "tfdbg": False, 23 | "train": True, 24 | "permutation": [0, 1, 2, 3] 25 | }, 26 | "model": { 27 | "aggregate_fun": "Max", 28 | "input_size": 100, 29 | "k_max": 10, 30 | "keep_prob": 1.0, 31 | "l2": 0.001, 32 | "max_depth": 1, 33 | "name": "NTP ComplEx Reg", 34 | "neural_link_predictor": "ComplEx", 35 | "train_0ntp": True, 36 | "unification": "cos", 37 | "unit_normalize": False 38 | }, 39 | "training": { 40 | "clip": [ 41 | -1.0, 42 | 1.0 43 | ], 44 | "epsilon": 1e-10, 45 | "init": [ 46 | -1.0, 47 | 1.0 48 | ], 49 | "learning_rate": 0.001, 50 | "mean_loss": False, 51 | "neg_per_pos": 1, 52 | "num_epochs": 100, 53 | "optimizer": "Adam", 54 | "pos_per_batch": 10, 55 | "report_interval": 10, 56 | "sampling_scheme": "all" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /models/nations_ntpl/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/nations/train.nl", 4 | "templates": "./data/nations/nations.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/nations_ntp_complex_reg.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/nations/17-05-18/20-52-19/", 12 | "experiment_prefix": "nations", 13 | "file_name": "nations_ntp_complex_reg.conf", 14 | "name": "nations_ntp_complex_reg", 15 | "output_predictions": false, 16 | "parent": "./conf/nations.conf", 17 | "result_file": "./out/nations/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP ComplEx Reg", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/umls_complex/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/umls_complex/events.out.tfevents.1494941070.brooks.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_complex/events.out.tfevents.1494941070.brooks.local -------------------------------------------------------------------------------- /models/umls_complex/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | location_of Predicate 4 | acquired_abnormality Constant 5 | experimental_model_of_disease Constant 6 | manifestation_of Predicate 7 | anatomical_abnormality Constant 8 | physiologic_function Constant 9 | isa Predicate 10 | alga Constant 11 | entity Constant 12 | affects Predicate 13 | mental_or_behavioral_dysfunction Constant 14 | associated_with Predicate 15 | health_care_activity Constant 16 | interacts_with Predicate 17 | population_group Constant 18 | age_group Constant 19 | result_of Predicate 20 | clinical_attribute Constant 21 | natural_phenomenon_or_process Constant 22 | body_part_organ_or_organ_component Constant 23 | biologic_function Constant 24 | complicates Predicate 25 | biologically_active_substance Constant 26 | disease_or_syndrome Constant 27 | carbohydrate Constant 28 | vitamin Constant 29 | molecular_sequence Constant 30 | spatial_concept Constant 31 | steroid Constant 32 | mental_process Constant 33 | occurs_in Predicate 34 | professional_or_occupational_group Constant 35 | uses Predicate 36 | patient_or_disabled_group Constant 37 | clinical_drug Constant 38 | produces Predicate 39 | nucleic_acid_nucleoside_or_nucleotide Constant 40 | chemical_viewed_structurally Constant 41 | degree_of Predicate 42 | organism_function Constant 43 | cell_or_molecular_dysfunction Constant 44 | connected_to Predicate 45 | body_substance Constant 46 | human_caused_phenomenon_or_process Constant 47 | process_of Predicate 48 | archaeon Constant 49 | therapeutic_or_preventive_procedure Constant 50 | organ_or_tissue_function Constant 51 | pharmacologic_substance Constant 52 | co-occurs_with Predicate 53 | cell_function Constant 54 | pathologic_function Constant 55 | disrupts Predicate 56 | enzyme Constant 57 | fully_formed_anatomical_structure Constant 58 | cell Constant 59 | amino_acid_peptide_or_protein Constant 60 | cell_component Constant 61 | hormone Constant 62 | organic_chemical Constant 63 | behavior Constant 64 | group Constant 65 | issue_in Predicate 66 | biomedical_occupation_or_discipline Constant 67 | molecular_function Constant 68 | neuroreactive_substance_or_biogenic_amine Constant 69 | part_of Predicate 70 | amphibian Constant 71 | embryonic_structure Constant 72 | occupation_or_discipline Constant 73 | immunologic_factor Constant 74 | bacterium Constant 75 | neoplastic_process Constant 76 | measures Predicate 77 | laboratory_procedure Constant 78 | fungus Constant 79 | prevents Predicate 80 | invertebrate Constant 81 | causes Predicate 82 | receptor Constant 83 | indicates Predicate 84 | self_help_or_relief_organization Constant 85 | research_activity Constant 86 | treats Predicate 87 | sign_or_symptom Constant 88 | rickettsia_or_chlamydia Constant 89 | genetic_function Constant 90 | regulation_or_law Constant 91 | intellectual_product Constant 92 | human Constant 93 | vertebrate Constant 94 | eicosanoid Constant 95 | element_ion_or_isotope Constant 96 | group_attribute Constant 97 | conceptual_entity Constant 98 | organism_attribute Constant 99 | finding Constant 100 | congenital_abnormality Constant 101 | anatomical_structure Constant 102 | molecular_biology_research_technique Constant 103 | evaluation_of Predicate 104 | diagnoses Predicate 105 | diagnostic_procedure Constant 106 | injury_or_poisoning Constant 107 | tissue Constant 108 | animal Constant 109 | social_behavior Constant 110 | hazardous_or_poisonous_substance Constant 111 | chemical_viewed_functionally Constant 112 | environmental_effect_of_humans Constant 113 | exhibits Predicate 114 | reptile Constant 115 | family_group Constant 116 | virus Constant 117 | ingredient_of Predicate 118 | indicator_reagent_or_diagnostic_aid Constant 119 | antibiotic Constant 120 | body_space_or_junction Constant 121 | fish Constant 122 | health_care_related_organization Constant 123 | plant Constant 124 | lipid Constant 125 | organization Constant 126 | property_of Predicate 127 | manages Predicate 128 | chemical Constant 129 | classification Constant 130 | assesses_effect_of Predicate 131 | method_of Predicate 132 | physical_object Constant 133 | organism Constant 134 | gene_or_genome Constant 135 | measurement_of Predicate 136 | laboratory_or_test_result Constant 137 | precedes Predicate 138 | consists_of Predicate 139 | performs Predicate 140 | activity Constant 141 | conceptual_part_of Predicate 142 | occupational_activity Constant 143 | analyzes Predicate 144 | substance Constant 145 | geographic_area Constant 146 | organophosphorus_compound Constant 147 | carries_out Predicate 148 | professional_society Constant 149 | body_location_or_region Constant 150 | event Constant 151 | mammal Constant 152 | research_device Constant 153 | inorganic_chemical Constant 154 | bird Constant 155 | phenomenon_or_process Constant 156 | manufactured_object Constant 157 | individual_behavior Constant 158 | qualitative_concept Constant 159 | daily_or_recreational_activity Constant 160 | biomedical_or_dental_material Constant 161 | quantitative_concept Constant 162 | developmental_form_of Predicate 163 | drug_delivery_device Constant 164 | educational_activity Constant 165 | machine_activity Constant 166 | nucleotide_sequence Constant 167 | body_system Constant 168 | food Constant 169 | carbohydrate_sequence Constant 170 | contains Predicate 171 | governmental_or_regulatory_activity Constant 172 | adjacent_to Predicate 173 | interconnects Predicate 174 | idea_or_concept Constant 175 | conceptually_related_to Predicate 176 | temporal_concept Constant 177 | medical_device Constant 178 | amino_acid_sequence Constant 179 | language Constant 180 | functional_concept Constant 181 | surrounds Predicate 182 | derivative_of Predicate 183 | practices Predicate 184 | -------------------------------------------------------------------------------- /models/umls_complex/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_complex/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/umls_complex/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_complex/model.ckpt-0.index -------------------------------------------------------------------------------- /models/umls_complex/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_complex/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/umls_complex/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/umls_complex/rules.nl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_complex/rules.nl -------------------------------------------------------------------------------- /models/umls_complex/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/umls_complex_alt.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/umls/17-05-16/13-24-27/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_complex_alt.conf", 14 | "name": "umls_complex_alt", 15 | "output_predictions": False, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": False, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": False 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": False, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/umls_complex/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": None 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_complex_alt.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/13-24-27/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_complex_alt.conf", 14 | "name": "umls_complex_alt", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/umls_complex/umls_complex_alt.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": null 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_complex_alt.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/13-24-27/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_complex_alt.conf", 14 | "name": "umls_complex_alt", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": true, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "ComplEx", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/umls_ntp/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/umls_ntp/events.out.tfevents.1494927512.tesla1.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntp/events.out.tfevents.1494927512.tesla1.local -------------------------------------------------------------------------------- /models/umls_ntp/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntp/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/umls_ntp/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntp/model.ckpt-0.index -------------------------------------------------------------------------------- /models/umls_ntp/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntp/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/umls_ntp/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/umls_ntp/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 2 | 0.942011 co-occurs_with(X,Y) :- degree_of(X,Y). 3 | 0.862528 prevents(X,Y) :- treats(X,Y). 4 | 0.82948 measures(X,Y) :- analyzes(X,Y). 5 | 0.477553 developmental_form_of(X,Y) :- adjacent_to(X,Y). 6 | 0.476172 developmental_form_of(X,Y) :- adjacent_to(X,Y). 7 | 0.474864 developmental_form_of(X,Y) :- adjacent_to(X,Y). 8 | 0.474651 developmental_form_of(X,Y) :- adjacent_to(X,Y). 9 | 0.472924 developmental_form_of(X,Y) :- adjacent_to(X,Y). 10 | 0.471849 developmental_form_of(X,Y) :- adjacent_to(X,Y). 11 | 0.468755 developmental_form_of(X,Y) :- developmental_form_of(X,Y). 12 | 0.465784 adjacent_to(X,Y) :- adjacent_to(X,Y). 13 | 0.465047 developmental_form_of(X,Y) :- adjacent_to(X,Y). 14 | 0.464889 developmental_form_of(X,Y) :- adjacent_to(X,Y). 15 | 0.464707 developmental_form_of(X,Y) :- adjacent_to(X,Y). 16 | 0.464532 developmental_form_of(X,Y) :- adjacent_to(X,Y). 17 | 0.463158 developmental_form_of(X,Y) :- adjacent_to(X,Y). 18 | 0.442301 isa(X,Y) :- co-occurs_with(X,Y). 19 | 0.420866 method_of(X,Y) :- method_of(X,Y). 20 | 0.406279 analyzes(X,Y) :- measures(X,Y). 21 | 0.402711 developmental_form_of(X,Y) :- method_of(X,Y). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p1', 'X2', 'X1')) 24 | 0.990477 interacts_with(X,Y) :- interacts_with(X,Z), interacts_with(Z,Y). 25 | 0.764667 developmental_form_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 26 | 0.586205 isa(X,Y) :- conceptual_part_of(X,Z), conceptual_part_of(Z,Y). 27 | 0.428585 consists_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 28 | 0.398652 conceptually_related_to(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 29 | 0.395944 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 30 | 0.388299 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 31 | 0.383544 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 32 | 0.380323 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 33 | 0.376661 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 34 | 0.374857 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 35 | 0.373426 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 36 | 0.372877 method_of(X,Y) :- developmental_form_of(X,Z), developmental_form_of(Z,Y). 37 | 0.367539 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 38 | 0.347574 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 39 | 0.345293 conceptually_related_to(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 40 | 0.335167 treats(X,Y) :- manages(X,Z), manages(Z,Y). 41 | 0.313067 method_of(X,Y) :- conceptually_related_to(X,Z), conceptually_related_to(Z,Y). 42 | 0.171882 exhibits(X,Y) :- practices(X,Z), practices(Z,Y). 43 | 0.167955 conceptually_related_to(X,Y) :- precedes(X,Z), precedes(Z,Y). 44 | 45 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p2', 'X2', 'X1')) 46 | 0.981781 performs(X,Y) :- interacts_with(X,Z), performs(Z,Y). 47 | 0.98061 part_of(X,Y) :- part_of(X,Z), interacts_with(Z,Y). 48 | 0.942 isa(X,Y) :- isa(X,Z), isa(Z,Y). 49 | 0.923871 method_of(X,Y) :- isa(X,Z), method_of(Z,Y). 50 | 0.875344 result_of(X,Y) :- isa(X,Z), result_of(Z,Y). 51 | 0.87499 associated_with(X,Y) :- associated_with(X,Z), degree_of(Z,Y). 52 | 0.677233 conceptual_part_of(X,Y) :- adjacent_to(X,Z), conceptual_part_of(Z,Y). 53 | 0.653239 location_of(X,Y) :- developmental_form_of(X,Z), location_of(Z,Y). 54 | 0.344066 conceptual_part_of(X,Y) :- adjacent_to(X,Z), adjacent_to(Z,Y). 55 | 0.342012 evaluation_of(X,Y) :- evaluation_of(X,Z), method_of(Z,Y). 56 | 0.330638 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 57 | 0.330059 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 58 | 0.318259 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 59 | 0.312912 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 60 | 0.308828 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 61 | 0.293754 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 62 | 0.247132 measures(X,Y) :- measures(X,Z), conceptual_part_of(Z,Y). 63 | 0.246786 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 64 | 0.246704 conceptually_related_to(X,Y) :- connected_to(X,Z), adjacent_to(Z,Y). 65 | 0.211109 measures(X,Y) :- measures(X,Z), degree_of(Z,Y). 66 | 67 | -------------------------------------------------------------------------------- /models/umls_ntp/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/umls_ntp.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/umls/17-05-16/09-38-05/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp.conf", 14 | "name": "umls_ntp", 15 | "output_predictions": False, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": False, 22 | "tfdbg": False, 23 | "train": True, 24 | "permutation": [1, 2, 3, 0] 25 | }, 26 | "model": { 27 | "aggregate_fun": "Max", 28 | "input_size": 100, 29 | "k_max": 10, 30 | "keep_prob": 1.0, 31 | "l2": 0.001, 32 | "max_depth": 1, 33 | "name": "NTP", 34 | "neural_link_predictor": None, 35 | "train_0ntp": True, 36 | "unification": "cos", 37 | "unit_normalize": False 38 | }, 39 | "training": { 40 | "clip": [ 41 | -1.0, 42 | 1.0 43 | ], 44 | "epsilon": 1e-10, 45 | "init": [ 46 | -1.0, 47 | 1.0 48 | ], 49 | "learning_rate": 0.001, 50 | "mean_loss": False, 51 | "neg_per_pos": 1, 52 | "num_epochs": 100, 53 | "optimizer": "Adam", 54 | "pos_per_batch": 10, 55 | "report_interval": 10, 56 | "sampling_scheme": "all" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /models/umls_ntp/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/09-38-05/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp.conf", 14 | "name": "umls_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": True, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": None, 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /models/umls_ntp/umls_ntp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_ntp.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/09-38-05/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp.conf", 14 | "name": "umls_ntp", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": true, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.001, 31 | "max_depth": 1, 32 | "name": "NTP", 33 | "neural_link_predictor": null, 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": [ 45 | -1.0, 46 | 1.0 47 | ], 48 | "learning_rate": 0.001, 49 | "mean_loss": false, 50 | "neg_per_pos": 1, 51 | "num_epochs": 100, 52 | "optimizer": "Adam", 53 | "pos_per_batch": 10, 54 | "report_interval": 10, 55 | "sampling_scheme": "all" 56 | } 57 | } -------------------------------------------------------------------------------- /models/umls_ntpl/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "model.ckpt-0" 2 | all_model_checkpoint_paths: "model.ckpt-0" 3 | -------------------------------------------------------------------------------- /models/umls_ntpl/events.out.tfevents.1494923910.tesla2.local: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntpl/events.out.tfevents.1494923910.tesla2.local -------------------------------------------------------------------------------- /models/umls_ntpl/metadata.tsv: -------------------------------------------------------------------------------- 1 | Symbol Class 2 | Constant 3 | #1_0_0 Param 4 | #2_0_0 Param 5 | #1_0_1 Param 6 | #2_0_1 Param 7 | #1_0_2 Param 8 | #2_0_2 Param 9 | #1_0_3 Param 10 | #2_0_3 Param 11 | #1_0_4 Param 12 | #2_0_4 Param 13 | #1_0_5 Param 14 | #2_0_5 Param 15 | #1_0_6 Param 16 | #2_0_6 Param 17 | #1_0_7 Param 18 | #2_0_7 Param 19 | #1_0_8 Param 20 | #2_0_8 Param 21 | #1_0_9 Param 22 | #2_0_9 Param 23 | #1_0_10 Param 24 | #2_0_10 Param 25 | #1_0_11 Param 26 | #2_0_11 Param 27 | #1_0_12 Param 28 | #2_0_12 Param 29 | #1_0_13 Param 30 | #2_0_13 Param 31 | #1_0_14 Param 32 | #2_0_14 Param 33 | #1_0_15 Param 34 | #2_0_15 Param 35 | #1_0_16 Param 36 | #2_0_16 Param 37 | #1_0_17 Param 38 | #2_0_17 Param 39 | #1_0_18 Param 40 | #2_0_18 Param 41 | #1_0_19 Param 42 | #2_0_19 Param 43 | #1_1_0 Param 44 | #2_1_0 Param 45 | #1_1_1 Param 46 | #2_1_1 Param 47 | #1_1_2 Param 48 | #2_1_2 Param 49 | #1_1_3 Param 50 | #2_1_3 Param 51 | #1_1_4 Param 52 | #2_1_4 Param 53 | #1_1_5 Param 54 | #2_1_5 Param 55 | #1_1_6 Param 56 | #2_1_6 Param 57 | #1_1_7 Param 58 | #2_1_7 Param 59 | #1_1_8 Param 60 | #2_1_8 Param 61 | #1_1_9 Param 62 | #2_1_9 Param 63 | #1_1_10 Param 64 | #2_1_10 Param 65 | #1_1_11 Param 66 | #2_1_11 Param 67 | #1_1_12 Param 68 | #2_1_12 Param 69 | #1_1_13 Param 70 | #2_1_13 Param 71 | #1_1_14 Param 72 | #2_1_14 Param 73 | #1_1_15 Param 74 | #2_1_15 Param 75 | #1_1_16 Param 76 | #2_1_16 Param 77 | #1_1_17 Param 78 | #2_1_17 Param 79 | #1_1_18 Param 80 | #2_1_18 Param 81 | #1_1_19 Param 82 | #2_1_19 Param 83 | location_of Predicate 84 | acquired_abnormality Constant 85 | experimental_model_of_disease Constant 86 | manifestation_of Predicate 87 | anatomical_abnormality Constant 88 | physiologic_function Constant 89 | isa Predicate 90 | alga Constant 91 | entity Constant 92 | affects Predicate 93 | mental_or_behavioral_dysfunction Constant 94 | associated_with Predicate 95 | health_care_activity Constant 96 | interacts_with Predicate 97 | population_group Constant 98 | age_group Constant 99 | result_of Predicate 100 | clinical_attribute Constant 101 | natural_phenomenon_or_process Constant 102 | body_part_organ_or_organ_component Constant 103 | biologic_function Constant 104 | complicates Predicate 105 | biologically_active_substance Constant 106 | disease_or_syndrome Constant 107 | carbohydrate Constant 108 | vitamin Constant 109 | molecular_sequence Constant 110 | spatial_concept Constant 111 | steroid Constant 112 | mental_process Constant 113 | occurs_in Predicate 114 | professional_or_occupational_group Constant 115 | uses Predicate 116 | patient_or_disabled_group Constant 117 | clinical_drug Constant 118 | produces Predicate 119 | nucleic_acid_nucleoside_or_nucleotide Constant 120 | chemical_viewed_structurally Constant 121 | degree_of Predicate 122 | organism_function Constant 123 | cell_or_molecular_dysfunction Constant 124 | connected_to Predicate 125 | body_substance Constant 126 | human_caused_phenomenon_or_process Constant 127 | process_of Predicate 128 | archaeon Constant 129 | therapeutic_or_preventive_procedure Constant 130 | organ_or_tissue_function Constant 131 | pharmacologic_substance Constant 132 | co-occurs_with Predicate 133 | cell_function Constant 134 | pathologic_function Constant 135 | disrupts Predicate 136 | enzyme Constant 137 | fully_formed_anatomical_structure Constant 138 | cell Constant 139 | amino_acid_peptide_or_protein Constant 140 | cell_component Constant 141 | hormone Constant 142 | organic_chemical Constant 143 | behavior Constant 144 | group Constant 145 | issue_in Predicate 146 | biomedical_occupation_or_discipline Constant 147 | molecular_function Constant 148 | neuroreactive_substance_or_biogenic_amine Constant 149 | part_of Predicate 150 | amphibian Constant 151 | embryonic_structure Constant 152 | occupation_or_discipline Constant 153 | immunologic_factor Constant 154 | bacterium Constant 155 | neoplastic_process Constant 156 | measures Predicate 157 | laboratory_procedure Constant 158 | fungus Constant 159 | prevents Predicate 160 | invertebrate Constant 161 | causes Predicate 162 | receptor Constant 163 | indicates Predicate 164 | self_help_or_relief_organization Constant 165 | research_activity Constant 166 | treats Predicate 167 | sign_or_symptom Constant 168 | rickettsia_or_chlamydia Constant 169 | genetic_function Constant 170 | regulation_or_law Constant 171 | intellectual_product Constant 172 | human Constant 173 | vertebrate Constant 174 | eicosanoid Constant 175 | element_ion_or_isotope Constant 176 | group_attribute Constant 177 | conceptual_entity Constant 178 | organism_attribute Constant 179 | finding Constant 180 | congenital_abnormality Constant 181 | anatomical_structure Constant 182 | molecular_biology_research_technique Constant 183 | evaluation_of Predicate 184 | diagnoses Predicate 185 | diagnostic_procedure Constant 186 | injury_or_poisoning Constant 187 | tissue Constant 188 | animal Constant 189 | social_behavior Constant 190 | hazardous_or_poisonous_substance Constant 191 | chemical_viewed_functionally Constant 192 | environmental_effect_of_humans Constant 193 | exhibits Predicate 194 | reptile Constant 195 | family_group Constant 196 | virus Constant 197 | ingredient_of Predicate 198 | indicator_reagent_or_diagnostic_aid Constant 199 | antibiotic Constant 200 | body_space_or_junction Constant 201 | fish Constant 202 | health_care_related_organization Constant 203 | plant Constant 204 | lipid Constant 205 | organization Constant 206 | property_of Predicate 207 | manages Predicate 208 | chemical Constant 209 | classification Constant 210 | assesses_effect_of Predicate 211 | method_of Predicate 212 | physical_object Constant 213 | organism Constant 214 | gene_or_genome Constant 215 | measurement_of Predicate 216 | laboratory_or_test_result Constant 217 | precedes Predicate 218 | consists_of Predicate 219 | performs Predicate 220 | activity Constant 221 | conceptual_part_of Predicate 222 | occupational_activity Constant 223 | analyzes Predicate 224 | substance Constant 225 | geographic_area Constant 226 | organophosphorus_compound Constant 227 | carries_out Predicate 228 | professional_society Constant 229 | body_location_or_region Constant 230 | event Constant 231 | mammal Constant 232 | research_device Constant 233 | inorganic_chemical Constant 234 | bird Constant 235 | phenomenon_or_process Constant 236 | manufactured_object Constant 237 | individual_behavior Constant 238 | qualitative_concept Constant 239 | daily_or_recreational_activity Constant 240 | biomedical_or_dental_material Constant 241 | quantitative_concept Constant 242 | developmental_form_of Predicate 243 | drug_delivery_device Constant 244 | educational_activity Constant 245 | machine_activity Constant 246 | nucleotide_sequence Constant 247 | body_system Constant 248 | food Constant 249 | carbohydrate_sequence Constant 250 | contains Predicate 251 | governmental_or_regulatory_activity Constant 252 | adjacent_to Predicate 253 | interconnects Predicate 254 | idea_or_concept Constant 255 | conceptually_related_to Predicate 256 | temporal_concept Constant 257 | medical_device Constant 258 | amino_acid_sequence Constant 259 | language Constant 260 | functional_concept Constant 261 | surrounds Predicate 262 | derivative_of Predicate 263 | practices Predicate 264 | -------------------------------------------------------------------------------- /models/umls_ntpl/model.ckpt-0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntpl/model.ckpt-0.data-00000-of-00001 -------------------------------------------------------------------------------- /models/umls_ntpl/model.ckpt-0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntpl/model.ckpt-0.index -------------------------------------------------------------------------------- /models/umls_ntpl/model.ckpt-0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/models/umls_ntpl/model.ckpt-0.meta -------------------------------------------------------------------------------- /models/umls_ntpl/projector_config.pbtxt: -------------------------------------------------------------------------------- 1 | embeddings { 2 | tensor_name: "embeddings:0" 3 | metadata_path: "metadata.tsv" 4 | } 5 | -------------------------------------------------------------------------------- /models/umls_ntpl/rules.nl: -------------------------------------------------------------------------------- 1 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X1')) 2 | 0.729181 derivative_of(X,Y) :- derivative_of(X,Y). 3 | 0.729127 derivative_of(X,Y) :- derivative_of(X,Y). 4 | 0.728575 derivative_of(X,Y) :- derivative_of(X,Y). 5 | 0.728282 derivative_of(X,Y) :- derivative_of(X,Y). 6 | 0.727868 derivative_of(X,Y) :- derivative_of(X,Y). 7 | 0.727198 derivative_of(X,Y) :- derivative_of(X,Y). 8 | 0.726968 derivative_of(X,Y) :- derivative_of(X,Y). 9 | 0.726931 derivative_of(X,Y) :- derivative_of(X,Y). 10 | 0.726386 derivative_of(X,Y) :- derivative_of(X,Y). 11 | 0.726282 derivative_of(X,Y) :- derivative_of(X,Y). 12 | 0.725836 derivative_of(X,Y) :- derivative_of(X,Y). 13 | 0.725436 derivative_of(X,Y) :- derivative_of(X,Y). 14 | 0.725371 derivative_of(X,Y) :- derivative_of(X,Y). 15 | 0.724676 derivative_of(X,Y) :- derivative_of(X,Y). 16 | 0.724538 derivative_of(X,Y) :- derivative_of(X,Y). 17 | 0.72379 derivative_of(X,Y) :- derivative_of(X,Y). 18 | 0.723727 derivative_of(X,Y) :- derivative_of(X,Y). 19 | 0.72351 derivative_of(X,Y) :- derivative_of(X,Y). 20 | 0.720229 derivative_of(X,Y) :- derivative_of(X,Y). 21 | 0.719627 derivative_of(X,Y) :- derivative_of(X,Y). 22 | 23 | (('p0', 'X0', 'X1'), ('p1', 'X0', 'X2'), ('p1', 'X2', 'X1')) 24 | 0.876634 interacts_with(X,Y) :- interacts_with(X,Z), interacts_with(Z,Y). 25 | 0.766196 isa(X,Y) :- isa(X,Z), isa(Z,Y). 26 | 0.713058 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 27 | 0.711295 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 28 | 0.71098 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 29 | 0.710713 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 30 | 0.710604 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 31 | 0.708805 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 32 | 0.708301 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 33 | 0.708014 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 34 | 0.70796 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 35 | 0.706654 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 36 | 0.706515 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 37 | 0.705833 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 38 | 0.705212 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 39 | 0.704667 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 40 | 0.704187 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 41 | 0.702255 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 42 | 0.699708 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 43 | 0.68899 derivative_of(X,Y) :- derivative_of(X,Z), derivative_of(Z,Y). 44 | 45 | -------------------------------------------------------------------------------- /models/umls_ntpl/tmp.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls_alt.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": False, 8 | "conf": "conf/umls_ntp_complex_reg_alt3.conf", 9 | "debug": False, 10 | "ensemble": False, 11 | "experiment_dir": "./out/umls/17-05-16/08-38-11/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp_complex_reg_alt3.conf", 14 | "name": "umls_ntp_complex_reg_alt3", 15 | "output_predictions": False, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": False, 19 | "test_set": "test", 20 | "test_time_batching": False, 21 | "test_time_neural_link_prediction": False, 22 | "tfdbg": False, 23 | "train": True, 24 | "permutation": [1, 0, 2] 25 | }, 26 | "model": { 27 | "aggregate_fun": "Max", 28 | "input_size": 100, 29 | "k_max": 10, 30 | "keep_prob": 1.0, 31 | "l2": 0.01, 32 | "max_depth": 1, 33 | "name": "NTP ComplEx Reg", 34 | "neural_link_predictor": "ComplEx", 35 | "train_0ntp": True, 36 | "unification": "cos", 37 | "unit_normalize": False 38 | }, 39 | "training": { 40 | "clip": [ 41 | -1.0, 42 | 1.0 43 | ], 44 | "epsilon": 1e-10, 45 | "init": None, 46 | "learning_rate": 0.001, 47 | "mean_loss": False, 48 | "neg_per_pos": 1, 49 | "num_epochs": 100, 50 | "optimizer": "Adam", 51 | "pos_per_batch": 10, 52 | "report_interval": 10, 53 | "sampling_scheme": "all" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /models/umls_ntpl/tmp.conf-e: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls_alt.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_ntp_complex_reg_alt3.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/08-38-11/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp_complex_reg_alt3.conf", 14 | "name": "umls_ntp_complex_reg_alt3", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": True 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.01, 31 | "max_depth": 1, 32 | "name": "NTP ComplEx Reg", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": True, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": None, 45 | "learning_rate": 0.001, 46 | "mean_loss": false, 47 | "neg_per_pos": 1, 48 | "num_epochs": 100, 49 | "optimizer": "Adam", 50 | "pos_per_batch": 10, 51 | "report_interval": 10, 52 | "sampling_scheme": "all" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /models/umls_ntpl/umls_ntp_complex_reg_alt3.conf: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "kb": "./data/umls/train.nl", 4 | "templates": "./data/umls/umls_alt.nlt" 5 | }, 6 | "meta": { 7 | "check_numerics": false, 8 | "conf": "conf/umls_ntp_complex_reg_alt3.conf", 9 | "debug": false, 10 | "ensemble": false, 11 | "experiment_dir": "./out/umls/17-05-16/08-38-11/", 12 | "experiment_prefix": "umls", 13 | "file_name": "umls_ntp_complex_reg_alt3.conf", 14 | "name": "umls_ntp_complex_reg_alt3", 15 | "output_predictions": false, 16 | "parent": "./conf/umls.conf", 17 | "result_file": "./out/umls/results.tsv", 18 | "test_graph_creation": false, 19 | "test_set": "test", 20 | "test_time_batching": false, 21 | "test_time_neural_link_prediction": false, 22 | "tfdbg": false, 23 | "train": true 24 | }, 25 | "model": { 26 | "aggregate_fun": "Max", 27 | "input_size": 100, 28 | "k_max": 10, 29 | "keep_prob": 1.0, 30 | "l2": 0.01, 31 | "max_depth": 1, 32 | "name": "NTP ComplEx Reg", 33 | "neural_link_predictor": "ComplEx", 34 | "train_0ntp": true, 35 | "unification": "cos", 36 | "unit_normalize": false 37 | }, 38 | "training": { 39 | "clip": [ 40 | -1.0, 41 | 1.0 42 | ], 43 | "epsilon": 1e-10, 44 | "init": null, 45 | "learning_rate": 0.001, 46 | "mean_loss": false, 47 | "neg_per_pos": 1, 48 | "num_epochs": 100, 49 | "optimizer": "Adam", 50 | "pos_per_batch": 10, 51 | "report_interval": 10, 52 | "sampling_scheme": "all" 53 | } 54 | } -------------------------------------------------------------------------------- /ntp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/__init__.py -------------------------------------------------------------------------------- /ntp/data/countries.py: -------------------------------------------------------------------------------- 1 | # @rockt, @timdettmers, @pminervini 2 | 3 | import random 4 | import re 5 | import os 6 | from os.path import join 7 | import numpy as np 8 | import copy 9 | 10 | 11 | def clean(x): 12 | return x.replace(" ", "_").replace("(", "").replace(")", "").lower() 13 | 14 | seed = 1337 15 | rdm = np.random.RandomState(seed) 16 | base_path = os.path.join('./data/countries') 17 | delimiter = '\t' 18 | 19 | acronym2name = {} 20 | table = [] 21 | 22 | countries = set() 23 | regions = set() 24 | subregions = set() 25 | 26 | country2neighbors = {} 27 | 28 | subregion2region = {} 29 | 30 | with open(join(base_path, "countries.csv"), "r") as f_in: 31 | for line in f_in.readlines()[1:]: 32 | line = line.strip().split(";") 33 | country = clean(line[0][1:-1].split(",")[0]) 34 | acronym = line[4][1:-1] 35 | acronym2name[acronym] = country 36 | capital = line[8] 37 | region = clean(line[10][1:-1]) 38 | subregion = clean(line[11][1:-1]) 39 | borders = line[17][1:-1].split(",") 40 | if borders == ['']: 41 | borders = [] 42 | 43 | assert country != "" 44 | 45 | if region != "": 46 | regions.add(region) 47 | if subregion != "": 48 | subregions.add(subregion) 49 | 50 | if region != "" and subregion != "": 51 | table.append((country, region, subregion, borders)) 52 | countries.add(country) 53 | subregion2region[subregion] = region 54 | f_in.close() 55 | 56 | facts = set() 57 | 58 | country2region = {} 59 | country2subregion = {} 60 | 61 | for country, region, subregion, borders in table: 62 | neighbors = ["neighborOf(%s,%s).\n" % (country, acronym2name[x]) 63 | for x in borders] 64 | country2neighbors[country] = list(set(acronym2name[x] for x in borders)) 65 | country2region[country] = region 66 | country2subregion[country] = subregion 67 | 68 | assert len(countries) == 244 69 | assert len(regions) == 5 70 | assert len(subregions) == 23 71 | 72 | 73 | train_dict = {} 74 | test_candidates = [] 75 | dev_test_dict = {} 76 | 77 | countries = list(countries) 78 | 79 | for c in countries: 80 | train_dict[(c, 'subregion')] = [country2subregion[c]] 81 | train_dict[(c, 'region')] = [country2region[c]] 82 | train_dict[(c, 'neighbor')] = [] 83 | for neighbor in country2neighbors[c]: 84 | train_dict[(c, 'neighbor')].append(neighbor) 85 | 86 | # more than one neighbor -> can be in dev or test set 87 | if len(country2neighbors[c]) > 0: 88 | test_candidates.append(c) 89 | 90 | n = len(countries) 91 | dev_test_size = int(n*0.1) 92 | 93 | # splits 0.8 / 0.1 / 0.1 94 | i = 0 95 | violations = [] 96 | while True: 97 | dev_test = set(rdm.choice(test_candidates, size=dev_test_size*2, replace=False)) 98 | contains_all_neighbor = False 99 | for c in dev_test: 100 | contains_all_neighbors = all([n in dev_test for n in country2neighbors[c]]) 101 | print([n in dev_test for n in country2neighbors[c]]) 102 | 103 | if not contains_all_neighbors: 104 | dev_test = list(dev_test) 105 | break 106 | else: 107 | i += 1 108 | print(i) 109 | 110 | dev = dev_test[:dev_test_size] 111 | test = dev_test[dev_test_size:] 112 | 113 | # save region data for test / dev set 114 | dev_dict = {} 115 | test_dict = {} 116 | for c in dev: 117 | dev_dict[(c, 'region')] = train_dict[(c, 'region')] 118 | for c in test: 119 | test_dict[(c, 'region')] = train_dict[(c, 'region')] 120 | 121 | 122 | def merge_predicates(pred): 123 | if pred == 'region' or pred == 'subregion': 124 | return 'locatedIn' 125 | else: 126 | return 'neighborOf' 127 | 128 | with open(join(base_path, "countries.nl"), "w") as f: 129 | for corpus, name in [(train_dict, "train")]: 130 | # (dev_dict, "dev"), 131 | # (test_dict, "test")]: 132 | #f.write("% " + "### %s ###\n" % name) 133 | for (country, relation), values in corpus.items(): 134 | for value in values: 135 | f.write(("%s(%s,%s).\n" % 136 | (merge_predicates(relation), country, value))) 137 | # f.write("% " + "### subregions ###\n") 138 | for subregion in subregion2region: 139 | f.write(("locatedIn(%s,%s).\n" % 140 | (subregion, subregion2region[subregion]))) 141 | 142 | S1 = copy.deepcopy(train_dict) 143 | S2 = copy.deepcopy(train_dict) 144 | S3 = copy.deepcopy(train_dict) 145 | for s in [dev, test]: 146 | for c in s: 147 | # remove all regions in S1 148 | S1.pop((c, 'region'), None) 149 | 150 | # remove all regions and subregion in S2 151 | S2.pop((c, 'region'), None) 152 | S2.pop((c, 'subregion'), None) 153 | 154 | # remove all region and subregion in S3, and additionally all regions of all neighbors of the tested country 155 | S3.pop((c, 'region'), None) 156 | S3.pop((c, 'subregion'), None) 157 | for n in country2neighbors[c]: 158 | S3.pop((n, 'region'), None) 159 | 160 | print(len(S1.keys())) 161 | print(len(S2.keys())) 162 | print(len(S3.keys())) 163 | 164 | for train, name in zip([S1, S2, S3], ['S1', 'S2', 'S3']): 165 | with open(join(base_path, 'countries_{0}.nl'.format(name)), 'w') as f: 166 | # for (country, relation), values in train.items(): 167 | # for value in values: 168 | # # f.write(delimiter.join([country, relation, value]) + '\n') 169 | # relation = merge_predicates(relation) 170 | # f.write("%s(%s,%s).\n" % (relation, country, value)) 171 | # for subregion in subregion2region: 172 | # f.write(("locatedIn(%s,%s).\n" % 173 | # (subregion, subregion2region[subregion]))) 174 | # # fixme: add dev / test data! 175 | for corpus, name in [(train, "train")]: 176 | # f.write("% " + "### %s ###\n" % name) 177 | for (country, relation), values in corpus.items(): 178 | for value in values: 179 | f.write(("%s(%s,%s).\n" % 180 | (merge_predicates(relation), country, value))) 181 | #f.write("% " + "### subregions ###\n") 182 | for subregion in subregion2region: 183 | f.write(("locatedIn(%s,%s).\n" % 184 | (subregion, subregion2region[subregion]))) 185 | 186 | 187 | for dev_test, name in zip([dev_dict, test_dict], ['valid', 'test']): 188 | with open(join(base_path, '{0}.txt'.format(name)), 'w') as f: 189 | for (country, relation), values in dev_test.items(): 190 | for value in values: 191 | # f.write(delimiter.join([country, relation, value]) + '\n') 192 | # relation = merge_predicates(relation) 193 | # f.write("%s(%s,%s).\n" % (relation, country, value)) 194 | f.write(country + "\n") 195 | -------------------------------------------------------------------------------- /ntp/data/countries2nkb.py: -------------------------------------------------------------------------------- 1 | import random 2 | import re 3 | from ntp.kb import load_from_file 4 | 5 | 6 | def clean(x): 7 | return x.replace(" ", "_").replace("(", "").replace(")", "").lower() 8 | 9 | 10 | acronym2name = {} 11 | table = [] 12 | 13 | countries = set() 14 | regions = set() 15 | subregions = set() 16 | 17 | country2neighbors = {} 18 | 19 | with open("./data/countries/countries.csv", "r") as f_in: 20 | for line in f_in.readlines()[1:]: 21 | line = line.strip().split(";") 22 | country = clean(line[0][1:-1].split(",")[0]) 23 | acronym = line[4][1:-1] 24 | acronym2name[acronym] = country 25 | capital = line[8] 26 | region = clean(line[10][1:-1]) 27 | subregion = clean(line[11][1:-1]) 28 | borders = line[17][1:-1].split(",") 29 | if borders == ['']: 30 | borders = [] 31 | 32 | assert country != "" 33 | 34 | if region != "": 35 | regions.add(region) 36 | if subregion != "": 37 | subregions.add(subregion) 38 | 39 | if region != "" and subregion != "": 40 | table.append((country, region, subregion, borders)) 41 | countries.add(country) 42 | f_in.close() 43 | 44 | facts = set() 45 | 46 | country2facts = {} 47 | 48 | for country, region, subregion, borders in table: 49 | country_facts = ["locatedIn(%s,%s).\n" % (country, region), 50 | "locatedIn(%s,%s).\n" % (country, subregion), 51 | "locatedIn(%s,%s).\n" % (subregion, region)] 52 | neighbors = ["neighborOf(%s,%s).\n" % (country, acronym2name[x]) 53 | for x in borders] 54 | country2neighbors[country] = set(acronym2name[x] for x in borders) 55 | for neighbor in neighbors: 56 | country_facts.append(neighbor) 57 | for fact in country_facts: 58 | facts.add(fact) 59 | country2facts[country] = country_facts 60 | 61 | assert len(countries) == 244 62 | assert len(regions) == 5 63 | assert len(subregions) == 23 64 | 65 | # print(sorted(list(subregions))) 66 | 67 | with open("./data/countries/countries.nl", "w") as f_out: 68 | for fact in facts: 69 | f_out.write(fact) 70 | f_out.close() 71 | 72 | with open("./data/countries/regions.txt", "w") as f_out: 73 | for region in regions: 74 | f_out.write("%s\n" % region) 75 | f_out.close() 76 | 77 | with open("./data/countries/subregions.txt", "w") as f_out: 78 | for region in subregions: 79 | f_out.write("%s\n" % region) 80 | f_out.close() 81 | 82 | 83 | countries = list(countries) 84 | 85 | countries_w_neighbors = [] 86 | countries_wo_neigbors = [] 87 | for country in countries: 88 | if len(country2neighbors[country]) > 0: 89 | countries_w_neighbors.append(country) 90 | else: 91 | countries_wo_neigbors.append(country) 92 | 93 | 94 | num_countries = len(countries) 95 | splits = [0.1, 0.1, 0.8] 96 | splits = [int(num_countries * x) for x in splits] 97 | 98 | train_countries = countries_wo_neigbors 99 | random.shuffle(countries_w_neighbors) 100 | 101 | test = countries_w_neighbors[0:splits[0]] 102 | dev = countries_w_neighbors[splits[0]:splits[0]+splits[1]] 103 | train = countries_w_neighbors[splits[0]+splits[1]:] + countries_wo_neigbors 104 | 105 | 106 | def ensure_consistency(train, dev, test, tries=100): 107 | print("Ensuring consistency", tries) 108 | swap_test_with_train = [] 109 | swap_dev_with_train = [] 110 | new_test = [] 111 | new_dev = [] 112 | 113 | for x in test: 114 | neighbors = country2neighbors[x] 115 | train_neighbors = [x for x in neighbors if x in train] 116 | if len(train_neighbors) == 0: 117 | # print(x, len(neighbors), len(train_neighbors)) 118 | swap_test_with_train.append(x) 119 | else: 120 | new_test.append(x) 121 | 122 | for x in dev: 123 | neighbors = country2neighbors[x] 124 | train_neighbors = [x for x in neighbors if x in train] 125 | if len(train_neighbors) == 0: 126 | # print(x, len(neighbors), len(train_neighbors)) 127 | swap_dev_with_train.append(x) 128 | else: 129 | new_dev.append(x) 130 | 131 | #print(swap_dev_with_train) 132 | #print(swap_test_with_train) 133 | 134 | if len(swap_dev_with_train) + len(swap_test_with_train) == 0: 135 | return train, dev, test 136 | elif tries == 0: 137 | print("Damn!") 138 | else: 139 | random.shuffle(train) 140 | new_dev += train[len(swap_test_with_train):len(swap_test_with_train) + 141 | len(swap_dev_with_train)] 142 | new_test += train[:len(swap_test_with_train)] 143 | train = train[len(swap_test_with_train)+len(swap_dev_with_train):] + \ 144 | swap_test_with_train + swap_dev_with_train 145 | return ensure_consistency(train, new_dev, new_test, tries - 1) 146 | 147 | 148 | train, dev, test = ensure_consistency(train, dev, test, tries=10) 149 | 150 | # with open("./data/countries/countries_train.nl", "w") as f_out: 151 | # for country in train: 152 | # for fact in country2facts[country]: 153 | # f_out.write(fact) 154 | # f_out.close() 155 | 156 | 157 | with open("./data/countries/test.txt", "w") as f_out: 158 | for country in test: 159 | f_out.write("%s\n" % country) 160 | f_out.close() 161 | 162 | 163 | with open("./data/countries/dev.txt", "w") as f_out: 164 | for country in dev: 165 | f_out.write("%s\n" % country) 166 | f_out.close() 167 | 168 | with open("./data/countries/countries_S1.nl", "w") as f_out: 169 | for corpus in [dev, test]: 170 | for country in corpus: 171 | for fact in country2facts[country]: 172 | arg2 = fact.split(",")[1].split(")")[0] 173 | if arg2 not in regions: 174 | f_out.write(fact) 175 | for country in train: 176 | for fact in country2facts[country]: 177 | f_out.write(fact) 178 | 179 | f_out.close() 180 | 181 | with open("./data/countries/countries_S2.nl", "w") as f_out: 182 | for corpus in [dev, test]: 183 | for country in corpus: 184 | for fact in country2facts[country]: 185 | arg2 = fact.split(",")[1].split(")")[0] 186 | if arg2 not in regions and arg2 not in subregions: 187 | f_out.write(fact) 188 | for country in train: 189 | for fact in country2facts[country]: 190 | f_out.write(fact) 191 | 192 | f_out.close() 193 | 194 | with open("./data/countries/countries_S3.nl", "w") as f_out: 195 | for corpus in [dev, test]: 196 | for country in corpus: 197 | for fact in country2facts[country]: 198 | arg2 = fact.split(",")[1].split(")")[0] 199 | if arg2 not in regions and arg2 not in subregions: 200 | f_out.write(fact) 201 | 202 | test_countries = set(dev).union(set(test)) 203 | for country in train: 204 | is_neighbor_of_test_country = False 205 | country_neighbors = country2neighbors[country] 206 | country_test_neighbors = \ 207 | test_countries.intersection(set(country_neighbors)) 208 | is_test_neighbor = len(country_test_neighbors) > 0 209 | 210 | for fact in country2facts[country]: 211 | arg2 = fact.split(",")[1].split(")")[0] 212 | if arg2 not in regions or not is_test_neighbor: 213 | f_out.write(fact) 214 | 215 | f_out.close() 216 | -------------------------------------------------------------------------------- /ntp/data/db2nkb.py: -------------------------------------------------------------------------------- 1 | import re 2 | import random 3 | 4 | random.seed(1337) 5 | 6 | # for dat in ["umls", "kinship"]: 7 | # for dat in ["kinship", "nations"]: 8 | # for dat in ["animals"]: 9 | for dat in ["nations"]: 10 | db_name = dat[:3] 11 | atoms = [] 12 | entities = set() 13 | 14 | with open("./data/%s/%s.db" % (dat, db_name), "r") as f_in: 15 | for line in f_in.readlines(): 16 | line = line.strip() 17 | atom = re.split("\(|\)|,", line)[1:-1] 18 | print(atom) 19 | atom = [x.lower() for x in atom if x != ""] 20 | if len(atom) > 2: 21 | entities.add(atom[1]) 22 | entities.add(atom[2]) 23 | # else: 24 | # atom = atom[::-1] 25 | # 26 | # if len(atom) != 0: 27 | atoms.append(atom) 28 | 29 | with open("./data/%s/%s.nl" % (dat, dat), "w") as f_out: 30 | for atom in atoms: 31 | f_out.write(atom[0] + "(%s)" % ",".join(atom[1:]) + ".\n") 32 | 33 | random.shuffle(atoms) 34 | split = int(len(atoms) * 0.1) 35 | 36 | train = atoms[:split * 8] 37 | dev = atoms[split * 8:split * 9] 38 | test = atoms[split*9:] 39 | 40 | for name, corpus in [("train", train), ("dev", dev), ("test", test)]: 41 | with open("./data/%s/%s.nl" % (dat, name), "w") as f_out: 42 | for atom in corpus: 43 | f_out.write(atom[0] + "(%s)" % ",".join(atom[1:]) + ".\n") 44 | f_out.close() 45 | 46 | with open("./data/%s/entities.txt" % dat, "w") as f: 47 | for entity in entities: 48 | f.write(entity + "\n") 49 | -------------------------------------------------------------------------------- /ntp/data/umls2nkb.py: -------------------------------------------------------------------------------- 1 | import re 2 | import random 3 | 4 | atoms = [] 5 | entities = set() 6 | with open("./data/umls/uml.db", "r") as f_in: 7 | for line in f_in.readlines(): 8 | line = line.strip() 9 | atom = re.split("\(|\)|,", line)[1:-1] 10 | print(atom) 11 | atom = [x.lower() for x in atom if x != ""] 12 | 13 | entities.add(atom[1]) 14 | entities.add(atom[2]) 15 | 16 | if len(atom) != 0: 17 | atoms.append(atom) 18 | 19 | with open("./data/umls/umls.nl", "w") as f_out: 20 | for atom in atoms: 21 | f_out.write(atom[0] + "(%s)" % ",".join(atom[1:]) + ".\n") 22 | 23 | 24 | random.shuffle(atoms) 25 | split = int(len(atoms) * 0.1) 26 | 27 | train = atoms[:split * 8] 28 | dev = atoms[split * 8:split * 9] 29 | test = atoms[split*9:] 30 | 31 | for name, corpus in [("train", train), ("dev", dev), ("test", test)]: 32 | with open("./data/umls/%s.nl" % name, "w") as f_out: 33 | for atom in corpus: 34 | f_out.write(atom[0] + "(%s)" % ",".join(atom[1:]) + ".\n") 35 | f_out.close() 36 | 37 | with open("./data/umls/entities.txt", "w") as f: 38 | for entity in entities: 39 | f.write(entity + "\n") 40 | -------------------------------------------------------------------------------- /ntp/experiments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/experiments/__init__.py -------------------------------------------------------------------------------- /ntp/experiments/util.py: -------------------------------------------------------------------------------- 1 | def kb_ids2known_facts(kb_ids): 2 | """ 3 | :param kb_ids: a knowledge base of facts that are already mapped to ids 4 | :return: a set of all known facts (used later for negative sampling) 5 | """ 6 | 7 | facts = set() 8 | for struct in kb_ids: 9 | arrays = kb_ids[struct][0] 10 | num_facts = len(arrays[0]) 11 | for i in range(num_facts): 12 | fact = [x[i] for x in arrays] 13 | facts.add(tuple(fact)) 14 | return facts 15 | -------------------------------------------------------------------------------- /ntp/jtr/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/jtr/__init__.py -------------------------------------------------------------------------------- /ntp/jtr/nn/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/jtr/nn/__init__.py -------------------------------------------------------------------------------- /ntp/jtr/preprocess/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/jtr/preprocess/__init__.py -------------------------------------------------------------------------------- /ntp/jtr/train.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | 3 | 4 | def train(loss, optim, batches, placeholders=None, predict=None, max_epochs=10, 5 | hooks=[], pre_run=None, post_run=None, sess=None, l2=0.0, clip=None, 6 | clip_op=tf.clip_by_value, check_numerics=False): 7 | """Trains a model which can be decorated with various options. 8 | 9 | Args: 10 | loss (function): The TensorFlow function for the loss. 11 | optim (function): Optimizer for the loss function such as Adam. 12 | batches (list of feed dicts or list of numpy arrays): Input data. 13 | placeholders (TensorFlow placeholder=None): Needed if batches is a 14 | list of arrays. 15 | predict (function): Function that predicts values via the model. 16 | max_epochs (int): How often to iterate over the entire data. 17 | hooks (list of TraceHook interfaces): Hooks are executed at the end of 18 | an iteration or at the end of an epoch. 19 | pre_run (function): A function that is execute before each iteration 20 | on a batch. 21 | post_run (function): A function that is execute after each iteration 22 | on a batch. 23 | sess (TensorFlow session): The TensorFlow session object. 24 | l2 (float): The L2 penalty for the parameters (0.0 == turned off). 25 | clip (float,float): Tuple for the lower and upper cut-off value for the 26 | gradient. 27 | clip_op (TensorFlow clip function): Either clip_by_value, or 28 | clip_by_norm. Applies the respective TensowFlow function. 29 | 30 | Returns: None 31 | 32 | """ 33 | if l2 != 0.0: 34 | loss += \ 35 | tf.add_n([tf.nn.l2_loss(v) for v in tf.trainable_variables()]) * l2 36 | 37 | if clip is not None: 38 | gradients = optim.compute_gradients(loss) 39 | if clip_op == tf.clip_by_value: 40 | capped_gradients = [(tf.clip_by_value(grad, clip[0], clip[1]), var) 41 | for grad, var in gradients] 42 | elif clip_op == tf.clip_by_norm: 43 | capped_gradients = [(tf.clip_by_norm(grad, clip), var) 44 | for grad, var in gradients] 45 | min_op = optim.apply_gradients(capped_gradients) 46 | else: 47 | min_op = optim.minimize(loss) 48 | 49 | # Do not take up all the GPU memory, all the time. 50 | sess_config = tf.ConfigProto() 51 | sess_config.gpu_options.allow_growth = True 52 | 53 | if sess is None: 54 | sess = tf.Session(config=sess_config) 55 | 56 | tf.global_variables_initializer().run(session=sess) 57 | 58 | nodes = [min_op, loss] 59 | if check_numerics: 60 | nodes.append(tf.add_check_numerics_ops()) 61 | 62 | for i in range(1, max_epochs + 1): 63 | for j, batch in enumerate(batches): 64 | if placeholders is not None: 65 | feed_dict = dict(zip(placeholders, batch)) 66 | else: 67 | feed_dict = batch 68 | 69 | if pre_run is not None: 70 | pre_run(sess, i, feed_dict, loss, predict) 71 | 72 | result = sess.run(nodes, feed_dict=feed_dict) 73 | current_loss = result[1] 74 | 75 | if post_run is not None: 76 | post_run(sess, i, feed_dict, loss, predict) 77 | 78 | for hook in hooks: 79 | hook.at_iteration_end(sess, i, predict, current_loss, feed_dict) 80 | 81 | # calling post-epoch hooks 82 | for hook in hooks: 83 | hook.at_epoch_end(sess, i, predict, 0) 84 | -------------------------------------------------------------------------------- /ntp/jtr/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uclnlp/ntp/23687f5ccbb089ed78b4bcef5d055091408ee8d2/ntp/jtr/util/__init__.py -------------------------------------------------------------------------------- /ntp/jtr/util/rs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def singleton(cls): 5 | instances = {} 6 | 7 | def getinstance(*args, **kwargs): 8 | if cls not in instances: 9 | instances[cls] = cls(*args, **kwargs) 10 | return instances[cls] 11 | return getinstance 12 | 13 | 14 | @singleton 15 | class DefaultRandomState(np.random.RandomState): 16 | def __init__(self, seed=None): 17 | super().__init__(seed) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ntp/jtr/util/util.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # __ _ __ 4 | # __ __/ /_(_) / 5 | # / / / / __/ / / 6 | #/ /_/ / /_/ / / 7 | #\____/\__/_/_/ v0.2 8 | # 9 | #Making useful stuff happen since 2016 10 | 11 | import numpy as np 12 | import contextlib 13 | from time import gmtime, strftime 14 | import os 15 | import json 16 | import tensorflow as tf 17 | import logging 18 | logger = logging.getLogger("tfutil") 19 | 20 | 21 | @contextlib.contextmanager 22 | def printoptions(*args, **kwargs): 23 | """Switches printoptions temporarily via yield before switching back.""" 24 | original = np.get_printoptions() 25 | np.set_printoptions(*args, **kwargs) 26 | yield 27 | np.set_printoptions(**original) 28 | 29 | 30 | def shape2str(x): 31 | """Converts a shape array to a string.""" 32 | return "[" + " x ".join([str(x) for x in x.shape]) + "]" 33 | 34 | 35 | def nprint(x, prefix="", precision=3, surpress=True, max_list_len=5, show_shape=True): 36 | """Prints `x` with given numpy options (default=compact+shape).""" 37 | with printoptions(precision=precision, suppress=surpress): 38 | if isinstance(x, np.ndarray): 39 | print(prefix + "ndarray") 40 | print(str(x)) 41 | if show_shape: 42 | print("of shape " + shape2str(x) + "\n") 43 | elif isinstance(x, tuple): 44 | print(prefix + "tuple") 45 | for i, j in enumerate(x): 46 | print(str(i)) 47 | nprint(j, prefix, precision, surpress, max_list_len, show_shape) 48 | print() 49 | elif isinstance(x, list): 50 | # fixme: breaks when list elements are not ndarrays 51 | print(prefix + "list of %d elements with shape %s" 52 | % (len(x), shape2str(x[0]))) 53 | for i in range(min(len(x), max_list_len)): 54 | nprint(x[i], prefix + "list[%d] " % i, precision, surpress, max_list_len, show_shape=False) 55 | print() 56 | # todo: do the same for tensors 57 | else: 58 | print(x) 59 | print() 60 | 61 | 62 | def tfprint(tensor, message="", precision=2, first_n=None, summarize=10000, 63 | name=None, print_shape=True): 64 | def print_tensor(x): 65 | str_val = message 66 | str_val += np.array2string(x, precision=precision) 67 | if print_shape: 68 | str_val += "\n" + str(x.shape) 69 | logger.debug(str_val) 70 | return x 71 | 72 | log_op = tf.py_func(print_tensor, [tensor], [tensor.dtype])[0] 73 | with tf.control_dependencies([log_op]): 74 | res = tf.identity(tensor) 75 | return res 76 | 77 | 78 | def tfprint_legacy(tensor, message=None, precision=5, first_n=None, summarize=10000, 79 | name=None, print_shape=True): 80 | def reduce_precision(a, precision=2): 81 | return tf.floordiv(a * 100, 1) / 100 82 | tmp = tf.Print(tensor, [reduce_precision(tensor, precision=precision)], 83 | message=message, first_n=first_n, 84 | summarize=summarize, name=name) 85 | if print_shape: 86 | tmp = tf.Print(tmp, [tf.shape(tmp)], message="shape_" + message) 87 | return tmp 88 | 89 | 90 | def get_timestamped_dir(path, name=None, link_to_latest=False): 91 | """Create a directory with the current timestamp.""" 92 | current_time = strftime("%y-%m-%d/%H-%M-%S", gmtime()) 93 | dir = path + "/" + current_time + "/" 94 | if not os.path.exists(dir): 95 | os.makedirs(dir) 96 | if name is not None: 97 | if os.path.exists(path + "/" + name): 98 | os.remove(path + "/" + name) 99 | os.symlink(current_time, path + "/" + name, target_is_directory=True) 100 | if link_to_latest: 101 | if os.path.exists(path + "/latest"): 102 | os.remove(path + "/latest") 103 | os.symlink(current_time, path + "/latest", target_is_directory=True) 104 | return dir 105 | 106 | 107 | def save_conf(path, conf): 108 | with open(path, "w") as f_out: 109 | splits = path.split("/") 110 | dir = "/".join(splits[:-1]) + "/" 111 | conf["meta"]["experiment_dir"] = dir 112 | json.dump(conf, f_out, indent=4, sort_keys=True) 113 | f_out.close() 114 | 115 | 116 | def deep_merge(dict1, dict2): 117 | """ 118 | overrides entries in dict1 with entries in dict2! 119 | """ 120 | if isinstance(dict1, dict) and isinstance(dict2, dict): 121 | tmp = {} 122 | for key in dict1: 123 | if key not in dict2: 124 | tmp[key] = dict1[key] 125 | else: 126 | tmp[key] = deep_merge(dict1[key], dict2[key]) 127 | for key in dict2: 128 | if key not in dict1: 129 | tmp[key] = dict2[key] 130 | return tmp 131 | else: 132 | return dict2 133 | 134 | 135 | def load_conf(path, experiment_dir=None): 136 | file_name = path.split("/")[-1] 137 | 138 | with open(path, 'r') as f: 139 | conf = eval(f.read()) 140 | 141 | if "meta" not in conf: 142 | conf["meta"] = {} 143 | 144 | conf["meta"]["conf"] = path 145 | conf["meta"]["name"] = file_name.split(".")[0] 146 | conf["meta"]["file_name"] = file_name 147 | 148 | if "parent" in conf["meta"] and conf["meta"]["parent"] is not None: 149 | parent = load_conf(conf["meta"]["parent"]) 150 | conf = deep_merge(parent, conf) # {**parent, **conf} 151 | 152 | if experiment_dir is not None: 153 | save_conf(experiment_dir+file_name, conf) 154 | 155 | f.close() 156 | 157 | return conf -------------------------------------------------------------------------------- /ntp/kb.py: -------------------------------------------------------------------------------- 1 | """ 2 | [INSERT ASCII ART HERE] v0.1 3 | Symbolic Representation of a Knowledge Base 4 | """ 5 | 6 | import re 7 | from pprint import pprint 8 | from ntp.util import trim, is_variable, has_free_variables, Atom 9 | 10 | 11 | def parse_rules(rules, delimiter="#####", rule_template=False): 12 | """ 13 | :param rules: 14 | :param delimiter: 15 | :return: 16 | """ 17 | kb = [] 18 | for rule in rules: 19 | if rule_template: 20 | splits = re.split("\A\n?([0-9]?[0-9]+)", rule) 21 | # fixme: should be 0 and 1 respectively 22 | num = int(splits[1]) 23 | rule = splits[2] 24 | rule = re.sub(":-", delimiter, rule) 25 | rule = re.sub("\),", ")"+delimiter, rule) 26 | rule = [trim(x) for x in rule.split(delimiter)] 27 | rule = [x for x in rule if x != ""] 28 | if len(rule) > 0: 29 | atoms = [] 30 | for atom in rule: 31 | splits = atom.split("(") 32 | predicate = splits[0] 33 | args = [x for x in re.split("\s?,\s?|\)", splits[1]) if x != ""] 34 | atoms.append(Atom(predicate, args)) 35 | if rule_template: 36 | kb.append((atoms, num)) 37 | else: 38 | kb.append(atoms) 39 | return kb 40 | 41 | 42 | def load_from_file(path, rule_template=False): 43 | with open(path, "r") as f: 44 | text = f.readlines() 45 | text = [x for x in text if not x.startswith("%") and x.strip() != ""] 46 | text = "".join(text) 47 | rules = [x for x in re.split("\.\n|\.\Z", text) if x != "" and 48 | x != "\n" and not x.startswith("%")] 49 | kb = parse_rules(rules, rule_template=rule_template) 50 | # pprint(kb) 51 | return kb 52 | 53 | 54 | def normalize(kb): 55 | counter = 0 56 | normalized_kb = [] 57 | 58 | def suffix_variables(atom, suffix): 59 | new_args = [] 60 | for arg in atom.arguments: 61 | if is_variable(arg): 62 | new_args.append(arg+suffix) 63 | else: 64 | new_args.append(arg) 65 | return Atom(atom.predicate, new_args) 66 | 67 | for rule in kb: 68 | if has_free_variables(rule): 69 | normalized_kb.append([suffix_variables(atom, str(counter)) 70 | for atom in rule]) 71 | counter += 1 72 | else: 73 | normalized_kb.append(rule) 74 | return normalized_kb 75 | 76 | 77 | if __name__ == '__main__': 78 | kb = load_from_file("./data/ntp/legal.nl") 79 | pprint(kb) 80 | for rule in kb: 81 | for atom in rule: 82 | print(atom.predicate) 83 | print(atom.arguments) 84 | -------------------------------------------------------------------------------- /ntp/kmax.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | import numpy as np 3 | from tensorflow.python.framework import ops 4 | import logging 5 | import sys 6 | 7 | logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) 8 | 9 | 10 | # (Approximately) Differentiable K-Max 11 | # forward 12 | def diff_k_max(scores, k): 13 | """ 14 | :param scores: [N x M] 15 | :param k: number of maximum elements to keep 16 | :return: 17 | [k x M] k max scores 18 | [k x M] indices of k max scores 19 | """ 20 | #scores = np.transpose(scores) 21 | # print("np scores\n", scores) 22 | #ix = np.transpose(np.argpartition(-scores, k)[:, :k]) 23 | # print("np ix\n", ix) 24 | #scores = np.transpose(-np.partition(-scores, k)[:, :k]) 25 | # ix = np.fliplr(ix) 26 | 27 | ix = np.argsort(-scores, axis=0)[:k, :] 28 | # fixme: slow as we are sorting twice 29 | # replace this by indexing 30 | scores = -np.sort(-scores, axis=0)[:k, :] 31 | 32 | return scores.astype(np.float32), ix.astype(np.int32) 33 | 34 | 35 | # backward 36 | def diff_k_max_grad(op, grad1, grad2): 37 | """ 38 | :param op: 39 | - scores: [N x M] 40 | - k 41 | :param 42 | - grad1: [k x M] upstream gradient 43 | - grad2: discarded 44 | :return: scores_grad, 0 45 | """ 46 | scores = op.inputs[0] 47 | k = op.inputs[1] 48 | N = int(scores.get_shape()[0]) 49 | M = int(scores.get_shape()[1]) 50 | success_grad = grad1 51 | 52 | top_k_scores, top_k_ix = tf.nn.top_k(tf.transpose(scores), k) 53 | 54 | #top_k_ix = tfprint(top_k_ix, "backward scores\n", other_tensors=[top_k_scores]) 55 | #top_k_ix = tfprint(top_k_ix, "backward ix\n") 56 | #ix = tf.reverse(ix, [1]) 57 | #ix = tfprint(ix, "ix") 58 | 59 | 60 | # gradient scores 61 | 62 | # fixme: error here? 63 | row_ids = tf.constant([list(range(0, M))], dtype=tf.int32) 64 | row_ids = tf.transpose(tf.tile(row_ids, [k, 1])) 65 | row_ids = tf.reshape(row_ids, [-1, 1]) 66 | 67 | sparse_ix = tf.reshape(top_k_ix, [-1, 1]) 68 | sparse_ix = tf.concat([sparse_ix, row_ids], 1) 69 | sparse_ix = tf.cast(sparse_ix, tf.int64) 70 | sparse_grad_vals = tf.reshape(tf.transpose(success_grad), [-1]) 71 | 72 | # validate_indices=False is unproblematic as we check that there are no 73 | # duplicate indices 74 | scores_grad_downstream = tf.sparse_to_dense( 75 | sparse_ix, [N, M], sparse_grad_vals, 76 | validate_indices=False) 77 | return scores_grad_downstream, tf.constant(0) 78 | 79 | 80 | def my_py_func(func, inp, Tout, stateful=True, name=None, grad=None): 81 | # Need to generate a unique name to avoid duplicates: 82 | rnd_name = 'MyPyFuncGrad' + str(np.random.randint(0, int(1E+8))) 83 | 84 | tf.RegisterGradient(rnd_name)(grad) # see _MySquareGrad for grad example 85 | g = tf.get_default_graph() 86 | with g.gradient_override_map({"PyFunc": rnd_name}): 87 | return tf.py_func(func, inp, Tout, stateful=stateful, name=name) 88 | 89 | 90 | def tf_k_max(scores, k, name=None): 91 | """ 92 | :param scores: [N x M] 93 | :param k: int 94 | :param name: 95 | :return: 96 | - [k x M] k max scores 97 | - [k x M] indices of k max scores 98 | """ 99 | # with tf.name_scope(name, tf_k_max, [scores, k]) as name: 100 | with ops.op_scope([scores, k], name, "tf_k_max") as name: 101 | z = my_py_func(diff_k_max, [scores, k], 102 | [tf.float32, tf.int32], 103 | name=name, grad=diff_k_max_grad) 104 | 105 | M = int(scores.get_shape()[1]) 106 | z[0].set_shape([k, M]) 107 | return z 108 | 109 | if __name__ == '__main__': 110 | with tf.Session() as my_sess: 111 | N = 5 112 | M = 6 113 | k = 3 114 | input_size = 1 115 | 116 | scores = tf.Variable(np.random.randn(N, M), 117 | dtype=tf.float32) 118 | 119 | reps = tf.constant(np.random.rand(N, input_size)) 120 | 121 | tf.global_variables_initializer().run() 122 | 123 | top_k_scores, top_k_ix = tf_k_max(scores, k) 124 | 125 | print("in:") 126 | print("scores\n", scores.eval()) 127 | print("out:") 128 | print("top k scores\n", top_k_scores.eval()) 129 | print("top k ix\n", top_k_ix.eval()) 130 | print() 131 | 132 | upstream_success_grad = tf.constant( 133 | np.random.randn(k, M) * 0.01, 134 | dtype=tf.float32) 135 | 136 | print("success grad upstream\n", upstream_success_grad.eval()) 137 | gr_success = tf.gradients(top_k_scores, [scores, k], 138 | grad_ys=upstream_success_grad) 139 | print("success grad downstream\n", gr_success[0].eval()) 140 | print() 141 | 142 | success_flat = tf.reshape(tf.transpose(top_k_scores), [1, -1]) 143 | print("success flat\n", success_flat.eval()) 144 | 145 | ix_k_flat = tf.reshape(tf.transpose(top_k_ix), [-1]) 146 | print("ix k flat\n", ix_k_flat.eval()) 147 | # fixme: need validate indices? 148 | var_rep = tf.gather(reps, ix_k_flat, validate_indices=True) 149 | print("reps\n", reps.eval()) 150 | print("k reps\n", var_rep.eval()) -------------------------------------------------------------------------------- /ntp/nkb.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | _ ____ _____ 4 | / |/ / //_/ _ ) 5 | / / ,< / _ | 6 | /_/|_/_/|_/____/ v0.6 7 | 8 | Neural Knowledge Base 9 | """ 10 | 11 | import tensorflow as tf 12 | 13 | from ntp.kb import Atom 14 | from pprint import pprint 15 | from ntp.util import is_variable, is_parameter 16 | from ntp.jtr.preprocess.vocab import Vocab 17 | from ntp.jtr.util.tfutil import unit_length_transform 18 | import numpy as np 19 | import copy 20 | 21 | 22 | def rule2struct(rule): 23 | """ 24 | Returns the structure of a rule used to partition a knowledge base 25 | :param rule: a rule 26 | :return: a tuple representing the structure of the rule 27 | """ 28 | predicates = {} 29 | constants = {} 30 | variables = {} 31 | struct = [] 32 | for predicate, args in rule: 33 | atom_struct = [] 34 | if predicate not in predicates: 35 | predicates[predicate] = "p" + str(len(predicates)) 36 | atom_struct.append(predicates[predicate]) 37 | for arg in args: 38 | if is_variable(arg): 39 | if arg not in variables: 40 | variables[arg] = "X" + str(len(variables)) 41 | atom_struct.append(variables[arg]) 42 | else: 43 | if arg not in constants: 44 | constants[arg] = "c" # + str(len(constants)) 45 | atom_struct.append(constants[arg]) 46 | struct.append(tuple(atom_struct)) 47 | return tuple(struct) 48 | 49 | 50 | def augment_with_templates(kb, rule_templates): 51 | """ 52 | :param kb: a knowledge base with symbolic representations 53 | :return: knowledge base agumented with parameterized rule templates 54 | """ 55 | kb_copy = copy.deepcopy(kb) 56 | 57 | def suffix_rule_parameters(rule, num_rule, num_copy): 58 | new_rule = [] 59 | for predicate, args in rule: 60 | if is_parameter(predicate): 61 | new_rule.append(Atom("%s_%d_%d" % 62 | (predicate, num_rule, num_copy), args)) 63 | else: 64 | new_rule.append(Atom(predicate, args)) 65 | return new_rule 66 | 67 | for i, (rule_template, num) in enumerate(rule_templates): 68 | for j in range(num): 69 | # fixme: need to suffix parameters by i and j 70 | kb_copy.append(suffix_rule_parameters(rule_template, i, j)) 71 | return kb_copy 72 | 73 | 74 | def partition(kb): 75 | """ 76 | :param kb: a knowledge base with symbolic representations 77 | :return: a knowledge base partitioned by the structure of rules 78 | """ 79 | kb_partitioned = {} 80 | for rule in kb: 81 | struct = rule2struct(rule) 82 | if struct not in kb_partitioned: 83 | kb_partitioned[struct] = [rule] 84 | else: 85 | kb_partitioned[struct].append(rule) 86 | return kb_partitioned 87 | 88 | 89 | def kb2ids(kb, vocab=None, permutation=[0, 1, 2, 3]): 90 | """ 91 | :param kb: a partitioned knowledge base 92 | :return: a partitioned knowledge base where symbols (except variables) are 93 | mapped to ids 94 | """ 95 | kb_ids = {} 96 | vocab = vocab or Vocab() 97 | 98 | predicate_ids = [] 99 | constant_ids = [] 100 | 101 | keys = sorted(list(kb.keys())) 102 | print("before") 103 | pprint(keys) # permutation = [1, 3, 0, 2] 104 | 105 | if permutation: 106 | keys = [x for i, x in sorted(zip(permutation, keys))] 107 | 108 | print("after") 109 | # fixme: non-deterministic! 110 | for struct in keys: 111 | print(struct) 112 | rules = kb[struct] 113 | kb_stacked = [] 114 | 115 | for rule in rules: 116 | for i, (predicate, args) in enumerate(rule): 117 | if len(kb_stacked) < i + 1: 118 | kb_stacked.append([]) 119 | symbols = [x for x in [predicate] + args] # if not is_variable(x)] 120 | for j, sym in enumerate(symbols): 121 | if not is_variable(sym): 122 | if j == 0 and sym not in vocab: 123 | predicate_ids.append(vocab(sym)) 124 | elif j > 0 and sym not in vocab: 125 | constant_ids.append(vocab(sym)) 126 | 127 | if len(kb_stacked[i]) < j + 1: 128 | kb_stacked[i].append([]) 129 | kb_stacked[i][j].append(sym) 130 | 131 | # mapping to ids and stacking as numpy array 132 | for i, atom in enumerate(kb_stacked): 133 | for j, symbols in enumerate(atom): 134 | if not is_variable(symbols[0]): 135 | kb_stacked[i][j] = np.hstack(vocab(symbols)) 136 | else: 137 | kb_stacked[i][j] = symbols 138 | 139 | kb_ids[struct] = kb_stacked 140 | return kb_ids, vocab, predicate_ids, constant_ids 141 | 142 | 143 | def embed_symbol(symbol, embedding_matrix, unit_normalize=True, dim=1, 144 | keep_prob=1.0): 145 | symbol_embedded = tf.nn.embedding_lookup(embedding_matrix, symbol) 146 | if unit_normalize: 147 | symbol_embedded = unit_length_transform(symbol_embedded, dim) 148 | 149 | if keep_prob != 1.0: 150 | symbol_embedded = tf.nn.dropout(symbol_embedded, keep_prob) 151 | 152 | return symbol_embedded 153 | 154 | 155 | def kb2nkb(kb, input_size=10, vocab=None, unit_normalize=True, 156 | init=(-1.0, 1.0), keep_prob=1.0, emb = None, permutation=None): 157 | """ 158 | Embeds symbols in a kb 159 | :param kb: a knowledge base with symbolic representations 160 | :return: a partitioned knowledge base with trainable vector representations 161 | """ 162 | 163 | kb_partitioned = partition(kb) 164 | 165 | kb_ids, vocab, predicate_ids, constant_ids = kb2ids(kb_partitioned, vocab, permutation) 166 | 167 | # with tf.variable_scope("nkb", reuse=None) as scope: 168 | initializer = tf.contrib.layers.xavier_initializer() 169 | if init is not None: 170 | initializer = tf.random_uniform_initializer(init[0], init[1]) 171 | 172 | 173 | if emb is None: 174 | embedding_matrix = \ 175 | tf.get_variable( 176 | "embeddings", [len(vocab), input_size], 177 | # initializer=tf.random_uniform_initializer(-1.0, 1.0) 178 | initializer=initializer 179 | #tf.random_normal_initializer() 180 | ) 181 | else: 182 | embedding_matrix = emb 183 | 184 | nkb = {} 185 | for ix, struct in enumerate(kb_ids): 186 | kb_stacked = kb_ids[struct] 187 | 188 | atoms_embedded = [] 189 | for i, atom in enumerate(kb_stacked): 190 | atom_embedded = [] 191 | for j in range(len(kb_stacked[i])): 192 | symbol = kb_stacked[i][j] 193 | if isinstance(symbol, np.ndarray): 194 | atom_embedded.append( 195 | embed_symbol(symbol, embedding_matrix, 196 | unit_normalize=unit_normalize, 197 | keep_prob=keep_prob)) 198 | else: 199 | if isinstance(symbol, list): 200 | atom_embedded.append("%s%d" % (symbol[0][0], ix)) 201 | # atom_embedded.append(symbol) 202 | atoms_embedded.append(atom_embedded) 203 | nkb[struct] = atoms_embedded 204 | 205 | return nkb, kb_ids, vocab, embedding_matrix, predicate_ids, constant_ids 206 | -------------------------------------------------------------------------------- /ntp/nunify.py: -------------------------------------------------------------------------------- 1 | """ 2 | [INSERT ASCII ART HERE] v0.1 3 | Neural Unification 4 | """ 5 | 6 | import tensorflow as tf 7 | 8 | # slope 10, offset 2 seems reasonable for N(0, 0.1) initalization 9 | # fixme: the higher the dimensionality, the lower the chances of a match, 10 | # hence slope and offset should be a function of the input dimension 11 | # or even a trainable variable 12 | def representation_match(rhs, goals, sigmoid_slope=10, sigmoid_offset=2): 13 | # def representation_match(rhs, goals, sigmoid_slope=2, sigmoid_offset=0): 14 | """ 15 | :param rhs: [N x k] rhs representations 16 | :param goals: [M x k] goal representations 17 | :return: [N x M] of match scores -- previously: [M x N]??? 18 | """ 19 | # return tf.sigmoid( 20 | # tf.matmul(rhs, goals, transpose_b=True) * sigmoid_slope - 21 | # sigmoid_offset 22 | # ) 23 | 24 | #rhs = tf.Print(rhs, [tf.shape(rhs)], "rhs") 25 | #goals = tf.Print(goals, [tf.shape(goals)], "goals") 26 | 27 | 28 | # dot = tf.einsum("ik,jk->ij", rhs, goals) 29 | # dot = (dot + 1.0) / 2.0 30 | 31 | def sigm_l1_sim(a, b): 32 | N = int(a.get_shape()[0]) # -- N x k 33 | M = int(b.get_shape()[0]) # -- M x k 34 | 35 | #a = tf.Print(a, [a], "a:\n", summarize=1000) 36 | #b = tf.Print(b, [b], "b:\n", summarize=1000) 37 | 38 | A = tf.tile(tf.expand_dims(a, 1), [1, M, 1]) # -- N x M x k 39 | B = tf.tile(tf.expand_dims(b, 0), [N, 1, 1]) # -- N x M x k 40 | 41 | #A = tf.Print(A, [A], "A:\n", summarize=1000) 42 | #B = tf.Print(B, [B], "B:\n", summarize=1000) 43 | 44 | l1 = tf.reduce_sum(tf.abs(A - B), 2) 45 | sim = tf.sigmoid(-l1) * 2.0 46 | 47 | #sim = tf.Print(sim, [sim], "sim:\n", summarize=1000) 48 | 49 | return sim 50 | 51 | def l2_sim(a, b, slope=1.0, imaginary=False): 52 | # using trick from: https://github.com/clinicalml/cfrnet/blob/master/cfr_net.py#L240 53 | 54 | #if imaginary: 55 | # a, _ = tf.split(a, 2, axis=1) 56 | # b, _ = tf.split(b, 2, axis=1) 57 | 58 | c = -2 * tf.matmul(a, tf.transpose(b)) 59 | na = tf.reduce_sum(tf.square(a), 1, keep_dims=True) 60 | nb = tf.reduce_sum(tf.square(b), 1, keep_dims=True) 61 | # this is broadcasting! 62 | l2 = (c + tf.transpose(nb)) + na 63 | l2 = tf.clip_by_value(l2, 1e-6, 1000) 64 | l2 = tf.sqrt(l2) 65 | if slope != 1.0: 66 | sim = tf.exp(-l2 * slope) 67 | else: 68 | sim = tf.exp(-l2) 69 | 70 | # if slope != 1.0: 71 | # sim = 1 / (1 + l2) 72 | # else: 73 | # sim = 1 / (1 + slope * l2) 74 | 75 | #sim = tf.Print(sim, [sim], "sim:\n", summarize=1000) 76 | 77 | return sim 78 | 79 | # dot = sigm_l1_sim(rhs, goals) 80 | dot = l2_sim(rhs, goals) 81 | 82 | # dot = tf.nn.elu(dot) 83 | 84 | # dot = tf.nn.relu(dot) 85 | 86 | # dot = tf.Print(dot, [dot], "dot") 87 | 88 | return dot 89 | 90 | 91 | def l2_unification(rhs, goal): 92 | """ 93 | :param rhs: [N x k] rhs representations 94 | :param goals: [M x k] goal representations 95 | :return: [M x N] of match scores 96 | """ 97 | 98 | pass -------------------------------------------------------------------------------- /ntp/util.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """ 3 | __ _ __ 4 | __ __/ /_(_) / 5 | / / / / __/ / / 6 | / /_/ / /_/ / / 7 | \__,_/\__/_/_/ v0.2 8 | 9 | Making useful stuff happen since 2016 10 | """ 11 | 12 | import re 13 | import collections 14 | import numpy as np 15 | 16 | Atom = collections.namedtuple("Atom", ["predicate", "arguments"]) 17 | 18 | 19 | def trim(string): 20 | """ 21 | :param string: an input string 22 | :return: the string without trailing whitespaces 23 | """ 24 | return re.sub("\A\s+|\s+\Z", "", string) 25 | 26 | 27 | def is_atom(arg): 28 | return isinstance(arg, Atom) 29 | 30 | 31 | def is_variable(arg): 32 | if isinstance(arg, str): 33 | return arg.isupper() 34 | else: 35 | return False 36 | 37 | 38 | def is_list(arg): 39 | return isinstance(arg, list) 40 | 41 | 42 | def is_array(arg): 43 | return isinstance(arg, np.ndarray) 44 | 45 | 46 | def is_constant(arg): 47 | if isinstance(arg, str): 48 | return arg.islower() 49 | else: 50 | return False 51 | 52 | 53 | def is_parameter(predicate): 54 | if isinstance(predicate, str): 55 | return predicate[0] == "#" 56 | else: 57 | return False 58 | 59 | 60 | def atom2string(atom): 61 | return "%s(%s)" % (atom.predicate, ",".join(atom.arguments)) 62 | 63 | 64 | def rule2string(rule): 65 | head = atom2string(rule[0]) 66 | body = [atom2string(x) for x in rule[1:]] 67 | if len(rule) == 1: 68 | return "%s." % head 69 | else: 70 | return "%s :- %s." % (head, ", ".join(body)) 71 | 72 | 73 | def subs2string(substitutions): 74 | return "{%s}" % ", ".join([key+"/"+val for 75 | key, val in substitutions.items()]) 76 | 77 | 78 | def is_ground_atom(atom): 79 | if is_atom(atom): 80 | return len([x for x in atom.arguments if is_variable(x)]) == 0 81 | else: 82 | return False 83 | 84 | 85 | def has_free_variables(rule): 86 | return len([atom for atom in rule if not is_ground_atom(atom)]) > 0 87 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | parsimonious 2 | gensim 3 | sklearn 4 | flask 5 | flask_socketio 6 | tabulate 7 | termcolor 8 | pytest 9 | pytest-runner 10 | pytest-pep8 11 | pytest-xdist 12 | pytest-cov 13 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | -------------------------------------------------------------------------------- /tests/ntp/test_kb.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ntp.kb import load_from_file 4 | from ntp.nkb import kb2nkb 5 | 6 | import pytest 7 | 8 | 9 | def test_kb(): 10 | kb = load_from_file("./data/synth/one.nl") 11 | 12 | for i, entry in enumerate(kb): 13 | assert len(entry) == 1 14 | atom = entry[0] 15 | assert atom.predicate == 'p' 16 | assert atom.arguments == ['e{}'.format(i), 'e{}'.format(i)] 17 | 18 | INPUT_SIZE = 100 19 | UNIT_NORMALIZE = False 20 | KEEP_PROB = 1.0 21 | 22 | nkb, kb_ids, vocab, emb, predicate_ids, constant_ids = \ 23 | kb2nkb(kb, INPUT_SIZE, unit_normalize=UNIT_NORMALIZE, 24 | keep_prob=KEEP_PROB) 25 | 26 | for k, v in kb_ids.items(): 27 | assert k == (('p0', 'c', 'c'),) 28 | a, b, c = v[0] 29 | assert a.shape == b.shape == c.shape == (33,) 30 | print(b, c) 31 | 32 | if __name__ == '__main__': 33 | pytest.main([__file__]) 34 | --------------------------------------------------------------------------------