Giter VIP home page Giter VIP logo

open_type's Introduction

This repository contains code for the following paper:

Ultra-Fine Entity Typing

Eusol Choi, Omer Levy, Yejin Choi and Luke Zettlemoyer. (ACL 2018)

Project website: https://homes.cs.washington.edu/~eunsol/_site/open_entity.html

Dependencies:

Configuration:

  • You have to put set three paths at ./resources/constant.py

    FILE_ROOT=where you our dataset.

    GLOVE_VEC=the path where you can find pretrained glove vectors.

    EXP_ROOT=where you save models.

Preprocessing:

  • The model reported in the paper is trained on a data from (1) a subset of Gigaword corpus, (2) Wikilink dataset, (3) Wikipedia document and (4) Indomain crowd-sourced data

(2), (3), (4) can be downloaded from here http://nlp.cs.washington.edu/entity_type/data/ultrafine_acl18.tar.gz

  • Gigaword is a licensed dataset from LDC, so is not released with the code.

  • Without it, however, model can reach reasonable performances (29.8F1 instead of 31.7F1 reported).

  • Alternatively, you can email the first author get the processed version after verifying your LDC license.

To train a model:

python3 main.py MODEL_ID -lstm_type single -enhanced_mention -data_setup joint -add_crowd -multitask

To train model on the Ontonotes dataset python3 main.py onto -lstm_type single -goal onto -enhanced_mention

To run predictions of pre-trained model: python3 main.py MODEL_ID -lstm_type single -enhanced_mention -data_setup joint -add_crowd -multitask -mode test -reload_model_name MODEL_NAME_TIMESTAMP -eval_data crowd/test.json -load

Scorer:

python3 scrorer.py OUTPUT_FILENAME

Contact: Eunsol Choi -- [email protected]

Credit:

open_type's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

open_type's Issues

New dataset

Hi,

I already produced a dataset in the same format as yours, but I noticed that the code is a little tricky.

How can I do experiments on my dataset?

New data

Is there any way to predict entity types on new data?

slice indices must be integers or None or have an __index__ method

I kept getting "TypeError: slice indices must be integers or None or have an index method" errors. I fixed it by casting floats to integers in models.py:

def sorted_rnn(self, sequences, sequence_lengths, rnn):
    sorted_inputs, sorted_sequence_lengths, restoration_indices = sort_batch_by_length(sequences, sequence_lengths)
    packed_sequence_input = pack_padded_sequence(sorted_inputs,
                                                 [int(_) for _ in sorted_sequence_lengths.data.tolist()],
                                                 batch_first=True)
    packed_sequence_output, _ = rnn(packed_sequence_input, None)
    unpacked_sequence_tensor, _ = pad_packed_sequence(packed_sequence_output, batch_first=True)
    return unpacked_sequence_tensor.index_select(0, restoration_indices)

IndexError: invalid index of a 0-dim tensor

Run command: python main.py onto -lstm_type single -goal onto -enhanced_mention

Error:

.../model_utils.py:167: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
weighted_keys = self.key_softmax(k).view(input_embed.size()[0], -1, 1)
Traceback (most recent call last):
File "main.py", line 276, in
_train(config)
File "main.py", line 133, in _train
total_loss += loss.data.cpu()[0]
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

dimension mismatch while testing

-rw-rw-r-- 1 gpuws gpuws 5619697 12月 24 22:09 onto_95000.pt
-rw-rw-r-- 1 gpuws gpuws 5619697 12月 24 22:13 onto_96000.pt
-rw-rw-r-- 1 gpuws gpuws 5619697 12月 24 22:17 onto_97000.pt
-rw-rw-r-- 1 gpuws gpuws 5619697 12月 24 22:20 onto_98000.pt
-rw-rw-r-- 1 gpuws gpuws 5619697 12月 24 22:24 onto_99000.pt
(.venv) gpuws@gpuws32g:/media/gpuws/fcd84300-9270-4bbd-896a-5e04e79203b7/ub16_prj/open_type$ python3 main.py onto -lstm_type single -enhanced_mention -data_setup joint -add_crowd -multitask -mode test -reload_model_name onto_98000 -eval_data crowd/test.json -load
Loading word embeddings from /home/gpuws/data/glove/glove.840B.300d.txt...
Done loading word embeddings!
Answer num 10331
Found 1 shards at release/crowd/test.json
Multi-task learning
Traceback (most recent call last):
File "/media/gpuws/fcd84300-9270-4bbd-896a-5e04e79203b7/ub16_prj/open_type/.venv/lib/python3.5/site-packages/torch/nn/modules/module.py", line 514, in load_state_dict
own_state[name].copy_(param)
RuntimeError: invalid argument 2: sizes do not match at /pytorch/torch/lib/THC/THCTensorCopy.cu:31

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 277, in
_test(config)
File "main.py", line 230, in _test
load_model(args.reload_model_name, constant.EXP_ROOT, args.model_id, model)
File "main.py", line 203, in load_model
model.load_state_dict(checkpoint['state_dict'])
File "/media/gpuws/fcd84300-9270-4bbd-896a-5e04e79203b7/ub16_prj/open_type/.venv/lib/python3.5/site-packages/torch/nn/modules/module.py", line 519, in load_state_dict
.format(name, own_state[name].size(), param.size()))
RuntimeError: While copying the parameter named decoder.linear.weight, whose dimensions in the model are torch.Size([10331, 550]) and whose dimensions in the checkpoint are torch.Size([89, 550]).
(.venv) gpuws@gpuws32g:/media/gpuws/fcd84300-9270-4bbd-896a-5e04e79203b7/ub16_prj/open_type$
(.venv) gpuws@gpuws32g:/media/gpuws/fcd84300-9270-4bbd-896a-5e04e79203b7/ub16_prj/open_type$

Language guidelines

The University of Washington works hard to foster an inclusive and welcoming culture for everyone in the campus community.

Unfortunately, looking over your GitHub repositories, I have identified language that can be considered offensive due to its racist origins. Specifically the branch names, but I imagine if I looked at the code itself, I would find more.

Can you let me know when you’ll be adjusting the settings to be a inclusive product/service and follow University of Washington language guidelines?

does training terminate?

Does the training stop at some point? The code says "while True". I hope it's not an infinite loop. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.