{"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/sparse-and-constrained-attention-for-neural","title":"Sparse and Constrained Attention for Neural Machine Translation","arxiv_id":"1805.08241","date":"2018-05-21","proceeding":"ACL 2018 7","authors":["Chaitanya Malaviya","Pedro Ferreira","André F. T. Martins"],"abstract":"In NMT, words are sometimes dropped from the source or generated repeatedly\nin the translation. We explore novel strategies to address the coverage problem\nthat change only the attention transformation. Our approach allocates\nfertilities to source words, used to bound the attention each word can receive.\nWe experiment with various sparse and constrained attention transformations and\npropose a new one, constrained sparsemax, shown to be differentiable and\nsparse. Empirical evaluation is provided in three languages pairs.","url_abs":"http://arxiv.org/abs/1805.08241v1","url_pdf":"http://arxiv.org/pdf/1805.08241v1.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":"sparse-and-constrained-attention-for-neural","repo_url":"https://github.com/Unbabel/sparse_constrained_attention","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"machine-translation","task_name":"Machine Translation"},{"task_slug":"nmt","task_name":"NMT"},{"task_slug":"translation","task_name":"Translation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1805.08241","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1805.08241"}},"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/Unbabel/sparse_constrained_attention","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":11},"by_repo_kind":{"listed":{"samples":11,"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":"6f72f5575120536e","entry":"count_repetitions","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"coverage-eval/rep_score.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/coverage-eval/rep_score.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":true,"mcp_get_code":{"code_sha256":"6f72f5575120536e"}},{"code_sha256_prefix":"b9ea7b997195665c","entry":"create_fertility_dictionary","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"generate_fertilities.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/generate_fertilities.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":true,"mcp_get_code":{"code_sha256":"b9ea7b997195665c"}},{"code_sha256_prefix":"775e3fffe173e4c5","entry":"create_ngram_sentence_list","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"coverage-eval/rep_score.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/coverage-eval/rep_score.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":true,"mcp_get_code":{"code_sha256":"775e3fffe173e4c5"}},{"code_sha256_prefix":"883808c0a4cdfcfb","entry":"get_segments","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"aer/postprocess_attention_bpe.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/aer/postprocess_attention_bpe.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":true,"mcp_get_code":{"code_sha256":"883808c0a4cdfcfb"}},{"code_sha256_prefix":"fc25511b9fbfb2ea","entry":"get_train_order","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"fertility/utils.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/fertility/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":true,"mcp_get_code":{"code_sha256":"fc25511b9fbfb2ea"}},{"code_sha256_prefix":"6b5b0e687ba650c7","entry":"list_of_indeces","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"coverage-eval/drop_score.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/coverage-eval/drop_score.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":true,"mcp_get_code":{"code_sha256":"6b5b0e687ba650c7"}},{"code_sha256_prefix":"ee28c141250a7e04","entry":"load_sentences","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"aer/postprocess_attention_bpe.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/aer/postprocess_attention_bpe.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":true,"mcp_get_code":{"code_sha256":"ee28c141250a7e04"}},{"code_sha256_prefix":"2a63cefd985e399b","entry":"n_gram_score","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"coverage-eval/rep_score.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/coverage-eval/rep_score.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":true,"mcp_get_code":{"code_sha256":"2a63cefd985e399b"}},{"code_sha256_prefix":"20e6ab89b91679c4","entry":"popen_io","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"force_align.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/force_align.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":true,"mcp_get_code":{"code_sha256":"20e6ab89b91679c4"}},{"code_sha256_prefix":"dcf92267cfb613e2","entry":"read_file","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"fertility/utils.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/fertility/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":true,"mcp_get_code":{"code_sha256":"dcf92267cfb613e2"}},{"code_sha256_prefix":"560fe3552307f73a","entry":"sortbylength","repo":"Unbabel/sparse_constrained_attention","repo_kind":"listed","path":"fertility/utils.py","file_url":"https://github.com/Unbabel/sparse_constrained_attention/blob/HEAD/fertility/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":true,"mcp_get_code":{"code_sha256":"560fe3552307f73a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}