budzianowski / pytorch-beam-search-decoding Goto Github PK
View Code? Open in Web Editor NEWPyTorch implementation of beam search decoding for seq2seq models
License: Apache License 2.0
PyTorch implementation of beam search decoding for seq2seq models
License: Apache License 2.0
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?
Could you please, describe more beam search decoding ?
Why do you use 'number_required' in your code? When topk=1, the beam search algorithm only generates one sentence!
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.