{"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/arithmetic-sampling-parallel-diverse-decoding","title":"Arithmetic Sampling: Parallel Diverse Decoding for Large Language Models","arxiv_id":"2210.15458","date":"2022-10-18","proceeding":null,"authors":["Luke Vilnis","Yury Zemlyanskiy","Patrick Murray","Alexandre Passos","Sumit Sanghai"],"abstract":"Decoding methods for large language models often trade-off between diversity of outputs and parallelism of computation. Methods such as beam search and Gumbel top-k sampling can guarantee a different output for each element of the beam, but are not easy to parallelize. Alternatively, methods such as temperature sampling and its modifications (top-k sampling, nucleus sampling, typical decoding, and others), are embarrassingly parallel, but have no guarantees about duplicate samples. We present a framework for sampling according to an arithmetic code book implicitly defined by a large language model, compatible with common sampling variations, with provable beam diversity under certain conditions, as well as being embarrassingly parallel and providing unbiased and consistent expectations from the original model. We demonstrate the effectiveness of our approach on WMT machine translation, more than halving the standard deviation when estimating expected BLEU score reward, and closing the BLEU score gap between independent sampling and beam search by up to 63%.","url_abs":"https://arxiv.org/abs/2210.15458v2","url_pdf":"https://arxiv.org/pdf/2210.15458v2.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":"arithmetic-sampling-parallel-diverse-decoding","repo_url":"https://github.com/google-research/google-research","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":null}],"tasks":[{"task_slug":"diversity","task_name":"Diversity"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"large-language-model","task_name":"Large Language Model"},{"task_slug":"machine-translation","task_name":"Machine Translation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2210.15458","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2210.15458"}},"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/google-research/google-research","reach":null}],"summary":{"ran":1,"unverified":6},"by_repo_kind":{"official":{"samples":7,"ran":1,"repositories":1}},"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":0,"samples":[{"code_sha256_prefix":"f942d4bb565da7d6","entry":"ArithmeticSamplingLoopState","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f942d4bb565da7d6"}},{"code_sha256_prefix":"7bf6cc970aa273c7","entry":"_arithmetic_categorical","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7bf6cc970aa273c7"}},{"code_sha256_prefix":"d802259cf6cc00ef","entry":"_arithmetic_sample_single_trial","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d802259cf6cc00ef"}},{"code_sha256_prefix":"aebbc5f430da6c67","entry":"_is_tracer","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"aebbc5f430da6c67"}},{"code_sha256_prefix":"5f52f1744c825565","entry":"_make_default_codes","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5f52f1744c825565"}},{"code_sha256_prefix":"3ebcc75a4c924bb4","entry":"_sequential_cumsum","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3ebcc75a4c924bb4"}},{"code_sha256_prefix":"27a66bd8ed134a91","entry":"arithmetic_sample","repo":"google-research/google-research","repo_kind":"official","path":"arithmetic_sampling/t5x/decoding.py","file_url":"https://github.com/google-research/google-research/blob/HEAD/arithmetic_sampling/t5x/decoding.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"27a66bd8ed134a91"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}