Git Product home page Git Product logo

editnts's People

Contributors

yuedongcs avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

editnts's Issues

Please write down the instructions in more detail

This can be done by the following steps:
1.process_raw_data(comp_txt, simp_txt)
2.editnet_data_to_editnetID(df,output_path).

这里的comp_txt, simp_txt,df, output_path 能否用示例说明?
output_path是train.df.filtered.pos吗?

能否提供.sh文件,一键运行到结果

documenting system and dependency requirements

There is no requirements.txt file or documentation of the dependencies. So far, I have sleuthed out the following, which may or may not be the right versions:

nltk==3.4
pandas==0.24.2
torch==1.5.0

I still don't have it running since apparently a CUDA device is required. If I try to run main.py, I get the following error:

AttributeError: 'module' object has no attribute '_cuda_setDevice'

I tried setting the env variable:

CUDA_VISIBLE_DEVICES=""

which should prevent PyTorch from trying to use cuda, but this is not working.

Access to System Output

Hello,
Thanks for the great work. Is it possible to have access to your system's output in the Wikipedia-based test sets used (i.e. WikiSmall and TurkCorpus)?

Best,
Fernando

How to run the model on new data

Hi! I succesfully trained the model and now i would like to use it on new data, i assumed that the new data would need to be processed as well but the preprocessing expects the simplified sentences as an input, which i don't have.

How should i proceed? Is there any quick way to run the model on new data or do i need to write the preprocessing and the prediction myself?

RuntimeError: Sizes of tensors must match except in dimension 2. Expected size 32 but got size 1 for tensor number 3 in the list

I am running EDITNTS: https://github.com/yuedongP/EditNTS without teacher forcing on some training data. When I run main.py I get the error:

  File "/home/jba5337/work/ds440w/EditNTS-Google/editnts.py", line 252, in forward
    output_t = torch.cat((output_edits, attn_applied_org_t, c, hidden_words[0]),
RuntimeError: Sizes of tensors must match except in dimension 2. Expected size 32 but got size 1 for tensor number 3 in the list.

Here is what happens when I print c:

c tensor([[[-0.0353, -0.0617, -0.1176,  ...,  0.0507, -0.0174,  0.1828]],

        [[-0.0769, -0.0166, -0.1737,  ..., -0.1302, -0.1488,  0.1480]],

        [[-0.0570, -0.0683, -0.2270,  ..., -0.0820, -0.2011,  0.1915]],

        ...,

        [[-0.1127,  0.0051, -0.2119,  ..., -0.0853, -0.1813,  0.2058]],

        [[-0.0570, -0.0683, -0.2270,  ..., -0.0412, -0.1851,  0.1975]],

        [[-0.1127,  0.0051, -0.2119,  ..., -0.0477, -0.1822,  0.2200]]],
       device='cuda:0', grad_fn=<GatherBackward0>)

size torch.Size([32, 1, 400])

It looks like this is greater than a size 1, so I am unsure where the issue is. Here is the function of where the error is coming from if you could please take a look:

        else: # no teacher forcing
            decoder_input_edit = input_edits[:, :1]
            decoder_input_word=simp_sent[:,:1]
            t, tt = 0, max(MAX_LEN,input_edits.size(1)-1)

            # initialize
            embedded_edits = self.embedding(decoder_input_edit)
            output_edits, hidden_edits = self.rnn_edits(embedded_edits, hidden_org)

            embedded_words = self.embedding(decoder_input_word)
            output_words, hidden_words = self.rnn_words(embedded_words, hidden_org)
            #
            # # give previous word from tgt simp_sent
            # inds = torch.LongTensor(counter_for_keep_ins)
            # dummy = inds.view(-1, 1, 1)
            # dummy = dummy.expand(dummy.size(0), dummy.size(1), output_words.size(2)).cuda()
            # c_word = output_words.gather(1, dummy)

            while t < tt:
                if t>0:
                    embedded_edits = self.embedding(decoder_input_edit)
                    output_edits, hidden_edits = self.rnn_edits(embedded_edits, hidden_edits)

                key_org = self.attn_Projection_org(output_edits)  # bsz x nsteps x nhid
                logits_org = torch.bmm(key_org, encoder_outputs_org.transpose(1, 2))  # bsz x nsteps x encsteps
                attn_weights_org_t = F.softmax(logits_org, dim=-1)  # bsz x nsteps x encsteps
                attn_applied_org_t = torch.bmm(attn_weights_org_t, encoder_outputs_org)  # bsz x nsteps x nhid

                ## find current word
                inds = torch.LongTensor(counter_for_keep_del)
                dummy = inds.view(-1, 1, 1)
                dummy = dummy.expand(dummy.size(0), dummy.size(1), encoder_outputs_org.size(2)).cuda()
                c = encoder_outputs_org.gather(1, dummy)
                print('c',c)
                output_t = torch.cat((output_edits, attn_applied_org_t, c, hidden_words[0]),
                                     2)  # bsz*nsteps x nhid*2
                output_t = self.attn_MLP(output_t)
                output_t = F.log_softmax(self.out(output_t), dim=-1)

                decoder_out.append(output_t)
                decoder_input_edit=torch.argmax(output_t,dim=2)



                # gold_action = input[:, t + 1].vocab_data.cpu().numpy()  # might need to realign here because start added
                pred_action= torch.argmax(output_t,dim=2)
                counter_for_keep_del = [i[0] + 1 if i[1] == 2 or i[1] == 3 or i[1] == 5 else i[0]
                                        for i in zip(counter_for_keep_del, pred_action)]

                # update rnn_words
                # find previous generated word
                # give previous word from tgt simp_sent
                dummy_2 = inds.view(-1, 1).cuda()
                org_t = org_ids.gather(1, dummy_2)
                hidden_words = self.execute_batch(pred_action, org_t, hidden_words)  # we give the editted subsequence
                # hidden_words = self.execute_batch(pred_action, org_t, hidden_org)  #here we only give the word

                t += 1
                check = sum([x >= org_ids.size(1) for x in counter_for_keep_del])
                if check:
                    break
        return torch.cat(decoder_out, dim=1), hidden_edits

pretrained model

Hi @yuedongP! Was wondering if you'd mind releasing a pre-trained model for us to run inference!

The input to the Model and the target is the same.

Hi, I have been trying to understand the provided code and have certain concerns about the decoder.

main.py contains the following pieces of code

out = prepared_batch[2][:, :]
tar = prepared_batch[2][:, 1:]

I presume these are the output and the target (and have the same information content ie. edit actions) .
out is then being fed to the edit_net, this does not seem to make sense.

output = edit_net(org, out, org_ids, org_pos, simp_ids)

thereafter, In the decoder part, the code uses the same out does manipulation to create output_t which is then returned as the result of the EditNet. I am unable to find the parts in your code where prediction for actions is happening.

I am unable to understand that if your model is being fed the edit actions already what exactly is your model predicting?

How to run model on test set?

Thank you for the wonderful work.
After working on this code for a few days, I was able to fix its problems with Python 3 (Windows 10, Python 3.8.3, PyTorch 1.6.0 and CUDA 11.1) and perform a full run. (If you think it is needed, I can create a pull request)
Now my question is that I have the model saved after full execution. How should I run this model on the test set and get output?

'str' object has no attribute 'vocab_size'

运行main.py发生错误:

self.embedding = nn.Embedding(config.vocab_size, config.embedding_dim)
AttributeError: 'str' object has no attribute 'vocab_size'
但是vocab_size已定义啦
谢谢!!

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.