arXiv Science⌕ Search

arXiv · 2611.37273

Shared KV Heads, Sliding Windows, and Vocabulary Size: Measured Memory and Retrieval Trade-offs in LLaMA 7B, Mistral 7B, and Qwen2.5-7B

Abstract

Three widely used 7B-class language models, original LLaMA 7B, Mistral 7B v0.1, and Qwen2.5-7B, differ in three design choices that decide what fits on a small GPU: how many key-value (KV) heads the attention layers keep (32, 8, and 4), whether attention is limited to a sliding window (4,096 tokens in Mistral), and how large the vocabulary is (32,000 versus 151,643 tokens). We measure the consequences of each choice on one 16 GB T4 GPU. (1) Passkey retrieval in Mistral stops at the window. In 134 trials with the key placed 3,600 to 4,600 tokens from the end of the prompt, Mistral retrieved it in all 72 trials where it lay within 4,089 tokens and in none of the 62 trials where it lay 4,098 or more tokens away. With the same weights and the window turned off, retrieval succeeds at every tested position in 8K-token prompts, so the mask causes the limit; at 16K and 32K tokens the window-free model fails completely, while the windowed model still retrieves nearby keys. Qwen2.5 retrieves the key in all 60 trials up to 32K tokens. (2) KV-cache memory per token is 512, 128, and 56 KiB. LLaMA runs out of memory at 32K tokens, Qwen2.5 holds 64K tokens in 3.5 GiB, and Mistral's cache stops at 512 MiB. (3) On 1,997 parallel sentences in 15 languages, Qwen2.5's tokenizer removes 38-58% of tokens for five languages and 3-11% for the other ten; combined with KV sharing, LLaMA needs 9.5-22.0 times more cache memory than Qwen2.5 for the same sentence. (4) Decode latency in a common runtime grows with cache size, and copying the cache, measured on its own, costs about as much as that growth. Code and results are public.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Kapardhi Kannekanti, Durvankur Chavan, B Tarun Sandilya. 2026-11-27. Shared KV Heads, Sliding Windows, and Vocabulary Size: Measured Memory and Retrieval Trade-offs in LLaMA 7B, Mistral 7B, and Qwen2.5-7B. https://arxiv.science/abs/2611.37273

Citations retain the original authors and DOI and include this site’s record URL. If this discovery service contributed to your research, you can also cite arXiv Science by Indiciae: BibTeX · RIS.

KEEP EXPLORING

Related papers

Long-Short Chain-of-Thought Mixture Supervised Fine-Tuning Eliciting Efficient Reasoning in Large Language Models

Recent advances in large language models have demonstrated that Supervised Fine-Tuning (SFT) with Chain-of-Thought (CoT) reasoning data distilled from large reasoning models (e.g., DeepSeek R1) can effectively transfer reasoning capabilities to non-reasoning models. However, models fine-tuned with this approach inherit the "overthinking" problem from teacher models, producing verbose and redundant reasoning chains during inference. To address this challenge, we propose Long-Short Chain-of-Thought Mixture Supervised Fine-Tuning (LS-Mixture SFT), which combines long CoT reasoning dataset with their short counterparts obtained through structure-preserved rewriting. Our experiments demonstrate that models trained using the LS-Mixture SFT method, compared to those trained with direct SFT, achieved an average accuracy improvement of 2.3% across various benchmarks while substantially reducing model response length by approximately 47.61%. This work offers an approach to endow non-reasoning models with reasoning capabilities through supervised fine-tuning while avoiding the inherent overthinking problems inherited from teacher models, thereby enabling efficient reasoning in the fine-tuned models.

cs.CL↗

ADMIT: Few-Shot Knowledge Poisoning Attacks on RAG-Based Fact-Checking

Knowledge poisoning injects misleading content into the knowledge base of a Retrieval-Augmented Generation (RAG) system to manipulate its outputs. Prior work often assumes that poisoned passages fill the entire retrieved context. In real-world fact-checking, however, credible evidence is also retrieved, and knowledge sources dominated by misinformation would be considered unreliable. Therefore, we propose ADMIT (ADversarial Multi-Injection Technique), a black-box attack on RAG-based fact-checking that injects only a few passages into the knowledge base, a setting we call few-shot knowledge poisoning. We find that ADMIT-generated misinformation can mislead fact-checkers into producing and justifying incorrect verdicts, even in the presence of credible evidence. Such misinformation is also stylistically similar to the evidence observed by the attacker. Extensive experiments on four fact-checking benchmarks show that ADMIT is effective across domains, transfers across LLMs and retrievers, and remains effective against existing defenses. Our code is available at https://github.com/wuyoscar/ADMIT.

cs.CL↗

PingPong: A Natural Benchmark for Multi-Turn Code-Switching Dialogues

Code-switching is a widespread practice among the world's multilingual majority, yet few benchmarks accurately reflect its complexity in everyday communication. We present PINGPONG, a benchmark for natural multi-party code-switching dialogues covering five language-combination variations, some of which are trilingual. Our dataset consists of human-authored conversations among 2 to 4 participants covering authentic, multi-threaded structures where replies frequently reference much earlier points in the dialogue. We demonstrate that our data is significantly more natural and structurally diverse than machine-generated alternatives, offering greater variation in message length, speaker dominance, and reply distance. Based on these dialogues, we define three downstream tasks: Question Answering, Dialogue Summarization, and Topic Classification. Evaluations of several state-of-the-art language models on PINGPONG reveal that performance remains limited on code-switched inputs, underscoring the urgent need for more robust NLP systems capable of addressing the intricacies of real-world multilingual discourse.

cs.CL↗