I think about code representations both in day-to-day software development and in how AI might generate and reason about programs. I am wary of visual development approaches that stop being simple, readable text files, and I am curious whether tree-aware representations could help language models work with code. These questions connect to my broader reflections on ai assisted coding workflows.
I have seen countless efforts to make software development “more visual,” but anything that is not a simple collection of human- and LLM-readable text files continues to step on land mines.
I suspect there are still advantages to reasoning in a representation other than binary code, even if AI may move to directly generating binary code.
Textual code is a flattening of an abstract syntax tree, while LLMs produce tokens linearly and their prior context is connected through position embeddings.
I wonder whether LLMs could work more effectively if position embeddings directly represented tree structures, with code “parsed” into context instead of entered directly.
In a basic attention scheme, all tokens in the context attend to all the other tokens with no sense of order; transformers add position encodings so relative placement can be reasoned about.
Systems like RoPE or the original transformer's sinusoidal mappings provide information about one-dimensional distance; I wonder whether tokens could be mutated along many axes to incorporate higher-dimensional or non-uniform structures such as trees or graphs.
I do not know whether tree- or graph-structured position representations would be useful, and I am already out of my RL lane when talking about transformers, but I find the idea interesting.
Related: ai assisted coding workflows, skills and voice in ai, llm training and attribution