
SCBench (SharedContextBench) is a comprehensive benchmark to evaluate efficient long-context methods in a KV cache-centric perspective, analyzing their performance across the full KV cache lifecycle (generation, compression, retrieval, and loading) in real-world scenarios where context memory (KV cache) is shared and reused across multiple requests.
You can download and load the SCBench data through the Hugging Face datasets (🤗 HF Repo), and run the experiments in the Github (💻 SCBench):
from datasets import load_dataset
datasets = ["scbench_kv", "scbench_prefix_suffix", "scbench_vt", "scbench_repoqa", "scbench_qa_eng", "scbench_qa_chn", "scbench_choice_eng", "scbench_many_shot", "scbench_summary", "scbench_mf", "scbench_summary_with_needles", "scbench_repoqa_and_kv"]
for dataset in datasets:
data = load_dataset('microsoft/SCBench', dataset, split='test')
All data in SCBench are standardized to the following format:
{
"id": "Random id for each piece of data.",
"context": "The long context required for the task, such as repo-code, long-document, and many-shot.",
"multi_turns": [{"input": "multi-turn question.", "answer": "multi-turn reference answer."}],
}
We implement Multi-Turn and Multi-Request modes with HF and vLLM in GreedySearch and GreedySearch_vllm two class. Please refer the follow scripts to run the experiments.
First, build the environment, see basic environment.
Run the test:
bash scripts/test_llama.sh
Run multiple tasks in one command:
bash scripts/run_all_tasks.sh
Specify the max sequence length, max number of turns, and number of eval examples:
--max_seq_length: The maximum sequence length for the test.--max_turns: The maximum number of turns for the test.--num_eval_examples: The number of test examples to use, use all examples in default.--attn_type: The attention type to use.--kv_type: The KV cache type to use.For example, run with MInference and SnapKV:
bash scripts/test_minference_with_snapkv.sh
The supported efficient long-context methods are as follows:
attn_type:
dense: Dense attentionminference: MInferencea_shape: A-Shapetri_shape: Tri-Shapekv_type:
dense: Dense KV cachekivi: KIVIsnapkv: SnapKVquest: Questpyramidkv: PyramidKVstreamingllm: StreamingLLMYou will need to build specific environment for different attention types and KV cache types, see section Environment for more details.

SCBench covers 12 diverse tasks that test four key long-context capabilities: string retrieval, semantic retrieval, global information processing, and multi-tasking.
The benchmark evaluates these tasks across two shared context modes:

Our SCBench is the first long-context benchmark that covers single-turn, multi-turn, and multi-request scenarios. In addition, our impelmentation also involves KV cache reuse techniques, thereby providing a more comprehensive analysis on the full KV cache lifecycle of efficient long-context methods.

Our SCBench reveals that the following key insights:
@article{li2024scbench,
title={SCBench: A KV cache-centric analysis of long-context methods},
author={Li, Yucheng and Jiang, Huiqiang and Wu, Qianhui and Luo, Xufang and Ahn, Surin and Zhang, Chengruidong and Abdi, Amir H and Li, Dongsheng and Gao, Jianfeng and Yang, Yuqing and Qiu, Lili},
journal={arXiv preprint arXiv:2412.10319},
year={2024}
}

SCBench (SharedContextBench) is a comprehensive benchmark to evaluate efficient long-context methods in a KV cache-centric perspective, analyzing their performance across the full KV cache lifecycle (generation, compression, retrieval, and loading) in real-world scenarios where context memory (KV cache) is shared and reused across multiple requests.
You can download and load the SCBench data through the Hugging Face datasets (🤗 HF Repo), and run the experiments in the Github (💻 SCBench):
from datasets import load_dataset
datasets = ["scbench_kv", "scbench_prefix_suffix", "scbench_vt", "scbench_repoqa", "scbench_qa_eng", "scbench_qa_chn", "scbench_choice_eng", "scbench_many_shot", "scbench_summary", "scbench_mf", "scbench_summary_with_needles", "scbench_repoqa_and_kv"]
for dataset in datasets:
data = load_dataset('microsoft/SCBench', dataset, split='test')
All data in SCBench are standardized to the following format:
{
"id": "Random id for each piece of data.",
"context": "The long context required for the task, such as repo-code, long-document, and many-shot.",
"multi_turns": [{"input": "multi-turn question.", "answer": "multi-turn reference answer."}],
}
We implement Multi-Turn and Multi-Request modes with HF and vLLM in GreedySearch and GreedySearch_vllm two class. Please refer the follow scripts to run the experiments.
First, build the environment, see basic environment.
Run the test:
bash scripts/test_llama.sh
Run multiple tasks in one command:
bash scripts/run_all_tasks.sh
Specify the max sequence length, max number of turns, and number of eval examples:
--max_seq_length: The maximum sequence length for the test.--max_turns: The maximum number of turns for the test.--num_eval_examples: The number of test examples to use, use all examples in default.--attn_type: The attention type to use.--kv_type: The KV cache type to use.For example, run with MInference and SnapKV:
bash scripts/test_minference_with_snapkv.sh
The supported efficient long-context methods are as follows:
attn_type:
dense: Dense attentionminference: MInferencea_shape: A-Shapetri_shape: Tri-Shapekv_type:
dense: Dense KV cachekivi: KIVIsnapkv: SnapKVquest: Questpyramidkv: PyramidKVstreamingllm: StreamingLLMYou will need to build specific environment for different attention types and KV cache types, see section Environment for more details.

SCBench covers 12 diverse tasks that test four key long-context capabilities: string retrieval, semantic retrieval, global information processing, and multi-tasking.
The benchmark evaluates these tasks across two shared context modes:

Our SCBench is the first long-context benchmark that covers single-turn, multi-turn, and multi-request scenarios. In addition, our impelmentation also involves KV cache reuse techniques, thereby providing a more comprehensive analysis on the full KV cache lifecycle of efficient long-context methods.

Our SCBench reveals that the following key insights:
@article{li2024scbench,
title={SCBench: A KV cache-centric analysis of long-context methods},
author={Li, Yucheng and Jiang, Huiqiang and Wu, Qianhui and Luo, Xufang and Ahn, Surin and Zhang, Chengruidong and Abdi, Amir H and Li, Dongsheng and Gao, Jianfeng and Yang, Yuqing and Qiu, Lili},
journal={arXiv preprint arXiv:2412.10319},
year={2024}
}