{"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/transformer-vq-linear-time-transformers-via","title":"Transformer-VQ: Linear-Time Transformers via Vector Quantization","arxiv_id":"2309.16354","date":"2023-09-28","proceeding":null,"authors":["Lucas D. Lingle"],"abstract":"We introduce Transformer-VQ, a decoder-only transformer computing softmax-based dense self-attention in linear time. Transformer-VQ's efficient attention is enabled by vector-quantized keys and a novel caching mechanism. In our large-scale experiments, Transformer-VQ is shown highly competitive in quality, obtaining 0.99 bpb on Enwik8, 26.6 ppl on PG-19, and 3.16 bpb on ImageNet64. In addition, the optimized implementation of Transformer-VQ is over 3x faster than a comparable quadratic-time transformer at sequence length 8k, is over 12x faster at 32k, and can scale to 131k with similar throughput. Code available: \\url{https://github.com/transformer-vq/transformer_vq}","url_abs":"https://arxiv.org/abs/2309.16354v2","url_pdf":"https://arxiv.org/pdf/2309.16354v2.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":"transformer-vq-linear-time-transformers-via","repo_url":"https://github.com/transformer-vq/transformer_vq","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"jax","reach":null}],"tasks":[{"task_slug":null,"task_name":"8k"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"quantization","task_name":"Quantization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2309.16354","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2309.16354"}},"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":"deterministic:regex_extraction","url":"https://github.com/transformer-vq/transformer_vq","reach":null}],"summary":{"ran":4,"ran_fixture":1,"ran_honours":3,"unverified":1},"by_repo_kind":{"official":{"samples":9,"ran":8,"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":9,"samples":[{"code_sha256_prefix":"f736a3de7a2e5590","entry":"LayerNorm","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.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":"f736a3de7a2e5590"}},{"code_sha256_prefix":"373b8a31aa62a4f6","entry":"LearnableVQ","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.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":"373b8a31aa62a4f6"}},{"code_sha256_prefix":"999feb06aba92a5f","entry":"TransformerConfig","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.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":"999feb06aba92a5f"}},{"code_sha256_prefix":"f48b12c686f222ed","entry":"VQAttention","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.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":"f48b12c686f222ed"}},{"code_sha256_prefix":"187b7f355f8c0138","entry":"get_shortcodes","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"187b7f355f8c0138"}},{"code_sha256_prefix":"15931a925cb2244a","entry":"get_sinusoid_embs","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"15931a925cb2244a"}},{"code_sha256_prefix":"ed7452fdef804a28","entry":"sg","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ed7452fdef804a28"}},{"code_sha256_prefix":"7b29979f121a924b","entry":"st","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7b29979f121a924b"}},{"code_sha256_prefix":"3ed533aca2b723d7","entry":"get_codewords","repo":"transformer-vq/transformer_vq","repo_kind":"official","path":"src/transformer_vq/nn/attn.py","file_url":"https://github.com/transformer-vq/transformer_vq/blob/HEAD/src/transformer_vq/nn/attn.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":"3ed533aca2b723d7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}