Correct Standard English Text With AI21

Correct English Text for Grammar, Spelling, and Punctuation Errors.

No time to walk through the tutorial? Test this prompt out here.

Use Case

When most of our days are spent reading or typing text, it can be really easy to accidentally overlook a grammatical or phrasing error. Using a language generation tool that is trained to correct common errors can help reduce the amount of time that is spent proofreading and free up some mental space for other tasks. In this tutorial, we will be building a simple prompt to help achieve this!

It is important to note that this prompt is designed to address common grammar, spelling, and punctuation errors — there are instances in which it would not provide sufficient correction. For this reason, it has been designed to provide a suggestion as opposed to a definitive answer.

Prompt Creation

When you are ready to create your prompt, click AI Manager > Prompts > Add New Prompt, and fill out the following:

  • Name of Prompt: Grammar Improvement
  • Description: AI21 Complete

Tags and Intelets can be left blank.

For deploying your prompt publicly at the end of this tutorial, you can add a default security policy configured by Mantium. Click Add Security Policies under Security Policies and drag Default Policies from All Policies to Selected Policies. Click Done to save - you will know the policy has been applied when its name is visible under Security Policies.

Provider Settings

  • Provider: AI21
  • Endpoint: Complete

Prompt Body

We have prepared a text snippet for you to paste into the prompt line — it contains a series of entries with an incorrect sentence, followed by a corrected version.
When pasting, please be sure that there is no additional whitespace after "Incorrect: " (with one space after the colon) at the end of the text. Language models are sensitive to all characters, including spaces.

Incorrect: There dog ate my homework.
Suggested: Their dog ate my homework.
###
Incorrect: I went to the conference Shannon was there and set to give a speech he seemed a little nervous.
Suggested: I went to the conference. Shannon was there and set to give a speech; he seemed a little nervous.
###
Incorrect: That dish was excellente.
Suggested: That dish was excellent.
###
Incorrect: Your a very good friend to me.
Suggested: You're a very good friend to me.
###
Incorrect: For all intensive purposes, this prompt is going to help me with my grammer.
Suggested: For all intents and purposes, this prompt is going to help me with my grammar.
###
Incorrect: My dog, is sleeping on it's stomache.
Suggested: My dog is sleeping on its stomach.
###
Incorrect: This is a few sentances that have grammer issues; I'm hopeing that this prompt will help correct my simple mistakes!
Suggested: This is a few sentences that have grammar issues. I'm hoping that this prompt will help correct my simple mistakes!
### 
Incorrect: What @bout when we $ub$titute symbols for letters? It shouldnt change anything, but only fix the grammatical errors.
Suggested: What @bout when we $ub$titute symbols for letters? It shouldn't change anything, but only fix the grammatical errors.
###
Incorrect: Scientific advancement's in the field became possible with one women's immense contributions.
Suggested: Scientific advancements in the field became possible with one woman's immense contributions.
###
Incorrect: The USA mens' soccer team took gold in the last game of the season.
Suggested: The USA men's soccer team took gold in the last game of the season. 
###
Incorrect: These sentences are grammatically correct and do not need correction; punctuation, spelling, and grammar are used well.
Suggested: These sentences are grammatically correct and do not need correction; punctuation, spelling, and grammar are used well.
###
Incorrect: The womens' division of the Academic Decatlon is the biggest because of there high paticipation.
Suggested: The women's division of the Academic Decathlon is the biggest because of their high participation.
###
Incorrect: To many doughnuts go too the dumpster if they don't get baught.
Suggested: Too many doughnuts go to the dumpster if they don't get bought.
###
Incorrect: Some sentences look like they might run on if they don't have punctuation at the end
Suggested: Some sentences look like they might run on if they don't have punctuation at the end.
###
Incorrect: This sentence needs an exclamation point at the end because its very important
Suggested: This sentence needs an exclamation point at the end because it's very important!
###
Incorrect: I am yelling
Suggested: I am yelling!
###
Incorrect: These two recipes are one in the same, as far as I know.
Suggested: These two recipes are one and the same, as far as I know.
###
Incorrect: Case and point: the cat ate my plants again.
Suggested: Case in point: the cat ate my plants again.
###
Incorrect: I should of included you in our company wide email.
Suggested: I should have included you in our company-wide email.
###
Incorrect: Precede to the ceremony when they light the torch!
Suggested: Proceed to the ceremony when they light the torch!
###
Incorrect: 

Then, select an engine.

  • Choose an Engine: J1-Jumbo

The prompt body itself is a series of sentences that contain grammatical and phrasing errors in the English language. The sentence that needs correction is labeled as Incorrect:, followed by a suggested correction labeled as Suggested:. Because the English language contains homophones, or words and phrases that sound the same but mean different things, there is still potential for error with AI-powered correction. The more examples that are provided, the less likely an inaccurate correction is to be returned.

Prompt Settings

  • Max Tokens: 100
  • Temperature: .3
  • Top P: .1
  • Number of Results: 1
  • Stop Sequences: ###

Max Tokens controls the length of an output response. The count should be adjusted for the general expected length of the input and output. A “token” is approximately .75 of an English word, so this prompt would stop at roughly 75 words.

Temperature controls “creativity” - higher temperatures will produce more creative outputs but are less likely to adhere to structure. A lower temperature is advised for a prompt that requires a well-defined response, as the model will choose words with a higher probability of occurrence.

Top P is another way to control "creativity" using a different probability method. Setting Top P to .1 means that the model will only consider the words with top 10% probability masses as potential outputs.

Stop sequences are another method of controlling output - they allow you to define any text sequences that force the model to stop. If you don't have a stop sequence, the model might generate a stream of the requested response length or it may stop in the middle of a sentence.
Using "###" provides delineation that is clearly visible and not often present in natural language.

Test Prompt Text

Because these models are stochastic in nature, the resulting output will vary even when using the same input, but we have included a text snippet to run as a test:

This families farm is to big; they cant take care all the animals theyve got already.

There is still a chance that using the same input multiple times may yield a different output. However, configuring the prompt with a low temperature and small value for Top P will help increase consistency of the output. We suggest clicking Test Run multiple times and tweaking the values of Temperature and Top P to test output consistency as needed. Once you are satisfied with the results, click Save.

Results & Conclusion

Homophones are especially challenging to detect even in written text because the spelling and word arrangement may look correct despite them being misused grammatically. This use case particularly benefits from being provided with specific examples of phrasing errors, and will become more effective with specific examples of corrected sentences. For further exploration, it could be useful to try fine-tuning a model on a file containing many more examples beyond the ones provided in this prompt body.

One-Click Deploy

Mantium enables sharing your prompt using the One-Click Deploy feature, located in each prompt's drawer view. From your list of prompts, click on the Grammar Improvement prompt, click Deploy , and add the following configuration settings:

  • Name: Grammar Improvement
  • Description: Suggests improvements for sentences with grammar and phrasing errors!
  • Author Name: Your Name
  • ✅ Add Input Field
  • Public
  • Live
  • Input Placeholder Text: Enter a sentence that needs grammatical improvement!

After deploying your prompt, you will have a unique URL that you can share for others to interact with it. To interact with the prompt, a user should input a phrase or sentence that may contain grammatical errors for the model to correct.

To test out the prompt that we have configured, click this link!

Similar Use Cases

Language models don’t have to only correct grammatical or phrasing errors. Given enough data, it would be possible to configure a model to help reduce word redundancy, or change the tense or language used. We encourage you to explore other creative options for improving your writing!

Possible examples could include:

  • Reduce the frequency of use of a specific word by replacing it with synonyms.
  • Change all sentences from present tense to past tense.
  • Transform a list of steps into a paragraph of complete sentences, or vice versa.
  • Simplify the jargon in your text by replacing your original text
    with simpler language.

Did this page help you?