Use pretrained Google large language models (LLMs) using remote connection in BigQuery
Establish a Remote Connection to BigQuery
To establish a remote connection to BigQuery for integrating large language models (LLMs), you must first understand how to configure secure connections. These connections allow BigQuery to interact seamlessly with other Google Cloud services. This setup facilitates the execution of complex queries directly within the data warehouse. By doing so, you can leverage powerful AI tools without moving your data.
Configuring this connection usually involves setting up a Google Cloud service account. You can create a new account or use an existing one to manage permissions. While a service account key in JSON format is often used for authentication, using Workload Identity emails is recommended for better security. This approach minimizes the risks associated with handling static key files.
The integration process requires specific parameters to ensure the connection works correctly. You will need to specify the Account Type, which defaults to service_account, and the Project ID linked to your BigQuery instance. Additionally, the Private Key ID and Private Key found in the JSON file are necessary for authentication. Efficient integration depends on entering these details accurately.
Understanding the different authentication methods is vital for maintaining a secure environment. The Service Account Key JSON method provides all necessary details, including the project ID and keys, in a single file. However, Workload Identity is often the preferred method because it avoids the security risks of managing physical key files. This ensures that your connection to Google LLMs remains both secure and functional.
Utilize Google LLM Functions in BigQuery
BigQuery allows users to call remote functions to run pretrained Google large language models (LLMs) directly inside SQL queries. This method uses remote connections to communicate with Vertex AI endpoints, allowing you to analyze text data without moving it. This integration provides low-code access to advanced capabilities like text generation and summarization. It simplifies workflows by keeping both data storage and computation in one location.
Before applying these functions, you must ensure your text data is available in BigQuery. Common sources for this data include:
- Conversational Insights and Dialogflow CX exports for customer service logs.
- Firebase analytics and Google Analytics 4 session data.
- Search Console performance reports.
- Stored results from Vertex AI Batch Prediction.
To set up the function, you first create an external connection to the Vertex AI model endpoint. Next, you use the CREATE EXTERNAL FUNCTION command in BigQuery SQL to define the model name and input schemas. This process ensures that your queries interact with the LLM through a secure API call. This setup maintains data privacy while delivering consistent performance for your analytical tasks.
Once the remote function is defined, you can run queries that combine standard data operations with AI analysis. For instance, you can pass conversation texts into the LLM to generate summaries or compute sentiment on the fly. You can also join LLM outputs with user metadata to create richer reports. Monitoring query usage helps optimize performance and ensures your text analysis remains cost-effective.
Conclusion
In summary, utilizing pretrained Google LLMs in BigQuery relies on establishing secure remote connections and deploying specific SQL functions. By properly configuring service accounts and choosing the right authentication method, you ensure a safe link between BigQuery and Vertex AI. Once connected, utilizing remote functions allows for scalable, low-code text analysis and data processing directly within your data warehouse environment.