Large language models and chat-based AIs are kind of mind-blowing at the moment.
Many of us are playing with them for working on code or just as a fun alternative to search,
but others of us are building applications with AI at the core. And when doing that,
the slight unpredictable nature and probabilistic style of LLMs makes writing and testing Python
code very tricky. Enter Promptimize from Maxine Boschman and Preset. It's a framework for
non-deterministic testing of LLMs inside of our applications. Let's dive inside the AIs with Max.
This is Talk Python To Me, episode 417, recorded May 22nd, 2023.
Welcome to Talk Python To Me, a weekly podcast on Python. This is your host,
Michael Kennedy. Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using
at Talk Python, both on fosstodon.org. Be careful with impersonating accounts on other instances.
There are many. Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
We've started streaming most of our episodes live on YouTube. Subscribe to our YouTube channel over
at talkpython.fm.com to get notified about upcoming shows and be part of that episode.
This episode is brought to you by JetBrains, who encourage you to get work done with PyCharm.
Download your free trial of PyCharm Professional at talkpython.fm/done dash with dash PyCharm.
And it's brought to you by the Compiler Podcast from Red Hat. Listen to an episode of their podcast
to demystify the tech industry over at talkpython.fm/compiler.
Max, welcome to Talk Python to Me.
Well, it's good to be back on the show. And now I know it's live too, so no mistakes. I'm going to
try to not say anything outrageous.
People get the unfiltered versions. So absolutely. Absolutely. I love it when people come check out
the live show. Welcome back. It's been a little while since you were on the show, about since
September. We talked about superset. We also talked a little bit about airflow, some of the stuff that
you've been working on. And now we're kind of circling back through this data side of things,
but trying to bring AI into the whole story. So pretty cool project that I'm looking forward to
talking to you about.
Awesome. I'm excited to talk about it too. And these things are related in many ways. Like one
common foundation is Python. Like a lot of these projects are in Python. They're data related.
And here, promptimize and prompt engineering and integrating AI is related in a way that we're
building some AI features into superset right now and into presets. So it ties things together in some way.
Yeah, I can certainly see a lot of synergy here. Before we dive into it, it hasn't been that long,
since you were on the show. But give us a quick update, just a bit about your background for people who don't know you.
Yeah, so my career is a career of like maybe 20 or so years in data building, doing data engineering,
doing trying to make useful data useful for organizations. Over the past decade or so, I've been very involved in open source.
So I started Apache Airflow 2014. So for those not familiar with Airflow, though, it's pretty well known now.
It's used at, I heard like, I think it's like 10s of 1000, I think above 100,000 companies are using Apache Airflow, which is kind of insane to think about.
It's like you started a little project. So for me, I started this project at Airbnb, and it really took off.
And I think it's just like great project community fit, like people really needed that. It was the right abstraction for people at the time.
And still today, and it just really took off. So I was working on orchestration. And then I was like, I just love things that are visual and interactive.
So there was no great open source BI tool out there business intelligence. So the sole data, data dashboarding, exploration, SQL IDE.
So it's like a playground for people trying to understand and visualize and explore data. So I started working on Apache Super Set in 2000.
It was like 15 or 16 at Airbnb, too. And we also brought that to the Apache Software Foundation. So again, like a very, very popular open source project that's used in like 10s, 10s of 1000, 100,000 organizations.
And a great today, like it has become a super great open source alternative to Tableau Looker, like all those business intelligence tools very viable for organizations.
And then quick, quick plugs at preset IO company, I started some also an entrepreneur, started a company a little bit more than four years ago around Apache Super Set.
And then the idea is to bring, bring super set to the masses. So it's really like hosted, manage state of the art Apache Super Set for everyone with some bells and whistles.
So the best super set you can run, there's a there's a free version too. So you can go and play and try it, you know, today gets started in five minutes.
So it's a, it's a little bit of a commercial pointer, but also very relevant to what I've been doing, you know, personally over the past like three or four years.
Sure, it's some of the inspiration for some of the things we're going to talk about as well and trying to bring some of the AI craziness back to products, right?
So I think that's a, you know, from an engineering perspective, not just a, hey, look, I asked it, what basketball team was gonna, you know, win this year, and it gave me this answer, right?
It's like, and I, and caveats, I don't know anything that happened since 2021. So AI, or, and AI specifically, Bart is a little bit better at that. But it's like, you know, the last thing I read off of the internet was in fall 2021.
It makes some things a little bit challenging. But yeah, so we're looking at we're building, you know, AI features into preset, you know, as a commercial open source company, we need, we need to build some differentiators to from supersets, we contribute a huge amount, like maybe 50 80% of the work we do at preset is contributed back to superset, but we're looking to build differentiators. And we feel like AI is a, is a great, kind of commercial differentiator to on top, on top of superset that makes people even more interested to come and run, run, run, run, run,
on preset too. So yeah, excellent. And jump people you say they were popular, popular projects, like airflow has 30,000 stars, Apache superset has 50,000 stars, which puts it on par with Django and flask, for people sort of mentors models out there, which is, I would say it's pretty well known. So awesome.
Yeah, Star is a vanity metric in some ways. It's not necessarily usefulness or value delivered, but it's a proxy for popularity and hype. It gives a good sense. I think at 50,000 stars, it's probably in the top 100 of GitHub projects.
If you remove the top 100, there's a lot of documentations and guides and things that are not really open source projects. It's probably like top 100 open source project-ish in both cases.
Right.
It's pretty cool. It's like you start a project and you don't know whether it's going to take off and how. It's just nice to see that.
Yeah, absolutely. On one hand, it's nice, but it doesn't necessarily make it better.
But it does mean there's a lot of people using it. There's a lot of polish. There's a lot of PRs and stuff that have been submitted to make it work. A lot of things that can plug into it.
So there's certainly a value for having a project popular versus unpopular.
Oh my God. Yes. And I would say one thing is, you know, all the dark, call it like secondary assets outside of the core projects documentation. And there will be a lot of like use cases and testimonials and reviews and people bending the framework in various ways and forks and plugins.
So another thing too, that people, I think don't really understand the value of in software and open sources, or I'm sure people understand the value, but it's not talked about as just a whole battle tested thing.
So when something is run at thousands of organizations in production for a long time, there's a lot of things that happen in a software that are very, very valuable for the incremental organization adopting it.
Well, let's talk large language models for a second. So AI means different things to different people, right? It, they, they kind of get carved off as they find some kind of productive productize use, right?
AI is this general term and like, Oh, machine learning is now a thing that we've done, or computer vision is a thing we've done.
And the large language models are starting to find their own, their own special space. So maybe we could talk a bit about a couple of examples just so people get a sense.
I mean, to me, ChatGPT seems like the most well-known. What do you think?
Yeah. I mean, well, I'll say, if you think about like, what is a large language model and what are some of the leaps there?
And I'm not an expert, so I'm going to try to not put my foot in my mouth, but some things that I think are interesting.
So a large language model is a big neural network that is trained on a big corpus of text.
I think one of the big leaps we've seen is unsupervised learning. So like really often, like in machine learning in the past or pre-LLMs, we would have very specific like training set and outcomes we were looking for.
And then the training data would have to be really structured here.
Here, what we're doing with large language models is feeding a lot of huge corpus of text and what the large language model is trying to do or resolve is to chain words.
So he's trying to predict the next word, which seems like you would be able to put words together that kind of make sense.
But like you wouldn't think that consciousness, not just like consciousness, but intelligence would come out of that.
But somehow it does. Right.
Like if you chain that it's like if you say, you know, up to the empty that he sits on a it's really clear.
It's going to be wall, you know, the next word.
But if you push this idea much further with a very large corpus of like human knowledge, somehow there's some really amazing stuff that does happen on these large language models.
And I think that realization around happened at around, you know, Chad at GPT three, three, five getting pretty good.
And then at four, like, oh, my God, this stuff can really kind of seems like it can think or be smart to be very helpful.
Yeah. The thing that I think impresses me the most about these is they seem and people can tell me it's statistics and, you know, I'll believe them.
But it seems like they have an understanding of the context of what they're talking about more than just predicting like Humpty Dumpty sat on the what it said on the wall.
Right. Obviously, that's what was likely to come next when you see those that set of words.
But there's an example that I like to play with, which I copy.
You know, I'll give it a little thing. I'll say, hey, here's a program, Python program.
I'm going to ask you questions about it. Let's call it arrow.
And it's like this is a highly nested program that function that tests whether something's a platypus.
I saw this example somewhere and I thought, OK, this is this is pretty cool.
But it has this if it's a mammal, then if it has fur, then if it has a beak, then if it has a tail and you can just do stuff that's really interesting, like I'll ask it to a bird or something like that.
Yeah, yeah, yeah, yeah, rewrite it, write it using guarding clauses to be not nested.
Right.
Oh, yeah.
Right. And it will say, sure, here we go.
And instead of being if this, then nest, if this, then if this, it'll do if not, if not return false.
Right. Which is which is really cool. And that's kind of a pretty interesting one.
But like this is this is the one. This is the example that I think is crazy is rewrite arrow to test for crocodiles.
They're using that.
It's like what people would call a one shot, a few shot example of like a here's a here's an example, the kind of stuff I might want.
There's some different ways to do that.
But it's a pattern in prompt engineering where you'll say you have a zero shot, one shot, few shot examples we get into.
But it does feel like it understands the code. Right. Like what you're trying to do.
Right. Just for people listening, it said, OK, here's a function is crocodile.
If not, self thought is reptile. If not, self thought has scales. These are false examples. Right.
And if it has four legs and a long snout that can swim. Right. Like it it rewrote the little tests and stuff. Right.
In a way that seems really unlikely that just predicting likelihood because it's never seen anything like this, really, which is really it's pretty mind blowing, I think.
Or it or it had like it read the entire internet and all of GitHub and that kind of stuff.
So it has seen. Exactly.
Things that think that's mind boggling is just like can like when you think about what it did there is it read the the entire conversation so far, your your input prompt.
And it has like a system prompt ahead of time that says, you know, your ChatGPT try to be helpful to people.
And here's a bunch of things that you should or should not say and non bias.
You try to be concise and good and virtuous.
And people have found all sorts of jail breaks out of that.
But like all it does from that point on as I try to predict the new the next word, which is kind of insane that it gets to, you know, the amount of structure that that we see.
Right. Right. That's a lot of structure there. Right.
So pretty impressive. And ChatGPT is starting to grow.
You know, you've got version four and you can start using some of the plugins.
It's going to keep going crazy there.
Other examples are simply just released lemur, which is a large language model, but really focused on transcribing speech, which I think is kind of cool.
Microsoft reduce Microsoft security release Microsoft security copilot, which is a large language model to talk about things like engine X misconfiguration and stuff like that.
There's just just a lot of a lot of stuff out there that's coming along here. Right.
A lot of type of thing on the on the open source front to there's there's all ethical thing.
Like, should everyone and anyone have access to open source models doing that while we don't really understand and we probably shouldn't get to the ethics part of the debate here, because that's a whole series of episodes.
We probably want to get into.
But what's interesting is, you know, Databricks came up with a model for what's called Facebook call.
It came up with one called Lama and they open source and or the weight.
So you have the model topology with the pre trained weights.
In some cases, there's open source corpus of training that are also coming out and are also open source.
So that means like and these these open source models are somewhat competitive or increasingly competitive with GPT or.
Yeah, which is kind of crazy.
And some of them don't are where GPT for has limitations.
They break through these limitations.
So one thing that's really important as a current limitation of the GPT models and LLMs is the prompt window, the token prompt window.
So basically, when you ask a question, you know, it's been it's been trained and has machine learn with data up to I think in the case of GPT three, five or four.
It's the corpus of training goes all the way to fall 2021.
So if you ask like, who is the current president of the United States, it just doesn't know or I will tell you as of 2021 it is this person.
But so if you're trying to do tasks like what I've been working on, would probably get into later in the conversation is trying to generate SQL.
SQL, it doesn't know your table.
So you have to say, hey, here's all the tables in my database.
Now, can you generate SQL that does X on top of it?
And that context window is increased is limited and increasing.
And some of these open source models have different types of limitations.
This portion of talk Python to me is brought to you by JetBrains, who encourage you to get work done with PyCharm.
PyCharm Professional is the complete IDE that supports all major Python workflows, including full stack development.
That's front end JavaScript, Python back end and data support, as well as data science workflows with Jupyter.
PyCharm just works out of the box.
Some editors provide their functionality through piecemeal add ins that you put together from a variety of sources.
PyCharm is ready to go from minute one.
And PyCharm thrives on complexity.
The biggest selling point for me personally is that PyCharm understands the code structure of my entire project, even across languages such as Python and SQL and HTML.
If you see your editor completing statements just because the word appears elsewhere in the file, but it's not actually relevant to that code block, that should make you really nervous.
I've been a happy paying customer of PyCharm for years.
Hardly a workday passes that I'm not deep inside PyCharm working on projects here at Talk Python.
What tool is more important to your productivity than your code editor?
You deserve one that works the best.
So download your free trial of PyCharm Professional today at talkpython.fm/donewithpycharm and get work done.
That link is in your podcast player show notes.
Thank you to PyCharm from JetBrains for sponsoring the show and keeping Talk Python going strong.
Right. It's interesting to ask questions, right?
But it's more interesting from a software developer's perspective of, can I teach it a little bit more about what my app needs to know or what my app structure is, right?
In your case, I want to use superset to ask the database questions.
But if I'm going to bring in AI, it needs to understand the database structure so that when I say help me do a query to do this thing, it needs to know what the heck to do, right?
The table I need to know.
So there's the stuff it knows and the stuff it can't know.
And some of it goes, is related to the fact that whether this information is public on the internet, whether it has happened to be trained against it.
And then if it's in private, there's just no hope that it would know about, you know, your own internal documents or your database structure.
So in our case, it speaks SQL very, very well.
So as we get into this example, like how to get GPT to generate good SQL in the context of a tool like superset or SQL lab, which is our SQL IDE.
So it knows how to speak SQL super well.
It knows the different dialects of SQL very, very well.
It knows its functions, its dates functions, which a lot of the SQL engineers on the call, like, yeah, I can never remember like what Postgres data function is.
But at GPT or GPT models, just it knows SQL, it knows the dialects, it knows the mechanical SQL, it understands data modeling, foreign keys, drawings, primary, all this stuff it understands.
It knows nothing about your specific database, the, you know, the schema names and the table names, the column names that I might be able to use.
So that's where we need to start providing some context.
And this context window is limited.
So it's like, oh, how do you use that context well or as well as possible?
And that's the field and some of the ideas behind it is prompt crafting and prompt engineering, which we can get into once we get there.
Maybe we're there already.
Yeah, yeah.
Well, yeah, I think where I see this stuff going is from this general purpose knowledge starting to bring in more private or personal or internal type of information.
Right.
Like our data about our customers is like structured like this in a table.
And here's what we know about them.
Now let us ask questions about our company and our thing.
Right.
And it's like starting to make inroads in that direction, I think.
Yeah.
You know, one thing to know about is there's different approaches to teach or provide that context.
So one would be to build your own model from scratch.
Right.
And that's pretty prohibitive.
So you'd have to, you know, find the right corpus.
And instead of starting with a model that knows SQL and needs to know your table and context, you have to start from from zero and very prohibitive.
Another one is you start from a base model at some point of some kind.
There's a topology.
So there's, you know, different layers and number of neurons and it knows some things.
And then you load up some weights that are open source.
And then you say, I'm going to, I'm going to tune this model to teach it my database schemas and basically my own corpus of data.
So it could be your data dictionaries could be your internal documents.
It could be your GitHub code, your dbt projects.
If you have one of your airflow tags, be like, I'm going to dump all this stuff in the model and that will be get baked into their own network itself.
That's doable, pretty prohibitive in this era.
If you have the challenge that we have a preset, which is we have multiple customers with different schemas, we can't have spillover.
So you have to train a model for each one of our customers and serve a model for each one of our customers.
So still pretty prohibitive.
And a lot of people fall back on this third or fourth method that I would call prompt engineering, which is going to use the base model, the open API API or just an API on LLM.
And then I will, if no SQL already, I'll just say, hey, here's a bunch of tables that you might want to use.
Can you generate SQL on top of it?
So then that's just a big request with a lot of context.
Then we have to start thinking about maximizing the use of that context window to pass the information that's most relevant within the limits allowed by the specific model.
Right. And that starts to get into reproducibility, accuracy, and just those limitations, which is kind of an engineering type of thing. Right.
Yeah. And then, you know, maybe a topic too. And, you know, this conversation is based on a recent blog post and the flow.
Just going back to the flow of that blog post, we started by establishing the premise that everyone is trying to bring AI into their product today.
Right. Thousands of product builders are currently exploring ways to harness the power of AI and the products and experiences they create.
That's the premise for us with text to SQL and SQL lab as part of preset.
But I don't know if you think of any product, any startup, any SAS product you use to work at HubSpot today, you're trying to figure out how to leverage AI to build, you know, sales chat bots or as the chat chat bot.
So everyone everywhere is trying to figure that out. And the challenge is the challenges, I guess, very probabilistic in a different interface to anything we know.
Like, you know, engineers would be like, oh, let's look at an API and leverage it.
And APIs are very, very deterministic. And in general, AI is kind of wild beast to tame.
You know, you ask first the interface is language, not code.
And then what comes back is like semi probabilistic in nature.
And it could change underneath you. It's a little bit like web scraping in that regard that like it does the same.
It does the same. And then, you know, something out there change, not your code.
And then a potentially different behavior comes back. Right.
Because they may have trained another couple of years, refine the model, switch the model, change the default temperature, all these things.
Yeah, there's a lot that can happen there. One thing I noticed, like starting to work with what I would call prompt crafting, which is, you know, you work with ChatGPT and you, you craft different prompt with putting emphasis in a place or another or changing the order of things or just changing a word.
Right. Just say like important exclamation point, capitalize the words, you know, the reserve words in SQL.
And then just the fact that you put important exclamation point, you know, will make it do it or not do it, changing from a model to another.
So one thing that's great is the model, at least at OpenAI are, they are immutable as far as I know.
But like if you use GPT-5, 3.5 Turbo, for instance, as just one trained model, I believe that that is immutable.
The chat bot on top of it might get fine tuned and change over time.
But the model is supposed to be static.
You mentioned temperature.
Be kind of interesting to just mention for those who are not familiar with that.
So when you interact with AI, one of the core parameters is temperature.
And it's it's I think it's a value from zero to one or I'm not sure if you know how exactly you pass it.
But it basically defines how creative you want.
You want to let the AI be like how to put it to zero.
You're going to have something more deterministic.
So asking the same question should lead to a similar or the same answer.
Though not in my experience, it feels like it should, but it doesn't.
But then if you put a higher, it will get more creative to talk more about like how that actually seemed to work behind the scenes.
Yeah. Well, the that variability seems to show up more in the image based ones.
So, for example, this article, this blog post that you wrote, you have this image here and you said, oh, and I made this image from mid journey.
I've also I was I got some examples of a couple that I did.
Where did I stick them somewhere?
Here we go.
Where I asked just for like YouTube thumbnails.
I asked mid journey for like a radio astronomy example that I can use, because here's one that's not encumbered by, you know, some sort of licensing, but still looks kind of cool and is representative.
Right.
And there it's like massive difference.
I don't I'm not sure how much difference I've seen.
I know it will make some, but I haven't seen as dramatic of a difference on chat.
Yeah.
I'm not sure exactly how they introduce the variability on the generative images.
AI.
Right.
I know it's like this multi dimensional space with a lot of words and a lot of images in there.
And then it's probably like where the location point of that the rent rent, like they randomized that point in that multi dimensional space.
So for ChatGPT is pretty easy to reason about, and I might be wrong on this again, I'm not an expert, but you know how the way it works is it writes, it takes the prompt and then it comes up with the next word sequentially.
So for each word for the next word, so Humpty Dumpty sat on a, it might be wall at 99%, but like that might be 1% of, you know, fence or something like that.
And if you, you up the temperature, there's, it's more likely to pick the non first word and that probably less, they probably do in a weighted way.
Like it's possible.
I take a second or third word randomly.
And then of course it's going to get a tree or decision tree.
Once it picks the words, the next word is also changes.
So as you up that it goes down path that sends it into more creative or different.
Right.
Yeah.
A little butterfly effect.
It makes a different choice here.
And then it sends it, you know, sends it down through the graph.
Interesting.
So one thing that you really pointed out here, and I think is, is maybe worth touching on a bit is this idea of prompt engineering.
There's even places like learn prompting.org that like try to teach you how to talk to these things.
And, and you make a strong distinction between prompt crafting or just talking to the AI versus like really trying to put an engineering focus on it.
Do you want to?
Yeah.
Because like, yeah, I think it's a super important differentiation, but one that I'm proposing.
Right.
So I don't think that people have settled as to what is one or what is the other.
I think I saw a Reddit post recently that was like prompt engineering is just a load of crap.
Like, you know, anyone can go because they thought their, their understanding of prompt engineering was like, oh, you know, you fine tune or you craft your prompt.
Then you say like, you are an expert AI working on, you know, creating molecules.
Now, can you do this?
And then, you know, by doing that, you might get a better outcome or a one really interesting thing that people have been doing in prompt crafting.
That seemed to have like huge impact on there's been paper written on this specific just hint or craft tweak is let's proceed step by step.
So basically, whatever the question is that you are asking is specifically around like more mathematicals or like things that require more systematic step by step thinking the whole like just like, let's think let's expose this or let's go about it.
Step by step makes it much better.
So here you might be able to, well, so you know, if you had, if you had an example where ChatGPT three failed or ChatGPT four failed, you could just say, Colin, let's go step by step.
And it might succeed that, that time around, which is kind of, maybe you can get it to help you understand instead of just get the answer.
Right. Like factor this polynomial into its primary solutions or roots or whatever.
And you're like, okay, show me that. Don't just show me the answer.
Show me step by step.
So I could understand and try to learn from what you've done. Right.
Yeah. I mean, if you think about how the way that it's trying to come up with a new word, if all it does is a language based answer to a mathematical question, like how many days are there between this date and that date?
There's no, that specific example might not exist or it's kind of complicated for it to go about it.
But if you say, let's think step by steps. Okay. There's this many months. This month's duration is this long. There's this many days since the beginning of that month and might get it right. That, you know, that time around.
Right. Or if it fails, you could pick up partway along where it has some more.
Yeah. You know, and then you can trace, I mean, just you too, like, I think, you know, one thing is like, you should be extremely careful as like taking for granted that it's right all the time, you know?
So that means like, it also helps you review its process and where it might be wrong, but back to crafting versus engineering.
So crafting would be the process that I think is more attached to a use ChatGPT every day, the same way that, you know, we've been trained at Googling, you know, over the past like two decades.
You know, use a pollute, use quotes, use plus and minus, and you know which keywords to use intuitively, right? You know where it's going to get confused or not.
So I think prompt crafting is a different version of that. That's just more worthy.
And if you're, you know, you're working with the AI to try to assist you, write your blog post or to try to assist you in any task really, just to be smart about how you bring the context, how you tell it to proceed, goes a very, very long way.
So that's what I call prompt crafting, call it like one of cases.
What people do when they're interacting with, with the large language model.
I think so. Right. Like it's not evident for a lot of people. Well, they are exploring the edge of where it fails and they love to see it fail.
And, and then they don't think about like, Oh, what could I have told it to get the answer?
I was actually looking for like, ah, I got you wrong. You know, it's as if I had that actor in a conversation. I like, ah, you're wrong. And I told you so, you know, so I think there's a lot of that online, but I think for all these examples that I've seen,
I'm really tempted to take the prompt that they had and then give, give it an instruction or two or more, and then figure out how to get it to come up with the right thing.
So prompt crafting super important skill. you know, you could probably get a boost of, for most knowledge information workers, you'll get a boost of 50% to 10 X for a lot of the tasks you do every day.
If you use AI well, so it's great personal skill to have, go and develop that skill. If you don't.
This portion of talk Python is sponsored by the compiler podcast from Red Hat.
Just like you, I'm a big fan of podcasts and I'm happy to share a new one from a highly respected open source company compiler and original podcast from Red Hat.
Do you want to stay on top of tech without dedicating tons of time to it? Compiler presents perspectives, topics, and insights from the tech industry free from jargon and judgment.
They want to discover where technology is headed beyond the headlines and create a place for new IT professionals to learn, grow, and thrive.
Compiler helps people break through the barriers and challenges turning code into community at all levels of the enterprise.
One recent and interesting episode is there. The great stack debate.
I love, love, love talking to people about how they architect their code, the trade offs and conventions they chose, and the costs, challenges, and smiles that result.
This great stack debate episode is like that. Check it out and see if software is more like an onion or more like lasagna or maybe even more complicated than that.
It's the first episode in compiler series on software stacks. Learn more about compiler at talkpython.fm/compiler.
The link is in your podcast player show notes. And yes, you could just go search for compiler and subscribe to it. But follow that link and click on your players icon to add it.
That way they know you came from us. Our thanks to the compiler podcast for keeping this podcast going strong.
Prop engineering. In my case, I'm like, you're building something, you're using an AI as an API behind the scene.
You want to pass it a bunch of relevant contexts, really specify what you want to get out of it.
Maybe you even want to get a structured output, right? You might want to get a JSON blob out of it.
You say, return a JSON blob with the following format so it's more structured.
So then to give all these instructions, there's this idea of providing few shots too.
You might be storing context in a vector database. I don't know if we're getting to that today, but there are ways to kind of structure and organize your potential embeddings or the things you want to pass as context.
So there's a lot here. I think somewhere too, I talk about prompt engineering. If we scroll in the blog post, like what is prompt engineering?
And prompt engineering will list the kind of things. It might be higher in the post. Sorry, we're scrolling for people.
I want to introduce what is prompt engineering.
Yeah.
Well, there's not above this section.
You can scroll at the beginning of what is prompt engineering.
Yeah, here you go.
Oh yeah, right here. The definition of this is Chad's GPT's version of it. So when you do prompt engineering, you can add context, which that means that you're going to have to retrieve context maybe from a database, from a user session, from your Redux store if you're in the front end, right?
You're going to go and fetch the context that's relevant in the context of the application.
It leads while building products.
Specify an answer format.
You could just say, yes, I just want a yes or no, a Boolean.
I want a JSON blob with not only the answer, but your confidence on that answer or something like that.
Limiting scope, asking for pros and cons, incorporating verification or sourcing.
So that's more, you know, if you iterate on a prompt, you're going to be rigorous about is this prompt better than the previous prompt I had like this.
If I pass five rows of sample data while doing text to SQL, does it do better than if I or does it do more poorly than if I pass 10 rows of sample data or provide a certain amount of column level statistics.
So prompt engineering is not just prompt crafting.
It is like bringing maybe the scientific method to it, bring some engineering of like fetching the right context and organizing it well and then measuring the outcome.
Right. Exactly.
Something that comes out, you can measure and say, this is, you know, 10% better by my metric than it was before with this additional data.
Right. That's, that's a big difference.
Right. And then there's so many things moving, right?
Like, and everything is changing so fast in the space that you're like, oh, well, ChatGPT five or GPT five is out or GPT four turbo is half the price and then just came out.
Now I'm just going to move to that.
They're like, wait, is that that performing better?
Or, you know, what are, what are the trade off?
Or even I'm going to add, I'm going to move this section, you know, asking for a certain Jason format above this other section.
I'm going to write important exclamation point do X. Does that improve my results?
Does that messes mess it up?
And which one of my test case perhaps that succeeded before fails now, which one failed before succeeds now.
So you can be like, is that a better, a worse iteration towards my goal?
Right. Right.
Kind of training, bringing this unit testing TDD mindset.
Yes.
Yeah.
We're getting deeper into the blog post, right?
So the blog post is talking about bringing this TDD, the test driven development mindset to prompt engineering.
Right.
And there's a lot of things that are in common.
You can, you can take and apply and kind of transfer just over.
There are some things to that breakdown that are fundamentally different between testing a prompt or working with AI and working with, you know, just a bit more deterministic code testing type framework.
We can get into that.
Yeah. Yeah, for sure.
So you called out a couple of reasons of why TDD is important for prompt engineering.
Maybe we could run through those.
Yeah.
So, you know, the, the first thing is, the AI model is not a deterministic things, right?
You, you use a modern API or a graph, you are a rest API.
The, the format of what you ask is extremely clear.
And then the format of what you get back is usually defined, defined by a schema.
It's like very deterministic, pretty guaranteed that you're, you do the same request.
We'll get the same output ish, or at least format.
Um, what AI that's not the case, right?
So it's much more unpredictable and probabilistic by nature.
Uh, second one is handling complexity.
So, AI systems are complex, black boxy, kind of unpredictable too.
So, and embrace that and assume that you might get something really creative coming out of there for better or for worse.
Um, and then reducing risk, like you're shipping product, you know, if you're shipping product, writing product,
um, you don't want to silly, like any sort of like, bias or weird thing like the AI could go a little crazy and, and yeah,
There are examples of AIs going crazy before like Tay.
Do you remember Microsoft Tay?
I don't know that one, but I know of other examples.
Yeah.
I mean, it came out and it was like this, this sort of just, you know, I'm here to learn from you internet.
And people just turned it into a racist and made it do all sorts of horrible things.
And they had to shut it down a couple of days later because it's just, it's like, whoa, it met the internet and the internet is mean.
So, that's not great.
Yeah.
Train it on a 4chan or let it go crawl 4chan and Reddit.
And that's not always going to be nice.
So bad.
Right.
I mean, you, you, you don't entirely control what's going to come out of those things.
And so.
Oh yeah.
Or I would say a little more predictable.
Right.
I would say, yeah, like, you don't entirely control.
Like I think, yeah, like basically, you know, control might be a complete illusion.
Like even the people working at open AI don't fully understand what's happening in there.
Yeah.
Like, well, it read a bunch of stuff and it's predicting the next word and, it gets most things right.
By the way, like they do a lot around this idea of like, not necessarily TDD, but there's a whole eval framework.
So you can submit your evaluation functions to open AI.
And as they, they train the next version of things, they include that in what their evaluation system for the new thing.
So say if I wanted to go and contribute back a bunch of like text to SQL type use cases, as they call evals, then they would take that into consideration when they, they train their next models.
All right.
So going down the list, reducing risk, right?
So you're integrating some, that beast that's not fully tamed into your product.
So you probably want to make sure it's tamed enough to live inside your product.
Uh, continuous improvements that I, that should have been maybe the first one in the list is you're iterating on your prompts.
You're trying to figure out a past context.
Um, you're, you're, you're trying different model versions.
Maybe you're, you're trying some open source models or the latest GPT cheaper greater thing.
Um, so you want to make sure that as you iterate, you're getting to the actual outcomes that you want systematically.
And then performance measurement too, like how long does it take?
How much does it cost?
Um, you, you kind of need, to have a handle on that.
The new model might be 3% better on your corpus of tests, but it might be six times the price.
Like, do you, do you want, are you okay?
Right, right.
Or just from a user perspective.
Yeah.
Time to interaction.
You know, that's one thing with AI we're realizing now is a lot of the prompts on, on four will be like, you know, two to, one to seven seconds, which in the Google era, you know, there's been some really great papers out of Google early on that, prove that, you know, it's like a hundred milliseconds as an impact on user behaviors.
Right.
Yeah.
People give up on checkout flows or whatever, not going to the next part of your site on a measurably on a hundred millisecond blocks.
Right.
When you're talking, well, here's 7,000, you know, you're 70 of those.
That's going to have an effect potentially.
Oh, it has, has been proven and very intricate and usage pattern session duration session outcomes.
Right.
And you know, a second is a mountain.
If today, like we were at this AB test Google between like whatever millisecond it's at now, like just one second or half a second that the results coming out of that AB test would, which show very, very different behaviors.
Wow.
I think there's some, no code mailnet, there's some really great papers, you know, written on TTI and just time to interaction and the way it influenced user behavior.
So we're still, you know, in the AI world has to, if you're going to wait two to seven seconds for your prompt to come back, it's got to add some real, some real important value to what's happening.
Yeah, it does.
I think it's interesting that it's presented as a chat.
Right.
I think that gives people a little bit of a pause, like, oh, it's talking to me.
So let's let, let's let it think for a second rather than it's a website that's supposed to give me an answer.
Yeah.
Compared to then, I guess your basis for comparison is a human, not a, you know, a website or not comparing against Google.
So that's great.
Yeah.
I ask it a really hard question.
Give it some time, right?
Like that's not normally how we think about these things.
Okay.
So what's the workflow from this engineering, building a product testing, like an AI inside of your product.
You want to walk us through your workflow here?
Yeah.
And you know, if you, if you, I think I looked at TDD, you know, and, and originally what is the normal like TDD type workflow?
And I just adapted this little diagram to, to, to prompt engineering work.
Cause the whole idea of the blog post is to, to bring prompt engine, like TDD mindset to prompt engineering.
So this is where, where I went, but yeah, the, the workflow is like, okay, define the use case and desired AI behavior.
What are you trying to solve with AI?
In my case, the example that I'll, I'll use and try to reuse throughout this presentation is, as throughout this, you know, conversation is, you know, text to SQL.
So like, we're trying to, what a user prompt, what a database schema gets, get the AI to generate goods, good, useful SQL, find the right tables and columns to use that kind of stuff, create test cases.
So it's like, okay, if I have this database and I have this prompt, give me my top five salary per department on this HHR dataset, there's a fairly deterministic output to that.
Or you could say the SQL is not necessarily deterministic.
There's different ways to write that SQL, but there's a deterministic data frame or results set that might come up.
There is a right answer of the top five salaries.
That's right.
You can see like, you're not getting, ultimately get that.
And it's great if it's, if it is, deterministic, cause you can test it.
If you, you know, if you, if you're trying to use AI to say, write an essay about, Napoleon Bonaparte's, second conquest, you know, in less than 500 words, it's a, it's not as deterministic as it's hard to test whether the AI is doing good or not.
So you might need human evaluators before I would say in most AI product or people are trying to bring AI into their product.
Um, in many cases, more deterministic.
So another example of like more deterministic would say like, Oh, getting, if you say getting AI to write Python functions, it's like, Oh, write a function that, you know, returns.
If a, if, if a number is prime, yes or no, like the, you can get the function and test it in a deterministic kind of way.
So anyways, just pointing out it's better.
You're only going to be able to have a TDD mindset if you have like somewhat deterministic, you know, outcome to the, you want to use the AI for then create the prompt generator.
So that would be your first version or in the text to SQL example, it's given, you know, the, the, the 20 tables in this database and this columns and table names and data types and sample data generate SQL that answers the following user prompt.
And then the user prompt would say something like department by type, type five salary for department.
Uh, and then you, then we're getting for people that are not on the visual, stream, not YouTube, but on just audio, we're getting into the loop here where it's like, run the test, evaluate the results, refine the tests, refine the prompts and then start over.
Right.
And probably, compile the results, keep track of the results so that you can compare, not just like, Oh, are you 3% better on your test cases?
Um, but also did you, which tests that used to fail succeed now, which, which tests that used to fail, succeed, fail now.
And then, once you're happy with the level of success you have, you know, you can integrate the prompt into the product or maybe upgrade.
Ship it.
Yeah.
Ship it.
So I think it's probably a good time to jump over to your framework for this because py tests and other testing frameworks in Python are great.
But they're pretty low level compared to these types of questions you're trying to answer.
Right.
Like how has this improved over time for, you know, I was doing 83% right.
Right.
Py tests, a search, a true or a false.
It doesn't assert that 83% is.
Yeah.
Like if, if any of your, your py tests fail, you're, you're probably gonna not see, I not allow, see, I'm not even merge the PR.
Right.
So one thing that's different between test driven development and unit testing and prompt engineering is that the out, the out, the outcome is probabilistic.
It's not true or false to it might just be like zero or one, right.
Where I are a spectrum, you know, it fails.
Um, so for a specific test, you're like, off, it gets this column, but not this other column, you succeed at, you know, 50%.
So it's non binary.
It's also, you don't need perfection to ship.
You just need better than the previous version or good enough to start with.
So the mindset is, is, so there's a bunch of differences.
And for, for those interested, we won't, get into the, in the blog post.
I think I list out the things that are, different between the two.
I think it's a little bit above this, but, you know, the first thing I want to say is like the level of ambition of this project versus an air flow is super set is like very low.
Right. So it's maybe, more similar to, a test, a unit test library and no discredit to the great, awesome, like a unit test libraries out there.
But you would think those are fairly simple and straightforward.
I was just the information architecture of a pie test is probably simpler than the information architecture of a Django for instance.
Right. It's just like a different thing.
And here, the level of ambition is much low and much, you know, for this is, is fairly simple.
So prompt demise is something that I created, which is a toolkit to help people write, to, to evaluate and score and understand while they iterate on their pro while doing prompt engineering.
But so in this case, I think, I talk about the use case at preset, which is a, we have a big corpus, that luckily was contributed by, I forgot which university, but a bunch of PhD people did a text to SQL, contest.
I think it was Yale.
Yale. Yeah.
Yeah.
So yeah.
So great people at Yale were like, Hey, we're going to generate, you know, 3000 prompts on 200 databases with the, the SQL that should be the outcome of that.
It's a big test set so that different researchers working on text to SQL can compare their results.
Um, so for us, we're able to take that test set and some of our own test sets and run it at scale against, you know, open AI or against Lama or against, different models.
And by, by doing that, we're able to evaluate like, you know, this particular combo of like this prompt engine methodology with this model generates, you know, 73% accuracy.
And we have these reports we can compare, you know, fairly easily, which prompts that, as I said before, we're failing before succeeding now and vice versa.
So you know, I mean, am I actually making progress here or going backwards?
And if you try to do that on your own, like if you're crafting your prompt, just anecdotally and try on five or six things like you quickly realize like, Oh shit, I'm going to need to really test out of much broader range of this and some rigor methodology around that.
So, right.
And try and you remember and go back and go, this actually made it better.
Right.
Cause it's, it's hard to keep all that in your mind.
Yeah.
And something interesting that I'm realizing to work on this stuff is like everything is changing so fast, right?
The models are changing fast.
The prompting windows are changing fast.
The vector databases, which is a way that organize and structure context for your prompts evolving extremely fast.
It feels like you're working on unsettled ground in a lot of ways.
Like a lot of stuff you're doing might be challenged by, you know, but the BART API came out last week and maybe it's better at SQL generation.
And then I got to throw everything that I did on open act, but here's something you don't throw away your test library and your use cases.
Right.
Maybe is the thing is the real asset here.
The rest of the stuff is like, oh yeah, it's moving so fast that all the mechanics of the prompt engineering itself and the interface with the, whatever model is the best at the time.
You're probably gonna have to throw away as this evolves quickly.
But your test library is something really, really solid that you can perpetuate or like, you know, keep improving and bringing along with you along the way.
So it's kind of an interesting thought around that.
Yeah.
Let's talk to this.
Let's talk to this example.
You have on promptimize is GitHub read me here to give it, make it a little concrete for people.
Like how do you actually write one of these tests?
Yeah.
So, so there's different types of prompts, but yeah, the, you know, what I wanted to get to was just like, just like, what is the prompt and how do you evaluate it?
Right.
And then behind the scene, we're going to be, you know, discovering all your prompts and running them and compiling results and reports, right.
And doing analytics and making it easy to do analytics on it.
The examples that we have here and I'll try to be conscious of both the people who can read the code and people who don't like the people who are just on audio, but here from promptimize.prompt, we import a simple prompt.
And then we bring some evals that are just like utility functions around evaluating the output of what comes back from the AI.
And here, the first prompt case in the model, here, I could just create an array or a list of prompt cases.
And it's a prompt case, like a test case.
And with this prompt case, this very simple one, I say, hello there, exclamation point.
And then I evaluate that as says, you know, either hi or hello in the output.
Right.
So if any of the words exists and what comes back, I give it a one or a zero framework allows you to, you could say, oh, it has to have both these words or give the percentage of success based on the number of words from this list that it has.
But, you know, that's the first case.
The second one is like a little bit more complicated, but name the top 50 guitar players of all time, I guess.
And I make sure that Frank Zappa is in the list because I'm a Frank Zappa fan here.
But, you know, you could have a different, you could say, hey, I want to make sure that, you know, at least three out of five of these are in the list.
Those are like very more like natural language, very simple tests to, you know, just so that's the hello world, essentially.
And then, you know, we're showing some examples of what's happening behind the scene.
Well, it will actually like call, you know, the underlying API, get the results, run your eval function and compile a report.
What was the prompt?
What was, oh, a bird just flew into my room.
Inside?
Yeah, that's going to make the podcast interesting.
Oh, my goodness.
Okay.
That might be a first here.
That is nuts.
Oh, well, it's out of my room.
Guess what?
There's other people in the house.
I'm just going to close the door to my room.
I'm dealing with it later.
All right.
Well, that's a first.
I've had a bat fly into my house once, but never a bird.
So both are crazy.
How indirect.
You're the first on the podcast out of eight years.
We've never had a bird wild animal enter the studio of the guests.
Yes.
Well, welcome to my room.
I live in Tahoe.
So I guess that's something that's better than a bear.
You know, it could have been better.
It is better than there.
All right.
But yes, like this, I keep an emery any kind of what we're seeing visually here.
You know, we'll keep a YAML file as the report output.
So in promptimize, you have your test case or your prompt cases.
I like test cases.
You have an output report that says for this, you know, prompt case.
Here's the key.
Here's what the prompt that was actually the user input that came in.
Here's what the prompt looked like.
You know, what was the response or raw response from the API?
What are all the tasks?
How long did it run?
So a bunch of metadata and relevant information that we can use later to create these reports.
Saying like was the score zero or one.
So you get the whole output report.
Yeah.
Okay.
And then you also have a way to get like a report.
I'm not sure.
Maybe I scroll down.
Yeah.
It shows you how it, how it did.
Right.
I think that was in your, in your.
I think at the blog post, do you see a much more?
Yeah.
So this one we're running the spider data set that I just, that I talked about.
Remember it's like the Yale generated text to SQL competition, you know, corpus.
And so here we, we, we looked at, you know, my percentage of success is 70%.
So, you know, here you say weight and score.
So there's a way to say, oh, this, this particular prompt case is 10 times more important.
Another one.
Right.
So you can do a relative importance of weight of your different text cases.
Now, one thing we didn't mention too, it's like all these tests are generated programmatically too.
So that it's the same philosophy behind, you know, airflow of like, you know, it's almost like a little DSL to write your test case.
So you could, you know, I could read from a YAML file, for instance, in the case of a, what we do with spider SQL, there's a big Jason file of all the prompts and all the databases.
And then we dynamically generate, you know, a thousand tests, based on that.
So you can do programmatic test definition, so more and more dynamic if you want it to be, or you could do more static if you prefer that.
So in this case we're doing, we introduced this idea of a category too.
So I mentioned like there's some features and prompt them as like categorizing your tests or, weights, you know, and things like that.
So here we'll do some reporting on, on per category.
What is the score per category?
You can see which database is perfect.
We're perfect.
Well, or poorly again.
So I could have another category that is large database, small databases and see how that, what the score is and compare reports.
It's pretty cool that it saves the test run to a file that then you can ask questions about and write and generate this report on and rather than just running it and passing or failing.
Right.
Yeah.
Or like giving the output and then having to run it again.
Yeah.
There's some other features around if, so you can memoize the test.
So because it has a reports, if you like, you know, exit off of it or restart it later, you, you, it will, it won't rerun the same tests.
If it's the same hash input, even though with AI, you might get a different answer with the same input, but at least in this case, it will say like, Hey, I reran, I'm rerunning the same prompt instead of like waiting five seconds for open AI and paying the tokens and paying the piper.
You know, I'm just gonna skip that.
So there's some logic around skipping what's been done already.
It's not just a couple of milliseconds to run it.
It could be a while to get the answers.
Yeah.
It's also like early libraries out.
I haven't written the sub the threading for it where you can say like, Oh, run it on eight threads.
Um, so sure.
With prompt demise, I think.
And you know, the blog post is probably more impactful than the Python project itself.
Um, if the project takes off and a bunch of people are using it to test prompts and improve and contribute to it is great.
But I think it's more like, okay, this is uncharted territory.
Um, working with what an AI type interface.
And then it's more like, Oh, how do we, what's, how do we best do that as practitioners or as people building products?
I think that's the, the big idea there, you know, then the test library, you could probably write your own.
Like, I think for me, that was like a one or two week project.
The weather, what I just say is like, normally, if it wasn't for getting all the help from ChatGPT on, you know, it's like, I'm create a project.
I'm setting up my setup.py, you know, set up tools is always a little bit of a gas.
And then I'm like, can you help me set it, create like my setup.py and then, you know, generate some code and I'm like, Oh, I want to make sure that pipe E is going to get my read me from GitHub.
I forgot how to read the mark down and pass the stuff.
Can you do that for me?
And then ChatGPT generates this stuff very nicely.
Right.
Or I want to make sure I use my request that requirements of TXT inside my dynamically building my setup tools integration.
Can you do that for me?
And it's just like, bam, bam, bam.
Like all the repetitive stuff.
I need to function.
It's incredible.
Go ahead.
Yeah.
I kind of want to close out the conversation with that.
I do agree that the blog post is super powerful in how it, it kind of teaches you to think about how might you go about testing, integrating with an AI and these types of products.
Right.
Much like TDD brought a way to think about how do we actually apply the concept just, well, I have things that I can test them with this assert thing.
How should I actually go about building software?
Right.
So this is kind of that for, for AI integrated software.
So it's certainly worth people watching.
Let's just close it out with, you know, you kind of touched on some of those things there.
Like, you know, how do you recommend that people leverage things like ChatGPT to help them build, build their, their apps or how to use AI.
Just kind of amp up your software development.
A hundred percent.
I mean, it's, it's been a lot of people report, you know, on Twitter, people used to Google, you know, all the problems that they had while writing, you know, writing code and using a lot of stack overflow.
I don't know what the stats on like stack overflow traffic, but if once you try working with ChatGPT to do coding, you probably don't go back to those other flows of, I don't know.
It's like putting your error message or stack trace into Google and then go into a bunch of stack overflow link and try to make, make sense of what comes out.
To me, it's been so much better to go just with ChatGPT.
And there's a conversation there too.
So say for instance, if I'm in proptimize, I needed a function to say, can you write, I wrote that function before, you know, but it's a, can you crawl a certain given folder and look for modules that contain objects of a certain class and then bring that back.
And, you know, you have to use the import lib and she's a little bit of pain in the ass to write this.
So it writes, you know, a function that works pretty well.
I'm like, Oh yeah, I forgot to ask you to look into lists and dictionaries.
Can you do that too?
Then it does that in a second.
It's like, I, you know, you didn't have like type hints and duck string and duck, duck test.
Can you write that, you know, too?
And it's a bang, bang, bang.
And just like copy paste in your utils file and it works.
And you save like two hours, you know, I think it would be really good at those things that are kind of algorithmic.
Now you might, they might be the kind of thing that you would do on a whiteboard job interview test.
Right.
It just, it's just going to know that really, really solid.
It actually, but it knows quite a bit about the other libraries and stuff that are out there.
It's insane.
Yeah.
So one, one thing that I came across is I wanted, I leveraged something called length chain, which pointed to people getting interested in prompt engineering.
There's a really good, well, the library length chain is really interesting.
That's not perfect.
It's new.
It's moving fast, but I appreciate people to check it out.
Also like 41,000 stars.
So very, I know that's right.
Is it in Python?
Yes.
You can do like, yeah, it's in Python too.
You should talk to whoever is writing this or started this, but yeah, you can change some prompt to say like the output of a prompt will generate the next one.
There's this idea of agents.
There's this idea of estimating tokens before the, doing the request.
There's a bunch of really cool things that it does to me.
The docs are not that comprehensive.
There's someone else that created, if you Google, link change, link chain cookbook, you'll find someone else that wrote what I thought was more comprehensive way to start.
This one has a YouTube video and an IP one B file introduces you to the concept in an interactive way.
I thought that was really, really good.
But yeah, so we were trying to, I was trying to use this.
I was like, oh, can you generate a bunch of like land chain really?
So I was like, I don't know of a project calling chain.
It was created after 2021.
So that's like, I wish I could just say like, just go read the GitHub, you know, just read it all, read the docs.
And then I'll ask you questions and then ChaggPD is not that great at that currently at learning things that doesn't know for a reason we talked about.
Bard is much more up to date.
So you can always for those projects, you know, ChaggPD might be better at Django because it's, it's old and settled and it's better at writing code overall.
But Bard might be decent and pretty good for the new project.
Right.
If you ask advice on how to do promptimize stuff, it's like, I don't know what that is.
Yeah, it's like, I've never heard of it might hallucinate too.
I think if you'd go and might make sure that like, I've seen it.
I prompt them.
It sounds like it would be this and it just makes up stuff.
So, so not that great.
But yeah, absolutely.
I encourage people to try, you know, for any subtasks that you're trying to do to see if it can help you at it and maybe try a variation on the prompt.
And then, you know, if it's not good at it, do it the, the old way.
But yeah, it might be better too for those familiar with the idea of like functional programming where each function is more deterministic and can be reasoned about and unit tested in isolation.
So, yeah, it's going to be better at that because it doesn't know about all your other packages and modules.
So really great for the utils functions are very deterministic functional.
Yeah.
Super great at that.
Another thing is, and I don't, you tell me when we run out of time, but another thing that that was really interesting too, of, you know, bring the, some of the concept and promptimize and writing the blog post itself.
Right.
And things like, Hey, I'm thinking about the difference of like the properties of test driven development as it applies for prompt engineering.
Here's my blog post, but can you think of other differences between the two that are very core?
And, you know, can you talk about the similarities and the differences?
And it would come up with like, just really, really great ideas, right?
Brainstorming and just very smart at mixing concepts.
I do think one thing that not a great idea is just say, write this for me.
But if you've got something in mind and you're going to say, give me some ideas or how should I go?
Where should I go deeper into this?
And then you use your own creativity to create that.
That's a totally valid use.
I wouldn't feel like, Oh, I'm reading this AI crap.
Right.
It just, it, it brought out some insights that you had forgot to think about.
And now you, now you are.
Right.
Or when it fails and says, say like, I got it to fail.
AI is wrong.
I'm smarter than it.
You're like, wait, is there something I can, can I try to, you know, here's what it didn't get right.
And why, like, what did I need to tell it?
So you can go and edit your prompt or ask a follow up.
And generally it will, it will do better and well.
Yeah.
I think also you can ask it to find bugs or security vulnerabilities.
Yeah.
Right.
You like here, here's my 30 line function.
Do you see any bugs?
Do you, do you, do you see it?
Do you see any security vulnerability?
Like, yeah, you're, you're passing this straight to, you're concatenating the string into SQL or something.
Yeah.
The rigor.
Yeah.
The rigor stuff too.
Um, or like, you know, I would say writing a good doc string, writing doc tests, writing unit tests, reviewing the logic, that kind of stuff.
It does type hints, right?
If you, you're like me, like, I don't really like to write type hints upfront.
Um, but I'm like, can you just like sprinkle some type hints on top of that?
Retrofit this thing for me.
Yeah.
That's it.
Just make it that production grade.
You know, one thing that's interesting too, of like, you know, you would think I'm a big TDD guy.
Like I, I don't do tests.
It's just not my thing.
I like to write code.
I don't think of like what I'm going to use the function for.
And before I write it, but like generating, it's good at generating unit tests for a function too.
And then I think what's interesting with prompt and nice too, is you might think you want to deterministic, what I call prompt cases or test cases, but you can say, I've written, you know, five or six of these.
Can you write variations on that theme too?
So you can use it to generate test cases in the case of like TDD, but also the opposite, like for, for prompt demise, you can get it to generate stuff dynamically to itself.
Yeah.
It's, it's pretty amazing.
It is.
It is pretty.
Let's maybe close this out, but I'll ask you one more question.
Okay.
Can I do one more?
Can I show one more thing?
Since it's a Python podcast, if you go on my repo on that repo for prompt demise under examples, there's one called Python exam.
Here we go.
Something like this.
Yeah.
So I'm going to do this stuff right here.
Um, so say here it says, so here I wrote a prompt that asks the bot to, generate Python function.
Then I sandbox it and, and bring the function it wrote into the interpreter.
And then I test it.
So I say, write a function that tests if a number is a prime number returns, and returns a Boolean.
And then I test, I have, you know, six state test cases for it.
So I write a function that finds the greatest common denominator of two numbers.
Right.
Um, then behind the scene, if we won't get into the class above the class above, like basically interacts with it, gets the input, then runs the test and compiles the results.
Right.
So we could test, you know, how well, 3.5 compares to four.
Sure.
But I thought it was relevant for the Python folks on the line.
So we're testing out what it is at writing Python function.
Write a function that generates the Fibonacci sequence.
Yeah.
Up to a number of terms, right?
It's easy to test.
So it's cool stuff.
And what was your last question?
Oh, I was going to say something like, see if I see how far we could push it.
I'm right.
A Python function to use requests and beautiful soup to scrape the titles of episodes of talk Python to me.
Oh yeah.
And then, yeah, it is.
And if you don't have a, you know, one thing that's a pain in the butt for a podcast people is to write the, like what, what all we talk about.
So you use another AI to get the transcripts.
It's like, can you write something that's going to leverage this library to transcript the library, summarize it and publish it back on the, with SEO in mind.
Yeah, it's, it's really quite amazing.
It went through and said, okay, here's a function and it knows talkpython.fm/episode/all.
Use H, get the title.
And let's, let's just finish this out, Max.
I'll throw this into a.
An interpreter.
See if it runs.
An interpreter and I'll see if I can get it to run.
Hey, you know, what's really interesting too, is like, you can give it a random function.
Like you can write a function and say like, if you know, write a, write a certain function that does certain things.
And you say, if I give the, this input to this function, what is it going to come out of?
And it doesn't have an interpreter, but it can interpret code like you and I do.
Right.
Like, like an interview question of like, Hey, here's a function.
If I input a three as a value, what's going to come, what's going to return.
So it's able to do it, follow the loops, you know, follow the if statements and basically just do a logical.
Yeah.
Another thing I think would be really good is to say, here's a function.
Explain to me what it does.
Oh yeah.
It's super great at that.
It's great at that for SQL too.
Here's a, there's a stupid long SQL query.
Can you explain to me?
No, it does.
It's like, the explanation is on, can you just summarize that 300, you know, in a hundred words?
Yeah.
Let's go step by step.
What's this do?
But yeah, I mean, maybe a closing statement is like, this stuff is changing our world.
Like for me, I'm interested in how it's changing, how we're building products, you know, but the core things as a, as a data practitioner, as a Python expert.
As a programmer, it's really changing the way people work day after day faster than, than, than we all think.
Um, and, and across a lot, like, you know, you might understand pretty well, it's changing your daily workflow as an, as a software engineer, but it's changing people.
Like people's workflow to do chemistry or like in every field.
There's a lot we can leverage here.
Um, if you use it well.
Right.
Yeah.
And apply it to, you know, whatever, vertical you want to think of it's, it's doing the same thing there.
Right.
Medicine all over.
Yeah.
A hundred percent.
Well, let's, let's call it a color up.
I think we're, we're out of, out of time here.
So, really quick before, before we quit PI PI package to recommend, maybe something AI related that you found recently.
Like all this thing's cool.
People should check it out.
Uh, prompt to my eyes.
I think it would be, you know, something to check out.
I think there's something called future tools that you could try to navigate there, but it's, it shows like all of the AI powered tools that are coming out and it's, it's hard to keep up.
Yeah.
I think I have seen that.
Yeah.
And then, if you, if you want to keep up on a daily with what's happening in AI, there's, you know, TLDR AI, they have like a DL with their relevant list for the day.
I think that's a, it's, it's hard to stay on to, I prefer like their weekly digest of what's going on in AI.
It's like, just a stream of information.
Uh, yeah.
It's just kind of dizzying and it's like, oh, this new model does this.
Like I've got to change everything to that.
And then, then something else.
If you update the correct course too often, and it's just like, you know, do nothing.
Cause you're like the foundation, the foundation is shifting too fast on through you.
So yeah, absolutely.
Well, very cool.
All right.
And then final question, you know, right.
Supply the code, what editor using these days?
Uh, I'm a Vim user.
Yeah.
I, I, I know it's not the best.
I'd like, I know all the limitation, but it's like muscle memory.
And, I, I, I'm a UX guy now working on supersets.
I do appreciate the development of all the, the, the new IDEs and the functionality that they have.
I think it's, it's amazing.
And it's just like, for me, it's all like, I know all my bash commands and big commands.
Absolutely.
All right.
Well, Max, thanks for coming on the show, helping everyone explore this wild new frontier of AI and large language models.
And, you know, exploring while we're exploring, while we're still relevant, because I don't know how long we're going to be relevant for.
So yeah.
Yeah.
Enjoy.
Enjoy while we can, right.
Get out there.
Either control the robots or be controlled by them.
So get on the right side of that.
All right.
Thanks again.
Thank you.
This has been another episode of talk Python to me.
Thank you to our sponsors.
Be sure to check out what they're offering.
It really helps support the show.
The folks over at jet brains encourage you to get work done with PyCharm.
PyCharm professional understands complex projects across multiple languages and technologies.
So you can stay productive while you're writing Python code and other code like HTML or SQL.
Download your free trial at talkpython.fm/donewithpycharm.
Listen to an episode of compiler, an original podcast from Red Hat.
Compiler unravels industry topics, trends, and things you've always wanted to know about tech through interviews with the people who know it best.
Subscribe today by following talkpython.fm/compiler.
Want to level up your Python?
We have one of the largest catalogs of Python video courses over at Talk Python.
Our content ranges from true beginners to deeply advanced topics like memory and async.
And best of all, there's not a subscription in sight.
Check it out for yourself at training.talkpython.fm.
Be sure to subscribe to the show.
Open your favorite podcast app and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
We're live streaming most of our recordings these days.
If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at /talkpython.fm/youtube.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
Thanks for listening.
you
Thank you.