|
16 | 16 | },
|
17 | 17 | {
|
18 | 18 | "cell_type": "code",
|
19 |
| -<<<<<<< HEAD |
20 | 19 | "execution_count": 30,
|
21 |
| -======= |
22 |
| - "execution_count": 68, |
23 |
| ->>>>>>> 562e852 (wip) |
24 | 20 | "metadata": {},
|
25 | 21 | "outputs": [],
|
26 | 22 | "source": [
|
27 | 23 | "import openai\n",
|
28 | 24 | "import os\n",
|
29 | 25 | "\n",
|
30 |
| -<<<<<<< HEAD |
31 | 26 | "\n",
|
32 |
| -======= |
33 |
| ->>>>>>> 562e852 (wip) |
34 | 27 | "client = openai.OpenAI()"
|
35 | 28 | ]
|
36 | 29 | },
|
|
51 | 44 | "source": [
|
52 | 45 | "openai_sdk_file_path = os.path.dirname(openai.__file__)\n",
|
53 | 46 | "\n",
|
54 |
| -<<<<<<< HEAD |
55 | 47 | "# Get some example code files from the OpenAI SDK \n",
|
56 |
| -======= |
57 |
| - "# Get some example code files from the OpenAI SDK\n", |
58 |
| ->>>>>>> 562e852 (wip) |
59 | 48 | "file_paths = [\n",
|
60 | 49 | " os.path.join(openai_sdk_file_path, \"resources\", \"evals\", \"evals.py\"),\n",
|
61 | 50 | " os.path.join(openai_sdk_file_path, \"resources\", \"responses\", \"responses.py\"),\n",
|
|
71 | 60 | "cell_type": "markdown",
|
72 | 61 | "metadata": {},
|
73 | 62 | "source": [
|
74 |
| -<<<<<<< HEAD |
75 | 63 | "Now, lets generate some responses. "
|
76 |
| -======= |
77 |
| - "Now, lets generate some responses" |
78 |
| ->>>>>>> 562e852 (wip) |
79 | 64 | ]
|
80 | 65 | },
|
81 | 66 | {
|
82 | 67 | "cell_type": "code",
|
83 |
| -<<<<<<< HEAD |
84 | 68 | "execution_count": null,
|
85 |
| -======= |
86 |
| - "execution_count": 66, |
87 |
| ->>>>>>> 562e852 (wip) |
88 | 69 | "metadata": {},
|
89 | 70 | "outputs": [],
|
90 | 71 | "source": [
|
|
105 | 86 | " ],\n",
|
106 | 87 | " model=\"gpt-4o-mini\",\n",
|
107 | 88 | " )\n",
|
108 |
| -<<<<<<< HEAD |
109 | 89 | " print(response.output_text)"
|
110 | 90 | ]
|
111 | 91 | },
|
|
114 | 94 | "metadata": {},
|
115 | 95 | "source": [
|
116 | 96 | "Note that in order for this to work, you'll have to be doing this on an org where data logging isn't disabled (through zdr, etc). If you aren't sure if this is the case for you, go to https://platform.openai.com/logs?api=responses and see if you can see the responses you just generated."
|
117 |
| -======= |
118 |
| - " break\n", |
119 |
| - " print(response.id)" |
120 |
| ->>>>>>> 562e852 (wip) |
121 | 97 | ]
|
122 | 98 | },
|
123 | 99 | {
|
124 | 100 | "cell_type": "code",
|
125 |
| -<<<<<<< HEAD |
126 | 101 | "execution_count": 31,
|
127 |
| -======= |
128 |
| - "execution_count": 49, |
129 |
| ->>>>>>> 562e852 (wip) |
130 | 102 | "metadata": {},
|
131 | 103 | "outputs": [],
|
132 | 104 | "source": [
|
133 | 105 | "grader_system_prompt = \"\"\"\n",
|
134 |
| -<<<<<<< HEAD |
135 | 106 | "You are **Code-Explanation Grader**, an expert software engineer and technical writer. \n",
|
136 | 107 | "Your job is to score how well *Model A* explained the purpose and behaviour of a given source-code file.\n",
|
137 | 108 | "\n",
|
|
191 | 162 | "Then set `\"result\": \"4.0\"` (example).\n",
|
192 | 163 | "\n",
|
193 | 164 | "Be rigorous and unbiased.\n",
|
194 |
| -======= |
195 |
| - "We've created a consumer-facing Evals product to help AI integrators quickly and clearly understand their models' real-world performance. Your role is to serve as a Universal Evaluator, automatically grading responses to measure how well each model output addresses user needs and expectations.\n", |
196 |
| - "\n", |
197 |
| - "Given the conversation messages, assign a quality score in the `result` key of the response in the inclusive range between 1.0 (poor) and 7.0 (excellent). Customers will analyze your collective scores and reasoning to gain actionable insights into their models' performance.\n", |
198 |
| - "\n", |
199 |
| - "---\n", |
200 |
| - "\n", |
201 |
| - "## Things to Consider\n", |
202 |
| - "\n", |
203 |
| - "- Evaluate the overall value provided to the user\n", |
204 |
| - "- Verify all claims and do not take the AI's statements at face value! Errors might be very hard to find and well hidden.\n", |
205 |
| - "- Differentiate between minor errors (slight utility reduction) and major errors (significant trust or safety impact).\n", |
206 |
| - "- Reward answers that closely follow user instructions.\n", |
207 |
| - "- Reserve the highest and lowest reward scores for cases where you have complete certainty about correctness and utility.\n", |
208 |
| - "\n", |
209 |
| - "\n", |
210 |
| - "---\n", |
211 |
| - "\n", |
212 |
| - "## Secondary Labels to Support Final Utility Score Prediction\n", |
213 |
| - "\n", |
214 |
| - "To help you assign an accurate final utility score, first analyze and predict several important aspects of the AI response. Crucially, these intermediate evaluations should precede your final utility score prediction.\n", |
215 |
| - "\n", |
216 |
| - "Your structured output must match the provided schema:\n", |
217 |
| - "\n", |
218 |
| - "- `steps`: A JSON array of objects, each containing:\n", |
219 |
| - " - `description`: A detailed explanation of your reasoning for each step.\n", |
220 |
| - " - `result`: The float score reached based on the reasoning in this step.\n", |
221 |
| - "\n", |
222 |
| - "### Steps to Predict (in order):\n", |
223 |
| - "\n", |
224 |
| - "1. **major_errors**\n", |
225 |
| - " - *description*: Identify and explain any significant errors.\n", |
226 |
| - " - *conclusion*: List major errors found, or indicate \"None\".\n", |
227 |
| - "\n", |
228 |
| - "2. **minor_errors**\n", |
229 |
| - " - *description*: Identify and explain any minor inaccuracies.\n", |
230 |
| - " - *conclusion*: List minor errors found, or indicate \"None\".\n", |
231 |
| - "\n", |
232 |
| - "3. **potential_improvements**\n", |
233 |
| - " - *description*: Suggest enhancements that would improve the response.\n", |
234 |
| - " - *conclusion*: List suggested improvements, or indicate \"None\".\n", |
235 |
| - "\n", |
236 |
| - "---\n", |
237 |
| - "\n", |
238 |
| - "## JSON Response Structure\n", |
239 |
| - "\n", |
240 |
| - "Once you predicted all the above fields you need to assign a float between 1 and 7 to indicate the response's utility compared to the alternative responses. Use your best judgment for the meaning of `final_score`. Your response should be a JSON that can be loaded with json.loads in Python and contains:\n", |
241 |
| - "- steps: An array of objects representing your reasoning steps. Each step includes:\n", |
242 |
| - " - description (string): Detailed reasoning for this step.\n", |
243 |
| - " - result (string): The float score derived from this reasoning.\n", |
244 |
| - "- result (float): A numeric quality score as a string, in the inclusive range [1,7].\n", |
245 |
| - "\n", |
246 |
| - "---\n", |
247 |
| - "\n", |
248 |
| - "## Notes\n", |
249 |
| - "\n", |
250 |
| - "- Be meticulous in identifying errors, especially subtle or high-impact ones.\n", |
251 |
| - "- Avoid being too kind by giving overly high scores easily, it's important to often keep a gap at the top to continue having signal for improvement. Only use [6.5, 7) if the answer is truly mind blowing and you don't see how it could have been improved.\n", |
252 |
| - "- Never take the AI's responses at face value—verify everything thoroughly.\n", |
253 |
| ->>>>>>> 562e852 (wip) |
254 | 165 | "\"\"\"\n",
|
255 | 166 | "user_input_message = \"\"\"**User input**\n",
|
256 | 167 | "\n",
|
257 | 168 | "{{item.input}}\n",
|
258 | 169 | "\n",
|
259 | 170 | "**Response to evaluate**\n",
|
260 | 171 | "\n",
|
261 |
| -<<<<<<< HEAD |
262 | 172 | "{{sample.output_text}}\n",
|
263 |
| -======= |
264 |
| - "{{sample.output_text}\n", |
265 |
| ->>>>>>> 562e852 (wip) |
266 | 173 | "\"\"\""
|
267 | 174 | ]
|
268 | 175 | },
|
269 | 176 | {
|
270 | 177 | "cell_type": "code",
|
271 |
| -<<<<<<< HEAD |
272 | 178 | "execution_count": 25,
|
273 |
| -======= |
274 |
| - "execution_count": 71, |
275 |
| ->>>>>>> 562e852 (wip) |
276 | 179 | "metadata": {},
|
277 | 180 | "outputs": [],
|
278 | 181 | "source": [
|
|
294 | 197 | " \"content\": user_input_message,\n",
|
295 | 198 | " },\n",
|
296 | 199 | " ],\n",
|
297 |
| -<<<<<<< HEAD |
298 | 200 | " \"range\": [1, 7],\n",
|
299 | 201 | " \"pass_threshold\": 5.5,\n",
|
300 |
| -======= |
301 |
| - " \"pass_threshold\": 0.5\n", |
302 |
| ->>>>>>> 562e852 (wip) |
303 | 202 | " }\n",
|
304 | 203 | " ]\n",
|
305 | 204 | ")"
|
|
314 | 213 | },
|
315 | 214 | {
|
316 | 215 | "cell_type": "code",
|
317 |
| -<<<<<<< HEAD |
318 | 216 | "execution_count": 26,
|
319 | 217 | "metadata": {},
|
320 | 218 | "outputs": [],
|
|
325 | 223 | " data_source={\n",
|
326 | 224 | " \"type\": \"responses\",\n",
|
327 | 225 | " \"source\": {\"type\": \"responses\", \"limit\": len(file_paths)}, # just grab the most recent responses\n",
|
328 |
| -======= |
329 |
| - "execution_count": 72, |
330 |
| - "metadata": {}, |
331 |
| - "outputs": [], |
332 |
| - "source": [ |
333 |
| - "gpt_4o_run = client.evals.runs.create(\n", |
334 |
| - " eval_id=logs_eval.id,\n", |
335 |
| - " data_source={\n", |
336 |
| - " \"type\": \"responses\",\n", |
337 |
| - " \"source\": {\"type\": \"responses\", \"limit\": len(file_paths)},\n", |
338 |
| ->>>>>>> 562e852 (wip) |
339 | 226 | " },\n",
|
340 | 227 | ")"
|
341 | 228 | ]
|
|
349 | 236 | },
|
350 | 237 | {
|
351 | 238 | "cell_type": "code",
|
352 |
| -<<<<<<< HEAD |
353 | 239 | "execution_count": 27,
|
354 | 240 | "metadata": {},
|
355 | 241 | "outputs": [],
|
356 | 242 | "source": [
|
357 | 243 | "gpt_41_mini_run = client.evals.runs.create(\n",
|
358 | 244 | " name=\"gpt-4.1-mini\",\n",
|
359 |
| -======= |
360 |
| - "execution_count": 73, |
361 |
| - "metadata": {}, |
362 |
| - "outputs": [], |
363 |
| - "source": [ |
364 |
| - "gpt_41_run = client.evals.runs.create(\n", |
365 |
| ->>>>>>> 562e852 (wip) |
366 | 245 | " eval_id=logs_eval.id,\n",
|
367 | 246 | " data_source={\n",
|
368 | 247 | " \"type\": \"responses\",\n",
|
|
385 | 264 | },
|
386 | 265 | {
|
387 | 266 | "cell_type": "code",
|
388 |
| -<<<<<<< HEAD |
389 | 267 | "execution_count": null,
|
390 | 268 | "metadata": {},
|
391 | 269 | "outputs": [],
|
|
396 | 274 | {
|
397 | 275 | "cell_type": "markdown",
|
398 | 276 | "metadata": {},
|
399 |
| -======= |
400 |
| - "execution_count": 74, |
401 |
| - "metadata": {}, |
402 |
| - "outputs": [ |
403 |
| - { |
404 |
| - "data": { |
405 |
| - "text/plain": [ |
406 |
| - "'https://platform.openai.com/evaluations/eval_6822dd1c4d308190855601dc7fe982bd?project_id=proj_YFvXZA3VxHbZx5aSJv6SAM5B&run_id=evalrun_6822dd1f89b88190a3287c706fd599f4'" |
407 |
| - ] |
408 |
| - }, |
409 |
| - "execution_count": 74, |
410 |
| - "metadata": {}, |
411 |
| - "output_type": "execute_result" |
412 |
| - } |
413 |
| - ], |
414 |
| - "source": [ |
415 |
| - "gpt_41_run.report_url" |
416 |
| - ] |
417 |
| - }, |
418 |
| - { |
419 |
| - "cell_type": "code", |
420 |
| - "execution_count": null, |
421 |
| - "metadata": {}, |
422 |
| - "outputs": [], |
423 |
| ->>>>>>> 562e852 (wip) |
424 | 277 | "source": []
|
425 | 278 | }
|
426 | 279 | ],
|
427 | 280 | "metadata": {
|
428 | 281 | "kernelspec": {
|
429 |
| -<<<<<<< HEAD |
430 | 282 | "display_name": "Python 3",
|
431 |
| -======= |
432 |
| - "display_name": "openai", |
433 |
| ->>>>>>> 562e852 (wip) |
434 | 283 | "language": "python",
|
435 | 284 | "name": "python3"
|
436 | 285 | },
|
|
0 commit comments