Giter VIP home page Giter VIP logo

pytorch-beam-search-decoding's People

Contributors

budzianowski 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  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

pytorch-beam-search-decoding's Issues

def beam_decode

How to use the value 'decoded_batch' in function 'def beam_decode' when I test my own model?
image

In the while loop, will the queue explode quickly

When decoding a sentence of length 5 and beamsize=10, and we entered the while loop. After the first while loop, we end up with a queue with length 10. Now we move to T=1. According to the code, we have to run 10 while loops to decode for T=1. So after decoding for T=1, we will end up with a queue of length 100 instead of 10 cause there is no topK selection in the queue. After decoding for T=2, we will have a queue with length 1000. This queue will explode quickly. Did I miss something here?

TypeError: '<' not supported between instances of 'BeamSearchNode' and 'BeamSearchNode'

I had this problem. I found out that this happens when in the PriorityQueue(PQ) two elements have the same value then, the algorithm moves to the element itself. Because the element in the PQ is an object it generates this Error.

The solution was that I add in the class a special function to handle this by choosing the element with the highest probability., as follows. If this seems ok to you, you can add this lines in your code. Or I can make a pull request.

#function in the class BeamSearchNode
def __lt__(self, other):
        return self.prob < other.prob

Score function

Hi,

Thank's for this work. It's really usefull.

Why you defined the score function as (line 66)??

self.logp / float(self.leng - 1 + 1e-6) + alpha * reward

Can you explain this definition?

Thank's,
Best

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.