|
13 | 13 | "\n",
|
14 | 14 | "### Setting Up Observability\n",
|
15 | 15 | "\n",
|
| 16 | + "We use MLFlow for tracing. MLflow has already been installed but you have to start the server locally with `mlflow ui` command.\n", |
| 17 | + "\n", |
16 | 18 | "1. Navigate to the linkedin_ai directory:\n",
|
17 | 19 | " ```bash\n",
|
18 | 20 | " cd linkedin_ai\n",
|
|
21 | 23 | "2. Host mlflow UI and point to the URI\n",
|
22 | 24 | " ```bash\n",
|
23 | 25 | " mlflow ui --port 8080 --backend-store-uri file:///<your-file-path>/linkedin_ai/mlruns \n",
|
24 |
| - " ```" |
| 26 | + " ```\n", |
| 27 | + "\n", |
| 28 | + "to find the exact command to run check 👇🏻" |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "code", |
| 33 | + "execution_count": null, |
| 34 | + "metadata": {}, |
| 35 | + "outputs": [], |
| 36 | + "source": [ |
| 37 | + "# if you want to find the mlflow path\n", |
| 38 | + "import os\n", |
| 39 | + "\n", |
| 40 | + "current_dir = os.getcwd()\n", |
| 41 | + "tracking_uri = os.path.join(current_dir, \"mlruns\")\n", |
| 42 | + "tracking_uri = f\"file:///{tracking_uri.lstrip('/')}\"\n", |
| 43 | + "\n", |
| 44 | + "print(\"now you run this in your terminal\")\n", |
| 45 | + "print(f\"$kmlflow ui --port 8080 --backend-store-uri {tracking_uri}\")" |
25 | 46 | ]
|
26 | 47 | },
|
27 | 48 | {
|
|
45 | 66 | "import os\n",
|
46 | 67 | "import mlflow\n",
|
47 | 68 | "\n",
|
48 |
| - "current_dir = os.getcwd()\n", |
49 |
| - "tracking_uri = os.path.join(current_dir, \"mlruns\")\n", |
50 |
| - "tracking_uri = f\"file:///{tracking_uri.lstrip('/')}\"\n", |
51 | 69 | "\n",
|
52 | 70 | "os.environ[\"MLFLOW_HOST\"] = \"http://127.0.0.1:8080\"\n",
|
53 | 71 | "os.environ[\"MLFLOW_TRACKING_URI\"] = tracking_uri\n",
|
|
56 | 74 | },
|
57 | 75 | {
|
58 | 76 | "cell_type": "code",
|
59 |
| - "execution_count": 3, |
| 77 | + "execution_count": null, |
60 | 78 | "metadata": {},
|
61 |
| - "outputs": [ |
62 |
| - { |
63 |
| - "data": { |
64 |
| - "text/plain": [ |
65 |
| - "'905517997201736171'" |
66 |
| - ] |
67 |
| - }, |
68 |
| - "execution_count": 3, |
69 |
| - "metadata": {}, |
70 |
| - "output_type": "execute_result" |
71 |
| - } |
72 |
| - ], |
| 79 | + "outputs": [], |
73 | 80 | "source": [
|
74 | 81 | "# mlflow uses this to log your traces\n",
|
75 | 82 | "mlflow.create_experiment(\n",
|
|
80 | 87 | },
|
81 | 88 | {
|
82 | 89 | "cell_type": "code",
|
83 |
| - "execution_count": 4, |
| 90 | + "execution_count": null, |
84 | 91 | "metadata": {},
|
85 |
| - "outputs": [ |
86 |
| - { |
87 |
| - "data": { |
88 |
| - "text/plain": [ |
89 |
| - "<Experiment: artifact_location='file:///Users/jjmachan/workspace/eglabs/clientwork/linkedin_ai/mlruns/905517997201736171', creation_time=1744931730125, experiment_id='905517997201736171', last_update_time=1744931730125, lifecycle_stage='active', name='my_hackathon_experiment', tags={}>" |
90 |
| - ] |
91 |
| - }, |
92 |
| - "execution_count": 4, |
93 |
| - "metadata": {}, |
94 |
| - "output_type": "execute_result" |
95 |
| - } |
96 |
| - ], |
| 92 | + "outputs": [], |
97 | 93 | "source": [
|
98 | 94 | "mlflow.set_experiment(\n",
|
99 | 95 | " \"my_hackathon_experiment\",\n",
|
|
110 | 106 | },
|
111 | 107 | {
|
112 | 108 | "cell_type": "code",
|
113 |
| - "execution_count": 5, |
| 109 | + "execution_count": null, |
114 | 110 | "metadata": {},
|
115 |
| - "outputs": [ |
116 |
| - { |
117 |
| - "name": "stdout", |
118 |
| - "output_type": "stream", |
119 |
| - "text": [ |
120 |
| - "Loaded 437 LinkedIn posts\n", |
121 |
| - "BM25 index initialized\n" |
122 |
| - ] |
123 |
| - } |
124 |
| - ], |
| 111 | + "outputs": [], |
125 | 112 | "source": [
|
126 | 113 | "from linkedin_ai import LinkedinAI\n",
|
127 | 114 | "my_ai = await LinkedinAI.from_bm25('data/posts.json')\n"
|
128 | 115 | ]
|
129 | 116 | },
|
130 | 117 | {
|
131 | 118 | "cell_type": "code",
|
132 |
| - "execution_count": 6, |
| 119 | + "execution_count": null, |
133 | 120 | "metadata": {},
|
134 |
| - "outputs": [ |
135 |
| - { |
136 |
| - "data": { |
137 |
| - "text/plain": [ |
138 |
| - "\"Open-source models are a significant part of Meta's approach, as seen with LLAMA. I believe that open-sourcing models can accelerate innovation and collaboration within the AI community. By making models and code accessible, we enable researchers and developers to build upon existing work, fostering a more inclusive and rapid advancement in AI technologies. This approach aligns with the vision of creating AI systems that can better understand and interact with the physical world.\"" |
139 |
| - ] |
140 |
| - }, |
141 |
| - "execution_count": 6, |
142 |
| - "metadata": {}, |
143 |
| - "output_type": "execute_result" |
144 |
| - } |
145 |
| - ], |
| 121 | + "outputs": [], |
146 | 122 | "source": [
|
147 | 123 | "await my_ai.ask(\"what is your take on opensource models\")"
|
148 | 124 | ]
|
|
191 | 167 | },
|
192 | 168 | {
|
193 | 169 | "cell_type": "code",
|
194 |
| - "execution_count": 10, |
| 170 | + "execution_count": null, |
195 | 171 | "metadata": {},
|
196 |
| - "outputs": [ |
197 |
| - { |
198 |
| - "data": { |
199 |
| - "text/plain": [ |
200 |
| - "TestDataset(question='Did you found or advise any startups in the AI or biometrics space?', citations='[\"https://www.linkedin.com/in/yann-lecun\"]', grading_notes='- Should mention Element Inc as a co-founded startup.\\n- May also mention Museami.\\n- Describes involvement in biometric authentication or AI-related products.')" |
201 |
| - ] |
202 |
| - }, |
203 |
| - "execution_count": 10, |
204 |
| - "metadata": {}, |
205 |
| - "output_type": "execute_result" |
206 |
| - } |
207 |
| - ], |
| 172 | + "outputs": [], |
208 | 173 | "source": [
|
209 | 174 | "test_dataset[0]"
|
210 | 175 | ]
|
|
218 | 183 | },
|
219 | 184 | {
|
220 | 185 | "cell_type": "code",
|
221 |
| - "execution_count": 11, |
| 186 | + "execution_count": null, |
222 | 187 | "metadata": {},
|
223 |
| - "outputs": [ |
224 |
| - { |
225 |
| - "data": { |
226 |
| - "text/plain": [ |
227 |
| - "'fail'" |
228 |
| - ] |
229 |
| - }, |
230 |
| - "execution_count": 11, |
231 |
| - "metadata": {}, |
232 |
| - "output_type": "execute_result" |
233 |
| - } |
234 |
| - ], |
| 188 | + "outputs": [], |
235 | 189 | "source": [
|
236 | 190 | "# de\n",
|
237 | 191 | "from ragas_experimental.llm import ragas_llm\n",
|
|
296 | 250 | },
|
297 | 251 | {
|
298 | 252 | "cell_type": "code",
|
299 |
| - "execution_count": 15, |
300 |
| - "metadata": {}, |
301 |
| - "outputs": [ |
302 |
| - { |
303 |
| - "name": "stdout", |
304 |
| - "output_type": "stream", |
305 |
| - "text": [ |
306 |
| - "\u001b[31mSignature:\u001b[39m\n", |
307 |
| - "p.mlflow_experiment(\n", |
308 |
| - " experiment_model,\n", |
309 |
| - " name_prefix: str = \u001b[33m''\u001b[39m,\n", |
310 |
| - " save_to_git: bool = \u001b[38;5;28;01mTrue\u001b[39;00m,\n", |
311 |
| - " stage_all: bool = \u001b[38;5;28;01mTrue\u001b[39;00m,\n", |
312 |
| - ")\n", |
313 |
| - "\u001b[31mDocstring:\u001b[39m\n", |
314 |
| - "Decorator for creating experiment functions with mlflow integration.\n", |
315 |
| - "\n", |
316 |
| - "Args:\n", |
317 |
| - " experiment_model: The NotionModel type to use for experiment results\n", |
318 |
| - " name_prefix: Optional prefix for experiment names\n", |
319 |
| - "\n", |
320 |
| - "Returns:\n", |
321 |
| - " Decorator function that wraps experiment functions with mlflow observation\n", |
322 |
| - "\u001b[31mFile:\u001b[39m ~/workspace/eglabs/clientwork/linkedin_ai/.venv/lib/python3.12/site-packages/ragas_experimental/project/experiments.py\n", |
323 |
| - "\u001b[31mType:\u001b[39m method" |
324 |
| - ] |
325 |
| - } |
326 |
| - ], |
327 |
| - "source": [ |
328 |
| - "p.mlflow_experiment?" |
329 |
| - ] |
330 |
| - }, |
331 |
| - { |
332 |
| - "cell_type": "code", |
333 |
| - "execution_count": 14, |
| 253 | + "execution_count": null, |
334 | 254 | "metadata": {},
|
335 |
| - "outputs": [ |
336 |
| - { |
337 |
| - "name": "stderr", |
338 |
| - "output_type": "stream", |
339 |
| - "text": [ |
340 |
| - "Running experiment: 100%|██████████| 100/100 [00:46<00:00, 2.13it/s]\n" |
341 |
| - ] |
342 |
| - }, |
343 |
| - { |
344 |
| - "name": "stdout", |
345 |
| - "output_type": "stream", |
346 |
| - "text": [ |
347 |
| - "No changes detected, nothing to commit\n", |
348 |
| - "Created branch: ragas/quirky_shamir\n" |
349 |
| - ] |
350 |
| - }, |
351 |
| - { |
352 |
| - "data": { |
353 |
| - "text/plain": [ |
354 |
| - "Experiment(name=quirky_shamir, model=ExperimentModel)" |
355 |
| - ] |
356 |
| - }, |
357 |
| - "execution_count": 14, |
358 |
| - "metadata": {}, |
359 |
| - "output_type": "execute_result" |
360 |
| - } |
361 |
| - ], |
| 255 | + "outputs": [], |
362 | 256 | "source": [
|
363 | 257 | "await experiment_func.run_async(test_dataset)"
|
364 | 258 | ]
|
|
397 | 291 | },
|
398 | 292 | {
|
399 | 293 | "cell_type": "code",
|
400 |
| - "execution_count": 14, |
| 294 | + "execution_count": null, |
401 | 295 | "metadata": {},
|
402 |
| - "outputs": [ |
403 |
| - { |
404 |
| - "name": "stderr", |
405 |
| - "output_type": "stream", |
406 |
| - "text": [ |
407 |
| - "Running experiment: 100%|██████████| 100/100 [00:44<00:00, 2.25it/s]" |
408 |
| - ] |
409 |
| - }, |
410 |
| - { |
411 |
| - "name": "stdout", |
412 |
| - "output_type": "stream", |
413 |
| - "text": [ |
414 |
| - "Staging changes to tracked files\n", |
415 |
| - "Changes committed with hash: a0692b82\n", |
416 |
| - "Created branch: ragas/elegant_rivest\n" |
417 |
| - ] |
418 |
| - }, |
419 |
| - { |
420 |
| - "name": "stderr", |
421 |
| - "output_type": "stream", |
422 |
| - "text": [ |
423 |
| - "\n" |
424 |
| - ] |
425 |
| - }, |
426 |
| - { |
427 |
| - "data": { |
428 |
| - "text/plain": [ |
429 |
| - "Experiment(name=elegant_rivest, model=ExperimentModel)" |
430 |
| - ] |
431 |
| - }, |
432 |
| - "execution_count": 14, |
433 |
| - "metadata": {}, |
434 |
| - "output_type": "execute_result" |
435 |
| - } |
436 |
| - ], |
| 296 | + "outputs": [], |
437 | 297 | "source": [
|
438 | 298 | "await experiment_func.run_async(test_dataset)"
|
439 | 299 | ]
|
|
0 commit comments