Remix.run Logo
alexchamberlain 4 days ago

I'm not sure how, and maybe some of the coding agents are doing this, but we need to teach the AI to use abstractions, rather than the whole code base for context. We as humans don't hold the whole codebase in our hear, and we shouldn't expect the AI to either.

LinXitoW 3 days ago | parent | next [-]

They already do, or at least Claude Code does. It will search for a method name, then only load a chunk of that file to get the method signature, for example.

It will use the general information you give it to make educated guesses of where things are. If it knows the code is Vue based and it has to do something with "users", it might seach for "src/*/User.vue.

This is also the reason why the quality of your code makes such a large difference. The more consistent the naming of files and classes, the better the AI is at finding them.

felipeerias 3 days ago | parent [-]

Claude Code can get access to a language server like clangd through a MCP server, for example https://github.com/isaacphi/mcp-language-server

sdesol 4 days ago | parent | prev | next [-]

LLMs (current implementation) are probabilistic so it really needs the actual code to predict the most likely next tokens. Now loading the whole code base can be a problem in itself, since other files may negatively affect the next token.

photon_lines 3 days ago | parent | next [-]

Sorry -- I keep seeing this being used but I'm not entirely sure how it differs from most of human thinking. Most human 'reasoning' is probabilistic as well and we rely on 'associative' networks to ingest information. In a similar manner - LLMs use association as well -- and not only that, but they are capable of figuring out patterns based on examples (just like humans are) -- read this paper for context: https://arxiv.org/pdf/2005.14165. In other words, they are capable of grokking patterns from simple data (just like humans are). I've given various LLMs my requirements and they produced working solutions for me by simply 1) including all of the requirements in my prompt and 2) asking them to think through and 'reason' through their suggestions and the products have always been superior to what most humans have produced. The 'LLMs are probabilistic predictors' comments though keep appearing on threads and I'm not quite sure I understand them -- yes, LLMs don't have 'human context' i.e. data needed to understand human beings since they have not directly been fed in human experiences, but for the most part -- LLMs are not simple 'statistical predictors' as everyone brands them to be. You can see a thorough write-up I did of what GPT is / was here if you're interested: https://photonlines.substack.com/p/intuitive-and-visual-guid...

sdesol 3 days ago | parent | next [-]

I'm not sure if I would say human reasoning is 'probabilistic' unless you are taking a very far step back and saying based on how the person lived, they have ingrained biases (weights) that dictates how they reason. I don't know if LLMs have a built in scepticism like humans do, that plays a significant role in reasoning.

Regardless if you believe LLMs are probabilistic or not, I think what we are both saying is context is king and what it (LLM) says is dictated by the context (either through training) or introduced by the user.

photon_lines 3 days ago | parent | next [-]

'I don't know if LLMs have a built in scepticism like humans do' - humans don't have an 'in built skepticism' -- we learn in through experience and through being taught how to 'reason' within school (and it takes a very long time to do this). You believe that this is in-grained but you may have forgotten having to slog through most of how the world works and being tested when you went to school and when your parents taught you these things. On the context component: yes, context is vitally important (just as it is with humans) -- you can't produce a great solution unless you understand the 'why' behind it and how the current solution works so I 100% agree with that.

ijidak 3 days ago | parent | prev | next [-]

For me, the way humans finish each other's sentences and often think of quotes from the same movies at the same time in conversation (when there is no clear reason for that quote to be a part of the conversation), indicates that there is a probabilistic element to human thinking.

Is it entirely probabilistic? I don't think so. But, it does seem that a chunk of our speech generation and processing is similar to LLMs. (e.g. given the words I've heard so far, my brain is guessing words x y z should come next.)

I feel like the conscious, executive mind humans have exercises some active control over our underlying probabilistic element. And LLMs lack the conscious executive.

e.g. They have our probabilistic capabilities, without some additional governing layer that humans have.

coderenegade 3 days ago | parent [-]

I think the better way to look at it is that probabilistic models seem to be an accurate model for human thought. We don't really know how humans think, but we know that they probably aren't violating information theoretic principles, and we observe similar phenomena when we compare humans with LLMs.

Workaccount2 3 days ago | parent | prev [-]

Humans have a neuro-chemical system that performs operations with electrical signals.

That's the level to look at, unless you have a dualist view of the brain (we are channeling a super-natural forces).

lll-o-lll 3 days ago | parent [-]

Yep, just like like looking at a birds feather through a microscope explains the principles of flight…

Complexity theory doesn’t have a mathematics (yet), but that doesn’t mean we can’t see that it exists. Studying the brain at the lowest levels haven’t lead to any major insights in how cognition functions.

brookst 3 days ago | parent [-]

I personally believe that quantum effects play a role and we’ll learn more once we understand the brain at that level, but I recognize that is an intuition and may well be wrong.

didibus 3 days ago | parent | prev [-]

You seem possibly more knowledgeable then me on the matter.

My impression is that LLMs predict the next token based on the prior context. They do that by having learned a probability distribution from tokens -> next-token.

Then as I understand, the models are never reasoning about the problem, but always about what the next token should be given the context.

The chain of thought is just rewarding them so that the next token isn't predicting the token of the final answer directly, but instead predicting the token of the reasoning to the solution.

Since human language in the dataset contains text that describes many concepts and offers many solutions to problems. It turns out that predicting the text that describes the solution to a problem often ends up being the correct solution to the problem. That this was true was kind of a lucky accident and is where all the "intelligence" comes from.

photon_lines 3 days ago | parent | next [-]

So - in the pre-training step you are right -- they are simple 'statistical' predictors but there are more steps involved in their training which turn them from simple predictors to being able to capture patterns and reason -- I tried to come up with an intuitive overview of how they do this in the write-up and I'm not sure I can give you a simple explanation here, but I would recommend you play around with Deep-Seek and other more advanced 'reasoning' or 'chain-of-reason' models and ask them to perform tasks for you: they are not simply statistically combining information together. Many times they are able to reason through and come up with extremely advanced working solutions. To me this indicates that they are not 'accidently' stumbling upon solutions based on statistics -- they actually are able to 'understand' what you are asking them to do and to produce valid results.

didibus 3 days ago | parent [-]

If you observe the failure modes of current models, you see that they fail in ways that align with probabilistic token prediction.

I don't mean that the textual prediction is simple, it's very advanced and it learns all kinds of relationships, patterns and so on.

But it doesn't have a real model and thinking process relating to the the actual problem. It thinks about what text could describe a solution that is linguistically and language semantically probable.

Since human language embedds so many of the logics and ground truths that's good enough to result in a textual description that approximate or nails the actual underlying problem.

And this is why we see them being able to solve quite advanced problems.

I admit that people are wondering now, what's different about human thinking? Maybe we do the same, you invent a probable sounding answer and then check if it was correct, rinse and repeat until you find one that works.

But this in itself is a big conjecture. We don't really know how human thinking works. We've found a method that works well for computers and now we wonder if maybe we're just the same but scaled even higher or with slight modifications.

I've heard from ML experts though that they don't think so. Most seem to believe different architecture will be needed, world models, model ensembles with various specialized models with different architecture working together, etc. That LLMs fundamentaly are kind of limited by their nature as next token predictors.

coderenegade 3 days ago | parent | prev [-]

I think the intuitive leap (or at least, what I believe) is that meaning is encoded in the media. A given context and input encodes a particular meaning that the model is able to map to an output, and because the output is also in the same medium (tokens, text), it also has meaning. Even reasoning can fit in with this, because the model generates additional meaningful context that allows it to better map to an output.

How you find the function that does the mapping probably doesn't matter. We use probability theory and information theory, because they're the best tools for the job, but there's nothing to say you couldn't handcraft it from scratch if you were some transcendent creature.

didibus 2 days ago | parent [-]

Yes exactly.

The text of human natural language that it is trained on encodes the solutions to many problems as well as a lot of ground truths.

The way I think of it is. First you have a random text generator. This generative "model" in theory can find the solution to all problems that text can describe.

If you had a way to assert if it found the correct solution, you could run it and eventually it would generate the text that describes the working solution.

Obviously inefficient and not practical.

What if you made it so it skipped generating all text that aren't valid sensical English?

Well now it would find the correct solution in way less iterations, but still too slow.

What if it generated only text that made sense to follow the context of the question?

Now you might start to see it 100-shot, 10-shot, maybe even 1-shot some problems.

What if you tuned that to the max? Well you get our current crop of LLMs.

What else can you do to make it better?

Tune the dataset, remove text that describe wrong answers to prior context so it learns not to generate those. Add more quality answers to prior context, add more problems/solutions, etc.

Instead of generating the answer to a mathematical equation the above way, generate the Python code to run to get the answer.

Instead of generating the answer to questions about current real world events/facts (like the weather). Have it generate the web search query to find it.

If you're asking a more complex question, instead of generating the answer directly, have it generate smaller logical steps towards the answer.

Etc.

nomel 3 days ago | parent | prev [-]

No, it doesn’t, nor do we. It’s why abstractions and documentations exist.

If you know what a function achieves, and you trust it to do that, you don’t need to see/hold its exact implementation in your head.

sdesol 3 days ago | parent [-]

But documentation doesn't include styling or preferred pattern, which is why I think a lot people complain that the LLM will just produce garbage. Also documentation is not guaranteed to be correct or up to date. To be able to produce the best code based on what you are hoping for, I do think having the actual code is necessary unless styling/design patterns are not important, then yes documentation will be suffice, provided they are accurate and up to date.

anthonypasq 4 days ago | parent | prev | next [-]

the fact we cant keep the repo in our working memory is a flaw of our brains. i cant see how you could possibly make the argument that if you were somehow able to keep the entire codebase in your head that it would be a disadvantage.

SkyBelow 3 days ago | parent [-]

Information tradeoff. Even if you could keep the entire code base in memory, if something else has to be left out of memory, then you have to consider the value of an abstraction verses whatever other information is lost. Abstractions also apply to the business domain and works the same.

You also have time tradeoffs. Like time to access memory and time to process that memory to achieve some outcome.

There is also quality. If you can keep the entire code base in memory but with some chance of confusion, while abstractions will allow less chance of confusion, then the tradeoff of abstractions might be worth it still.

Even if we assume a memory that has no limits, can access and process all information at constant speed, and no quality loss, there is still communication limitations to worry about. Energy consumption is yet another.

4 days ago | parent | prev | next [-]
[deleted]
siwatanejo 4 days ago | parent | prev | next [-]

I do think AIs are already using abstractions, otherwise you would be submitting all the source code of your dependencies into the context.

TheOtherHobbes 3 days ago | parent [-]

I think they're recognising patterns, which is not the same thing.

Abstractions are stable, they're explicit in their domains, good abstractions cross multiple domains, and they typically come with a symbolic algebra of available operations.

Math is made of abstractions.

Patterns are a weaker form of cognition. They're implicit, heavily context-dependent, and there's no algebra. You have to poke at them crudely in the hope you can make them do something useful.

Using LLMs feels more like the latter than the former.

If LLMs were generating true abstractions they'd be finding meta-descriptions for code and language and making them accessible directly.

AGI - or ASI - may be be able to do that some day, but it's not doing that now.

F7F7F7 4 days ago | parent | prev | next [-]

There are a billion and one repos that claim to help do this. Let us know when you find one.

throwaway314155 3 days ago | parent | prev [-]

/compact in Claude Code is effectively this.

brulard 3 days ago | parent [-]

Compact is a reasonable default way to do that, but quite often it discards important details. It's better to have CC to store important details, decisions and reasons in a document where it can be reviewed and modified if needed.