|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -"""This module integrates BigQuery built-in AI functions for use with Series/DataFrame objects, |
16 | | -such as AI.GENERATE_BOOL: |
17 | | -https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-generate-bool""" |
| 15 | +""" |
| 16 | +Integrate BigQuery built-in AI functions into your BigQuery DataFrames workflow. |
| 17 | +
|
| 18 | +The ``bigframes.bigquery.ai`` module provides a Pythonic interface to leverage BigQuery ML's |
| 19 | +generative AI and predictive functions directly on BigQuery DataFrames and Series objects. |
| 20 | +These functions enable you to perform advanced AI tasks at scale without moving data |
| 21 | +out of BigQuery. |
| 22 | +
|
| 23 | +Key capabilities include: |
| 24 | +
|
| 25 | +* **Generative AI:** Use :func:`bigframes.bigquery.ai.generate` (Gemini) to |
| 26 | + perform text analysis, translation, or |
| 27 | + content generation. Specialized versions like |
| 28 | + :func:`~bigframes.bigquery.ai.generate_bool`, |
| 29 | + :func:`~bigframes.bigquery.ai.generate_int`, and |
| 30 | + :func:`~bigframes.bigquery.ai.generate_double` are available for structured |
| 31 | + outputs. |
| 32 | +* **Embeddings:** Generate vector embeddings for text using |
| 33 | + :func:`~bigframes.bigquery.ai.generate_embedding`, which are essential for |
| 34 | + semantic search and retrieval-augmented generation (RAG) workflows. |
| 35 | +* **Classification and Scoring:** Apply machine learning models to your data for |
| 36 | + predictive tasks with :func:`~bigframes.bigquery.ai.classify` and |
| 37 | + :func:`~bigframes.bigquery.ai.score`. |
| 38 | +* **Forecasting:** Predict future values in time-series data using |
| 39 | + :func:`~bigframes.bigquery.ai.forecast`. |
| 40 | +
|
| 41 | +**Example usage:** |
| 42 | +
|
| 43 | + >>> import bigframes.pandas as bpd |
| 44 | + >>> import bigframes.bigquery as bbq |
| 45 | +
|
| 46 | + >>> df = bpd.DataFrame({ |
| 47 | + ... "text_input": [ |
| 48 | + ... "Is this a positive review? The food was terrible.", |
| 49 | + ... ], |
| 50 | + ... }) # doctest: +SKIP |
| 51 | +
|
| 52 | + >>> # Assuming a Gemini model has been created in BigQuery as 'my_gemini_model' |
| 53 | + >>> result = bq.ai.generate_text("my_gemini_model", df["text_input"]) # doctest: +SKIP |
| 54 | +
|
| 55 | +For more information on the underlying BigQuery ML syntax, see: |
| 56 | +https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-generate-bool |
| 57 | +""" |
18 | 58 |
|
19 | 59 | from bigframes.bigquery._operations.ai import ( |
20 | 60 | classify, |
|
0 commit comments