The Prompt To Rule All Prompts // BrXnd Dispatch vol. 007
My very favorite prompting technique + lots of new AI companies
Hi everyone. Welcome to the BrXnd Dispatch: your bi-weekly dose of ideas at the intersection of brands and AI. I hope you enjoy it and, as always, send good stuff my way. Today’s post is a bit nerdier than usual, so please bear with me. It’s a super powerful GPT3 prompt that I have shared with a few friends to great effect. NYC spring 2023 Brand X AI conference planning is in full effect (targeting mid-May🤞🤞). We are grateful to Red Scout & LinkedIn for being our first supporters. If you are interested in speaking or sponsoring, please be in touch.
I debated with myself about what to write for this week’s newsletter. It was between some experiments I’ve been doing with getting a large language model to tell me what it thinks of brands and between some specific techniques I’ve been using that have been shaping a bunch of my thinking about what these tools do best right now.
And then, a friend sent me this post about creating a tool that uses GPT3 and a site called StatMuse to do natural language searches of basketball data. I’m a reasonably serious basketball nerd, so the headline immediately sucked me in. The basics are that he used GPT3 to interpret his searches into a natural language format that would work for Statmuse and tied the whole thing together with a python tool called Langchain, which is growing in popularity.
You can read the whole thing if that’s your thing, but I want to pull out the piece that I found particularly interesting:
Gluing this together only took an hour or two, and felt very weird compared to the traditional software development I’m used to. Instead of composing well-defined APIs, I was gluing together modules which used natural language as the interface, and even using an LLM to drive control flow. It left me wondering how common these kinds of fuzzy APIs will be in the future…
I like the idea that these tools can be a powerful fuzzy interface between systems: They bridge the gap between the structure of code with the lawlessness of natural language.
This idea of a fuzzy interface matches a bunch of work I’ve been doing with GPT3 recently. I feed it (via the API) various content and have it return in a structured format: taking something very human (a newsletter, webpage, etc.) and turning it into data I can work with in code and even store in a database. This is the first AI use case where I really feel like it’s entirely solved a problem—I can’t really imagine going back to parsing data by hand or with many lines of code.
Before I jump in, mainly because I know most of you aren’t technical, let me quickly give you a grounding in a few things. First, Typescript is a programming language that is a “superset” of Javascript, meaning that all Javascript is Typescript, but not all Typescript is Javascript. It fixes a bunch of annoying stuff about Javascript, but the most significant addition is what’s called static typing. What this means is that when you’re writing code, you can explicitly tell your functions whether to expect a number or a boolean (true/false). Imagine it a bit like setting a validation rule on a spreadsheet row that says this can only be a dollar figure so you never get weird values. If you try to pass something other than your predetermined type in Typescript, your code editor will yell at you like this:
Basically, what it’s telling me is that because I said that my example function only takes a string, when I try to pass it anything different (like a number, boolean, object, and so on), it will give me a big red underline and tell me to fix it. Depending on how you’ve set things up with your codebase, it might also not allow you to build or deploy your code until you fix the problem. I have found it to be a fantastic way to hold myself accountable for writing better code.
Anyway, what’s interesting about this is that Typescript gives me a straightforward way to describe complex data. Although the simple example function above only expects a string, moving large data objects around with code is much more common. So defining those interfaces is crucial to making it all work (and keeping yourself from introducing stupid bugs). The syntax for writing these interfaces is pretty simple: you add a colon and define the type (string, number, boolean, etc.). Here’s an example of what a slightly more complicated Typescript interface might look like (this is a version of what’s included in a company listing from my marketing AI landscape):
{
"name": string,
"url": string,
"description": string,
"twitterUrl": string|null,
"linkedInUrl": string|null,
"yearFounded": number|null
}
Hopefully, that’s all pretty straightforward. The gist is that for each property of the company “object,” I’m telling the code what it should expect as input. For example, a URL must always be a string, while a Twitter URL may either be a string or null, which means empty (in this case the | symbol represents or). Again, the power here is that when you’re writing a lot of code and moving around a lot of data, it’s amazing to be able to write these kinds of definitions and then have your IDE (the thing you write code in—such as VS Code) yell at you if you mess something up.
Ok, so what does this have to do with GPT3? Well, one thing that has been fairly obvious to me and everyone else is that these large language models (LLMs), like GPT3, are very good at understanding (and writing) code. One reason is that the corpus for these models is the internet, and there is no larger body of knowledge on the web than information about how to build the web.
Since it has such a good understanding of this stuff, I wondered whether I could just give it a Typescript interface and have it kick out valid JSON for whatever I’m asking. The idea is that returning this structure of data would be super helpful because rather than having to parse the plain text response in code, most programming languages are set up to be able to work with JSON out of the box. That means our fuzzy interface would have an even less fuzzy output.
And … it worked. Consistently. And with valid JSON. Here’s a silly example prompt that works with GPT3:
Using the following Typescript type definition, return valid JSON that describes the animal.
{
"name": string,
"species": string,
"average weight (lbs)": number | null,
"average height (inches)": number | null,
"description": string
}
Animal: pig
Valid JSON:
And here’s the response:
{
"name": "pig",
"species": "Sus scrofa domesticus",
"average weight (lbs)": 260,
"average height (inches)": 30,
"description": "The pig is a domesticated animal that is commonly kept as livestock for its meat, hides, and other products."
}
I haven’t done the research to know whether those height and weight values are correct. So my point here isn’t about the data coming out but rather about the prompting technique.
That, my friends, is valid JSON that you can do anything you want with. In this silly example, I’m asking it for basic info it knows from its corpus, but it gets particularly powerful when you give it something external to parse.
One thing I’ve found that is particularly fascinating is that when it returns fake info, you can generally fix it by offering it the option to return null. By doing that, you give the AI the option to skip the property, and it will take you up on the offer instead of returning a fake value.
I hope this is helpful. Have fun, subscribe to the newsletter, share it, visit my BrXndscape Marketing AI Landscape, come to my conference (and sponsor it!), and be merry.
—Noah
New BrXndscape Companies
New companies listed on BrXndscape, a landscape of marketing AI companies (writeup in case you missed it). If I missed anything, feel free to reply or add a company. (The companies are hand-picked, but the descriptions are AI-generated—part of an automated pipeline that grabs pricing, features, and use cases from each company’s website and one of many experiments I’ve got running at the moment.)
[Large Language Models] ALEPH ALPHA: ALEPH ALPHA offers revolutionary interaction capabilities with unstructured data and information for your organization’s growth. It is a conversational module built on top of our base AI model, “Luminous.”
[Video Generation] D-ID: D-ID offers a robust set of generative AI tools to produce stunning videos featuring talking avatars. With three ways to create faces, three ways to make your avatar speak, and the power of AI to bring your creations to life, the Creative Reality™ Studio is the essential platform for those seeking to create amazing and cutting-edge videos. In addition, AI Presenters from D-ID is an easy-to-use add-in for Microsoft PowerPoint that lets users supercharge training presentations, corporate communications, sales, marketing content, and more.
Thanks for reading. If you want to continue the conversation, feel free to reply, comment, or join us on Discord. Also, please share this email with others you think would find it interesting.
— Noah