Skip to content

Commit 65b0e65

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
Use stream_data instead of publish_batch_data for LLM monitoring example
1 parent b128be5 commit 65b0e65

File tree

1 file changed

+27
-41
lines changed

1 file changed

+27
-41
lines changed

examples/monitoring/llms/general-llm/monitoring-llms.ipynb

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": "ef55abc9",
66
"metadata": {},
77
"source": [
8-
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openlayer-ai/examples-gallery/blob/main/monitoring/llms/monitoring-llms.ipynb)\n",
8+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openlayer-ai/examples-gallery/blob/main/monitoring/llms/general-llm/monitoring-llms.ipynb)\n",
99
"\n",
1010
"\n",
1111
"# <a id=\"top\">Monitoring LLMs</a>\n",
@@ -87,7 +87,7 @@
8787
"source": [
8888
"import openlayer\n",
8989
"\n",
90-
"client = openlayer.OpenlayerClient(\"YOUR_API_KEY_HERE\")"
90+
"client = openlayer.OpenlayerClient(\"YOUR_OPENLAYER_API_KEY_HERE\")"
9191
]
9292
},
9393
{
@@ -132,7 +132,7 @@
132132
"\n",
133133
"[Back to top](#top)\n",
134134
"\n",
135-
"In production, as the model makes predictions, the data can be published to Openlayer. This is done with the `publish_batch_data` method. \n",
135+
"In production, as the model makes predictions, the data can be published to Openlayer. This is done with the `stream_data` method. \n",
136136
"\n",
137137
"The data published to Openlayer can have a column with **inference ids** and another with **timestamps** (UNIX sec format). These are both optional and, if not provided, will receive default values. The inference id is particularly important if you wish to publish ground truths at a later time. "
138138
]
@@ -148,35 +148,26 @@
148148
]
149149
},
150150
{
151-
"cell_type": "code",
152-
"execution_count": null,
153-
"id": "deec9e95",
151+
"cell_type": "markdown",
152+
"id": "1bcf399a",
154153
"metadata": {},
155-
"outputs": [],
156154
"source": [
157-
"batch_1 = production_data.loc[:9]\n",
158-
"batch_2 = production_data.loc[10:18]\n",
159-
"batch_3 = production_data.loc[19:]"
155+
"### <a id=\"publish-batches\"> Publish to Openlayer </a>\n",
156+
"\n",
157+
"Here, we're simulating three calls to `stream_data`. In practice, this is a code snippet that lives in your inference pipeline and that gets called after the model predictions."
160158
]
161159
},
162160
{
163161
"cell_type": "code",
164162
"execution_count": null,
165-
"id": "25b66229",
163+
"id": "c6f7223f-f96c-4573-9825-71dc186d5c60",
166164
"metadata": {},
167165
"outputs": [],
168166
"source": [
169-
"batch_1.head()"
170-
]
171-
},
172-
{
173-
"cell_type": "markdown",
174-
"id": "1bcf399a",
175-
"metadata": {},
176-
"source": [
177-
"### <a id=\"publish-batches\"> Publish to Openlayer </a>\n",
178-
"\n",
179-
"Here, we're simulating three calls to `publish_batch_data`. In practice, this is a code snippet that lives in your inference pipeline and that gets called after the model predictions."
167+
"prompt = [\n",
168+
" {\"role\": \"system\", \"content\": \"You are an expert in Python (programming language).\"},\n",
169+
" {\"role\": \"user\", \"content\": \"Answer the following user question: {{ question }}\"}\n",
170+
"]"
180171
]
181172
},
182173
{
@@ -186,49 +177,44 @@
186177
"metadata": {},
187178
"outputs": [],
188179
"source": [
189-
"batch_config = {\n",
180+
"stream_config = {\n",
181+
" \"prompt\": prompt,\n",
190182
" \"inputVariableNames\": [\"question\"],\n",
191183
" \"outputColumnName\": \"answer\",\n",
192-
" \"inferenceIdColumnName\": \"inference_id\",\n",
193184
"}\n"
194185
]
195186
},
196187
{
197-
"cell_type": "code",
198-
"execution_count": null,
199-
"id": "bde01a2b",
188+
"cell_type": "markdown",
189+
"id": "e9956786-9117-4e27-8f2b-5dff0f6eab97",
200190
"metadata": {},
201-
"outputs": [],
202191
"source": [
203-
"inference_pipeline.publish_batch_data(\n",
204-
" batch_df=batch_1,\n",
205-
" batch_config=batch_config\n",
206-
")"
192+
"You can refer to our documentation guides on [how to write configs for LLM project](https://docs.openlayer.com/how-to-guides/write-dataset-configs/llm-dataset-config) for details on other fields you can use."
207193
]
208194
},
209195
{
210196
"cell_type": "code",
211197
"execution_count": null,
212-
"id": "bfc3dea6",
198+
"id": "bde01a2b",
213199
"metadata": {},
214200
"outputs": [],
215201
"source": [
216-
"inference_pipeline.publish_batch_data(\n",
217-
" batch_df=batch_2,\n",
218-
" batch_config=batch_config\n",
202+
"inference_pipeline.stream_data(\n",
203+
" stream_data=dict(production_data.iloc[0, :]),\n",
204+
" stream_config=stream_config\n",
219205
")"
220206
]
221207
},
222208
{
223209
"cell_type": "code",
224210
"execution_count": null,
225-
"id": "159b4e24",
211+
"id": "bfc3dea6",
226212
"metadata": {},
227213
"outputs": [],
228214
"source": [
229-
"inference_pipeline.publish_batch_data(\n",
230-
" batch_df=batch_3,\n",
231-
" batch_config=batch_config\n",
215+
"inference_pipeline.stream_data(\n",
216+
" stream_data=dict(production_data.iloc[1, :]),\n",
217+
" stream_config=stream_config\n",
232218
")"
233219
]
234220
},
@@ -366,7 +352,7 @@
366352
"name": "python",
367353
"nbconvert_exporter": "python",
368354
"pygments_lexer": "ipython3",
369-
"version": "3.8.13"
355+
"version": "3.9.18"
370356
}
371357
},
372358
"nbformat": 4,

0 commit comments

Comments
 (0)