Paraphrase
Takes a piece of text and returns a list of paraphrases that convey the same meaning using different words.
This model is no longer supported. For better results, see Jamba 1.5.
AI21 Studio's paraphrase Task-Specific Model offers access to our world-class paraphrasing engine. It has been specifically developed for suggesting alternative ways to convey the same message using different words.
The model takes a piece of text and returns a list of paraphrases that convey the same meaning using different words, according to the style you choose. As a specialized API for paraphrasing, it contains features to enable you more control over the output by adjusting the tone and style. Moreover, you can add additional context to the text, to make the rewrite suggestion more relevant (by paraphrasing a certain range of your text).
Links
- Playground: Try it in the browser, with all the API parameters.
- API documentation: Learn how to use it via REST or our SDK.
Usage
Choose a style that fits your needs
You have the choice between five different styles:
- General - there are fresh and creative ways to rephrase sentences. Offer them to your users.
- Casual - convey a friendlier and more accessible tone for the right audience.
- Formal - present your words in a more professional way.
- Short - express your messages clearly and concisely.
- Long - expand your sentences to give more detail, nuance and depth.
Provide context for your paraphrased text
You can specify start and end points to paraphrase from a longer text. If you want to paraphrase part of a longer text, provide as much context as makes sense, so that the system can get a good idea of what you're trying to say when it generates suggestions.
To improve fluency, the model can modify up to one word before or after the suggested range. For example, consider the following sentence (where the range to paraphrase is bolded):
I had a good night.
Among the response suggestions, you may see “I had a relaxing evening”, where the range is on the limit, as well as “I had an enjoyable evening”, where you can see the range included an extra word before.
Don't over-narrow your selection
For example, consider the sentence “This is a flat out bad example”. Paraphrasing the word “flat” alone in this sentence without violating fluency is not possible, because “flat” is part of the term “flat out”. Cases like this usually yield few or no suggestions.
Examples
By integrating the Paraphrase API into your system, your users gain an embedded co-writer within the experience. This is useful for virtually all text-based tasks, from marketing content (like that post about a newly specialized API) to emails (a formal report to higher-ups or casual correspondence with a colleague) and even general descriptions. Following are some examples illustrating both use cases and special features you can take advantage of with this API.
General writing
Example 1
You can enhance the writing experience of your users by adding paraphrasing functionality to your writing platforms. See the following example for a generic call, without any of the special features. Here is an example for paraphrasing suggestions (note that the API will return up to 10 suggestions in every call):
Text |
---|
We will explore the Paraphrase API's advantages and features throughout this page. |
Suggestions |
The Paraphrase API will be explored throughout this page. |
On this page, we will look at the advantages and features of the Paraphrase API. |
In this page, we'll explore Paraphrase API's benefits and features. |
This page provides an overview of the Paraphrase API's advantages and features |
We will discuss the benefits and features of the Paraphrase API throughout this page. |
You can use this code and see for yourself:
from ai21 import AI21Client
client = AI21Client(
# This is the default and can be omitted
api_key=os.environ.get("AI21_API_KEY"),
)
response = client.paraphrase.create(
text=="Throughout this page, we will explore the advantages and features of the Paraphrase API.",
)
import requests
fetch("https://api.ai21.com/studio/v1/paraphrase", {
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "Throughout this page, we will explore the advantages and features of the Paraphrase API."
}),
method: "POST"
});
{
"id":"e218271d-bc3a-3c31-5576-e6b09eb75f8b",
"suggestions":[
{
"text":"We will explore the Paraphrase API's advantages and features throughout this page."
},
{
"text":"The Paraphrase API will be explored throughout this page."
},
{
"text":"On this page, we will look at the advantages and features of the Paraphrase API."
},
{
"text":"In this page, we'll explore Paraphrase API's benefits and features."
},
{
"text":"This page explores the advantages and features of Paraphrase API."
},
{
"text":"This page provides an overview of the Paraphrase API's advantages and features."
},
{
"text":"We will discuss the benefits and features of the Paraphrase API throughout this page."
},
{
"text":"During this page, you will learn about the features and advantages of the Paraphrase API."
},
{
"text":"This page will explore the Paraphrase API's advantages and features."
},
{
"text":"In this page, we'll discuss the advantages and features of the Paraphrase API."
}
]
}
Example 2
Request:
from ai21 import AI21Client
client = AI21Client(
# This is the default and can be omitted
api_key=os.environ.get("AI21_API_KEY"),
)
// Paraphrase everything after “Is my contractor licensed?”
response = client.paraphrase.create(
text="My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” We figured that we should create some pages that satisfied this need.",
start_index=116,
)
Response:
[
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Therefore, we decided to create some pages that answered this question."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Our team decided to create some pages to answer this question."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” This led to the idea of creating some pages that answered this question."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Thus, some pages were created to provide this information."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Thus, we decided to create some pages that address this issue."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Therefore, we designed some pages that addressed this question."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Therefore, we decided to create some pages that would fulfill this need."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Thus, we created some pages that provide that information."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Thus, we decided to create a few pages about this topic."
},
{
"text":"My team discovered that there was little-to-no information that answered the question, “Is my contractor licensed?” Therefore, we decided to create some pages that would provide this information."
}
]
You can see that everything before start_index
remains the same in all of the suggestions.
Retail product descriptions (short style and context use)
Writing product descriptions requires understanding your customers' needs and communicating the features and benefits of your product in an engaging, informative, and compelling manner. Also, as a copywriter, they need to keep a consistent tone in descriptions. On top of that, there is often a strict length restriction, which may cause multiple descriptions for the same product on different platforms. Offering your users different paraphrasing styles, such as shortening, can improve their productivity and help them provide high-quality results, all with their own voice and consistency.
See the following example for a call that combines a short style and the context feature, i.e. - paraphrase only part of the text, while maintaining the full context. Note that unlike in this table, the response will include the full text and not just the paraphrased part.
Text (full context) |
This classic cotton t-shirt is made from soft, comfortable cotton and is suitable for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out. |
Text to paraphrase |
This classic cotton t-shirt is made from soft, comfortable cotton and is suitable for everyday wear. |
Suggestions |
Designed from 100% soft, comfortable cotton, this classic cotton t-shirt is ideal for everyday use and would make a stylish addition to any wardrobe. |
You can use this code and see for yourself:
from ai21 import AI21Client
from ai21.models import ParaphraseStyleType
client = AI21Client(
# This is the default and can be omitted
api_key=os.environ.get("AI21_API_KEY"),
)
text = "This classic cotton t-shirt is made from soft, comfortable cotton and is suitable for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
text_to_paraphrase = "This classic cotton t-shirt is made from soft, comfortable cotton and is suitable for everyday wear."
start_index = text.find(text_to_paraphrase)
end_index = start_index + len(text_to_paraphrase)
response = client.paraphrase.create(
text=text,
style=ParaphraseStyleType.SHORT,
start_index=start_index,
end_index=end_index,
)
{
"id":"9d0908f7-84f1-5ba4-0c81-14103191e737",
"suggestions":[
{
"text":"Cotton t-shirt made from soft, comfortable cotton for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"Soft, comfortable cotton makes this cotton t-shirt perfect for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"Suitable for everyday wear, this classic cotton t-shirt is made of soft, comfortable cotton. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"The soft, comfortable cotton used in this t-shirt makes it suitable for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"The cotton t-shirt is soft, comfortable, and suitable for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"Soft, comfortable cotton makes for a great everyday t-shirt. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"Comfortable cotton t-shirt for everyday wear made of soft, comfy cotton. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"Soft and comfortable cotton makes this classic cotton t-shirt ideal for daily wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"A classic cotton t-shirt that's comfortable and versatile. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
},
{
"text":"The classic cotton t-shirt is soft and comfortable for everyday wear. In addition to providing ultimate comfort and a timeless appearance, this t-shirt has a durable ribbed neckline and a regular fit. It is available in a variety of colors so that you can wear it up or down for any occasion. It's great for running errands or dressing up for a night out."
}
]
}
Customer inquiries (formal style)
It takes years to learn how to sound professional in work emails. You can save your users as much time as possible by providing them with a paraphrased version of their response that sounds professional using the formal tone. Note that unlike in this table, the response will include the full text and not just the paraphrased part.
Text (full context) |
---|
Dear (customer name), Thank you for choosing (company name). At (company name), we appreciate our customers and aim to provide good service. Our delivery policy includes: 1- Delivery within 48 hours 2- Delivery within 72 hours for orders above $100. 3- All deliveries are free of charge. 4- All deliveries are insured. 5- All deliveries are tracked. 6- Delivery within 48 hours for orders above $500. (Company name) offers a 10% discount on all purchases. If you require any additional information or assistance, please do not hesitate to contact us. Best regards, John |
Text to paraphrase |
At (company name), we appreciate our customers and aim to provide good service |
Suggestions |
We at (company name) are committed to providing excellent service to our customers. |
Updated about 1 month ago