‹ BackHN Continuity

Thread

Context Language Models

176 points · 51 comments · emersonmacro

Loading the complete thread in the background. This saved snapshot is available now. Refresh

  1. svachalek · · focus · HN ↗
    Wow. Context management is one of the big remaining hassles with modern LLMs so this could be big. The obvious complication is cache busting so it's also exciting they investigated solutions for that.
  2. Bolwin · · focus · HN ↗
    The biggest discovery might actually be that they ignored regular caching rules and kept invalid cache suffixes and it didn't hurt performance
    1. TeMPOraL · · focus · HN ↗
      I wonder how bad the performance would be if they plain ignored the whole rotary encoding dance and just back-filled precisely the parts of the cache that changed directly. Would it break the model? Confuse the model? Or would the model internally correct for it?
      1. dist-epoch · · focus · HN ↗
        The rotary issue is a simple rotation, cheap, no reason to skip it.

        But this is the kind of thing you could ask your agent to test locally.

        1. imtringued · · focus · HN ↗
          The issue is this, rotary encoding basically numbers the tokens on the request level.

          If you pre-process a text file you cannot insert it into the context because even if you numbered the tokens within a file properly, it is numbered wrong in the global context of the request. So you have cached data but the request structure does not allow you to insert it.

          1. TeMPOraL · · focus · HN ↗
            > The issue is that when you have messages 1, 2, 3, 4, 5. And you want to update messages 1,2,3, because they are in the reserved chunk, then 4 and 5 already contain some baked in information from 1,2,3. This means you cannot modify 1, 2, 3 arbitrarily without changing the architecture

            What does "you cannot modify without changing the architecture" mean exactly? I.e. will the runtime crash if you do it wrong, or would it merely risk confusing the LLM?

            Because if it's the latter, I wonder if this isn't less of a problem in practice than it sounds.

            Humans don't update their memories all at the same time, either. We often end up in inconsistent mental picture that we resolve automatically when it becomes apparent (the brief "pause to think" moments).

            1. dist-epoch · · focus · HN ↗
              Nothing will crash. It might create "surprise".

              Example:

              Trajectory: >>What is the capital of France? Let me think<<

              the KV cache tokens for "let me think" will have baked in them among other things "France", "Paris", "major city", "question"

              Now you compact, and reuse the later tokens (suffix)

              Compacted trajectory: >>Let me think, all right, let's see<<

              Now the compacted KV cache for "Let me think" will have baked in them "France", "Paris", and the model can be "that is weird, why am I thinking about France and Paris? there is nothing related in the previous context"

              1. TeMPOraL · · focus · HN ↗
                So, from this follows there must be a point between "pristine cache" and "100% stale cache" where the surprise is small enough the model can recover. Perhaps with extra hint at the end, "your context cache is no fully rebuilt after a change, except confusion".

                Bit like a person who just woke up, or was suddenly distracted, and now has some stray thoughts from previous context floating around. We normally dismiss them. Maybe the models can, too, and this could achieve more flexibility with cache management (therefore much lower costs of context management), at the price of slight capability reduction after context management events?

                1. dist-epoch · · focus · HN ↗
                  > Perhaps with extra hint at the end

                  most of this stuff will be "unconscious" the model will have a pull in a particular direction.

                  > stray thoughts from previous context floating around. We normally dismiss them

                  It&#x27;s not that simple, see <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Priming_(psychology)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Priming_(psychology)

                  &gt; Priming is a concept in psychology and psycholinguistics to describe how exposure to one stimulus may influence a response to a subsequent stimulus, without conscious guidance or intention

                  But nobody knows, what will happen is people will experiment with this, you can run the benchmarks, if it works it will be used, if not, well...

      2. imtringued · · focus · HN ↗
        You can apply rotary encoding on the file level to keep relative positioning within a file. Then there would be no global order of files (which could be an issue) but you can now add or remove whole files as you like.
      3. wren6991 · · focus · HN ↗
        Kimi K3 is an example of a modern LLM that doesn&#x27;t use positional encodings. It uses NoPE&#x27;d MLA for global attention and a variant of Gated DeltaNet (KDA) for local attention. I wonder how much the KDA would degrade if you just did a bounded replay over the last few thousand tokens to recover its approximate state when assembling your context window from chunks of known MLA KV.
  3. visarga · · focus · HN ↗
    Can&#x27;t we do this trick today with any model? Just send the file as next context. Of course you pay the price for cache misses, depending how deep you make changes. I mean they also relax cache recomputation a bit more.
    1. nsingh2 · · focus · HN ↗
      One approximation of this is the experimental context management Codex has been moving towards (not released yet). Rather than relying on summary compaction, the model maintains notes as it works and as it approaches the context limit. A new session is just a fresh context with those notes attached, and a pointer back to the previous session.

      Not exactly like what this paper is suggesting, but similar in the sense it lets the model decide what and how to persist across turns.

      I recreated this in Pi, with a max token limit on how long the note can be, to pressure the model to be concise. Ends up being cheaper than summary compaction too.

      1. visarga · · focus · HN ↗
        That is similar to what I am thinking... not just edit the context as a file or string, but have a way to evict blocks and replace them with summary notes and also be able to retrieve them on demand.

        Do you have a public repo for your approach?

        1. nsingh2 · · focus · HN ↗
          No public repo but it&#x27;s not too difficult to point a LLM at the general idea. Since Codex is open source, you can even take a look at how they do it. Here is what the model is instructed to do in codex: <a href="https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;codex&#x2F;blob&#x2F;d91294c39edb93d204926b33f21310dc968edc34&#x2F;codex-rs&#x2F;models-manager&#x2F;models.json#L109-L112" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;codex&#x2F;blob&#x2F;d91294c39edb93d204926b3...
        2. flyinfra · · focus · HN ↗

          [dead]

      2. ijidak · · focus · HN ↗
        Memento
      3. TeMPOraL · · focus · HN ↗
        Interesting. It matches my manual workflow with all harnesses (including vanilla web ChatGPT&#x2F;Gemini&#x2F;Claude) for the past year or so: when the session gets compacted, or (ideally) when I feel it&#x27;s about to be, I just tell it to write a handover note, and start a new session.

        With some specific workflow I use in some cases (involving leaving long-lived intermediary artifacts), this turned into me pasting a path to handover file in previous agent&#x27;s session, and handover itself directs the agent to key files from that session to read, and that&#x27;s it. So far, with this process, at no point I felt any quality degradation (though early on I often see &quot;I need to check how my predecessor did ${something}&quot;, followed by surgical spelunking of past chat&#x27;s history), even as I carry a single piece of complex analytical work over 5+ sessions.

      4. veqq · · focus · HN ↗
        Claude Roux uses a refined version:

        &gt; LLMs have a lot of knowledge but few competencies. If you constrain them to output knowledge and use that to further constrain results, you’ll go far. For context management, I have the system generate `log.jsonl` and `log.py` (which queries the other document). Whenever an action is processed (an error’s corrected etc.) the system adds something to `log.jsonl`. If it needs to know what happens, it uses `log.py` to query and display only the relevant&#x2F;required information (like a date, errors or attempted fixes) reducing tokens. - <a href="https:&#x2F;&#x2F;alexalejandre.com&#x2F;interviews&#x2F;interview-with-claude-roux&#x2F;" rel="nofollow">https:&#x2F;&#x2F;alexalejandre.com&#x2F;interviews&#x2F;interview-with-claude-r...

    2. verdverm · · focus · HN ↗
      yup, I build a set of fs tools in my custom coding harness that worked like this, doing it again in another custom harness that I only expect to take one turn per request, you can still get decent caching by ordering things so most dynamic comes later
  4. bob1029 · · focus · HN ↗
    I would be concerned with context management consuming limited attention resources.

    Do you want your agent solving its own memory crisis, or do you want it solving the actual task? It can probably do both at the same time, but I suspect there is a non trivial cost associated with this.

    A separate hypervisor agent that manages the main agent&#x27;s context would be much better in my experience. You can run it on a different schedule and the main agent has to spend zero tokens thinking about it. This also makes it a lot easier to control when caches will be missed.

    1. alightsoul · · focus · HN ↗
      Maybe have A second model do the management?
      1. theroadnotbacon · · focus · HN ↗
        Looks like they tested that in the paper, and the code allows for it as well. <a href="https:&#x2F;&#x2F;github.com&#x2F;facebookresearch&#x2F;context-language-models&#x2F;tree&#x2F;main&#x2F;clm&#x2F;clm_icl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;facebookresearch&#x2F;context-language-models&#x2F;... Of course, this is for suggesting context management strategies rather than the actual management afaict.
        1. alightsoul · · focus · HN ↗
          Yeah maybe a second model can do the actual management
      2. vatsachak · · focus · HN ↗
        Yeah, that would be the canonical solution. Modularity is better
      3. verdverm · · focus · HN ↗
        I was thinking this, not so dissimilar from co-training dflash drafters
    2. naw103 · · focus · HN ↗

      [dead]

    3. rajveerb · · focus · HN ↗
      An argument against having a separate hypervisor agent.

      A separate hypervisor agent at least doubles the cost because (1) the underlying model needs to be the same so that we get the same degree of intelligence, and (2) it needs to have the same context + more tokens for the work it does.

    4. flyinfra · · focus · HN ↗

      [dead]

  5. gitghxst · · focus · HN ↗
    that&#x27;s interesting!
  6. aghuang · · focus · HN ↗
    Looks great!
  7. plastic-enjoyer · · focus · HN ↗
    &gt; We implement this by treating the context as a file and allowing the model to make unrestricted updates to this file. This allows the model to learn what is most important to maintain in context, and naturally extends to multi-agent systems where multiple agent contexts coexist as files.

    So, is this like RAM, just for an LLM? Do we have to reinvent MMUs for LLMs and all the abstractions that come along with it?

    1. actionfromafar · · focus · HN ↗
      yes, and &quot;kubernetes&quot;
    2. kgeist · · focus · HN ↗
      &gt;Do we have to reinvent MMUs for LLMs

      MMUs are already emulated in engines like vLLM (paged attention).

  8. gavinray · · focus · HN ↗

      &gt; We implement this by treating the context as a file and allowing the model to make unrestricted updates to this file. 
    
    What an incredibly novel and unprecedented idea!
    1. royal__ · · focus · HN ↗
      This was my gut reaction as well but I think this is just a poor abstract. What they actually did appears to be much deeper than reinventing agents.md
  9. vatsachak · · focus · HN ↗
    Eventually the CLM will be a separate model co-trained with the actual model right?

    And there will be multiple contexts like hot vs cold pages in DBs

  10. jkhdigital · · focus · HN ↗
    Bitter Lesson showing up yet again, this time in context management?
  11. killerstorm · · focus · HN ↗
    Related: &quot;Recursive Language Models&quot; <a href="https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2512.24601" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2512.24601
    1. bob1029 · · focus · HN ↗
      [delayed]
  12. _jayhack_ · · focus · HN ↗
    Letting a model manage its own context is very bitter lesson-pilled

    Biggest challenge is you will get a much lower cache hit rate if you frequently edit the agent&#x27;s context&#x2F;prefix, so this can not be implemented efficiently via e.g. the Anthropic API.

    This ^ can be solved in principle but likely requires modifications to the transformer architecture and definitely to serving infrastructure

    See related: &quot;KV Cache Rules Everything Around Me&quot;: <a href="https:&#x2F;&#x2F;www.completeskeptic.com&#x2F;p&#x2F;kv-cache-rules-everything-around" rel="nofollow">https:&#x2F;&#x2F;www.completeskeptic.com&#x2F;p&#x2F;kv-cache-rules-everything-...

    1. wangii · · focus · HN ↗
      is kvcache a prematural optimization?
      1. f_devd · · focus · HN ↗
        It&#x27;s pretty much required to make it work with large contexts, so probably not
      2. gfrecvh · · focus · HN ↗
        Do you even understand what you&#x27;re suggesting? Do you understand how the data flow would look like without a kv cache?
        1. wangii · · focus · HN ↗
          Java spent decades making pointer-rich identity semantics cheaper, before increasingly recognizing that many things programmers call “objects” are actually values.

          We may spend a decade making persistent token-level KV state cheaper, before recognizing that much of what we call “context” should actually be transient, compressed, reconstructed, or represented in an entirely different state space.

          KV cache risks turning an optimization of today&#x27;s representation of history into tomorrow&#x27;s semantics of memory.

      3. wat10000 · · focus · HN ↗
        Not having it would be like a text editor that loads your entire document from disk and re-saves it every time you press a key. On a floppy drive.
        1. wangii · · focus · HN ↗

          [dead]

    2. metalspot · · focus · HN ↗
      this is done on the model side so it is invisible to the caller. all of deepseeks kv cache compression stuff is basically the same thing. it doesn&#x27;t really put the entire context into kv cache and does various inference side stuff to decide what to actually use as context.
    3. trenchgun · · focus · HN ↗
      If you read the paper, they had a solution for this.
    4. Neywiny · · focus · HN ↗
      True facts. Cline does this with auto compact and it&#x27;s so dumb. At the start of the session it reads the plan.md. during compaction, it forgets it. Same with its own output. It&#x27;ll tell me the list of steps to take. By step 4 it needs to compact. So I prompt to do step 4. It spends 15 minutes searching the codebase and comes back that it couldn&#x27;t find such a step. So dumb. So so dumb
  13. hashmap · · focus · HN ↗
    how long until cutting out the token middleman and just keep the cache constant sized but edit it and just send the model new information instead of the same thing over and over. token bad latent good.
  14. sayamss · · focus · HN ↗
    Looks Slop. Isn&#x27;t this just RLMs? but instead of variable its just a file?
    1. rajveerb · · focus · HN ↗
      <a href="https:&#x2F;&#x2F;x.com&#x2F;a1zhang&#x2F;status&#x2F;2105409935936782708?s=20" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;a1zhang&#x2F;status&#x2F;2105409935936782708?s=20
  15. imtringued · · focus · HN ↗
    Mom can we have deep equilibrium (DEQ) transformers?

    No, we have DEQ at home.

    DEQ at home: We just put the context into a file first and then prompt the model to edit it.

  16. thelocalnode · · focus · HN ↗

    [dead]

  17. darkoob12 · · focus · HN ↗
    Did they just rename their AI lab to superinterlligence lab!!

    It is pathetic

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.