cpae icon indicating copy to clipboard operation
cpae copied to clipboard

Use entity definitions to generate entity embeddings

Open tgalery opened this issue 5 years ago • 5 comments

Thanks for the great work. I was wondering whether your tool could use pre-trained word embeddings and a definitions of entities in a knowledge base (e.g. wikidata). Wikidata and or dbpedia would contain definitions for entities provided that entity ids are represented as a special token. If this is the case, are there any needed modifications in your source code that would be needed (I'm thinking of a cli tool that has --embeddings <path> and --definitions <path> cli args?

tgalery avatar Apr 25 '19 17:04 tgalery

Hi, @tgalery

I cannot install the environment with the given requirements.txt file. Did you have the same issue? If not, could please explain how you install packages? Thanks.

iamkissg avatar Apr 30 '19 08:04 iamkissg

@iamkissg I haven't installed this myself, but if you use anaconda, the requirements.txt file contains this intruction: conda create --name <env> --file requirements.txt. After that you need to install the libs that are mentioned in the readme (note that this is python2). Any specific error that you got?

tgalery avatar Apr 30 '19 09:04 tgalery

@tgalery Actually, I cannot install the environment with the given command. Neither can I solve the dependency with pip. I'm so depressed.

iamkissg avatar Apr 30 '19 10:04 iamkissg

erm do you have miniconda installed ?. After having it set up and making sure the conda command works, you can try

conda create -n cpae python=2.7 [this will create a python 2.7 virtual env called cpae]
source activate cpa [this will activate your env]
pip install -r requirements.txt

If you have any errors please paste them here otherwise it's tricky to find out what's going on

tgalery avatar Apr 30 '19 15:04 tgalery

Hi @tgalery, I have installed Anaconda. Before talking to you, I have tried many many times with different command combinations but always failed. I tried again with your suggestion, but got:

ERROR: Invalid requirement: 'jupyter=1.0.0=py27_3'
= is not a valid operator. Did you mean == ?

I have sent an email to the author in late January 2019. The followings are problems I have ever had. I describe them step by step.

  1. conda create --name cpae --file requirements.txt (set pip=9; comment out last 3 lines)

However, the following error occurs:

...
    from jupyter_core.utils import ensure_dir_exists
ImportError: cannot import name ensure_dir_exists
  1. Delete version of jupyter*, and try again;
  2. install blocks and fuel with the command in README;
pip install git+git://github.com/mila-udem/blocks.git@stable -r https://raw.githubusercontent.com/mila-udem/blocks/stable/requirements.txt

In fact, this command also installs fuel==0.2.0, but it uninstalls pre-installed numpy==1.11.3 and installs the version 1.9.3. Thus, the following issue occurs:

# ./run.sh
/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/configdefaults.py:1686: UserWarning: Theano does not recognise this flag: blas.check_openmp
  warnings.warn('Theano does not recognise this flag: {0}'.format(key))
Traceback (most recent call last):
  File "bin/train_s2s.py", line 3, in <module>
    from dictlearn.def_autoencoder_training import train_model
  File "/home/kissg/Gode/cpae/dictlearn/def_autoencoder_training.py", line 13, in <module>
    import theano
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/__init__.py", line 118, in <module>
    import theano.sandbox.gpuarray
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/sandbox/gpuarray/__init__.py", line 20, in <module>
    import pygpu
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/pygpu/__init__.py", line 7, in <module>
    from . import gpuarray, elemwise, reduction
  File "__init__.pxd", line 155, in init pygpu.gpuarray
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96

pip freeze gives only one version of numpy, but conda list gives two versions of numpy (1.9.3, 1.11.3). It seems numpy==1.9.3 is used, which is installed with the above pip command. Besides, Theano==0.8.0.dev0.

  1. So I reinstall numpy==1.11.3 and install theano==0.10.0b3 with pip (these aren't any 0.10* versions of theano available from conda https://anaconda.org/conda-forge/theano/files?page=2);
/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/configdefaults.py:1890: UserWarning: Theano does not recognise this flag:
 blas.check_openmp                                                                                              
  warnings.warn('Theano does not recognise this flag: {0}'.format(key))
/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py:177: UserWarning: Your cuDNN version is more recent than
Theano. If you encounter problems, try updating Theano or downgrading cuDNN to a version >= v5 and <= v7.
  warnings.warn("Your cuDNN version is more recent than "                                                                   
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled                                         
Traceback (most recent call last):                                                                              
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 220, in <module>
    use(config.device)                                                                                       
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 207, in use
    init_dev(device, preallocate=preallocate)                                                                 
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 110, in init_dev
    context.cudnn_handle = dnn._make_handle(context)                                                            
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 117, in _make_handle
    cudnn = _dnn_lib()                                                                                         
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 104, in _dnn_lib     
    raise RuntimeError('Could not load cudnn library')                                                          
RuntimeError: Could not load cudnn library                                                                       
Traceback (most recent call last):                                                                                 
  File "bin/train_s2s.py", line 3, in <module>                                                                       
    from dictlearn.def_autoencoder_training import train_model                                                           
  File "/home/kissg/Gode/cpae/dictlearn/def_autoencoder_training.py", line 25, in <module>                                  
    from blocks.extensions.saveload import Load, Checkpoint                                                         
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/blocks/extensions/saveload.py", line 9, in <module>
    from blocks.serialization import (                                                                                                      
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/blocks/serialization.py", line 20, in <module>    
    from theano.misc.pkl_utils import (PersistentCudaNdarrayID,                                                  
ImportError: cannot import name PersistentCudaNdarrayID
  1. Then I try to install cudnn and cudatoolkit (cudatoolkit==7.5 and cudatoolkit==8.0, both with cudnn==5.1.10)

But

./run.sh
Traceback (most recent call last):
  File "bin/train_s2s.py", line 3, in <module>
    from dictlearn.def_autoencoder_training import train_model
  File "/home/kissg/Gode/cpae/dictlearn/def_autoencoder_training.py", line 13, in <module>
    import theano
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/__init__.py", line 156, in <module>
    import theano.gpuarray
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 31, in <module>
    from . import fft, dnn, opt, extra_ops, multinomial, reduction, sort, rng_mrg, ctc
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/fft.py", line 14, in <module>
    from .opt import register_opt, op_lifter, register_opt2
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/opt.py", line 2796, in <module>
    from .dnn import (local_abstractconv_cudnn,
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 326, in <module>
    handle_type = CUDNNDataType('cudnnHandle_t', 'cudnnDestroy')
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 246, in CUDNNDataType
    version=version(raises=False))
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 306, in version
    if not dnn_present():
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 202, in dnn_present
    dnn_present.avail, dnn_present.msg = _dnn_check_version()
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 173, in _dnn_check_version
    v = version()
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 317, in version
    profile=False)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/compile/function.py", line 317, in function
    output_keys=output_keys)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/compile/pfunc.py", line 486, in pfunc
    output_keys=output_keys)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/compile/function_module.py", line 1841, in orig_function
    fn = m.create(defaults)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/compile/function_module.py", line 1715, in create
    input_storage=input_storage_lists, storage_map=storage_map)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/link.py", line 699, in make_thunk
    storage_map=storage_map)[:3]
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/vm.py", line 1084, in make_all
    impl=impl))
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/op.py", line 955, in make_thunk
    no_recycling)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/op.py", line 858, in make_c_thunk
    output_storage=node_output_storage)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cc.py", line 1217, in make_thunk
    keep_lock=keep_lock)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cc.py", line 1157, in __compile__
    keep_lock=keep_lock)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cc.py", line 1620, in cthunk_factory
    key=key, lnk=self, keep_lock=keep_lock)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cmodule.py", line 1174, in module_from_key
    module = lnk.compile_cmodule(location)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cc.py", line 1523, in compile_cmodule
    preargs=preargs)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cmodule.py", line 2362, in compile_str
    return dlimport(lib_filename)
  File "/home/kissg/anaconda3/envs/cpae/lib/python2.7/site-packages/theano/gof/cmodule.py", line 302, in dlimport
    rval = __import__(module_name, {}, {}, [module_name])
ImportError: ('The following error happened while compiling the node', DnnVersion(), '\n', 'libcudnn.so.5: cannot open shared object file: No such file or directory', '[DnnVersion()]')

Do you have any idea? Thanks.

iamkissg avatar May 01 '19 07:05 iamkissg