Almost Timely News, January 21, 2024: Prompt Engineering and Latent Space

Almost Timely News: Prompt Engineering and Latent Space (2024-01-21) :: View in Browser

Almost Timely News

👉 Register for my newly updated Generative AI for Marketers course! Use ALMOSTTIMELY for $50 off the tuition

Content Authenticity Statement

98% of this week’s newsletter was generated by me, the human. There’s some AI generated artwork in the opening piece. Learn why this kind of disclosure is important.

Watch This Newsletter On YouTube 📺

Almost Timely News: Prompt Engineering and Latent Space (2024-01-21)

Click here for the video 📺 version of this newsletter on YouTube »

Click here for an MP3 audio 🎧 only version »

What’s On My Mind: Prompt Engineering and Latent Space

This week, let’s talk about prompt engineering and latent space. This is a concept that I’m working on for our upcoming Advanced Prompt Engineering Course, which will be a supplement to our Generative AI For Marketers course.

There are a ton of different prompting strategies out there on the Internet, and a gazillion people hawking their secret prompt recipes for whatever amount of money they’re charging. How good are these prompts? Are they worth spending money on? What about all the other prompts people are sharing on LinkedIn and other social networks?

To answer this question, we have to start with latent space. What the heck is this? Latent space is the encoded knowledge of language in a large language model. It’s the stored patterns of data that captures relationships and, when prompted, reconstructs language from those patterns.

Let’s give a tangible example. Suppose you wanted to build a pizza model, an AI that could generate pizza. You’d take photo after photo of pizza after pizza, noting how all the toppings looked. You’d look at the relationships between toppings and cheese, where the toppings are spread, whether they’re on top or under the cheese, what kind of cheese was used, how much sauce was used. You’d measure this from every pizza you could get your hands on, and when you were done, you’d have a database of measurements about pizza. You’d have things like the average number of slices of pepperoni, or how close the jalapeños are to the onions, or how much pineapple belongs on a pizza.

Then, when someone came to you and said, hey, I want a pepperoni and pineapple pizza, you would go into your HUGE catalog of statistics and query it for pineapple and pepperoni, get some averaged answers about how much of each belongs on the pizza, etc. and you can bake a pizza with those directions.

That database of statistics is the latent space. It’s an understanding of patterns that you can use to generate new outputs. This, by the way, is why the issue of copyright is so tricky with generative AI; the original author’s works, be they words or images, are NOT in the model. Statistical descriptions of an author’s works are, but just like our pizza database contains no actual pizza, a language model or a diffusion model contains no actual original works.

Okay, so the latent space is basically a statistical database. What does this have to do with prompting a language model? All language models are trained from large text databases, like Common Crawl, ArXiv, StackExchange, Wikipedia, Project Gutenberg, etc. Those big databases contain varying amounts of knowledge on a significant number of topics – and the quality of knowledge varies wildly. Just because it’s in Wikipedia doesn’t make it correct, and just because it’s on Blogspot doesn’t make it wrong.

When we write a prompt for a language model, our prompt is ingested by the model and matched up against its latent space, against its database of statistics. It returns a pile of statistics that then get assembled as words, just like a recipe is ingested by a chef’s mind and performed into food.

If we prompt a language model and we get a dissatisfactory response, it’s very likely the prompt we used was insufficient when it comes to the very largest models. But it’s equally possible – and grows more probable the smaller a model gets – that the latent space of the model may not have enough information about what we’re prompting it about.

What happens in that case? The model hallucinates – which is tech speak for drawing on the next set of likely probabilities, even if they are factually wrong. A model that doesn’t know the exact specifics of a prompt because the knowledge isn’t in its latent space will choose the closest match – that’s how models work. We interpret that as a mistake, but the model is actually functioning correctly.

For example, in the early days of language models, when they were trained with relatively small amounts of data and not fine tuned to follow instructions based on millions of examples, you could ask a model who was President of the United States in 1492. We know from history and reasoning capabilities that there was no President of the United States in 1492 because there was no United States in 1492. But a model doesn’t reason – it just assembles probabilities. The President of the United States is a person, and typically a prominent person (unless you were President Taylor or President Van Buren, names no one can seem to remember). 1492 is associated for good or ill with a prominent person, Christopher Columbus. In the absence of a factually correct statistical match, early language models replied that Christopher Columbus was President of the United States in 1492. Statistically, a sensible answer even though it’s factually wrong.

A key part of advanced prompt engineering is knowing the limitations of a language model’s latent space. You have to assess its latent space for a given topic to know what it knows on that topic – assuming it’s important enough for you to want to use generative AI in the first place – before you can start constructing prompts. Otherwise, you will prompt it for things it doesn’t know well, and the answers you get back will have a high chance of hallucination. They’ll be statistically correct under the hood, but factually wrong from a reasoning standpoint.

Going back to our pizza analogy, suppose you gave your pizza chef a request for a pizza with ham and pineapple, but our chef had never heard of a pineapple. Chef knows that from our description, pineapple is a tropical fruit, a sweet fruit, and a yellow fruit, so chef makes us a pizza with their best guess:

AI image of banana pizza
image generated with DALL-E 3 via Microsoft Bing Image Creator

…a ham and banana pizza. You can see how, from a descriptive characteristics perspective, pineapple and banana might be thought of similarly, but… no. If you think pineapple doesn’t belong on pizza, banana REALLY doesn’t belong on pizza.

But that’s a concrete example of prompting a model for something that isn’t in its latent space, isn’t in the database of knowledge that it has, and it substituting the next closest thing that seems rational and logical, but is very much not the same thing.

How do you assess a model’s latent space? By asking it about what it knows on a topic, especially deep into the topic. If you know the topic well, you can ascertain just how deep a model’s knowledge goes before it runs out of knowledge and starts to hallucinate. For example, I started with this very, very technical prompt:

Describe the key characteristics of the SARS-CoV-2 JN.1 clade in terms of the L455S mutation.

When I ran this in Chatbot Arena, one model said the JN.1’s parent lineage is BA.2.86, while another model said JN.1 is also known as BA.2.75:

Prompt and response for the JN.1 clade of SARS-CoV-2

The second model’s response is factually incorrect – JN.1 comes from the BA.2.86 lineage. The model hallucinated, meaning that its latent space doesn’t know about what the JN.1 clade actually is.

What do you do when you evaluate a model and find its limitations? Latent space is basically the database that the model draws from, so if you find out a model lacks knowledge on a topic, you have to provide that knowledge. That means incorporating the knowledge either in the prompt itself, or through uploading data and documents like in ChatGPT and Custom GPTs. By providing the data you want the model to use, you are effectively increasing the latent space of the model and reducing the likelihood that it’s going to hallucinate on you.

This is the key part that prompt engineering guides overlook: no matter how good your prompt is, if the model doesn’t have knowledge of what you’re prompting, your prompt will not perform well. It’s like asking a chef to cook with ingredients they don’t know. You can be incredibly clear in your instructions, but if the chef has no knowledge of what you’re asking, you will NEVER get a satisfactory result without providing the ingredients for the chef (and maybe making it for them a couple of times so they can actually taste it themselves and understand it).

This is also why prompts should generally be associated with specific models; the prompt I used above would best be used in models that know what the JN.1 clade is, and should not be used in models that are unaware of it. Now, for common, old topics like management skills or personal finance, a prompt is probably fairly portable. But the deeper a dive you need to do, the more specific you’ll need to be about which model to use with prompts on the topic – and which supplementary data you’ll have to provide, no matter what.

Finally, apparently no one likes the idea of banana on pizza. I’m not thrilled with it either.

Banana on pizza poll

How Was This Issue?

Rate this week’s newsletter issue with a single click. Your feedback over time helps me figure out what content to create for you.

Share With a Friend or Colleague

If you enjoy this newsletter and want to share it with a friend/colleague, please do. Send this URL to your friend/colleague:

https://www.christopherspenn.com/newsletter

For enrolled subscribers on Substack, there are referral rewards if you refer 100, 200, or 300 other readers. Visit the Leaderboard here.

ICYMI: In Case You Missed it

Besides the new Generative AI for Marketers course I’m relentlessly flogging, I recommend the piece on legality of works in Custom GPTs, made with the assistance of 3 actual lawyers.

Skill Up With Classes

These are just a few of the classes I have available over at the Trust Insights website that you can take.

Premium

Free

Advertisement: Generative AI Workshops & Courses

Imagine a world where your marketing strategies are supercharged by the most cutting-edge technology available – Generative AI. Generative AI has the potential to save you incredible amounts of time and money, and you have the opportunity to be at the forefront. Get up to speed on using generative AI in your business in a thoughtful way with Trust Insights’ new offering, Generative AI for Marketers, which comes in two flavors, workshops and a course.

Workshops: Offer the Generative AI for Marketers half and full day workshops at your company. These hands-on sessions are packed with exercises, resources and practical tips that you can implement immediately.

👉 Click/tap here to book a workshop

Course: We’ve turned our most popular full-day workshop into a self-paced course. The Generative AI for Marketers online course is now available and just updated this week! Use discount code ALMOSTTIMELY for $50 off the course tuition.

👉 Click/tap here to pre-register for the course

If you work at a company or organization that wants to do bulk licensing, let me know!

Get Back to Work

Folks who post jobs in the free Analytics for Marketers Slack community may have those jobs shared here, too. If you’re looking for work, check out these recent open positions, and check out the Slack group for the comprehensive list.

What I’m Reading: Your Stuff

Let’s look at the most interesting content from around the web on topics you care about, some of which you might have even written.

Social Media Marketing

Media and Content

SEO, Google, and Paid Media

Advertisement: Business Cameos

If you’re familiar with the Cameo system – where people hire well-known folks for short video clips – then you’ll totally get Thinkers One. Created by my friend Mitch Joel, Thinkers One lets you connect with the biggest thinkers for short videos on topics you care about. I’ve got a whole slew of Thinkers One Cameo-style topics for video clips you can use at internal company meetings, events, or even just for yourself. Want me to tell your boss that you need to be paying attention to generative AI right now?

📺 Pop on by my Thinkers One page today and grab a video now.

Tools, Machine Learning, and AI

Analytics, Stats, and Data Science

All Things IBM

Dealer’s Choice : Random Stuff

How to Stay in Touch

Let’s make sure we’re connected in the places it suits you best. Here’s where you can find different content:

Advertisement: Ukraine 🇺🇦 Humanitarian Fund

The war to free Ukraine continues. If you’d like to support humanitarian efforts in Ukraine, the Ukrainian government has set up a special portal, United24, to help make contributing easy. The effort to free Ukraine from Russia’s illegal invasion needs our ongoing support.

👉 Donate today to the Ukraine Humanitarian Relief Fund »

Events I’ll Be At

Here’s where I’m speaking and attending. Say hi if you’re at an event also:

  • Tourism Industry Association of Alberta’s Tourism Summit, Edmonton, February 2024
  • Independent Consortium of Booksellers Association, Denver, February 2024
  • Social Media Marketing World, San Diego, February 2024
  • MarketingProfs AI Series, Virtual, March 2024
  • Australian Food and Grocery Council, Melbourne, May 2024
  • MAICON, Cleveland, September 2024

Events marked with a physical location may become virtual if conditions and safety warrant it.

If you’re an event organizer, let me help your event shine. Visit my speaking page for more details.

Can’t be at an event? Stop by my private Slack group instead, Analytics for Marketers.

Required Disclosures

Events with links have purchased sponsorships in this newsletter and as a result, I receive direct financial compensation for promoting them.

Advertisements in this newsletter have paid to be promoted, and as a result, I receive direct financial compensation for promoting them.

My company, Trust Insights, maintains business partnerships with companies including, but not limited to, IBM, Cisco Systems, Amazon, Talkwalker, MarketingProfs, MarketMuse, Agorapulse, Hubspot, Informa, Demandbase, The Marketing AI Institute, and others. While links shared from partners are not explicit endorsements, nor do they directly financially benefit Trust Insights, a commercial relationship exists for which Trust Insights may receive indirect financial benefit, and thus I may receive indirect financial benefit from them as well.

Thank You

Thanks for subscribing and reading this far. I appreciate it. As always, thank you for your support, your attention, and your kindness.

See you next week,

Christopher S. Penn


You might also enjoy:


Want to read more like this from Christopher Penn? Get updates here:

subscribe to my newsletter here


AI for Marketers Book
Take my Generative AI for Marketers course!

Analytics for Marketers Discussion Group
Join my Analytics for Marketers Slack Group!



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Shares
Share This