Using AI21 Studio, you can solve challenging text understanding and generation tasks. Its straightforward API and interactive playground allows you to get started in minutes, without any prior knowledge in Natural Language Processing (NLP).
Below is a quickstart guide to cover all the basics you need in order to start building your solution. After that, you should feel comfortable using our large language models to start and solve your own use-case.
A language model takes some text as input and produces a likely continuation. You can think of it as an exceptional student that can follow instructions and imitate examples.
Here are two words you should know:
Prompt - the input you provide to the model.
Completion - the output text the model returns.
Imagine owning an online retail platform. Your job requires you to come up with appealing titles for your products. By using AI21 Studio language models, you can optimize the process.
The most naive thing to do is simply provide the model a prompt which is a simple instruction. This is what it looks like:
The title is nice, but it is very generic. Let's add the T-shirt type (sports) to the prompt and see what we get:
The title has been refined to reflect the actual product. You can also apply a more realistic scenario: ask the model to incorporate specific keywords in the title.
This is called Zero-shot prompting, because we are giving the model zero examples in the prompt. If you care about a specific style you want the model to follow, you should consider adding examples to your prompt.
By providing the model with examples, just as a human would, it could produce completions that are more aligned with your intentions. It could also adhere to patterns that are more difficult to explain via instructions. In order to help the model distinguish between each example, we use a stop sequence. The stop sequence itself should be immediately recognizable when looking at the text as a whole. In this example, the stop sequence is ##:
This is called Few-shot prompting, because we are inserting a prompt which includes a few examples.
Another way to affect the completion is to adjust some of the model parameters. A useful parameter is the temperature. You can increase creativity by tweaking the temperature. With temperature 0, the model will always choose the most probable completion, so it will always be the same. Increasing the temperature will provide variable completions, where the completion may be different for every generation:
A task that requires accurate results (such as classification) is best performed with low temperature, whereas a task that requires more creativity should be conducted with high temperature (0.7 is a reasonable starting point).
Want to explore the various descriptions the model can generate? Try it yourself!
Once you have created your prompt, you can easily integrate it into your product using either our Python SDK or HTTP request:
import ai21 ai21.Completion.execute( model="j2-ultra", prompt="Write a product title for a sports T-shirt to be published on an online retail platform. Include the following keywords: activewear, gym, dryfit. ", maxTokens=200, temperature=0.8 )
Now you're ready to improve your product using generative AI.
We encourage you to play with our models in the AI21 Studio and explore the out-of-the-box solutions our task-specific models can provide.
Want to know more about the prompt design process? Read about prompt engineering.
Want to know more about our APIs? See the full API reference.
Updated 3 months ago