ai_gen function

Applies to: check marked yes Databricks SQL

Important

This feature is in Public Preview.

In the preview,

  • The underlying language model can handle several languages, however these functions are tuned for English.
  • There is rate limiting for the underlying Foundation Model APIs, see Foundation Model APIs limits to update these limits.

The ai_gen() function invokes a state-of-the-art generative AI model to answer the user-provided prompt 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 or Llama 2 community license. 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 may change the model (and the list of applicable licenses provided on this page).

Currently, Mixtral-8x7B Instruct is the underlying model that powers these AI functions.

Syntax

ai_gen(prompt)

Arguments

  • prompt: A STRING expression.

Returns

A STRING.

Examples

> SELECT ai_gen('Generate a concise, cheerful email title for a summer bike sale with 20% discount');
  Summer Bike Sale: Grab Your Dream Bike at 20% Off!

> SELECT
    question,
    ai_gen(
      'You are a teacher. Answer the students question in 50 words: ' || question
    ) AS answer
  FROM
    questions