{"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/positional-encoding-to-control-output","title":"Positional Encoding to Control Output Sequence Length","arxiv_id":"1904.07418","date":"2019-04-16","proceeding":"NAACL 2019 6","authors":["Sho Takase","Naoaki Okazaki"],"abstract":"Neural encoder-decoder models have been successful in natural language\ngeneration tasks. However, real applications of abstractive summarization must\nconsider additional constraint that a generated summary should not exceed a\ndesired length. In this paper, we propose a simple but effective extension of a\nsinusoidal positional encoding (Vaswani et al., 2017) to enable neural\nencoder-decoder model to preserves the length constraint. Unlike in previous\nstudies where that learn embeddings representing each length, the proposed\nmethod can generate a text of any length even if the target length is not\npresent in training data. The experimental results show that the proposed\nmethod can not only control the generation length but also improve the ROUGE\nscores.","url_abs":"http://arxiv.org/abs/1904.07418v1","url_pdf":"http://arxiv.org/pdf/1904.07418v1.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":"positional-encoding-to-control-output","repo_url":"https://github.com/takase/control-length","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"abstractive-text-summarization","task_name":"Abstractive Text Summarization"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"sentence-summarization","task_name":"Sentence Summarization"},{"task_slug":"text-generation","task_name":"Text Generation"},{"task_slug":"text-summarization","task_name":"Text Summarization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/text-summarization-on-duc-2004-task-1","task":"Text Summarization","dataset":"DUC 2004 Task 1","model":"Transformer+LRPE+PE+Re-ranking+Ensemble","rank_in_archive_order":2,"of":13,"metrics":{"ROUGE-1":"32.85","ROUGE-2":"11.78","ROUGE-L":"28.52"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1904.07418","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1904.07418"}},"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/takase/control-length","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"unverified":4},"by_repo_kind":{"official":{"samples":4,"ran":0,"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":"2020c8115ac4366b","entry":"dataset_dest_prefix","repo":"takase/control-length","repo_kind":"official","path":"encdec/preprocess.py","file_url":"https://github.com/takase/control-length/blob/HEAD/encdec/preprocess.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2020c8115ac4366b"}},{"code_sha256_prefix":"0870cb6c6f12fec1","entry":"extract_output","repo":"takase/control-length","repo_kind":"official","path":"encdec/rerank.py","file_url":"https://github.com/takase/control-length/blob/HEAD/encdec/rerank.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"0870cb6c6f12fec1"}},{"code_sha256_prefix":"f7be0d5349bd91dd","entry":"extract_source_word","repo":"takase/control-length","repo_kind":"official","path":"encdec/rerank.py","file_url":"https://github.com/takase/control-length/blob/HEAD/encdec/rerank.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"f7be0d5349bd91dd"}},{"code_sha256_prefix":"46c303dd0a228f2e","entry":"read_file","repo":"takase/control-length","repo_kind":"official","path":"eval/calculate_variance_from_fixlength.py","file_url":"https://github.com/takase/control-length/blob/HEAD/eval/calculate_variance_from_fixlength.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"46c303dd0a228f2e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}