Skip to main content

ai_fix_grammar function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Preview

This feature is in Public Preview.

During the preview:

  • This function is only supported in us-east1 and us-central1.
  • The underlying language model can handle several languages, but this AI Function is tuned for English.

The ai_fix_grammar() function allows you to invoke a state-of-the-art generative AI model to correct grammatical errors in a given text using SQL. This function uses a chat model serving endpoint made available by Databricks Foundation Model APIs.

Requirements

important

The underlying models that might be used at this time are licensed under the Apache 2.0 License, Copyright © The Apache Software Foundation or the LLAMA 3.3 Community License Copyright © Meta Platforms, Inc. All rights reserved. Customers are responsible for ensuring compliance with applicable model licenses.

Databricks recommends reviewing these licenses to ensure compliance with any applicable terms. If models emerge in the future that perform better according to Databricks’s internal benchmarks, Databricks might change the model (and the list of applicable licenses provided on this page).

Syntax

ai_fix_grammar(content)

Arguments

  • content: A STRING expression.

Returns

A STRING with corrected grammar.

If content is NULL, the result is NULL.

Examples

SQL
> SELECT ai_fix_grammar('This sentence have some mistake');
"This sentence has some mistakes"

> SELECT ai_fix_grammar('She dont know what to did.');
"She doesn't know what to do."

> SELECT ai_fix_grammar('He go to school every days.');
"He goes to school every day."

Limitations

  • This function is not available on Databricks SQL Classic.
  • This function can not be used with Spark UDFs.
  • This function can not be used with Views