项目作者: TatsuyaShirakawa

项目描述 :
Poincaré Embedding (unofficial)
高级语言: C++
项目地址: git://github.com/TatsuyaShirakawa/poincare-embedding.git
创建时间: 2017-06-23T15:00:09Z
项目社区:https://github.com/TatsuyaShirakawa/poincare-embedding

开源协议:MIT License

下载


poincare-embedding

These codes implement Poincar\’e Embedding introduced in the following paper:

Maximilian Nickel and Douwe Kiela, “Poincar\’e Embeddings for Learning Hierarchical Representations’”, arXiv preprint arXiv:1705.08039, 2017.

Requirements

  • C++ compiler that supports c++14 or later
    • for Windows user, using cygwin is recommended (with CMAKE and gcc/g++ selection) (thanks @patrickgitacc)

Build

  1. cd poincare-embedding
  2. mkdir work & cd work
  3. cmake ..
  4. make

Setup python environment

From the poincare-embeddings directory…

  1. python3 -m venv venv
  2. source venv/bin/activate

if using windows:

  1. python3 -m venv venv
  2. venv\Scripts\activate

Then run the following:

  1. python3 -m pip install -r requirements.txt
  2. python3 -c "import nltk; nltk.download('wordnet')"

Tutorial

We assume that you are in work directory

  1. cd poincare-embedding
  2. mkdir work & cd work

Data Creation

You can create WordNet noun hypernym pairs as follows

  1. python ../scripts/create_wordnet_noun_hierarchy.py ./wordnet_noun_hypernyms.tsv

and mammal subtree is created by

  1. python ../scripts/create_mammal_subtree.py ./mammal_subtree.tsv

Run

  1. ./poincare_embedding ./mammal_subtree.tsv ./embeddings.tsv -d 2 -t 8 -e 1000 -l 0.1 -L 0.0001 -n 20 -s 0

Plot a Mammal Tree

  1. python ../scripts/plot_mammal_subtree.py ./embeddings.tsv --center_mammal

Note: if that doesn’t work, may need to run the following:

  1. tr -d '\015' < embeddings.tsv > embeddings_clean.tsv

Double check that the file has removed the character in question, then run

  1. mv embeddings_clean.tsv embeddings.tsv

mammal.png