{"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/local-and-global-decoding-in-text-generation","title":"Local and Global Decoding in Text Generation","arxiv_id":"2410.10810","date":"2024-10-14","proceeding":null,"authors":["Daniel Gareev","Thomas Hofmann","Ezhilmathi Krishnasamy","Tiago Pimentel"],"abstract":"Text generation, a key component in applications such as dialogue systems, relies on decoding algorithms that sample strings from a language model distribution. Traditional methods, such as top-$k$ and top-$\\pi$, apply local normalisation to the model's output distribution, which can distort it. In this paper, we investigate the effect of this distortion by introducing globally-normalised versions of these decoding methods. Additionally, we propose an independent Metropolis-Hastings algorithm to approximate sampling from globally-normalised distributions without explicitly computing them. Our empirical analysis compares the performance of local and global normalisation across two decoding algorithms (top-$k$ and top-$\\pi$) with various hyperparameters, using Pythia language models. Results show that, in most configurations, global decoding performs worse than the local decoding version of the same algorithms -- despite preserving the distribution's integrity. Our results suggest that distortion is an important feature of local decoding algorithms.","url_abs":"https://arxiv.org/abs/2410.10810v1","url_pdf":"https://arxiv.org/pdf/2410.10810v1.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":"local-and-global-decoding-in-text-generation","repo_url":"https://github.com/lowlypalace/global-decoding","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"pythia","method_name":"Pythia"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.10810","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.10810"}},"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/lowlypalace/global-decoding","reach":{"status":"ok"}}],"summary":{"ran":11,"unverified":1},"by_repo_kind":{"official":{"samples":12,"ran":11,"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":12,"samples":[{"code_sha256_prefix":"8cdfeccd65fcf064","entry":"calculate_context_length","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/experiments/helpers.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/experiments/helpers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8cdfeccd65fcf064"}},{"code_sha256_prefix":"2739ee7e7e37880c","entry":"compute_95ci","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/results/get_results.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/results/get_results.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2739ee7e7e37880c"}},{"code_sha256_prefix":"9376ebd2fbbb675d","entry":"compute_kde","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/mcmc/plots.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/mcmc/plots.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9376ebd2fbbb675d"}},{"code_sha256_prefix":"1f446017f9ed893c","entry":"filter_padding_tokens","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/results/get_results.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/results/get_results.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1f446017f9ed893c"}},{"code_sha256_prefix":"74f767a079f7fb9a","entry":"indicator_top_k","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/experiments/global_decoding.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/experiments/global_decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"74f767a079f7fb9a"}},{"code_sha256_prefix":"b4716300a32ace4a","entry":"load_json_file","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/results/get_results.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/results/get_results.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b4716300a32ace4a"}},{"code_sha256_prefix":"9ad02553048ba5c5","entry":"metropolis_hastings","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/mcmc/metropolis_hastings.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/mcmc/metropolis_hastings.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9ad02553048ba5c5"}},{"code_sha256_prefix":"8b81b2e202edcee5","entry":"normalization_constant","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/experiments/local_decoding.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/experiments/local_decoding.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8b81b2e202edcee5"}},{"code_sha256_prefix":"b45a8da2e2ea7e5b","entry":"predict_logits","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/experiments/helpers.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/experiments/helpers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b45a8da2e2ea7e5b"}},{"code_sha256_prefix":"1c1380cdab9cb649","entry":"replace_nan_ci","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/results/plots.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/results/plots.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1c1380cdab9cb649"}},{"code_sha256_prefix":"7939c932cc2ff354","entry":"top_k_filtering","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/experiments/helpers.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/experiments/helpers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7939c932cc2ff354"}},{"code_sha256_prefix":"6a9447860dbc0e1e","entry":"generate_sequences_util","repo":"lowlypalace/global-decoding","repo_kind":"official","path":"src/sequences/generate_sequences_util.py","file_url":"https://github.com/lowlypalace/global-decoding/blob/HEAD/src/sequences/generate_sequences_util.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":"6a9447860dbc0e1e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}