From the course: Building with the Claude API by Anthropic

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Controlling model output

Controlling model output

Besides just changing our prompts that we send into Claude, there are two other ways we could strongly influence the output that we get out of it. So in this video, we're going to discuss two techniques. One is pre-filling assistant messages. The second is stop sequences. Let's first take a look at pre-filling assistant messages. Okay, let's imagine that we send Claude some kind of really tough to answer question. Something like, is tea or coffee better at breakfast? I have absolutely no idea what kind of response Claude would give me. As a matter of fact, let's go over to our Jupyter notebook really quickly and see what kind of response we get in the first place. Back inside of my notebook, I'm creating an empty list of messages. I'm then going to add in a user message with text of is tea or coffee better at breakfast. I then feed in the list messages to our chat function and then I'm going to print out the answer that we get back. I'm going to run this. Then if we take a look at the…

Contents