1. Text generation
Welcome back! Let's now explore text generation and its real-world applications.
2. How is the output generated?
When we send a prompt to a chat model, it returns the text that it believes is most likely to complete the prompt, which it infers based on the data the model was developed on.
If we send "Life is like a box of chocolates" to the model, it correctly completes the quote with high probability. We say "high probability" here because the model results are non-deterministic, so we cannot guarantee the exact same output every time.
3. Controlling response randomness
There are many use cases where randomness is undesirable. Think of a customer service chatbot—we wouldn't want the chatbot to provide different guidance to customers with the same issue. However, we would like the model to be flexible to different inputs, so there's often a trade-off in the amount of randomness.
We can control the amount of randomness in the response using the temperature parameter. temperature is set to one by default, but ranges from zero to two, where zero is almost entirely deterministic and two is highly random.
If we add a temperature of two here, we can see the model completes the prompt in a more bizarre way.
4. Text generation: marketing
As well as completing prompts, text generation can also be used to create brand-new content!
For example, let's generate a tagline for an electric car.
A well-crafted prompt should be clear and detailed to guide the model's response.
Here's what we got—that's not bad!
We can also tweak temperature and max_completion_tokens to experiment with different ideas.
5. Text generation: product description
Another common use case is creating product descriptions.
Here, we'll create a description for a new smartwatch aimed at fitness enthusiasts and busy professionals alike.
We start the prompt with the product features, and finish with instructions on the desired tone and target audience.
Passing this prompt to the chat model in a request,
6. Text generation: product description
we get something that already looks good enough for any e-commerce website.
If we need to iterate further, we can always update the original prompt with more specific information and re-run our request.
In the next video, we'll explore how to provide examples to the model, which can improve text generation consistency, but for now,
7. Let's practice!
enjoy exploring use cases for text generation in the exercises!