AI skills and dependency length minimization

Anthropic’s skill authoring best practices’ first core principle is “Concise is key”. AIs have a limited context window and their performance, their IQ, degrades as that context fills up with text.

If you're familiar with some of the theories around language models, you know that there is likely more to it than just reducing content in context. LLMs attention mechanism works by finding graphs of related words and concepts and it works best when the relevant relationships are close together in the text. Length matters but how well the information is organized matters as well.

It's useful to be familiar with the concept of dependency length. The two sentences in this image have the same words and same meaning but sentence C is organised to minimize the distance between related words.

Dependency graphs for sentences C and D, showing shorter distances between related words in sentence C

This can also apply to paragraphs and sections. Ordering them so that related information is recursively closer together, helps AIs think better (it also helps humans, Dependency Length Minimization, DLM is an idea from psycho-linguistics).

This is one reason progressive disclosure and sub agents are important. Including unnecessary information spreads apart surrounding information and makes it more difficult for AIs to figure things out.

For eg. optimizing skills, it can help to put more important information at the bottom of a skill. Usually after a skill is loaded, the AI will start “thinking”, talking to itself to try to reason through a problem. The thinking block will have an easier time considering the text closest to it, the last part of the skill, than information farther up.

Thinking blocks can produce a lot of text (a lot of it often hidden from users) that also spreads information apart. Sometimes, when an early instruction is still relevant but there’s been a lot of thinking and discussion added to the context since, it’s worth repeating a summary of the early information ( keeping in mind that too many reminders can also spread other information apart ). LLMs are however tuned to overweight very early information so that they don't disregard system prompts. You might be able to exploit this by placing some important facts near the very beginning of a conversation. There's likely only a small area at the start of the context window that is artificially boosted, after that DLM becomes important. So LLMs ability to track information ends up being somewhat U shaped. Note that this is also true for humans.

If you've ever written compression algorithms where repeated blocks are referenced instead of encoded, you'll be familiar with how related information being clustered allows for better compression. It's another example of the parallels between intelligence and compression and it hints at the information theoretic aspect of DLM (previously discussed in the entropy post).