Skip to content

Commit 74170da

Browse files
authored
docs: remove session and connection in llm notebook (#821)
1 parent e228010 commit 74170da

File tree

1 file changed

+41
-65
lines changed

1 file changed

+41
-65
lines changed

notebooks/generative_ai/large_language_models.ipynb

+41-65
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"cell_type": "markdown",
1717
"metadata": {},
1818
"source": [
19-
"## Prerequisites\n",
20-
"Create session and define a BQ connection which we already created and allowlisted. "
19+
"## Define the model"
2120
]
2221
},
2322
{
@@ -29,33 +28,14 @@
2928
"name": "stderr",
3029
"output_type": "stream",
3130
"text": [
32-
"/usr/local/google/home/garrettwu/src/bigframes/bigframes/session/__init__.py:1762: UserWarning: No explicit location is set, so using location US for the session.\n",
33-
" return Session(context)\n"
31+
"/usr/local/google/home/garrettwu/src/bigframes/bigframes/ml/llm.py:589: DefaultLocationWarning: No explicit location is set, so using location US for the session.\n",
32+
" self.session = session or bpd.get_global_session()\n"
3433
]
35-
}
36-
],
37-
"source": [
38-
"session = bigframes.pandas.get_global_session()\n",
39-
"connection = f\"{session.bqclient.project}.us.bigframes-default-connection\""
40-
]
41-
},
42-
{
43-
"attachments": {},
44-
"cell_type": "markdown",
45-
"metadata": {},
46-
"source": [
47-
"## Define the model"
48-
]
49-
},
50-
{
51-
"cell_type": "code",
52-
"execution_count": 3,
53-
"metadata": {},
54-
"outputs": [
34+
},
5535
{
5636
"data": {
5737
"text/html": [
58-
"Query job 12bcd690-ca99-4001-bf26-032f50e77d62 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:12bcd690-ca99-4001-bf26-032f50e77d62&page=queryresults\">Open Job</a>"
38+
"Query job 675a6c8a-213b-496c-9f77-b87bf7cfa5e0 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:675a6c8a-213b-496c-9f77-b87bf7cfa5e0&page=queryresults\">Open Job</a>"
5939
],
6040
"text/plain": [
6141
"<IPython.core.display.HTML object>"
@@ -66,7 +46,7 @@
6646
}
6747
],
6848
"source": [
69-
"model = GeminiTextGenerator(session=session, connection_name=connection)"
49+
"model = GeminiTextGenerator()"
7050
]
7151
},
7252
{
@@ -81,7 +61,7 @@
8161
},
8262
{
8363
"cell_type": "code",
84-
"execution_count": 4,
64+
"execution_count": 3,
8565
"metadata": {},
8666
"outputs": [],
8767
"source": [
@@ -102,13 +82,13 @@
10282
},
10383
{
10484
"cell_type": "code",
105-
"execution_count": 5,
85+
"execution_count": 4,
10686
"metadata": {},
10787
"outputs": [
10888
{
10989
"data": {
11090
"text/html": [
111-
"Query job f8fe31c6-7d8a-4919-9492-8304a0083cca is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:f8fe31c6-7d8a-4919-9492-8304a0083cca&page=queryresults\">Open Job</a>"
91+
"Query job 7967df2b-9f0f-45c8-a363-15f65891c3bf is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:7967df2b-9f0f-45c8-a363-15f65891c3bf&page=queryresults\">Open Job</a>"
11292
],
11393
"text/plain": [
11494
"<IPython.core.display.HTML object>"
@@ -118,21 +98,17 @@
11898
"output_type": "display_data"
11999
},
120100
{
121-
"data": {
122-
"text/html": [
123-
"Query job 28bab71f-e218-4d92-9a50-dab41bb0c71f is DONE. 24 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:28bab71f-e218-4d92-9a50-dab41bb0c71f&page=queryresults\">Open Job</a>"
124-
],
125-
"text/plain": [
126-
"<IPython.core.display.HTML object>"
127-
]
128-
},
129-
"metadata": {},
130-
"output_type": "display_data"
101+
"name": "stderr",
102+
"output_type": "stream",
103+
"text": [
104+
"/usr/local/google/home/garrettwu/src/bigframes/bigframes/core/__init__.py:108: PreviewWarning: Interpreting JSON column(s) as StringDtype. This behavior may change in future versions.\n",
105+
" warnings.warn(\n"
106+
]
131107
},
132108
{
133109
"data": {
134110
"text/html": [
135-
"Query job 01d66b61-459f-474e-9f66-d519f9c2f23d is DONE. 6 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:01d66b61-459f-474e-9f66-d519f9c2f23d&page=queryresults\">Open Job</a>"
111+
"Query job 9a1f57cd-98e1-4eac-a1b3-8f88d61971cd is DONE. 6 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:9a1f57cd-98e1-4eac-a1b3-8f88d61971cd&page=queryresults\">Open Job</a>"
136112
],
137113
"text/plain": [
138114
"<IPython.core.display.HTML object>"
@@ -144,7 +120,7 @@
144120
{
145121
"data": {
146122
"text/html": [
147-
"Query job af606ca7-4bcf-4bd1-95fd-c516542b5a4f is DONE. 5.3 kB processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:af606ca7-4bcf-4bd1-95fd-c516542b5a4f&page=queryresults\">Open Job</a>"
123+
"Query job 2a94a2cf-7d4c-4009-a798-d7a5d6d4049d is DONE. 8.5 kB processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:2a94a2cf-7d4c-4009-a798-d7a5d6d4049d&page=queryresults\">Open Job</a>"
148124
],
149125
"text/plain": [
150126
"<IPython.core.display.HTML object>"
@@ -183,28 +159,28 @@
183159
" <tbody>\n",
184160
" <tr>\n",
185161
" <th>0</th>\n",
186-
" <td>**BigQuery**\n",
162+
" <td>## BigQuery: A Serverless Data Warehouse\n",
187163
"\n",
188-
"**Definition:**\n",
189-
"\n",
190-
"BigQuery is a s...</td>\n",
191-
" <td>null</td>\n",
164+
"BigQ...</td>\n",
165+
" <td>[{\"category\":1,\"probability\":1,\"probability_sc...</td>\n",
192166
" <td></td>\n",
193167
" <td>What is BigQuery?</td>\n",
194168
" </tr>\n",
195169
" <tr>\n",
196170
" <th>1</th>\n",
197-
" <td>**BigQuery Machine Learning (BQML)**\n",
171+
" <td>## BigQuery Machine Learning (BQML)\n",
198172
"\n",
199-
"BQML is ...</td>\n",
200-
" <td>null</td>\n",
173+
"BQML is a...</td>\n",
174+
" <td>[{\"category\":1,\"probability\":1,\"probability_sc...</td>\n",
201175
" <td></td>\n",
202176
" <td>What is BQML?</td>\n",
203177
" </tr>\n",
204178
" <tr>\n",
205179
" <th>2</th>\n",
206-
" <td>BigQuery DataFrame is a Python DataFrame imple...</td>\n",
207-
" <td>null</td>\n",
180+
" <td>## What is BigQuery DataFrame?\n",
181+
"\n",
182+
"**BigQuery Dat...</td>\n",
183+
" <td>[{\"category\":1,\"probability\":1,\"probability_sc...</td>\n",
208184
" <td></td>\n",
209185
" <td>What is BigQuery DataFrame?</td>\n",
210186
" </tr>\n",
@@ -214,28 +190,28 @@
214190
],
215191
"text/plain": [
216192
" ml_generate_text_llm_result \\\n",
217-
"0 **BigQuery**\n",
193+
"0 ## BigQuery: A Serverless Data Warehouse\n",
218194
"\n",
219-
"**Definition:**\n",
195+
"BigQ... \n",
196+
"1 ## BigQuery Machine Learning (BQML)\n",
220197
"\n",
221-
"BigQuery is a s... \n",
222-
"1 **BigQuery Machine Learning (BQML)**\n",
198+
"BQML is a... \n",
199+
"2 ## What is BigQuery DataFrame?\n",
223200
"\n",
224-
"BQML is ... \n",
225-
"2 BigQuery DataFrame is a Python DataFrame imple... \n",
201+
"**BigQuery Dat... \n",
226202
"\n",
227-
" ml_generate_text_rai_result ml_generate_text_status \\\n",
228-
"0 null \n",
229-
"1 null \n",
230-
"2 null \n",
203+
" ml_generate_text_rai_result ml_generate_text_status \\\n",
204+
"0 [{\"category\":1,\"probability\":1,\"probability_sc... \n",
205+
"1 [{\"category\":1,\"probability\":1,\"probability_sc... \n",
206+
"2 [{\"category\":1,\"probability\":1,\"probability_sc... \n",
231207
"\n",
232208
" prompt \n",
233209
"0 What is BigQuery? \n",
234210
"1 What is BQML? \n",
235211
"2 What is BigQuery DataFrame? "
236212
]
237213
},
238-
"execution_count": 5,
214+
"execution_count": 4,
239215
"metadata": {},
240216
"output_type": "execute_result"
241217
}
@@ -255,16 +231,16 @@
255231
},
256232
{
257233
"cell_type": "code",
258-
"execution_count": 6,
234+
"execution_count": 5,
259235
"metadata": {},
260236
"outputs": [
261237
{
262238
"data": {
263239
"text/plain": [
264-
"'**BigQuery**\\n\\n**Definition:**\\n\\nBigQuery is a serverless, highly scalable, cloud-based data warehouse and analytics platform offered by Google Cloud.\\n\\n**Key Features:**\\n\\n* **Massive Scalability:** Can handle large datasets (petabytes or more) with fast query execution.\\n* **Elastic:** Automatically scales compute resources based on workload requirements.\\n* **Serverless:** Users do not need to manage infrastructure or provision resources.\\n* **Flexible Data Loading:** Supports a wide range of data sources, including files, databases, and streaming data.\\n* **SQL-Based Querying:** Uses standard SQL syntax for querying and analyzing data.\\n* **Machine Learning Integration:** Provides built-in machine learning capabilities for predictive analytics and data exploration.\\n* **Real-Time Analysis:** Supports streaming data analysis and interactive dashboards.\\n* **Collaboration and Sharing:** Allows multiple users to access and analyze data in a collaborative environment.\\n* **Cost-Effective:** Pay-as-you-go pricing based on data scanned and compute resources used.\\n\\n**Applications:**\\n\\n* Data warehousing and analytics\\n* Business intelligence and reporting\\n* Data science and machine learning\\n* Data exploration and visualization\\n* Marketing analytics\\n* Fraud detection and risk management\\n\\n**Benefits:**\\n\\n* Rapid data analysis on large datasets\\n* Reduced infrastructure management overhead\\n* Increased agility and flexibility\\n* Enhanced collaboration and data sharing\\n* Cost-effective data storage and analytics'"
240+
"\"## BigQuery: A Serverless Data Warehouse\\n\\nBigQuery is a serverless, cloud-based data warehouse that enables scalable analysis of large datasets. It's a popular choice for businesses of all sizes due to its ability to handle petabytes of data and run complex queries quickly and efficiently. Let's delve into its key features:\\n\\n**Serverless Architecture:** BigQuery eliminates the need for server management, allowing you to focus on analyzing data. Google manages the infrastructure, scaling resources up or down automatically based on your needs.\\n\\n**Scalability:** BigQuery can handle massive datasets, scaling seamlessly as your data volume grows. It automatically distributes queries across its infrastructure, ensuring fast and efficient processing.\\n\\n**SQL-like Querying:** BigQuery uses a familiar SQL-like syntax, making it easy for data analysts and developers to learn and use. This allows them to leverage their existing SQL knowledge for data exploration and analysis.\\n\\n**Cost-Effectiveness:** BigQuery offers a pay-as-you-go pricing model, meaning you only pay for the resources you use. This makes it a cost-effective solution for businesses with varying data processing needs.\\n\\n**Integration with Google Cloud:** BigQuery integrates seamlessly with other Google Cloud services like Cloud Storage, Dataflow, and Machine Learning, enabling a comprehensive data processing and analysis workflow within the Google Cloud ecosystem.\\n\\n**Security and Reliability:** BigQuery offers robust security features and high availability, ensuring data protection and reliable access.\\n\\n**Use Cases:** BigQuery finds applications in various scenarios, including:\\n\\n* **Data Warehousing:** Store and analyze large amounts of structured and semi-structured data.\\n* **Business Intelligence:** Generate insights from data for informed decision-making.\\n* **Data Analytics:** Perform complex data analysis and extract valuable patterns.\\n* **Machine Learning:** Train and deploy machine learning models on large datasets.\\n\\n**Getting Started:** To get started with BigQuery, you can create a free trial account on Google Cloud Platform and explore its features. Numerous tutorials and documentation are available to help you learn and use BigQuery effectively.\\n\\n## Additional Resources:\\n\\n* **BigQuery Documentation:** https://cloud.google.com/bigquery/docs/\\n* **BigQuery Quickstart:** https://cloud.google.com/bigquery/docs/quickstarts/quickstart-console\\n* **BigQuery Pricing:** https://cloud.google.com/bigquery/pricing\\n\\nFeel free to ask if you have any further questions about BigQuery!\""
265241
]
266242
},
267-
"execution_count": 6,
243+
"execution_count": 5,
268244
"metadata": {},
269245
"output_type": "execute_result"
270246
}

0 commit comments

Comments
 (0)