Anthropic's Prompt Engineering Tutorial (2024)

github.com

344 points by cjbarber a day ago


jwr - 12 hours ago

I find the word "engineering" used in this context extremely annoying. There is no "engineering" here. Engineering is about applying knowledge, laws of physics, and rules learned over many years to predictably design and build things. This is throwing stuff at the wall to see if it sticks.

kgeist - an hour ago

Yesterday I was trying to make a small quantized model work, but it just refused to follow all my instructions. I tried to use all the tricks I could remember, but fixing instruction-following for one rule would always break another.

Then I had an idea: do I really want to be a "prompt engineer" and waste time on this, when the latest SOTA models probably already have knowledge of how to make good prompts in their training data?

Five minutes and a few back-and-forths with GPT-5 later, I had a working prompt that made the model follow all my instructions. I did it manually, but I'm sure you can automate this "prompt calibration" with two LLMs: a prompt rewriter and a judge in a loop.

whatever1 - 12 hours ago

In today’s episode of Alchemy for beginners!

Reminds me of a time that I found I could speed up by 30% an Algo in a benchmark set if I seed the random number generator with the number 7. Not 8. Not 6. 7.

mold_aid - 9 hours ago

"Engineering" here seems rhetorically designed to convince people they're not just writing sentences. With respect "prompt writing" probably sounds bad to the same type of person who thinks there are "soft" skills.

Sammi - 9 hours ago

Here's my best advice of prompt engineering for hard problems. Always funnel out and then funnel in. Let me explain.

State your concrete problem and context. Then we funnel out by asking the AI to do a thorough analysis and investigate all the possible options and approaches for solving the issue. Ask it to go search the web for all possible relevant information. And now we start funneling in again by asking it to list the pros and cons of each approach. Finally we asked it to choose which one or two solutions are the most relevant to our problem at hand.

For easy problems you can just skip all of this and just ask directly because it'll know and it'll answer.

The issue with harder problems is that if you just ask it directly to come up with a solution then it'll just make something up and it will make up reasons for why it'll work. You need to ground it in reality first.

So you do: contrete context and problem, thorough analysis of options, list pros and cons, and pick a winner.

babblingfish - 18 hours ago

The big unlock for me reading this is to think about the order of the output. As in, ask it to produce evidence and indicators before answering a question. Obviously I knew LLMs are a probabilistic auto complete. For some reason, I didn't think to use this for priming.

raffael_de - 12 hours ago

Should have "(2024)" in the submission title.

gdudeman - 18 hours ago

This is written for the 3 models (Sonnet, Haiku, Opus 3). While some lessons will be relevant today, others will not be useful or necessary on smarter, RL’d models like Sonnet 4.5.

> Note: This tutorial uses our smallest, fastest, and cheapest model, Claude 3 Haiku. Anthropic has two other models, Claude 3 Sonnet and Claude 3 Opus, which are more intelligent than Haiku, with Opus being the most intelligent.

kuharich - an hour ago

Past comments: https://news.ycombinator.com/item?id=41395921

meander_water - 9 hours ago

Agree with the other commenters here that this doesn't feel like engineering.

However, Anthropic has done some cool work on model interpretability [0]. If that tool was exposed through the public API, then we could at least start to get a feedback loop going where we could compare the internal states of the model with different prompts, and try and tune them systematically.

[0] https://www.anthropic.com/research/tracing-thoughts-language...

vincnetas - 14 hours ago

It's one year old. Curious how much of it is irrelevant already. Would be nice to see it updated.

taspeotis - 8 hours ago

My workflow has gotten pretty lax around prompts since the models have gotten better. Especially with Claude 4.5 (and 4 before it) once they have a bit of context loaded about the task at hand.

I keep it short and conversational, but I do supervise it. If it goes off the rails just smash esc and give it a course correction.

And then if you're coming from no context: I throw a bit more detail in at the start and usually start by ending the initial prompt with a question asking it if it can see what I'm talking about in the code; or if it's going to be big: I use planning mode.

axpy906 - 5 hours ago

Suggest adding 2024 to the title

pluc - 7 hours ago

So we've taught this thing how to do what we did and now we need to be taught how to get it to do the things we taught it to do. If this didn't have the entire US economy behind it, it would catch fire like a hot balloon.

111yoav - 15 hours ago

Is there an up to date version of this that was written against their latest models?

CuriouslyC - 10 hours ago

Don't write prompts yourself, use DSPy. That's real prompt "engineering"

ipnon - 12 hours ago

I really struggle to feel the AGI when I read such things. I understand this is all of year old. And that we have superhuman results in mathematics, basic science, game playing, and other well-defined fields. But why is it difficult to impossible for LLMs to intuit and deeply comprehend what it is we are trying to coax from them?

smallerfish - 9 hours ago

Nothing about telling it to fuck off, of course to "engineer" its user sentiment analysis?

donperignon - 8 hours ago

This AI madness is getting more stupid every day…

- 2 hours ago
[deleted]
sarcasticsiri - 6 hours ago

[dead]