UT-ACA: Uncertainty-Triggered Adaptive Context Allocation for Long-Context Inference
Organizations: School of Computer Science and Engineering, Sun Yat-sen University · Shenzhen Loop Area Institute · Southern University of Science and Technology
Abstract
Long-context inference remains challenging for large language models due to attention dilution and out-of-distribution degradation. Context selection mitigates this limitation by attending to a subset of key-value cache entries, yet most methods allocate a fixed context budget throughout decoding despite highly non-uniform token-level contextual demands. To address this issue, we propose Uncertainty-Triggered Adaptive Context Allocation (UT-ACA), an inference-time framework that dynamically adjusts the context window based on token-wise uncertainty. UT-ACA learns an uncertainty detector that combines semantic embeddings with logit-based confidence while accounting for uncertainty accumulation across decoding steps. When insufficient evidence is indicated, UT-ACA selectively rolls back, expands the context window, and regenerates the token with additional support. Experiments show that UT-ACA substantially reduces average context usage while preserving generation quality in long-context settings. Code and dataset are available at https://github.com/Tommy307/UT-ACA.
Figures & tables
| Methods | mAcc | Recall N | Recall P |
|---|---|---|---|
| Top-10 Std | 57.43 | 35.66 | 73.19 |
| Logit Margin | 55.54 | 48.09 | 60.93 |
| Evidential Mass | 58.29 | 55.87 | 60.04 |
| Evidential | 70.85 | 74.45 | 68.25 |
| UT-ACA | 83.43 | 89.71 | 81.27 |
| Methods | Settings | mTokens | mAcc |
|---|---|---|---|
| InfLLM | 32 | 91.37 | |
| 48 | 99.83 | ||
| Update: Set.1 | 25 | 96.59 | |
| UT-ACA | Update: Sub.1 | 29 | 99.08 |
| Models | Methods | Settings | mTokens | mTime (s) | mAcc (%) |
|---|---|---|---|---|---|
| Llama-3.1-8B-it | † RetrievalAttn 33 | 2k | 0.021 | 15.25 | |
| † LLMLingua-2 36 | 32k | - | 18.08 | ||
| † SnapKV 28 | 1k | 0.210 | 23.43 | ||
| TokenSelect 45 | 1k | - | 39.43 | ||
| OmniKV 11 | 8k | - | 40.47 | ||
| † InfLLM-V2 55 | 1k | - | 40.29 |
| Method | mAcc | mTok. | E2E T. (s) | GPU (GiB) |
| InfLLM | 25.81 | 128 | 95.80 | 26.42 |
| 51.23 | 256 | 97.46 | 26.42 | |
| 72.26 | 512 | 99.56 | 26.44 | |
| UT-ACA | 45.23 | 123 | 98.42 | 26.44 |
| 62.17 | 218 | 99.56 | 26.47 | |
| 70.48 | 344 | 100.70 | 26.51 |
| LogM | SE | LSTM | mAcc | mAcc |
|---|---|---|---|---|
| ✔ | ✘ | ✘ | 26.82 | - |
| ✘ | ✔ | ✘ | 78.95 | 69.58 |
| ✔ | ✘ | ✔ | 53.71 | - |
| ✘ | ✔ | ✔ | 80.06 | 68.58 |
| ✔ | ✔ | ✘ | 80.19 | 69.42 |
| ✔ | ✔ | ✔ | 83.43 | 70.48 |
| Method | Bench | LongBench | RULER | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Sum Task | QA Task | narrativeqa | qmsum | QA-16k | QA-8k | |||||||
| mTok | Score | mTok | Score | mTok | Score | mTok | Score | mTok | Score | mTok | Score | |
| 1024 | 11.25 | 1024 | 1.14 | 64 | 5.35 | 64 | 13.84 | 128 | 12.00 | 128 | 14.30 | |
| 2048 | 11.52 | 2048 | 0.93 | 128 | 4.68 | 128 | 14.25 | 256 | 11.00 | 256 | 16.60 | |
| H 2 O | 4096 | 10.59 | 4096 | 1.27 | 256 | 4.44 | 256 | 14.81 | 512 | 10.70 | 512 | 21.00 |
| 1024 | 27.24 | 1024 | 16.27 | 64 | 14.95 | 64 | 18.40 | 128 | 14.05 | 128 | 14.90 | |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Attribute Names | Example Data |
|---|---|---|
| Training Set | • Marriage Date • Job Title • Current City • Email Address • Phone Number • Favorite Color • User Agent • Credit Card Provider • Currency Used • Catch Phrase • Street Address • Vehicle License Plate • Favorite File Extension • Domain Name • Cryptocurrency • Timezone • Isbn Code • Lucky Number • Hobby • Marital Status • Personality Type | • The marriage date of Laetitia Guyot de Paris is 2010-03-29. • The job title of Franck Jourdan is Magazine features editor. • The current city of Marcial Escalona Yuste is Augerdan. • The email address of Jeremy Wright is [email protected]. • The phone number of Clarence Byrd is 07703087971. • The favorite color of Letizia Fagotto is Black. • The user agent of Inés Novoa Sarabia is Mozilla/5.0 • The credit card provider of Douglas Baker is Maestro. • The currency used of Susann Jacobi Jäckel is Bahraini dinar. • The catch phrase of Olga Torre Rodriguez is Interfaccia estesa … • The street address of Gabriela Jesus is Bährgasse 62. • The vehicle license plate of Erdal Mälzer is GE 3041 CB. • The favorite file extension of Ornella Tomasini is tiff. • The domain name of Théo Macedo is chretien.com. • The cryptocurrency of Anaïs Gilbert du Rousset is Vertcoin. • The timezone of Eutimio Tejada Ibañez is Europe/Paris. • The isbn code of Jeanne-Sabine Brunet is 978-0-456-54959-9. • The lucky number of Zoé Chauvet is 61. • The hobby of María Manuela Guardia Moles is Sleeping. • The marital status of Gustavo Vallés is Widowed. • The personality type of Salvi Toscanini-Ferrabosco is Extrovert. |
| Validation Set and Test Set | • Birth Date • Birth Place • Company • Major • University • Work Place | • The birth date of Olivia Garcia is March 22, 1985. • The birth place of Daniel Lee is Seoul, South Korea. • The company of Olivia Chen is Microsoft. • The major of Ethan Clark is Computer Science. • The university of Aiden Gomez is Stanford University. • The work place of Elijah Robinson is Singapore, Singapore. |
| Wikipedia Source Articles | ||||
|---|---|---|---|---|
| Architecture | Mathematics | Pacific Ocean | Thermodynamics | Blockchain |
| Art | Number | Sahara | Virus | Cryptography |
| Baroque | Sport | South America | Communism | Engineering |
| Cinema | Vaccine | Volcano | Culture | Internal combustion engine |
| Classical music | French Revolution | Age of Enlightenment | Democracy | Internet |
| Impressionism | Maya civilization | American Civil War | Epistemology | Nanotechnology |
| Dataset | Example Summarization | Example Biography |
|---|---|---|
| Training Set | The email address of Jeremy Wright is [email protected]. | The sky is really blue. … The email address of Jeremy Wright is [email protected]. … The sky is really blue. |
| Validation Set | The birth date of Olivia Garcia is March 22, 1985. | The sky is really blue. … The birth date of Olivia Garcia is March 22, 1985. … The sky is really blue. |
| Test Set | • The birth date of Emma Thompson is 12/29/1880. • The birth place of Emma Thompson is Tokyo, Japan. • The university of Emma Thompson is Harvard University. • The major of Emma Thompson is Computer Science. • The company of Emma Thompson is Google. • The work place of Emma Thompson is San Francisco Bay Area. | … Emma Thompson was born on December 29, 1880, in the bustling metropolis of Tokyo, Japan. … She applied to Harvard University and was accepted into the Computer Science program. … After careful consideration, she chose to join Google, a company known for its innovative culture and cutting-edge technology. … Emma Thompson’s journey from Tokyo to the San Francisco Bay Area is a testament to her unwavering determination and exceptional talent. … |
| Component | Parameter | Value |
| Input Dimensions | Vector Dim ( ) | 4096 |
| Score Dim | 1 | |
| Hidden Model Dim ( ) | 64 | |
| Encoders | Vec Dropout | 0.5 |
| Score MLP Inner Dim | 32 | |
| Residual Head | Number of Blocks | 3 |
| ID | Name | Str | CAS | Hum | Cor | ID | Name | Str | CAS | Hum | Cor |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Emma Thompson | .000 | .000 | .000 | 0/6 | 16 | Lucas Scott | .262 | 1.00 | 1.00 | 6/6 |
| 2 | Liam Carter | .127 | .167 | .167 | 1/6 | 17 | Harper Coleman | .114 | .167 | .167 | 1/6 |
| 3 | Olivia Bennett | .230 | 1.00 | 1.00 | 6/6 | 18 | Henry Green | .260 | .500 | .667 | 3/6 |
| 4 | Noah Wright | .278 | .830 | .833 | 5/6 | 19 | Evelyn Perry | .308 | 1.00 | 1.00 | 6/6 |
| 5 | Ava Sullivan | .299 | .667 | .667 | 4/6 | 20 | Oliver Hughes | .358 | 1.00 | 1.00 | 6/6 |
| 6 | Ethan Brooks | .364 | .833 | .833 | 5/6 | 21 | Abigail Kelly | .333 | .833 | .833 | 5/6 |
| Case #3: Olivia Bennett | Case #17: Harper Coleman | ||||||
|---|---|---|---|---|---|---|---|
| (Str: 0.230, LLM: 1.000, Hum: 1.000) | (Str: 0.114, LLM: 0.167, Hum: 0.167) | ||||||
| Attr | GT | Pred. | Hum | Attr | GT | Pred. | Hum |
| Birth Date | June 3, 1888 | 1888-06-03 | ✔ | Birth Date | 10 Nov, 1907 | 1976 | ✘ |
| Birth Place | Sydney, NSW | Sydney, NSW | ✔ | Birth Place | Mexico City | Madrid, Spain | ✘ |
| University | MIT | Mass. Inst. Tech. | ✔ | University | NUS | Complutense Madrid | ✘ |
| Major | Medicine | Medicine | ✔ | Major | Intl. Rel. | Chem. Eng. | ✘ |
| Setting | mAcc (%) | Recall (%) | Recall (%) | mTokens | mAcc (%) |
|---|---|---|---|---|---|
| Two-Way Metric | 82.74 ( 0.69) | 88.04 ( 1.67) | 80.60 ( 0.67) | 348 | 67.99 ( 2.49) |
| Three-Way Metric | 83.43 | 89.71 | 81.27 | 344 | 70.48 |
| QA-16k | QA-8k | ||||
|---|---|---|---|---|---|
| Method | Setting | mTok | Score | mTok | Score |
| Original | topk8/sub4 | 105.00 | 14.65 | 108.00 | 14.40 |
| Calibration | topk8/sub4 | 101.77 | 19.30 | 102.68 | 23.10 |
| Original | topk32/sub16 | 385.00 | 21.65 | 352.00 | 26.85 |
| Calibration | topk32/sub16 | 364.15 | 26.10 | 367.24 | 26.90 |
| Setting | Top-1 | Rank of ‘‘29’’ | Log ( ‘‘29’’ ) |
|---|---|---|---|
| Before Expansion | ‘‘9’’ | 3rd | |
| After Expansion | ‘‘29’’ | 1st |
| Case | Intervention | Quality (%) | mTokens | Rollbacks |
|---|---|---|---|---|
| FP-1 | Suppress expansion | 100.0 100.0 | 379.36 367.83 ( ) | 12 10 |
| FP-2 | Suppress expansion | 100.0 100.0 | 370.14 359.75 ( ) | 9 9 |
| FN-1 | Force expansion | 16.7 66.7 | 173.47 238.00 ( ) | 1 6 |
| FN-2 | Force expansion | 8.3 75.0 | 316.80 385.47 ( ) | 1 9 |
Long-Context Inference
Long-context inference studies how language models retrieve, retain, and reason over information spanning very large inputs.
See all 52 papers