Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Add sampling strategies to beam search (#4768)
Browse files Browse the repository at this point in the history
* add node and beam samplers

* refactor

* get stochastic beam search working

* Add MultiomialSampler, TopPSampler, TopKSampler to beam_search.py, and tests for those samplers and stochastic_beam_search

* Update changelog and finalize documentation

* set default to without replacement

* Updated TopPSampler to remove loop, with testing and bugfix. Cleaned up documentation and sampeler code.

* added p sampler test

* Better error messages

* Update allennlp/nn/beam_search.py

* lint

* default to top-k if insufficient examples when top-p sampling

* formatting

* minor clean up

* fix CHANGELOG

Co-authored-by: Jackson Stokes <[email protected]>
  • Loading branch information
epwalsh and Jackson Stokes authored Nov 11, 2020
1 parent f6fe8c6 commit 9f7cc24
Show file tree
Hide file tree
Showing 3 changed files with 703 additions and 75 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added an optional `seed` parameter to `ModelTestCase.set_up_model` which sets the random
seed for `random`, `numpy`, and `torch`.
- Added sampler class and parameter in beam search for non-deterministic search, with several
implementations, including `MultinomialSampler`, `TopKSampler`, `TopPSampler`, and
`GumbelMaxSampler`. Utilizing `GumbelMaxSampler` will give [Stochastic Beam Search](https://api.semanticscholar.org/CorpusID:76662039).

### Changed

Expand Down
Loading

0 comments on commit 9f7cc24

Please sign in to comment.