Skip to main content

keep_first_last

Function keep_first_last 

Source
pub fn keep_first_last<T: Clone>(
    items: &[T],
    head: usize,
    tail: usize,
) -> Vec<T>
Expand description

Positional-bias mitigation (lost-in-the-middle): reorder so the most important items sit at the beginning and end of the context, where models attend most reliably (Anthropic’s ~18% middle drop vs 30-50% elsewhere, fable §13). Keeps the first head and last tail items in place and moves the middle to the end (least-attended region) preserving order.