{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/stochastic-beams-and-where-to-find-them-the","title":"Stochastic Beams and Where to Find Them: The Gumbel-Top-k Trick for Sampling Sequences Without Replacement","arxiv_id":"1903.06059","date":"2019-03-14","proceeding":null,"authors":["Wouter Kool","Herke van Hoof","Max Welling"],"abstract":"The well-known Gumbel-Max trick for sampling from a categorical distribution can be extended to sample $k$ elements without replacement. We show how to implicitly apply this 'Gumbel-Top-$k$' trick on a factorized distribution over sequences, allowing to draw exact samples without replacement using a Stochastic Beam Search. Even for exponentially large domains, the number of model evaluations grows only linear in $k$ and the maximum sampled sequence length. The algorithm creates a theoretical connection between sampling and (deterministic) beam search and can be used as a principled intermediate alternative. In a translation task, the proposed method compares favourably against alternatives to obtain diverse yet good quality translations. We show that sequences sampled without replacement can be used to construct low-variance estimators for expected sentence-level BLEU score and model entropy.","url_abs":"https://arxiv.org/abs/1903.06059v2","url_pdf":"https://arxiv.org/pdf/1903.06059v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"stochastic-beams-and-where-to-find-them-the","repo_url":"https://github.com/wouterkool/stochastic-beam-search","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"stochastic-beams-and-where-to-find-them-the","repo_url":"https://github.com/evanthebouncy/stoicastic_beam","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":null},{"paper_slug":"stochastic-beams-and-where-to-find-them-the","repo_url":"https://github.com/manueldeprada/decoders","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"stochastic-beams-and-where-to-find-them-the","repo_url":"https://github.com/wouterkool/estimating-gradients-without-replacement","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"translation","task_name":"Translation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1903.06059","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1903.06059"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/manueldeprada/decoders","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wouterkool/estimating-gradients-without-replacement","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wouterkool/stochastic-beam-search","reach":{"status":"ok","spdx":"NOASSERTION"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/evanthebouncy/stoicastic_beam","reach":null}],"summary":{"ran_violates":1,"ran_draft_wrong":2,"ran_honours":2,"unverified":12},"by_repo_kind":{"listed":{"samples":17,"ran":5,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":17,"samples":[{"code_sha256_prefix":"8409b65e19e7556b","entry":"drop_blocks","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"env.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/env.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8409b65e19e7556b"}},{"code_sha256_prefix":"698bb1dd63143c23","entry":"get_bigram","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"policy.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/policy.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"698bb1dd63143c23"}},{"code_sha256_prefix":"c27e7c7d0429cf3a","entry":"get_spec","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"env.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/env.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c27e7c7d0429cf3a"}},{"code_sha256_prefix":"e7f3eac1d9074f71","entry":"random_rollout","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"inference.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/inference.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e7f3eac1d9074f71"}},{"code_sha256_prefix":"48fbdb9b7b3a7e1a","entry":"sample_program","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"env.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/env.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"48fbdb9b7b3a7e1a"}},{"code_sha256_prefix":"7d28841f30ab263f","entry":"batched_bin_vec_to_decimal","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/binary_transformer.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/binary_transformer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"7d28841f30ab263f"}},{"code_sha256_prefix":"382342955f67f3f5","entry":"beam_k","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"inference.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/inference.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"382342955f67f3f5"}},{"code_sha256_prefix":"5318e71a079395fc","entry":"compute_logprobs_from_scores","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/toolbox.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/toolbox.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"5318e71a079395fc"}},{"code_sha256_prefix":"887fa7fd3a8a0e90","entry":"compute_transition_scores_nonbeam","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/toolbox.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/toolbox.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"887fa7fd3a8a0e90"}},{"code_sha256_prefix":"a42599a4d43260f4","entry":"compute_true_logprobs","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/toolbox.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/toolbox.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"a42599a4d43260f4"}},{"code_sha256_prefix":"5a227174a2c67965","entry":"decimal_to_bin_vec","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/binary_transformer.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/binary_transformer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"5a227174a2c67965"}},{"code_sha256_prefix":"cb389fa56b7724b7","entry":"f_experiment","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/small_prob_transformer.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/small_prob_transformer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"cb389fa56b7724b7"}},{"code_sha256_prefix":"42dff7fcdf075def","entry":"get_binary_completions","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/binary_transformer.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/binary_transformer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"42dff7fcdf075def"}},{"code_sha256_prefix":"e2f7ccfbe5b7cadd","entry":"pad_tensors","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/simple/simple_beam_utils.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/simple/simple_beam_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"e2f7ccfbe5b7cadd"}},{"code_sha256_prefix":"f7417c6b895e0503","entry":"random_rollout_k","repo":"evanthebouncy/stoicastic_beam","repo_kind":"listed","path":"inference.py","file_url":"https://github.com/evanthebouncy/stoicastic_beam/blob/HEAD/inference.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f7417c6b895e0503"}},{"code_sha256_prefix":"14699971d77c31de","entry":"route2length","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/small_prob_transformer.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/small_prob_transformer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"14699971d77c31de"}},{"code_sha256_prefix":"2644babce129f019","entry":"stack_model_outputs","repo":"manueldeprada/decoders","repo_kind":"listed","path":"src/decoders/strategies/beam_decoder.py","file_url":"https://github.com/manueldeprada/decoders/blob/HEAD/src/decoders/strategies/beam_decoder.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"2644babce129f019"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}