AlaFalaki commited on
Commit
8c29627
β€’
1 Parent(s): be5df4e

Created using Colab

Browse files
Files changed (1) hide show
  1. notebooks/Metadata_Filtering.ipynb +1420 -0
notebooks/Metadata_Filtering.ipynb ADDED
@@ -0,0 +1,1420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "authorship_tag": "ABX9TyM3k9teXGyUaTdppBByKY8t",
8
+ "include_colab_link": true
9
+ },
10
+ "kernelspec": {
11
+ "name": "python3",
12
+ "display_name": "Python 3"
13
+ },
14
+ "language_info": {
15
+ "name": "python"
16
+ },
17
+ "widgets": {
18
+ "application/vnd.jupyter.widget-state+json": {
19
+ "1350b1f2c9df4113bde94c59ad0db010": {
20
+ "model_module": "@jupyter-widgets/controls",
21
+ "model_name": "HBoxModel",
22
+ "model_module_version": "1.5.0",
23
+ "state": {
24
+ "_dom_classes": [],
25
+ "_model_module": "@jupyter-widgets/controls",
26
+ "_model_module_version": "1.5.0",
27
+ "_model_name": "HBoxModel",
28
+ "_view_count": null,
29
+ "_view_module": "@jupyter-widgets/controls",
30
+ "_view_module_version": "1.5.0",
31
+ "_view_name": "HBoxView",
32
+ "box_style": "",
33
+ "children": [
34
+ "IPY_MODEL_7f3d8a3d4f614b4d99b048c021c1615c",
35
+ "IPY_MODEL_bf68ea9156ea438da61f8ca1fc529f7d",
36
+ "IPY_MODEL_1fd460ecbf644d049ed1faf88322649f"
37
+ ],
38
+ "layout": "IPY_MODEL_36f78ffa8f9847149c5cab414fac1226"
39
+ }
40
+ },
41
+ "7f3d8a3d4f614b4d99b048c021c1615c": {
42
+ "model_module": "@jupyter-widgets/controls",
43
+ "model_name": "HTMLModel",
44
+ "model_module_version": "1.5.0",
45
+ "state": {
46
+ "_dom_classes": [],
47
+ "_model_module": "@jupyter-widgets/controls",
48
+ "_model_module_version": "1.5.0",
49
+ "_model_name": "HTMLModel",
50
+ "_view_count": null,
51
+ "_view_module": "@jupyter-widgets/controls",
52
+ "_view_module_version": "1.5.0",
53
+ "_view_name": "HTMLView",
54
+ "description": "",
55
+ "description_tooltip": null,
56
+ "layout": "IPY_MODEL_0862d91ad42b48e4b0de4997aa3a1dd8",
57
+ "placeholder": "​",
58
+ "style": "IPY_MODEL_277704b916aa40759b6db36688d1d151",
59
+ "value": "Parsing nodes: 100%"
60
+ }
61
+ },
62
+ "bf68ea9156ea438da61f8ca1fc529f7d": {
63
+ "model_module": "@jupyter-widgets/controls",
64
+ "model_name": "FloatProgressModel",
65
+ "model_module_version": "1.5.0",
66
+ "state": {
67
+ "_dom_classes": [],
68
+ "_model_module": "@jupyter-widgets/controls",
69
+ "_model_module_version": "1.5.0",
70
+ "_model_name": "FloatProgressModel",
71
+ "_view_count": null,
72
+ "_view_module": "@jupyter-widgets/controls",
73
+ "_view_module_version": "1.5.0",
74
+ "_view_name": "ProgressView",
75
+ "bar_style": "success",
76
+ "description": "",
77
+ "description_tooltip": null,
78
+ "layout": "IPY_MODEL_2f3166628904417f97438e7c852f3b82",
79
+ "max": 14,
80
+ "min": 0,
81
+ "orientation": "horizontal",
82
+ "style": "IPY_MODEL_0eec40171bba48268b176b55e7a85fff",
83
+ "value": 14
84
+ }
85
+ },
86
+ "1fd460ecbf644d049ed1faf88322649f": {
87
+ "model_module": "@jupyter-widgets/controls",
88
+ "model_name": "HTMLModel",
89
+ "model_module_version": "1.5.0",
90
+ "state": {
91
+ "_dom_classes": [],
92
+ "_model_module": "@jupyter-widgets/controls",
93
+ "_model_module_version": "1.5.0",
94
+ "_model_name": "HTMLModel",
95
+ "_view_count": null,
96
+ "_view_module": "@jupyter-widgets/controls",
97
+ "_view_module_version": "1.5.0",
98
+ "_view_name": "HTMLView",
99
+ "description": "",
100
+ "description_tooltip": null,
101
+ "layout": "IPY_MODEL_f51b2e545d794ccead531822085f1a2d",
102
+ "placeholder": "​",
103
+ "style": "IPY_MODEL_c9840d43284a419face648ce394a8e80",
104
+ "value": " 14/14 [00:00<00:00, 30.79it/s]"
105
+ }
106
+ },
107
+ "36f78ffa8f9847149c5cab414fac1226": {
108
+ "model_module": "@jupyter-widgets/base",
109
+ "model_name": "LayoutModel",
110
+ "model_module_version": "1.2.0",
111
+ "state": {
112
+ "_model_module": "@jupyter-widgets/base",
113
+ "_model_module_version": "1.2.0",
114
+ "_model_name": "LayoutModel",
115
+ "_view_count": null,
116
+ "_view_module": "@jupyter-widgets/base",
117
+ "_view_module_version": "1.2.0",
118
+ "_view_name": "LayoutView",
119
+ "align_content": null,
120
+ "align_items": null,
121
+ "align_self": null,
122
+ "border": null,
123
+ "bottom": null,
124
+ "display": null,
125
+ "flex": null,
126
+ "flex_flow": null,
127
+ "grid_area": null,
128
+ "grid_auto_columns": null,
129
+ "grid_auto_flow": null,
130
+ "grid_auto_rows": null,
131
+ "grid_column": null,
132
+ "grid_gap": null,
133
+ "grid_row": null,
134
+ "grid_template_areas": null,
135
+ "grid_template_columns": null,
136
+ "grid_template_rows": null,
137
+ "height": null,
138
+ "justify_content": null,
139
+ "justify_items": null,
140
+ "left": null,
141
+ "margin": null,
142
+ "max_height": null,
143
+ "max_width": null,
144
+ "min_height": null,
145
+ "min_width": null,
146
+ "object_fit": null,
147
+ "object_position": null,
148
+ "order": null,
149
+ "overflow": null,
150
+ "overflow_x": null,
151
+ "overflow_y": null,
152
+ "padding": null,
153
+ "right": null,
154
+ "top": null,
155
+ "visibility": null,
156
+ "width": null
157
+ }
158
+ },
159
+ "0862d91ad42b48e4b0de4997aa3a1dd8": {
160
+ "model_module": "@jupyter-widgets/base",
161
+ "model_name": "LayoutModel",
162
+ "model_module_version": "1.2.0",
163
+ "state": {
164
+ "_model_module": "@jupyter-widgets/base",
165
+ "_model_module_version": "1.2.0",
166
+ "_model_name": "LayoutModel",
167
+ "_view_count": null,
168
+ "_view_module": "@jupyter-widgets/base",
169
+ "_view_module_version": "1.2.0",
170
+ "_view_name": "LayoutView",
171
+ "align_content": null,
172
+ "align_items": null,
173
+ "align_self": null,
174
+ "border": null,
175
+ "bottom": null,
176
+ "display": null,
177
+ "flex": null,
178
+ "flex_flow": null,
179
+ "grid_area": null,
180
+ "grid_auto_columns": null,
181
+ "grid_auto_flow": null,
182
+ "grid_auto_rows": null,
183
+ "grid_column": null,
184
+ "grid_gap": null,
185
+ "grid_row": null,
186
+ "grid_template_areas": null,
187
+ "grid_template_columns": null,
188
+ "grid_template_rows": null,
189
+ "height": null,
190
+ "justify_content": null,
191
+ "justify_items": null,
192
+ "left": null,
193
+ "margin": null,
194
+ "max_height": null,
195
+ "max_width": null,
196
+ "min_height": null,
197
+ "min_width": null,
198
+ "object_fit": null,
199
+ "object_position": null,
200
+ "order": null,
201
+ "overflow": null,
202
+ "overflow_x": null,
203
+ "overflow_y": null,
204
+ "padding": null,
205
+ "right": null,
206
+ "top": null,
207
+ "visibility": null,
208
+ "width": null
209
+ }
210
+ },
211
+ "277704b916aa40759b6db36688d1d151": {
212
+ "model_module": "@jupyter-widgets/controls",
213
+ "model_name": "DescriptionStyleModel",
214
+ "model_module_version": "1.5.0",
215
+ "state": {
216
+ "_model_module": "@jupyter-widgets/controls",
217
+ "_model_module_version": "1.5.0",
218
+ "_model_name": "DescriptionStyleModel",
219
+ "_view_count": null,
220
+ "_view_module": "@jupyter-widgets/base",
221
+ "_view_module_version": "1.2.0",
222
+ "_view_name": "StyleView",
223
+ "description_width": ""
224
+ }
225
+ },
226
+ "2f3166628904417f97438e7c852f3b82": {
227
+ "model_module": "@jupyter-widgets/base",
228
+ "model_name": "LayoutModel",
229
+ "model_module_version": "1.2.0",
230
+ "state": {
231
+ "_model_module": "@jupyter-widgets/base",
232
+ "_model_module_version": "1.2.0",
233
+ "_model_name": "LayoutModel",
234
+ "_view_count": null,
235
+ "_view_module": "@jupyter-widgets/base",
236
+ "_view_module_version": "1.2.0",
237
+ "_view_name": "LayoutView",
238
+ "align_content": null,
239
+ "align_items": null,
240
+ "align_self": null,
241
+ "border": null,
242
+ "bottom": null,
243
+ "display": null,
244
+ "flex": null,
245
+ "flex_flow": null,
246
+ "grid_area": null,
247
+ "grid_auto_columns": null,
248
+ "grid_auto_flow": null,
249
+ "grid_auto_rows": null,
250
+ "grid_column": null,
251
+ "grid_gap": null,
252
+ "grid_row": null,
253
+ "grid_template_areas": null,
254
+ "grid_template_columns": null,
255
+ "grid_template_rows": null,
256
+ "height": null,
257
+ "justify_content": null,
258
+ "justify_items": null,
259
+ "left": null,
260
+ "margin": null,
261
+ "max_height": null,
262
+ "max_width": null,
263
+ "min_height": null,
264
+ "min_width": null,
265
+ "object_fit": null,
266
+ "object_position": null,
267
+ "order": null,
268
+ "overflow": null,
269
+ "overflow_x": null,
270
+ "overflow_y": null,
271
+ "padding": null,
272
+ "right": null,
273
+ "top": null,
274
+ "visibility": null,
275
+ "width": null
276
+ }
277
+ },
278
+ "0eec40171bba48268b176b55e7a85fff": {
279
+ "model_module": "@jupyter-widgets/controls",
280
+ "model_name": "ProgressStyleModel",
281
+ "model_module_version": "1.5.0",
282
+ "state": {
283
+ "_model_module": "@jupyter-widgets/controls",
284
+ "_model_module_version": "1.5.0",
285
+ "_model_name": "ProgressStyleModel",
286
+ "_view_count": null,
287
+ "_view_module": "@jupyter-widgets/base",
288
+ "_view_module_version": "1.2.0",
289
+ "_view_name": "StyleView",
290
+ "bar_color": null,
291
+ "description_width": ""
292
+ }
293
+ },
294
+ "f51b2e545d794ccead531822085f1a2d": {
295
+ "model_module": "@jupyter-widgets/base",
296
+ "model_name": "LayoutModel",
297
+ "model_module_version": "1.2.0",
298
+ "state": {
299
+ "_model_module": "@jupyter-widgets/base",
300
+ "_model_module_version": "1.2.0",
301
+ "_model_name": "LayoutModel",
302
+ "_view_count": null,
303
+ "_view_module": "@jupyter-widgets/base",
304
+ "_view_module_version": "1.2.0",
305
+ "_view_name": "LayoutView",
306
+ "align_content": null,
307
+ "align_items": null,
308
+ "align_self": null,
309
+ "border": null,
310
+ "bottom": null,
311
+ "display": null,
312
+ "flex": null,
313
+ "flex_flow": null,
314
+ "grid_area": null,
315
+ "grid_auto_columns": null,
316
+ "grid_auto_flow": null,
317
+ "grid_auto_rows": null,
318
+ "grid_column": null,
319
+ "grid_gap": null,
320
+ "grid_row": null,
321
+ "grid_template_areas": null,
322
+ "grid_template_columns": null,
323
+ "grid_template_rows": null,
324
+ "height": null,
325
+ "justify_content": null,
326
+ "justify_items": null,
327
+ "left": null,
328
+ "margin": null,
329
+ "max_height": null,
330
+ "max_width": null,
331
+ "min_height": null,
332
+ "min_width": null,
333
+ "object_fit": null,
334
+ "object_position": null,
335
+ "order": null,
336
+ "overflow": null,
337
+ "overflow_x": null,
338
+ "overflow_y": null,
339
+ "padding": null,
340
+ "right": null,
341
+ "top": null,
342
+ "visibility": null,
343
+ "width": null
344
+ }
345
+ },
346
+ "c9840d43284a419face648ce394a8e80": {
347
+ "model_module": "@jupyter-widgets/controls",
348
+ "model_name": "DescriptionStyleModel",
349
+ "model_module_version": "1.5.0",
350
+ "state": {
351
+ "_model_module": "@jupyter-widgets/controls",
352
+ "_model_module_version": "1.5.0",
353
+ "_model_name": "DescriptionStyleModel",
354
+ "_view_count": null,
355
+ "_view_module": "@jupyter-widgets/base",
356
+ "_view_module_version": "1.2.0",
357
+ "_view_name": "StyleView",
358
+ "description_width": ""
359
+ }
360
+ },
361
+ "3039a33537694d60a5321035fd0bbcc5": {
362
+ "model_module": "@jupyter-widgets/controls",
363
+ "model_name": "HBoxModel",
364
+ "model_module_version": "1.5.0",
365
+ "state": {
366
+ "_dom_classes": [],
367
+ "_model_module": "@jupyter-widgets/controls",
368
+ "_model_module_version": "1.5.0",
369
+ "_model_name": "HBoxModel",
370
+ "_view_count": null,
371
+ "_view_module": "@jupyter-widgets/controls",
372
+ "_view_module_version": "1.5.0",
373
+ "_view_name": "HBoxView",
374
+ "box_style": "",
375
+ "children": [
376
+ "IPY_MODEL_082a58bc5d1c4b9e902384a7aa8357c7",
377
+ "IPY_MODEL_e78bfb57ba894a1790129b747a280176",
378
+ "IPY_MODEL_6a7ece36105542e59a308b16c13c1a47"
379
+ ],
380
+ "layout": "IPY_MODEL_57a79b4c6aca4dd7b861d736b7181d5f"
381
+ }
382
+ },
383
+ "082a58bc5d1c4b9e902384a7aa8357c7": {
384
+ "model_module": "@jupyter-widgets/controls",
385
+ "model_name": "HTMLModel",
386
+ "model_module_version": "1.5.0",
387
+ "state": {
388
+ "_dom_classes": [],
389
+ "_model_module": "@jupyter-widgets/controls",
390
+ "_model_module_version": "1.5.0",
391
+ "_model_name": "HTMLModel",
392
+ "_view_count": null,
393
+ "_view_module": "@jupyter-widgets/controls",
394
+ "_view_module_version": "1.5.0",
395
+ "_view_name": "HTMLView",
396
+ "description": "",
397
+ "description_tooltip": null,
398
+ "layout": "IPY_MODEL_f11c9bb9afb245cc8141f1fd606ba659",
399
+ "placeholder": "​",
400
+ "style": "IPY_MODEL_508c726834b54f1b8605d2319d0fdcc0",
401
+ "value": "Generating embeddings: 100%"
402
+ }
403
+ },
404
+ "e78bfb57ba894a1790129b747a280176": {
405
+ "model_module": "@jupyter-widgets/controls",
406
+ "model_name": "FloatProgressModel",
407
+ "model_module_version": "1.5.0",
408
+ "state": {
409
+ "_dom_classes": [],
410
+ "_model_module": "@jupyter-widgets/controls",
411
+ "_model_module_version": "1.5.0",
412
+ "_model_name": "FloatProgressModel",
413
+ "_view_count": null,
414
+ "_view_module": "@jupyter-widgets/controls",
415
+ "_view_module_version": "1.5.0",
416
+ "_view_name": "ProgressView",
417
+ "bar_style": "success",
418
+ "description": "",
419
+ "description_tooltip": null,
420
+ "layout": "IPY_MODEL_9b16832c651b4be8b53237c8de248661",
421
+ "max": 108,
422
+ "min": 0,
423
+ "orientation": "horizontal",
424
+ "style": "IPY_MODEL_0db958902d654bcc8cd5dd922335a017",
425
+ "value": 108
426
+ }
427
+ },
428
+ "6a7ece36105542e59a308b16c13c1a47": {
429
+ "model_module": "@jupyter-widgets/controls",
430
+ "model_name": "HTMLModel",
431
+ "model_module_version": "1.5.0",
432
+ "state": {
433
+ "_dom_classes": [],
434
+ "_model_module": "@jupyter-widgets/controls",
435
+ "_model_module_version": "1.5.0",
436
+ "_model_name": "HTMLModel",
437
+ "_view_count": null,
438
+ "_view_module": "@jupyter-widgets/controls",
439
+ "_view_module_version": "1.5.0",
440
+ "_view_name": "HTMLView",
441
+ "description": "",
442
+ "description_tooltip": null,
443
+ "layout": "IPY_MODEL_afe9cbdfd8814f6281d3b3757c528110",
444
+ "placeholder": "​",
445
+ "style": "IPY_MODEL_9581c6ec8da8419e8d95a00932060fed",
446
+ "value": " 108/108 [00:01<00:00, 96.77it/s]"
447
+ }
448
+ },
449
+ "57a79b4c6aca4dd7b861d736b7181d5f": {
450
+ "model_module": "@jupyter-widgets/base",
451
+ "model_name": "LayoutModel",
452
+ "model_module_version": "1.2.0",
453
+ "state": {
454
+ "_model_module": "@jupyter-widgets/base",
455
+ "_model_module_version": "1.2.0",
456
+ "_model_name": "LayoutModel",
457
+ "_view_count": null,
458
+ "_view_module": "@jupyter-widgets/base",
459
+ "_view_module_version": "1.2.0",
460
+ "_view_name": "LayoutView",
461
+ "align_content": null,
462
+ "align_items": null,
463
+ "align_self": null,
464
+ "border": null,
465
+ "bottom": null,
466
+ "display": null,
467
+ "flex": null,
468
+ "flex_flow": null,
469
+ "grid_area": null,
470
+ "grid_auto_columns": null,
471
+ "grid_auto_flow": null,
472
+ "grid_auto_rows": null,
473
+ "grid_column": null,
474
+ "grid_gap": null,
475
+ "grid_row": null,
476
+ "grid_template_areas": null,
477
+ "grid_template_columns": null,
478
+ "grid_template_rows": null,
479
+ "height": null,
480
+ "justify_content": null,
481
+ "justify_items": null,
482
+ "left": null,
483
+ "margin": null,
484
+ "max_height": null,
485
+ "max_width": null,
486
+ "min_height": null,
487
+ "min_width": null,
488
+ "object_fit": null,
489
+ "object_position": null,
490
+ "order": null,
491
+ "overflow": null,
492
+ "overflow_x": null,
493
+ "overflow_y": null,
494
+ "padding": null,
495
+ "right": null,
496
+ "top": null,
497
+ "visibility": null,
498
+ "width": null
499
+ }
500
+ },
501
+ "f11c9bb9afb245cc8141f1fd606ba659": {
502
+ "model_module": "@jupyter-widgets/base",
503
+ "model_name": "LayoutModel",
504
+ "model_module_version": "1.2.0",
505
+ "state": {
506
+ "_model_module": "@jupyter-widgets/base",
507
+ "_model_module_version": "1.2.0",
508
+ "_model_name": "LayoutModel",
509
+ "_view_count": null,
510
+ "_view_module": "@jupyter-widgets/base",
511
+ "_view_module_version": "1.2.0",
512
+ "_view_name": "LayoutView",
513
+ "align_content": null,
514
+ "align_items": null,
515
+ "align_self": null,
516
+ "border": null,
517
+ "bottom": null,
518
+ "display": null,
519
+ "flex": null,
520
+ "flex_flow": null,
521
+ "grid_area": null,
522
+ "grid_auto_columns": null,
523
+ "grid_auto_flow": null,
524
+ "grid_auto_rows": null,
525
+ "grid_column": null,
526
+ "grid_gap": null,
527
+ "grid_row": null,
528
+ "grid_template_areas": null,
529
+ "grid_template_columns": null,
530
+ "grid_template_rows": null,
531
+ "height": null,
532
+ "justify_content": null,
533
+ "justify_items": null,
534
+ "left": null,
535
+ "margin": null,
536
+ "max_height": null,
537
+ "max_width": null,
538
+ "min_height": null,
539
+ "min_width": null,
540
+ "object_fit": null,
541
+ "object_position": null,
542
+ "order": null,
543
+ "overflow": null,
544
+ "overflow_x": null,
545
+ "overflow_y": null,
546
+ "padding": null,
547
+ "right": null,
548
+ "top": null,
549
+ "visibility": null,
550
+ "width": null
551
+ }
552
+ },
553
+ "508c726834b54f1b8605d2319d0fdcc0": {
554
+ "model_module": "@jupyter-widgets/controls",
555
+ "model_name": "DescriptionStyleModel",
556
+ "model_module_version": "1.5.0",
557
+ "state": {
558
+ "_model_module": "@jupyter-widgets/controls",
559
+ "_model_module_version": "1.5.0",
560
+ "_model_name": "DescriptionStyleModel",
561
+ "_view_count": null,
562
+ "_view_module": "@jupyter-widgets/base",
563
+ "_view_module_version": "1.2.0",
564
+ "_view_name": "StyleView",
565
+ "description_width": ""
566
+ }
567
+ },
568
+ "9b16832c651b4be8b53237c8de248661": {
569
+ "model_module": "@jupyter-widgets/base",
570
+ "model_name": "LayoutModel",
571
+ "model_module_version": "1.2.0",
572
+ "state": {
573
+ "_model_module": "@jupyter-widgets/base",
574
+ "_model_module_version": "1.2.0",
575
+ "_model_name": "LayoutModel",
576
+ "_view_count": null,
577
+ "_view_module": "@jupyter-widgets/base",
578
+ "_view_module_version": "1.2.0",
579
+ "_view_name": "LayoutView",
580
+ "align_content": null,
581
+ "align_items": null,
582
+ "align_self": null,
583
+ "border": null,
584
+ "bottom": null,
585
+ "display": null,
586
+ "flex": null,
587
+ "flex_flow": null,
588
+ "grid_area": null,
589
+ "grid_auto_columns": null,
590
+ "grid_auto_flow": null,
591
+ "grid_auto_rows": null,
592
+ "grid_column": null,
593
+ "grid_gap": null,
594
+ "grid_row": null,
595
+ "grid_template_areas": null,
596
+ "grid_template_columns": null,
597
+ "grid_template_rows": null,
598
+ "height": null,
599
+ "justify_content": null,
600
+ "justify_items": null,
601
+ "left": null,
602
+ "margin": null,
603
+ "max_height": null,
604
+ "max_width": null,
605
+ "min_height": null,
606
+ "min_width": null,
607
+ "object_fit": null,
608
+ "object_position": null,
609
+ "order": null,
610
+ "overflow": null,
611
+ "overflow_x": null,
612
+ "overflow_y": null,
613
+ "padding": null,
614
+ "right": null,
615
+ "top": null,
616
+ "visibility": null,
617
+ "width": null
618
+ }
619
+ },
620
+ "0db958902d654bcc8cd5dd922335a017": {
621
+ "model_module": "@jupyter-widgets/controls",
622
+ "model_name": "ProgressStyleModel",
623
+ "model_module_version": "1.5.0",
624
+ "state": {
625
+ "_model_module": "@jupyter-widgets/controls",
626
+ "_model_module_version": "1.5.0",
627
+ "_model_name": "ProgressStyleModel",
628
+ "_view_count": null,
629
+ "_view_module": "@jupyter-widgets/base",
630
+ "_view_module_version": "1.2.0",
631
+ "_view_name": "StyleView",
632
+ "bar_color": null,
633
+ "description_width": ""
634
+ }
635
+ },
636
+ "afe9cbdfd8814f6281d3b3757c528110": {
637
+ "model_module": "@jupyter-widgets/base",
638
+ "model_name": "LayoutModel",
639
+ "model_module_version": "1.2.0",
640
+ "state": {
641
+ "_model_module": "@jupyter-widgets/base",
642
+ "_model_module_version": "1.2.0",
643
+ "_model_name": "LayoutModel",
644
+ "_view_count": null,
645
+ "_view_module": "@jupyter-widgets/base",
646
+ "_view_module_version": "1.2.0",
647
+ "_view_name": "LayoutView",
648
+ "align_content": null,
649
+ "align_items": null,
650
+ "align_self": null,
651
+ "border": null,
652
+ "bottom": null,
653
+ "display": null,
654
+ "flex": null,
655
+ "flex_flow": null,
656
+ "grid_area": null,
657
+ "grid_auto_columns": null,
658
+ "grid_auto_flow": null,
659
+ "grid_auto_rows": null,
660
+ "grid_column": null,
661
+ "grid_gap": null,
662
+ "grid_row": null,
663
+ "grid_template_areas": null,
664
+ "grid_template_columns": null,
665
+ "grid_template_rows": null,
666
+ "height": null,
667
+ "justify_content": null,
668
+ "justify_items": null,
669
+ "left": null,
670
+ "margin": null,
671
+ "max_height": null,
672
+ "max_width": null,
673
+ "min_height": null,
674
+ "min_width": null,
675
+ "object_fit": null,
676
+ "object_position": null,
677
+ "order": null,
678
+ "overflow": null,
679
+ "overflow_x": null,
680
+ "overflow_y": null,
681
+ "padding": null,
682
+ "right": null,
683
+ "top": null,
684
+ "visibility": null,
685
+ "width": null
686
+ }
687
+ },
688
+ "9581c6ec8da8419e8d95a00932060fed": {
689
+ "model_module": "@jupyter-widgets/controls",
690
+ "model_name": "DescriptionStyleModel",
691
+ "model_module_version": "1.5.0",
692
+ "state": {
693
+ "_model_module": "@jupyter-widgets/controls",
694
+ "_model_module_version": "1.5.0",
695
+ "_model_name": "DescriptionStyleModel",
696
+ "_view_count": null,
697
+ "_view_module": "@jupyter-widgets/base",
698
+ "_view_module_version": "1.2.0",
699
+ "_view_name": "StyleView",
700
+ "description_width": ""
701
+ }
702
+ }
703
+ }
704
+ }
705
+ },
706
+ "cells": [
707
+ {
708
+ "cell_type": "markdown",
709
+ "metadata": {
710
+ "id": "view-in-github",
711
+ "colab_type": "text"
712
+ },
713
+ "source": [
714
+ "<a href=\"https://colab.research.google.com/github/towardsai/ai-tutor-rag-system/blob/main/notebooks/Metadata_Filtering.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
715
+ ]
716
+ },
717
+ {
718
+ "cell_type": "markdown",
719
+ "source": [
720
+ "# Install Packages and Setup Variables"
721
+ ],
722
+ "metadata": {
723
+ "id": "-zE1h0uQV7uT"
724
+ }
725
+ },
726
+ {
727
+ "cell_type": "code",
728
+ "execution_count": 1,
729
+ "metadata": {
730
+ "id": "QPJzr-I9XQ7l",
731
+ "colab": {
732
+ "base_uri": "https://localhost:8080/"
733
+ },
734
+ "outputId": "7cbbde9d-7340-4fdc-b02e-e1cca0c785a5"
735
+ },
736
+ "outputs": [
737
+ {
738
+ "output_type": "stream",
739
+ "name": "stdout",
740
+ "text": [
741
+ "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/226.7 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━\u001b[0m\u001b[90mβ•Ί\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.2/226.7 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91mβ•Έ\u001b[0m \u001b[32m225.3/226.7 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m226.7/226.7 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
742
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m509.0/509.0 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
743
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
744
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.0/13.0 MB\u001b[0m \u001b[31m36.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
745
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m15.4/15.4 MB\u001b[0m \u001b[31m58.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
746
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m59.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
747
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m7.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
748
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m55.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
749
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.0/92.0 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
750
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.4/62.4 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
751
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.3/41.3 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
752
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.4/5.4 MB\u001b[0m \u001b[31m59.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
753
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.8/6.8 MB\u001b[0m \u001b[31m32.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
754
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.9/59.9 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
755
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.0/107.0 kB\u001b[0m \u001b[31m12.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
756
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
757
+ "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
758
+ " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
759
+ " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
760
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m283.7/283.7 kB\u001b[0m \u001b[31m19.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
761
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m60.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
762
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.6/67.6 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
763
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m254.1/254.1 kB\u001b[0m \u001b[31m28.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
764
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.9/71.9 kB\u001b[0m \u001b[31m9.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
765
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.6/53.6 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
766
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.1/141.1 kB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
767
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m11.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
768
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
769
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.8/130.8 kB\u001b[0m \u001b[31m15.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
770
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m17.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
771
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m290.4/290.4 kB\u001b[0m \u001b[31m26.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
772
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
773
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m52.5/52.5 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
774
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.5/130.5 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
775
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.3/2.3 MB\u001b[0m \u001b[31m47.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
776
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.4/341.4 kB\u001b[0m \u001b[31m33.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
777
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m88.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
778
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m68.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
779
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m17.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
780
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m33.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
781
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.3/2.3 MB\u001b[0m \u001b[31m80.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
782
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.3/2.3 MB\u001b[0m \u001b[31m85.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
783
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.8/2.8 MB\u001b[0m \u001b[31m86.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
784
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m294.6/294.6 kB\u001b[0m \u001b[31m31.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
785
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.5/57.5 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
786
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m10.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
787
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.2/49.2 kB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
788
+ "\u001b[?25h Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
789
+ "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
790
+ "google-colab 1.0.0 requires pandas==2.0.3, but you have pandas 2.2.0 which is incompatible.\n",
791
+ "tensorflow-metadata 1.15.0 requires protobuf<4.21,>=3.20.3; python_version < \"3.11\", but you have protobuf 4.25.3 which is incompatible.\u001b[0m\u001b[31m\n",
792
+ "\u001b[0m"
793
+ ]
794
+ }
795
+ ],
796
+ "source": [
797
+ "!pip install -q llama-index==0.10.37 openai==1.12.0 chromadb==0.4.22 llama-index-vector-stores-chroma==0.1.7 tiktoken==0.6.0 pandas==2.2.0 llama-index-vector-stores-qdrant==0.2.10"
798
+ ]
799
+ },
800
+ {
801
+ "cell_type": "code",
802
+ "source": [
803
+ "import os\n",
804
+ "\n",
805
+ "# Set the \"OPENAI_API_KEY\" in the Python environment. Will be used by OpenAI client later.\n",
806
+ "os.environ[\"OPENAI_API_KEY\"] = \"[YOUR_OPENAI_KEY]\""
807
+ ],
808
+ "metadata": {
809
+ "id": "riuXwpSPcvWC"
810
+ },
811
+ "execution_count": 2,
812
+ "outputs": []
813
+ },
814
+ {
815
+ "cell_type": "code",
816
+ "source": [
817
+ "import nest_asyncio\n",
818
+ "\n",
819
+ "nest_asyncio.apply()"
820
+ ],
821
+ "metadata": {
822
+ "id": "jIEeZzqLbz0J"
823
+ },
824
+ "execution_count": 3,
825
+ "outputs": []
826
+ },
827
+ {
828
+ "cell_type": "markdown",
829
+ "source": [
830
+ "# Load a Model"
831
+ ],
832
+ "metadata": {
833
+ "id": "Bkgi2OrYzF7q"
834
+ }
835
+ },
836
+ {
837
+ "cell_type": "code",
838
+ "source": [
839
+ "from llama_index.llms.openai import OpenAI\n",
840
+ "\n",
841
+ "llm = OpenAI(temperature=0.9, model=\"gpt-4o\", max_tokens=512)"
842
+ ],
843
+ "metadata": {
844
+ "id": "9oGT6crooSSj"
845
+ },
846
+ "execution_count": 4,
847
+ "outputs": []
848
+ },
849
+ {
850
+ "cell_type": "markdown",
851
+ "source": [
852
+ "# Create a VectoreStore"
853
+ ],
854
+ "metadata": {
855
+ "id": "0BwVuJXlzHVL"
856
+ }
857
+ },
858
+ {
859
+ "cell_type": "code",
860
+ "source": [
861
+ "import qdrant_client\n",
862
+ "from llama_index.core import VectorStoreIndex\n",
863
+ "from llama_index.vector_stores.qdrant import QdrantVectorStore\n",
864
+ "\n",
865
+ "qdrant_client = qdrant_client.QdrantClient(location=\":memory:\")"
866
+ ],
867
+ "metadata": {
868
+ "id": "aNY6mrk6BF7V"
869
+ },
870
+ "execution_count": 5,
871
+ "outputs": []
872
+ },
873
+ {
874
+ "cell_type": "code",
875
+ "source": [
876
+ "vector_store = QdrantVectorStore(\n",
877
+ " client=qdrant_client, collection_name=\"mini-llama-articles\"\n",
878
+ ")"
879
+ ],
880
+ "metadata": {
881
+ "id": "Z109ur9OC7U_"
882
+ },
883
+ "execution_count": 6,
884
+ "outputs": []
885
+ },
886
+ {
887
+ "cell_type": "markdown",
888
+ "source": [
889
+ "# Load the Dataset (CSV)"
890
+ ],
891
+ "metadata": {
892
+ "id": "I9JbAzFcjkpn"
893
+ }
894
+ },
895
+ {
896
+ "cell_type": "markdown",
897
+ "source": [
898
+ "## Download"
899
+ ],
900
+ "metadata": {
901
+ "id": "ceveDuYdWCYk"
902
+ }
903
+ },
904
+ {
905
+ "cell_type": "markdown",
906
+ "source": [
907
+ "The dataset includes several articles from the TowardsAI blog, which provide an in-depth explanation of the LLaMA2 model. Read the dataset as a long string."
908
+ ],
909
+ "metadata": {
910
+ "id": "eZwf6pv7WFmD"
911
+ }
912
+ },
913
+ {
914
+ "cell_type": "code",
915
+ "source": [
916
+ "!wget https://raw.githubusercontent.com/AlaFalaki/tutorial_notebooks/main/data/mini-llama-articles.csv"
917
+ ],
918
+ "metadata": {
919
+ "colab": {
920
+ "base_uri": "https://localhost:8080/"
921
+ },
922
+ "id": "wl_pbPvMlv1h",
923
+ "outputId": "70f543d9-5adb-49ce-cfea-2697f2f67582"
924
+ },
925
+ "execution_count": 7,
926
+ "outputs": [
927
+ {
928
+ "output_type": "stream",
929
+ "name": "stdout",
930
+ "text": [
931
+ "--2024-07-03 19:38:17-- https://raw.githubusercontent.com/AlaFalaki/tutorial_notebooks/main/data/mini-llama-articles.csv\n",
932
+ "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.110.133, ...\n",
933
+ "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.\n",
934
+ "HTTP request sent, awaiting response... 200 OK\n",
935
+ "Length: 173646 (170K) [text/plain]\n",
936
+ "Saving to: β€˜mini-llama-articles.csv’\n",
937
+ "\n",
938
+ "\rmini-llama-articles 0%[ ] 0 --.-KB/s \rmini-llama-articles 100%[===================>] 169.58K --.-KB/s in 0.02s \n",
939
+ "\n",
940
+ "2024-07-03 19:38:17 (6.99 MB/s) - β€˜mini-llama-articles.csv’ saved [173646/173646]\n",
941
+ "\n"
942
+ ]
943
+ }
944
+ ]
945
+ },
946
+ {
947
+ "cell_type": "markdown",
948
+ "source": [
949
+ "## Read File"
950
+ ],
951
+ "metadata": {
952
+ "id": "VWBLtDbUWJfA"
953
+ }
954
+ },
955
+ {
956
+ "cell_type": "code",
957
+ "source": [
958
+ "import csv\n",
959
+ "\n",
960
+ "rows = []\n",
961
+ "\n",
962
+ "# Load the file as a JSON\n",
963
+ "with open(\"./mini-llama-articles.csv\", mode=\"r\", encoding=\"utf-8\") as file:\n",
964
+ " csv_reader = csv.reader(file)\n",
965
+ "\n",
966
+ " for idx, row in enumerate( csv_reader ):\n",
967
+ " if idx == 0: continue; # Skip header row\n",
968
+ " rows.append( row )\n",
969
+ "\n",
970
+ "# The number of characters in the dataset.\n",
971
+ "len( rows )"
972
+ ],
973
+ "metadata": {
974
+ "id": "0Q9sxuW0g3Gd",
975
+ "colab": {
976
+ "base_uri": "https://localhost:8080/"
977
+ },
978
+ "outputId": "e5942cc4-db86-435d-aa1e-e50872c54978"
979
+ },
980
+ "execution_count": 8,
981
+ "outputs": [
982
+ {
983
+ "output_type": "execute_result",
984
+ "data": {
985
+ "text/plain": [
986
+ "14"
987
+ ]
988
+ },
989
+ "metadata": {},
990
+ "execution_count": 8
991
+ }
992
+ ]
993
+ },
994
+ {
995
+ "cell_type": "markdown",
996
+ "source": [
997
+ "# Convert to Document obj"
998
+ ],
999
+ "metadata": {
1000
+ "id": "S17g2RYOjmf2"
1001
+ }
1002
+ },
1003
+ {
1004
+ "cell_type": "code",
1005
+ "source": [
1006
+ "from llama_index.core.schema import Document\n",
1007
+ "\n",
1008
+ "# Convert the chunks to Document objects so the LlamaIndex framework can process them.\n",
1009
+ "documents = [Document(text=row[1], metadata={\"title\": row[0], \"url\": row[2], \"source_name\": row[3]}) for row in rows]"
1010
+ ],
1011
+ "metadata": {
1012
+ "id": "YizvmXPejkJE"
1013
+ },
1014
+ "execution_count": 9,
1015
+ "outputs": []
1016
+ },
1017
+ {
1018
+ "cell_type": "markdown",
1019
+ "source": [
1020
+ "# Transforming"
1021
+ ],
1022
+ "metadata": {
1023
+ "id": "qjuLbmFuWsyl"
1024
+ }
1025
+ },
1026
+ {
1027
+ "cell_type": "code",
1028
+ "source": [
1029
+ "from llama_index.core.node_parser import TokenTextSplitter\n",
1030
+ "\n",
1031
+ "# Define the splitter object that split the text into segments with 512 tokens,\n",
1032
+ "# with a 128 overlap between the segments.\n",
1033
+ "text_splitter = TokenTextSplitter(\n",
1034
+ " separator=\" \", chunk_size=512, chunk_overlap=128\n",
1035
+ ")"
1036
+ ],
1037
+ "metadata": {
1038
+ "id": "9z3t70DGWsjO"
1039
+ },
1040
+ "execution_count": 10,
1041
+ "outputs": []
1042
+ },
1043
+ {
1044
+ "cell_type": "code",
1045
+ "source": [
1046
+ "from llama_index.core.extractors import (\n",
1047
+ " KeywordExtractor,\n",
1048
+ ")\n",
1049
+ "from llama_index.embeddings.openai import OpenAIEmbedding\n",
1050
+ "from llama_index.core.ingestion import IngestionPipeline\n",
1051
+ "\n",
1052
+ "# Create the pipeline to apply the transformation on each chunk,\n",
1053
+ "# and store the transformed text in the chroma vector store.\n",
1054
+ "pipeline = IngestionPipeline(\n",
1055
+ " transformations=[\n",
1056
+ " text_splitter,\n",
1057
+ " KeywordExtractor(keywords=15, llm=llm),\n",
1058
+ " OpenAIEmbedding(),\n",
1059
+ " ],\n",
1060
+ " vector_store=vector_store\n",
1061
+ ")\n",
1062
+ "\n",
1063
+ "# Run the transformation pipeline.\n",
1064
+ "nodes = pipeline.run(documents=documents, show_progress=True);"
1065
+ ],
1066
+ "metadata": {
1067
+ "colab": {
1068
+ "base_uri": "https://localhost:8080/",
1069
+ "height": 116,
1070
+ "referenced_widgets": [
1071
+ "1350b1f2c9df4113bde94c59ad0db010",
1072
+ "7f3d8a3d4f614b4d99b048c021c1615c",
1073
+ "bf68ea9156ea438da61f8ca1fc529f7d",
1074
+ "1fd460ecbf644d049ed1faf88322649f",
1075
+ "36f78ffa8f9847149c5cab414fac1226",
1076
+ "0862d91ad42b48e4b0de4997aa3a1dd8",
1077
+ "277704b916aa40759b6db36688d1d151",
1078
+ "2f3166628904417f97438e7c852f3b82",
1079
+ "0eec40171bba48268b176b55e7a85fff",
1080
+ "f51b2e545d794ccead531822085f1a2d",
1081
+ "c9840d43284a419face648ce394a8e80",
1082
+ "3039a33537694d60a5321035fd0bbcc5",
1083
+ "082a58bc5d1c4b9e902384a7aa8357c7",
1084
+ "e78bfb57ba894a1790129b747a280176",
1085
+ "6a7ece36105542e59a308b16c13c1a47",
1086
+ "57a79b4c6aca4dd7b861d736b7181d5f",
1087
+ "f11c9bb9afb245cc8141f1fd606ba659",
1088
+ "508c726834b54f1b8605d2319d0fdcc0",
1089
+ "9b16832c651b4be8b53237c8de248661",
1090
+ "0db958902d654bcc8cd5dd922335a017",
1091
+ "afe9cbdfd8814f6281d3b3757c528110",
1092
+ "9581c6ec8da8419e8d95a00932060fed"
1093
+ ]
1094
+ },
1095
+ "id": "P9LDJ7o-Wsc-",
1096
+ "outputId": "8fcb2a02-6322-40d8-9852-2b2814b6b9c6"
1097
+ },
1098
+ "execution_count": 11,
1099
+ "outputs": [
1100
+ {
1101
+ "output_type": "display_data",
1102
+ "data": {
1103
+ "text/plain": [
1104
+ "Parsing nodes: 0%| | 0/14 [00:00<?, ?it/s]"
1105
+ ],
1106
+ "application/vnd.jupyter.widget-view+json": {
1107
+ "version_major": 2,
1108
+ "version_minor": 0,
1109
+ "model_id": "1350b1f2c9df4113bde94c59ad0db010"
1110
+ }
1111
+ },
1112
+ "metadata": {}
1113
+ },
1114
+ {
1115
+ "output_type": "stream",
1116
+ "name": "stderr",
1117
+ "text": [
1118
+ "100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 108/108 [00:35<00:00, 3.07it/s]\n"
1119
+ ]
1120
+ },
1121
+ {
1122
+ "output_type": "display_data",
1123
+ "data": {
1124
+ "text/plain": [
1125
+ "Generating embeddings: 0%| | 0/108 [00:00<?, ?it/s]"
1126
+ ],
1127
+ "application/vnd.jupyter.widget-view+json": {
1128
+ "version_major": 2,
1129
+ "version_minor": 0,
1130
+ "model_id": "3039a33537694d60a5321035fd0bbcc5"
1131
+ }
1132
+ },
1133
+ "metadata": {}
1134
+ },
1135
+ {
1136
+ "output_type": "stream",
1137
+ "name": "stderr",
1138
+ "text": [
1139
+ "WARNING:root:Payload indexes have no effect in the local Qdrant. Please use server Qdrant if you need payload indexes.\n"
1140
+ ]
1141
+ }
1142
+ ]
1143
+ },
1144
+ {
1145
+ "cell_type": "code",
1146
+ "source": [
1147
+ "len( nodes )"
1148
+ ],
1149
+ "metadata": {
1150
+ "colab": {
1151
+ "base_uri": "https://localhost:8080/"
1152
+ },
1153
+ "id": "mPGa85hM2P3P",
1154
+ "outputId": "6c176992-8405-4702-a1e5-c27c975b29c2"
1155
+ },
1156
+ "execution_count": 12,
1157
+ "outputs": [
1158
+ {
1159
+ "output_type": "execute_result",
1160
+ "data": {
1161
+ "text/plain": [
1162
+ "108"
1163
+ ]
1164
+ },
1165
+ "metadata": {},
1166
+ "execution_count": 12
1167
+ }
1168
+ ]
1169
+ },
1170
+ {
1171
+ "cell_type": "code",
1172
+ "source": [
1173
+ "from llama_index.core import VectorStoreIndex\n",
1174
+ "\n",
1175
+ "# Create the index based on the vector store.\n",
1176
+ "index = VectorStoreIndex.from_vector_store(vector_store)"
1177
+ ],
1178
+ "metadata": {
1179
+ "id": "jKXURvLtkuTS"
1180
+ },
1181
+ "execution_count": 13,
1182
+ "outputs": []
1183
+ },
1184
+ {
1185
+ "cell_type": "markdown",
1186
+ "source": [
1187
+ "# Metadata Filtering"
1188
+ ],
1189
+ "metadata": {
1190
+ "id": "RyL-j2xZ7V6d"
1191
+ }
1192
+ },
1193
+ {
1194
+ "cell_type": "code",
1195
+ "source": [
1196
+ "from llama_index.core.vector_stores import (\n",
1197
+ " MetadataFilter,\n",
1198
+ " MetadataFilters,\n",
1199
+ " FilterOperator,\n",
1200
+ ")\n",
1201
+ "\n",
1202
+ "filters = MetadataFilters(\n",
1203
+ " filters=[\n",
1204
+ " MetadataFilter(key=\"excerpt_keywords\", operator=FilterOperator.TEXT_MATCH, value=\"model sizes\"),\n",
1205
+ " ]\n",
1206
+ ")"
1207
+ ],
1208
+ "metadata": {
1209
+ "id": "saug9jxugX0P"
1210
+ },
1211
+ "execution_count": 17,
1212
+ "outputs": []
1213
+ },
1214
+ {
1215
+ "cell_type": "markdown",
1216
+ "source": [
1217
+ "# Query Dataset"
1218
+ ],
1219
+ "metadata": {
1220
+ "id": "8JPD8yAinVSq"
1221
+ }
1222
+ },
1223
+ {
1224
+ "cell_type": "code",
1225
+ "source": [
1226
+ "# Define a query engine that is responsible for retrieving related pieces of text,\n",
1227
+ "# and using a LLM to formulate the final answer.\n",
1228
+ "query_engine = index.as_query_engine(filters=filters)\n",
1229
+ "\n",
1230
+ "res = query_engine.query(\"How many parameters LLaMA2 model has?\")"
1231
+ ],
1232
+ "metadata": {
1233
+ "id": "b0gue7cyctt1"
1234
+ },
1235
+ "execution_count": 18,
1236
+ "outputs": []
1237
+ },
1238
+ {
1239
+ "cell_type": "code",
1240
+ "source": [
1241
+ "res.response"
1242
+ ],
1243
+ "metadata": {
1244
+ "colab": {
1245
+ "base_uri": "https://localhost:8080/",
1246
+ "height": 35
1247
+ },
1248
+ "id": "VKK3jMprctre",
1249
+ "outputId": "f3dd8dd1-9c56-453c-a773-2a03c34981cf"
1250
+ },
1251
+ "execution_count": 19,
1252
+ "outputs": [
1253
+ {
1254
+ "output_type": "execute_result",
1255
+ "data": {
1256
+ "text/plain": [
1257
+ "'The Llama 2 model is available in four different sizes: 7 billion, 13 billion, 34 billion, and 70 billion parameters.'"
1258
+ ],
1259
+ "application/vnd.google.colaboratory.intrinsic+json": {
1260
+ "type": "string"
1261
+ }
1262
+ },
1263
+ "metadata": {},
1264
+ "execution_count": 19
1265
+ }
1266
+ ]
1267
+ },
1268
+ {
1269
+ "cell_type": "code",
1270
+ "source": [
1271
+ "# Show the retrieved nodes\n",
1272
+ "for src in res.source_nodes:\n",
1273
+ " print(\"Node ID\\t\", src.node_id)\n",
1274
+ " print(\"Title\\t\", src.metadata['title'])\n",
1275
+ " print(\"Text\\t\", src.text)\n",
1276
+ " print(\"Score\\t\", src.score)\n",
1277
+ " print(\"Score\\t\", src.metadata['excerpt_keywords'])\n",
1278
+ " print(\"-_\"*20)"
1279
+ ],
1280
+ "metadata": {
1281
+ "colab": {
1282
+ "base_uri": "https://localhost:8080/"
1283
+ },
1284
+ "id": "465dH4yQc7Ct",
1285
+ "outputId": "08479590-8442-48ad-b8a6-17edb7286a9b"
1286
+ },
1287
+ "execution_count": 20,
1288
+ "outputs": [
1289
+ {
1290
+ "output_type": "stream",
1291
+ "name": "stdout",
1292
+ "text": [
1293
+ "Node ID\t d72d9158-7f90-4161-8a1f-f8e0b7eebafa\n",
1294
+ "Title\t Meta's Llama 2: Revolutionizing Open Source Language Models for Commercial Use\n",
1295
+ "Text\t I. Llama 2: Revolutionizing Commercial Use Unlike its predecessor Llama 1, which was limited to research use, Llama 2 represents a major advancement as an open-source commercial model. Businesses can now integrate Llama 2 into products to create AI-powered applications. Availability on Azure and AWS facilitates fine-tuning and adoption. However, restrictions apply to prevent exploitation. Companies with over 700 million active daily users cannot use Llama 2. Additionally, its output cannot be used to improve other language models. II. Llama 2 Model Flavors Llama 2 is available in four different model sizes: 7 billion, 13 billion, 34 billion, and 70 billion parameters. While 7B, 13B, and 70B have already been released, the 34B model is still awaited. The pretrained variant, trained on a whopping 2 trillion tokens, boasts a context window of 4096 tokens, twice the size of its predecessor Llama 1. Meta also released a Llama 2 fine-tuned model for chat applications that was trained on over 1 million human annotations. Such extensive training comes at a cost, with the 70B model taking a staggering 1720320 GPU hours to train. The context window's length determines the amount of content the model can process at once, making Llama 2 a powerful language model in terms of scale and efficiency. III. Safety Considerations: A Top Priority for Meta Meta's commitment to safety and alignment shines through in Llama 2's design. The model demonstrates exceptionally low AI safety violation percentages, surpassing even ChatGPT in safety benchmarks. Finding the right balance between helpfulness and safety when optimizing a model poses significant challenges. While a highly helpful model may be capable of answering any question, including sensitive ones like \"How do I build a bomb?\", it also raises concerns about potential misuse. Thus, striking the perfect equilibrium between providing useful information and ensuring safety is paramount. However, prioritizing safety to an extreme extent can lead to a model that struggles to effectively address a diverse range of questions. This limitation could hinder the model's practical applicability and user experience. Thus, achieving\n",
1296
+ "Score\t 0.8345635869646741\n",
1297
+ "Score\t Keywords: Llama 2, Meta, open-source, commercial use, Azure, AWS, fine-tuning, model sizes, 7 billion parameters, 70 billion parameters, context window, AI safety, human annotations, language models, practical applicability\n",
1298
+ "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n"
1299
+ ]
1300
+ }
1301
+ ]
1302
+ },
1303
+ {
1304
+ "cell_type": "markdown",
1305
+ "source": [
1306
+ "# Filter Metadata (source_name)"
1307
+ ],
1308
+ "metadata": {
1309
+ "id": "Yjwq8BRzNGUy"
1310
+ }
1311
+ },
1312
+ {
1313
+ "cell_type": "code",
1314
+ "source": [
1315
+ "from llama_index.core.vector_stores import (\n",
1316
+ " MetadataFilter,\n",
1317
+ " MetadataFilters,\n",
1318
+ " FilterOperator,\n",
1319
+ ")\n",
1320
+ "\n",
1321
+ "filters = MetadataFilters(\n",
1322
+ " filters=[\n",
1323
+ " MetadataFilter(key=\"source_name\", operator=FilterOperator.EQ, value=\"towards_ai\"),\n",
1324
+ " ]\n",
1325
+ ")"
1326
+ ],
1327
+ "metadata": {
1328
+ "id": "82mM9wqkM0jr"
1329
+ },
1330
+ "execution_count": 27,
1331
+ "outputs": []
1332
+ },
1333
+ {
1334
+ "cell_type": "code",
1335
+ "source": [
1336
+ "# Define a query engine that is responsible for retrieving related pieces of text,\n",
1337
+ "# and using a LLM to formulate the final answer.\n",
1338
+ "query_engine = index.as_query_engine(filters=filters)\n",
1339
+ "\n",
1340
+ "res = query_engine.query(\"How many parameters LLaMA2 model has?\")"
1341
+ ],
1342
+ "metadata": {
1343
+ "id": "QX4UUuLEM6NK"
1344
+ },
1345
+ "execution_count": 28,
1346
+ "outputs": []
1347
+ },
1348
+ {
1349
+ "cell_type": "code",
1350
+ "source": [
1351
+ "res.response"
1352
+ ],
1353
+ "metadata": {
1354
+ "colab": {
1355
+ "base_uri": "https://localhost:8080/",
1356
+ "height": 35
1357
+ },
1358
+ "id": "mo3_T2fnM7yP",
1359
+ "outputId": "e4802209-9fac-4f3c-b29f-e466b2f6847a"
1360
+ },
1361
+ "execution_count": 29,
1362
+ "outputs": [
1363
+ {
1364
+ "output_type": "execute_result",
1365
+ "data": {
1366
+ "text/plain": [
1367
+ "'The Llama 2 model comes in four different sizes: 7 billion, 13 billion, 34 billion, and 70 billion parameters.'"
1368
+ ],
1369
+ "application/vnd.google.colaboratory.intrinsic+json": {
1370
+ "type": "string"
1371
+ }
1372
+ },
1373
+ "metadata": {},
1374
+ "execution_count": 29
1375
+ }
1376
+ ]
1377
+ },
1378
+ {
1379
+ "cell_type": "code",
1380
+ "source": [
1381
+ "# Show the retrieved nodes\n",
1382
+ "for src in res.source_nodes:\n",
1383
+ " print(\"Node ID\\t\", src.node_id)\n",
1384
+ " print(\"Title\\t\", src.metadata['title'])\n",
1385
+ " print(\"Text\\t\", src.text)\n",
1386
+ " print(\"Score\\t\", src.score)\n",
1387
+ " print(\"Score\\t\", src.metadata['excerpt_keywords'])\n",
1388
+ " print(\"-_\"*20)"
1389
+ ],
1390
+ "metadata": {
1391
+ "colab": {
1392
+ "base_uri": "https://localhost:8080/"
1393
+ },
1394
+ "id": "qxnS44WtM9Dz",
1395
+ "outputId": "711106d5-c919-46dc-af97-a058c367ea92"
1396
+ },
1397
+ "execution_count": 30,
1398
+ "outputs": [
1399
+ {
1400
+ "output_type": "stream",
1401
+ "name": "stdout",
1402
+ "text": [
1403
+ "Node ID\t d72d9158-7f90-4161-8a1f-f8e0b7eebafa\n",
1404
+ "Title\t Meta's Llama 2: Revolutionizing Open Source Language Models for Commercial Use\n",
1405
+ "Text\t I. Llama 2: Revolutionizing Commercial Use Unlike its predecessor Llama 1, which was limited to research use, Llama 2 represents a major advancement as an open-source commercial model. Businesses can now integrate Llama 2 into products to create AI-powered applications. Availability on Azure and AWS facilitates fine-tuning and adoption. However, restrictions apply to prevent exploitation. Companies with over 700 million active daily users cannot use Llama 2. Additionally, its output cannot be used to improve other language models. II. Llama 2 Model Flavors Llama 2 is available in four different model sizes: 7 billion, 13 billion, 34 billion, and 70 billion parameters. While 7B, 13B, and 70B have already been released, the 34B model is still awaited. The pretrained variant, trained on a whopping 2 trillion tokens, boasts a context window of 4096 tokens, twice the size of its predecessor Llama 1. Meta also released a Llama 2 fine-tuned model for chat applications that was trained on over 1 million human annotations. Such extensive training comes at a cost, with the 70B model taking a staggering 1720320 GPU hours to train. The context window's length determines the amount of content the model can process at once, making Llama 2 a powerful language model in terms of scale and efficiency. III. Safety Considerations: A Top Priority for Meta Meta's commitment to safety and alignment shines through in Llama 2's design. The model demonstrates exceptionally low AI safety violation percentages, surpassing even ChatGPT in safety benchmarks. Finding the right balance between helpfulness and safety when optimizing a model poses significant challenges. While a highly helpful model may be capable of answering any question, including sensitive ones like \"How do I build a bomb?\", it also raises concerns about potential misuse. Thus, striking the perfect equilibrium between providing useful information and ensuring safety is paramount. However, prioritizing safety to an extreme extent can lead to a model that struggles to effectively address a diverse range of questions. This limitation could hinder the model's practical applicability and user experience. Thus, achieving\n",
1406
+ "Score\t 0.8345635869646741\n",
1407
+ "Score\t Keywords: Llama 2, Meta, open-source, commercial use, Azure, AWS, fine-tuning, model sizes, 7 billion parameters, 70 billion parameters, context window, AI safety, human annotations, language models, practical applicability\n",
1408
+ "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n",
1409
+ "Node ID\t 1a4b66bc-c302-4a2c-ac41-a606280f346d\n",
1410
+ "Title\t Meta's Llama 2: Revolutionizing Open Source Language Models for Commercial Use\n",
1411
+ "Text\t The model demonstrates exceptionally low AI safety violation percentages, surpassing even ChatGPT in safety benchmarks. Finding the right balance between helpfulness and safety when optimizing a model poses significant challenges. While a highly helpful model may be capable of answering any question, including sensitive ones like \"How do I build a bomb?\", it also raises concerns about potential misuse. Thus, striking the perfect equilibrium between providing useful information and ensuring safety is paramount. However, prioritizing safety to an extreme extent can lead to a model that struggles to effectively address a diverse range of questions. This limitation could hinder the model's practical applicability and user experience. Thus, achieving an optimum balance that allows the model to be both helpful and safe is of utmost importance. To strike the right balance between helpfulness and safety, Meta employed two reward models - one for helpfulness and another for safety - to optimize the model's responses. The 34B parameter model has reported higher safety violations than other variants, possibly contributing to the delay in its release. IV. Helpfulness Comparison: Llama 2 Outperforms Competitors Llama 2 emerges as a strong contender in the open-source language model arena, outperforming its competitors in most categories. The 70B parameter model outperforms all other open-source models, while the 7B and 34B models outshine Falcon in all categories and MPT in all categories except coding. Despite being smaller, Llam a2's performance rivals that of Chat GPT 3.5, a significantly larger closed-source model. While GPT 4 and PalM-2-L, with their larger size, outperform Llama 2, this is expected due to their capacity for handling complex language tasks. Llama 2's impressive ability to compete with larger models highlights its efficiency and potential in the market. However, Llama 2 does face challenges in coding and math problems, where models like Chat GPT 4 excel, given their significantly larger size. Chat GPT 4 performed significantly better than Llama 2 for coding (HumanEval benchmark)and math problem tasks (GSM8k benchmark). Open-source AI technologies, like Llama 2, continue to advance, offering\n",
1412
+ "Score\t 0.8289011325398545\n",
1413
+ "Score\t Keywords: Llama 2, Meta, open-source language model, commercial use, AI safety, helpfulness, safety benchmarks, reward models, 34B parameter model, 70B parameter model, 7B parameter model, performance comparison, coding and math problems, HumanEval benchmark, GSM8k benchmark\n",
1414
+ "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n"
1415
+ ]
1416
+ }
1417
+ ]
1418
+ }
1419
+ ]
1420
+ }