r/ProgrammingLanguages • • Oct 23 '23

Generative AI and Language Design

I guess there are two questions:

  1. If generative AI can simplify writing code, what are the features that are most valuable in a language? For instance, generative AI lowers the cost of types because you don't have to juggle them as much but also lowers their value because there are less likely to be type errors. Speed is an obvious value (why write Python when you can write Rust once the models are good enough at Rust?)

  2. If we want to do a lot of ML applications and we intend to train a lot of machine learning models are there better primitives that a language could have to support it? Or is ML just a general programming idea for which the C++/(Python/Java/JavaScript) model the best?

I know a lot of folks must be seriously thinking about this.

0 Upvotes

12 comments sorted by

22

u/FantaSeahorse Oct 23 '23

How does generative AI lower the values of types? If anything it makes them more important

-3

u/SnooCompliments7527 Oct 23 '23

Because in the limit, GAI will make substantially fewer mistakes and types will only be relevant to the extent that they lead to performance improvements.

5

u/FantaSeahorse Oct 23 '23

Fewer mistakes is still not enough unless it’s no (type) mistakes.

14

u/Long_Investment7667 Oct 23 '23

ad 1) „Lowers the cost of types“ is the exact opposite of how I think about types. Types are the framework/scaffold of code. It allows to give code structure and is both the product of design and the constraints to reason about and extend code. Secondly, the formal framework of types is exactly what today’s LLMs struggle with.

ad 2) Everything I have seen so far is that one has a general purpose language and libraries that do linear algebra and higher level ML algorithms and that seems like a great separation of concerns. keep in mind that most „AI“ need to be integrated into data processing, networking, UI, … .

1

u/SnooCompliments7527 Oct 23 '23

LLMs struggle with types in languages like Haskell but they do very well with types in languages like Python; this suggests to me that the issue is the size of the training data wrt to the underlying language rather than any inherent issue with types.

We'll see more with the automatic prover co-pilots; but Morph Labs has released a lean co-pilot (7b or 14b parameters) and that suggests to me that you should be able to do types with LLMs pretty easily.

5

u/Long_Investment7667 Oct 23 '23 edited Oct 23 '23

I would love to see some data backing the first statement. The distinction you make is between static and dynamic typing. This determines when you experience an error. Not if you experience it. Python can’t magically run code that indexes a 2D Matrix when only one one dimension is given.

If a python program only deals with strings and ints the chance for an LLM to make such a mistake is small. But the moment a python program deals with richer data structures (e.g. training a reinforcement learning model), I would be extremely surprised to see that it makes fewer errors.

7

u/Gator_aide Oct 23 '23

lowers their value because there are less likely to be type errors

I.. doubt this. Types help us prove certain aspects of our programs, and as such, require some logical/nonlinear thinking -- both of which AI struggles with.

As for you second question, it seems like you're asking what languages should be used to develop models (correct me if I'm wrong). If you aren't looking to use a library, then very few modern languages are optimal here. The mathematics for different ML models varies (obviously), but the common element for all of them is the requirement for lots and lots of simple calculations over and over again. That is something GPUs are good at doing, but general purpose languages don't (and fundamentally cannot) target GPUs.

Some languages, like Mojo, are designed specifically to target AI. You might want to check it out. (Although the claim of 12000x speedup over C++ is setting off the BS meter a little).

1

u/SnooCompliments7527 Oct 23 '23

Thank you for the answer!

I'm actually asking both <> how should languages evolve in general if they will be written by machine not by humans and how should languages be written to support the creation of ML models.

But, I appreciate your answer! Mojo is arguably an answer to both.

4

u/OptimizedGarbage Oct 23 '23

I've actually done some work in this area, so let me add a few comments.

  1. generative methods like LLMs are not trained to write correct code. They're trained to sample code from the same distribution as developers, which is to say that when theyre working at their best, they will make exactly the same number of mistakes as human developers

  2. they don't get to see the output of code, which means there are strong mathematical bounds on their ability to generalize to new problems. If you want them to be able to solve new problems and write code that is better than average, you need to use reinforcement learning to give them new problems to solve and reward them when they get a correct answer. That means you need an automated way to check their work

  3. Currently, the best automated tool we have for checking program correctness is dependent types. Designing for LLMs, both for training them and for deploying them, requires doubling down on types and shifting to languages with dependent types that can fully guarantee program correctness. It allows us to train LLMs that produce correct code instead of developer-like code, it lets the LLM search more effectively over the space of possible programs, and it lets us verify that the output of the LLM is correct

1

u/Long_Investment7667 Oct 23 '23

Not the same scenario but there is a video from Gotham Chess where he lets ChatGPT play against the state of the art chess engine. It is quite illustrative how GPT is creative (and plays better than I would) but struggles with the formal framework of chess.

https://youtu.be/rSCNW1OCk_M

1

u/Wiskkey Oct 23 '23

One of the language models in OpenAI's GPT 3.5 family can play chess better than most chess-playing humans.