Hendrik05 commited on
Commit
fe46ef0
·
verified ·
1 Parent(s): 980bd32

Upload MovieSearch (1).ipynb

Browse files
Files changed (1) hide show
  1. MovieSearch (1).ipynb +649 -0
MovieSearch (1).ipynb ADDED
@@ -0,0 +1,649 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 29,
6
+ "id": "72e26e1c-3fda-4333-9401-4ee15d1bf3b8",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "model_id = \"sentence-transformers/all-MiniLM-L6-v2\"\n"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 30,
16
+ "id": "68f1d64b-12b2-4d2a-a06a-6a7d35c3a6f5",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "import requests\n",
21
+ "\n",
22
+ "api_url = f\"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}\"\n",
23
+ "headers = {\"Authorization\": f\"Bearer {hf_token}\"}"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 31,
29
+ "id": "aae00acb-6932-4b46-bc99-a542740c0f33",
30
+ "metadata": {},
31
+ "outputs": [],
32
+ "source": [
33
+ "def query(texts):\n",
34
+ " response = requests.post(api_url, headers=headers, json={\"inputs\": texts, \"options\":{\"wait_for_model\":True}})\n",
35
+ " return response.json()"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 48,
41
+ "id": "3955111a-6785-4375-b6cd-126f5bd9afd4",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "\n",
46
+ "import pandas as pd\n",
47
+ "\n",
48
+ "# Pfad zur CSV-Datei\n",
49
+ "file_path = '/Users/I569961/Downloads/imdb_top_1000.csv'\n",
50
+ "\n",
51
+ "# Einlesen der CSV-Datei\n",
52
+ "data = pd.read_csv(file_path)\n",
53
+ "\n",
54
+ "# Konvertieren des DataFrame in einen String\n",
55
+ "data_string = data.to_string()\n",
56
+ "\n",
57
+ "output = query(texts)"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": 41,
63
+ "id": "c5615ec3-2168-420c-9146-77c37b8df8fb",
64
+ "metadata": {},
65
+ "outputs": [
66
+ {
67
+ "data": {
68
+ "text/html": [
69
+ "<div>\n",
70
+ "<style scoped>\n",
71
+ " .dataframe tbody tr th:only-of-type {\n",
72
+ " vertical-align: middle;\n",
73
+ " }\n",
74
+ "\n",
75
+ " .dataframe tbody tr th {\n",
76
+ " vertical-align: top;\n",
77
+ " }\n",
78
+ "\n",
79
+ " .dataframe thead th {\n",
80
+ " text-align: right;\n",
81
+ " }\n",
82
+ "</style>\n",
83
+ "<table border=\"1\" class=\"dataframe\">\n",
84
+ " <thead>\n",
85
+ " <tr style=\"text-align: right;\">\n",
86
+ " <th></th>\n",
87
+ " <th>0</th>\n",
88
+ " <th>1</th>\n",
89
+ " <th>2</th>\n",
90
+ " <th>3</th>\n",
91
+ " <th>4</th>\n",
92
+ " <th>5</th>\n",
93
+ " <th>6</th>\n",
94
+ " <th>7</th>\n",
95
+ " <th>8</th>\n",
96
+ " <th>9</th>\n",
97
+ " <th>...</th>\n",
98
+ " <th>374</th>\n",
99
+ " <th>375</th>\n",
100
+ " <th>376</th>\n",
101
+ " <th>377</th>\n",
102
+ " <th>378</th>\n",
103
+ " <th>379</th>\n",
104
+ " <th>380</th>\n",
105
+ " <th>381</th>\n",
106
+ " <th>382</th>\n",
107
+ " <th>383</th>\n",
108
+ " </tr>\n",
109
+ " </thead>\n",
110
+ " <tbody>\n",
111
+ " <tr>\n",
112
+ " <th>0</th>\n",
113
+ " <td>-0.023889</td>\n",
114
+ " <td>0.055259</td>\n",
115
+ " <td>-0.011655</td>\n",
116
+ " <td>-0.033414</td>\n",
117
+ " <td>-0.012261</td>\n",
118
+ " <td>-0.024873</td>\n",
119
+ " <td>-0.012663</td>\n",
120
+ " <td>0.025346</td>\n",
121
+ " <td>0.018508</td>\n",
122
+ " <td>-0.083508</td>\n",
123
+ " <td>...</td>\n",
124
+ " <td>-0.161688</td>\n",
125
+ " <td>-0.046426</td>\n",
126
+ " <td>0.006004</td>\n",
127
+ " <td>0.005281</td>\n",
128
+ " <td>-0.003342</td>\n",
129
+ " <td>0.027754</td>\n",
130
+ " <td>0.020411</td>\n",
131
+ " <td>0.005778</td>\n",
132
+ " <td>0.034098</td>\n",
133
+ " <td>-0.006889</td>\n",
134
+ " </tr>\n",
135
+ " <tr>\n",
136
+ " <th>1</th>\n",
137
+ " <td>-0.012688</td>\n",
138
+ " <td>0.046874</td>\n",
139
+ " <td>-0.010502</td>\n",
140
+ " <td>-0.020384</td>\n",
141
+ " <td>-0.013361</td>\n",
142
+ " <td>0.042322</td>\n",
143
+ " <td>0.016628</td>\n",
144
+ " <td>-0.004099</td>\n",
145
+ " <td>-0.002607</td>\n",
146
+ " <td>-0.010188</td>\n",
147
+ " <td>...</td>\n",
148
+ " <td>-0.061594</td>\n",
149
+ " <td>-0.020717</td>\n",
150
+ " <td>-0.009082</td>\n",
151
+ " <td>-0.029260</td>\n",
152
+ " <td>-0.066253</td>\n",
153
+ " <td>0.065257</td>\n",
154
+ " <td>0.013229</td>\n",
155
+ " <td>-0.023103</td>\n",
156
+ " <td>-0.002785</td>\n",
157
+ " <td>0.010474</td>\n",
158
+ " </tr>\n",
159
+ " <tr>\n",
160
+ " <th>2</th>\n",
161
+ " <td>0.000494</td>\n",
162
+ " <td>0.119412</td>\n",
163
+ " <td>0.005229</td>\n",
164
+ " <td>-0.092734</td>\n",
165
+ " <td>0.007773</td>\n",
166
+ " <td>-0.005325</td>\n",
167
+ " <td>0.034506</td>\n",
168
+ " <td>-0.051981</td>\n",
169
+ " <td>-0.006265</td>\n",
170
+ " <td>-0.006111</td>\n",
171
+ " <td>...</td>\n",
172
+ " <td>-0.108326</td>\n",
173
+ " <td>-0.049646</td>\n",
174
+ " <td>-0.073399</td>\n",
175
+ " <td>-0.029898</td>\n",
176
+ " <td>-0.102734</td>\n",
177
+ " <td>0.062121</td>\n",
178
+ " <td>0.034606</td>\n",
179
+ " <td>0.016877</td>\n",
180
+ " <td>-0.023861</td>\n",
181
+ " <td>0.005264</td>\n",
182
+ " </tr>\n",
183
+ " <tr>\n",
184
+ " <th>3</th>\n",
185
+ " <td>-0.029711</td>\n",
186
+ " <td>0.023298</td>\n",
187
+ " <td>-0.057041</td>\n",
188
+ " <td>-0.012183</td>\n",
189
+ " <td>-0.013710</td>\n",
190
+ " <td>0.029796</td>\n",
191
+ " <td>0.063739</td>\n",
192
+ " <td>0.001101</td>\n",
193
+ " <td>-0.045124</td>\n",
194
+ " <td>-0.040748</td>\n",
195
+ " <td>...</td>\n",
196
+ " <td>-0.117682</td>\n",
197
+ " <td>0.031924</td>\n",
198
+ " <td>0.000854</td>\n",
199
+ " <td>0.020200</td>\n",
200
+ " <td>-0.020666</td>\n",
201
+ " <td>-0.005167</td>\n",
202
+ " <td>0.038370</td>\n",
203
+ " <td>0.003617</td>\n",
204
+ " <td>0.033993</td>\n",
205
+ " <td>-0.010255</td>\n",
206
+ " </tr>\n",
207
+ " <tr>\n",
208
+ " <th>4</th>\n",
209
+ " <td>-0.025628</td>\n",
210
+ " <td>0.070389</td>\n",
211
+ " <td>-0.017380</td>\n",
212
+ " <td>-0.056567</td>\n",
213
+ " <td>0.028577</td>\n",
214
+ " <td>0.052823</td>\n",
215
+ " <td>0.067063</td>\n",
216
+ " <td>-0.052618</td>\n",
217
+ " <td>-0.054702</td>\n",
218
+ " <td>-0.116230</td>\n",
219
+ " <td>...</td>\n",
220
+ " <td>-0.118145</td>\n",
221
+ " <td>0.013343</td>\n",
222
+ " <td>-0.055188</td>\n",
223
+ " <td>-0.032723</td>\n",
224
+ " <td>0.008436</td>\n",
225
+ " <td>0.019169</td>\n",
226
+ " <td>0.048212</td>\n",
227
+ " <td>-0.040412</td>\n",
228
+ " <td>0.083346</td>\n",
229
+ " <td>0.026855</td>\n",
230
+ " </tr>\n",
231
+ " <tr>\n",
232
+ " <th>5</th>\n",
233
+ " <td>-0.022656</td>\n",
234
+ " <td>0.021160</td>\n",
235
+ " <td>0.005105</td>\n",
236
+ " <td>-0.046494</td>\n",
237
+ " <td>0.009074</td>\n",
238
+ " <td>0.041495</td>\n",
239
+ " <td>0.054268</td>\n",
240
+ " <td>-0.024185</td>\n",
241
+ " <td>-0.013483</td>\n",
242
+ " <td>-0.075966</td>\n",
243
+ " <td>...</td>\n",
244
+ " <td>-0.100110</td>\n",
245
+ " <td>0.010750</td>\n",
246
+ " <td>-0.031469</td>\n",
247
+ " <td>-0.004822</td>\n",
248
+ " <td>0.039657</td>\n",
249
+ " <td>0.026384</td>\n",
250
+ " <td>0.045514</td>\n",
251
+ " <td>0.059089</td>\n",
252
+ " <td>-0.017509</td>\n",
253
+ " <td>0.007166</td>\n",
254
+ " </tr>\n",
255
+ " <tr>\n",
256
+ " <th>6</th>\n",
257
+ " <td>-0.002911</td>\n",
258
+ " <td>0.060791</td>\n",
259
+ " <td>-0.009176</td>\n",
260
+ " <td>-0.006133</td>\n",
261
+ " <td>0.040492</td>\n",
262
+ " <td>0.036594</td>\n",
263
+ " <td>0.002054</td>\n",
264
+ " <td>-0.031345</td>\n",
265
+ " <td>0.031806</td>\n",
266
+ " <td>-0.023495</td>\n",
267
+ " <td>...</td>\n",
268
+ " <td>-0.028763</td>\n",
269
+ " <td>-0.060458</td>\n",
270
+ " <td>-0.018598</td>\n",
271
+ " <td>-0.040189</td>\n",
272
+ " <td>-0.031486</td>\n",
273
+ " <td>-0.018299</td>\n",
274
+ " <td>0.002286</td>\n",
275
+ " <td>-0.073420</td>\n",
276
+ " <td>0.016235</td>\n",
277
+ " <td>-0.000244</td>\n",
278
+ " </tr>\n",
279
+ " <tr>\n",
280
+ " <th>7</th>\n",
281
+ " <td>-0.080526</td>\n",
282
+ " <td>0.059888</td>\n",
283
+ " <td>-0.048847</td>\n",
284
+ " <td>-0.040176</td>\n",
285
+ " <td>-0.063342</td>\n",
286
+ " <td>0.041848</td>\n",
287
+ " <td>0.119045</td>\n",
288
+ " <td>0.010652</td>\n",
289
+ " <td>-0.030095</td>\n",
290
+ " <td>-0.004561</td>\n",
291
+ " <td>...</td>\n",
292
+ " <td>-0.144566</td>\n",
293
+ " <td>0.020404</td>\n",
294
+ " <td>0.023088</td>\n",
295
+ " <td>0.005077</td>\n",
296
+ " <td>-0.055645</td>\n",
297
+ " <td>-0.007675</td>\n",
298
+ " <td>0.050791</td>\n",
299
+ " <td>-0.005989</td>\n",
300
+ " <td>0.134562</td>\n",
301
+ " <td>0.034817</td>\n",
302
+ " </tr>\n",
303
+ " <tr>\n",
304
+ " <th>8</th>\n",
305
+ " <td>-0.034388</td>\n",
306
+ " <td>0.072501</td>\n",
307
+ " <td>0.014440</td>\n",
308
+ " <td>-0.036695</td>\n",
309
+ " <td>0.014019</td>\n",
310
+ " <td>0.063070</td>\n",
311
+ " <td>0.034683</td>\n",
312
+ " <td>-0.014531</td>\n",
313
+ " <td>-0.059862</td>\n",
314
+ " <td>-0.045383</td>\n",
315
+ " <td>...</td>\n",
316
+ " <td>-0.114763</td>\n",
317
+ " <td>-0.035894</td>\n",
318
+ " <td>-0.019877</td>\n",
319
+ " <td>-0.033375</td>\n",
320
+ " <td>-0.030168</td>\n",
321
+ " <td>0.039412</td>\n",
322
+ " <td>0.044993</td>\n",
323
+ " <td>0.000578</td>\n",
324
+ " <td>-0.025124</td>\n",
325
+ " <td>0.034191</td>\n",
326
+ " </tr>\n",
327
+ " <tr>\n",
328
+ " <th>9</th>\n",
329
+ " <td>-0.005964</td>\n",
330
+ " <td>0.025044</td>\n",
331
+ " <td>-0.003182</td>\n",
332
+ " <td>-0.025243</td>\n",
333
+ " <td>-0.039823</td>\n",
334
+ " <td>-0.012772</td>\n",
335
+ " <td>0.044713</td>\n",
336
+ " <td>0.014535</td>\n",
337
+ " <td>-0.038213</td>\n",
338
+ " <td>-0.041149</td>\n",
339
+ " <td>...</td>\n",
340
+ " <td>-0.057621</td>\n",
341
+ " <td>0.021594</td>\n",
342
+ " <td>0.048983</td>\n",
343
+ " <td>-0.044541</td>\n",
344
+ " <td>-0.030137</td>\n",
345
+ " <td>0.006779</td>\n",
346
+ " <td>0.054854</td>\n",
347
+ " <td>0.029937</td>\n",
348
+ " <td>0.070214</td>\n",
349
+ " <td>0.041565</td>\n",
350
+ " </tr>\n",
351
+ " <tr>\n",
352
+ " <th>10</th>\n",
353
+ " <td>-0.039008</td>\n",
354
+ " <td>-0.010609</td>\n",
355
+ " <td>-0.007383</td>\n",
356
+ " <td>-0.050190</td>\n",
357
+ " <td>-0.002518</td>\n",
358
+ " <td>-0.041641</td>\n",
359
+ " <td>0.026969</td>\n",
360
+ " <td>-0.014801</td>\n",
361
+ " <td>-0.014127</td>\n",
362
+ " <td>-0.061637</td>\n",
363
+ " <td>...</td>\n",
364
+ " <td>-0.098168</td>\n",
365
+ " <td>-0.031694</td>\n",
366
+ " <td>-0.052128</td>\n",
367
+ " <td>0.014774</td>\n",
368
+ " <td>-0.091150</td>\n",
369
+ " <td>0.001324</td>\n",
370
+ " <td>0.053866</td>\n",
371
+ " <td>-0.083904</td>\n",
372
+ " <td>0.037684</td>\n",
373
+ " <td>0.002314</td>\n",
374
+ " </tr>\n",
375
+ " <tr>\n",
376
+ " <th>11</th>\n",
377
+ " <td>-0.095983</td>\n",
378
+ " <td>-0.063012</td>\n",
379
+ " <td>-0.116906</td>\n",
380
+ " <td>-0.059075</td>\n",
381
+ " <td>-0.051323</td>\n",
382
+ " <td>-0.003439</td>\n",
383
+ " <td>0.018687</td>\n",
384
+ " <td>0.006544</td>\n",
385
+ " <td>-0.049057</td>\n",
386
+ " <td>-0.031649</td>\n",
387
+ " <td>...</td>\n",
388
+ " <td>-0.041085</td>\n",
389
+ " <td>-0.008593</td>\n",
390
+ " <td>-0.021544</td>\n",
391
+ " <td>-0.021112</td>\n",
392
+ " <td>-0.019502</td>\n",
393
+ " <td>0.050040</td>\n",
394
+ " <td>-0.029175</td>\n",
395
+ " <td>0.005498</td>\n",
396
+ " <td>0.152892</td>\n",
397
+ " <td>0.024720</td>\n",
398
+ " </tr>\n",
399
+ " <tr>\n",
400
+ " <th>12</th>\n",
401
+ " <td>-0.011600</td>\n",
402
+ " <td>0.056510</td>\n",
403
+ " <td>0.016624</td>\n",
404
+ " <td>-0.094690</td>\n",
405
+ " <td>-0.009865</td>\n",
406
+ " <td>0.072347</td>\n",
407
+ " <td>0.044124</td>\n",
408
+ " <td>-0.041175</td>\n",
409
+ " <td>-0.042124</td>\n",
410
+ " <td>-0.102631</td>\n",
411
+ " <td>...</td>\n",
412
+ " <td>-0.135239</td>\n",
413
+ " <td>0.013612</td>\n",
414
+ " <td>-0.049410</td>\n",
415
+ " <td>-0.006925</td>\n",
416
+ " <td>0.085355</td>\n",
417
+ " <td>-0.007875</td>\n",
418
+ " <td>0.030402</td>\n",
419
+ " <td>-0.029012</td>\n",
420
+ " <td>0.001888</td>\n",
421
+ " <td>-0.000133</td>\n",
422
+ " </tr>\n",
423
+ " </tbody>\n",
424
+ "</table>\n",
425
+ "<p>13 rows × 384 columns</p>\n",
426
+ "</div>"
427
+ ],
428
+ "text/plain": [
429
+ " 0 1 2 3 4 5 6 \\\n",
430
+ "0 -0.023889 0.055259 -0.011655 -0.033414 -0.012261 -0.024873 -0.012663 \n",
431
+ "1 -0.012688 0.046874 -0.010502 -0.020384 -0.013361 0.042322 0.016628 \n",
432
+ "2 0.000494 0.119412 0.005229 -0.092734 0.007773 -0.005325 0.034506 \n",
433
+ "3 -0.029711 0.023298 -0.057041 -0.012183 -0.013710 0.029796 0.063739 \n",
434
+ "4 -0.025628 0.070389 -0.017380 -0.056567 0.028577 0.052823 0.067063 \n",
435
+ "5 -0.022656 0.021160 0.005105 -0.046494 0.009074 0.041495 0.054268 \n",
436
+ "6 -0.002911 0.060791 -0.009176 -0.006133 0.040492 0.036594 0.002054 \n",
437
+ "7 -0.080526 0.059888 -0.048847 -0.040176 -0.063342 0.041848 0.119045 \n",
438
+ "8 -0.034388 0.072501 0.014440 -0.036695 0.014019 0.063070 0.034683 \n",
439
+ "9 -0.005964 0.025044 -0.003182 -0.025243 -0.039823 -0.012772 0.044713 \n",
440
+ "10 -0.039008 -0.010609 -0.007383 -0.050190 -0.002518 -0.041641 0.026969 \n",
441
+ "11 -0.095983 -0.063012 -0.116906 -0.059075 -0.051323 -0.003439 0.018687 \n",
442
+ "12 -0.011600 0.056510 0.016624 -0.094690 -0.009865 0.072347 0.044124 \n",
443
+ "\n",
444
+ " 7 8 9 ... 374 375 376 377 \\\n",
445
+ "0 0.025346 0.018508 -0.083508 ... -0.161688 -0.046426 0.006004 0.005281 \n",
446
+ "1 -0.004099 -0.002607 -0.010188 ... -0.061594 -0.020717 -0.009082 -0.029260 \n",
447
+ "2 -0.051981 -0.006265 -0.006111 ... -0.108326 -0.049646 -0.073399 -0.029898 \n",
448
+ "3 0.001101 -0.045124 -0.040748 ... -0.117682 0.031924 0.000854 0.020200 \n",
449
+ "4 -0.052618 -0.054702 -0.116230 ... -0.118145 0.013343 -0.055188 -0.032723 \n",
450
+ "5 -0.024185 -0.013483 -0.075966 ... -0.100110 0.010750 -0.031469 -0.004822 \n",
451
+ "6 -0.031345 0.031806 -0.023495 ... -0.028763 -0.060458 -0.018598 -0.040189 \n",
452
+ "7 0.010652 -0.030095 -0.004561 ... -0.144566 0.020404 0.023088 0.005077 \n",
453
+ "8 -0.014531 -0.059862 -0.045383 ... -0.114763 -0.035894 -0.019877 -0.033375 \n",
454
+ "9 0.014535 -0.038213 -0.041149 ... -0.057621 0.021594 0.048983 -0.044541 \n",
455
+ "10 -0.014801 -0.014127 -0.061637 ... -0.098168 -0.031694 -0.052128 0.014774 \n",
456
+ "11 0.006544 -0.049057 -0.031649 ... -0.041085 -0.008593 -0.021544 -0.021112 \n",
457
+ "12 -0.041175 -0.042124 -0.102631 ... -0.135239 0.013612 -0.049410 -0.006925 \n",
458
+ "\n",
459
+ " 378 379 380 381 382 383 \n",
460
+ "0 -0.003342 0.027754 0.020411 0.005778 0.034098 -0.006889 \n",
461
+ "1 -0.066253 0.065257 0.013229 -0.023103 -0.002785 0.010474 \n",
462
+ "2 -0.102734 0.062121 0.034606 0.016877 -0.023861 0.005264 \n",
463
+ "3 -0.020666 -0.005167 0.038370 0.003617 0.033993 -0.010255 \n",
464
+ "4 0.008436 0.019169 0.048212 -0.040412 0.083346 0.026855 \n",
465
+ "5 0.039657 0.026384 0.045514 0.059089 -0.017509 0.007166 \n",
466
+ "6 -0.031486 -0.018299 0.002286 -0.073420 0.016235 -0.000244 \n",
467
+ "7 -0.055645 -0.007675 0.050791 -0.005989 0.134562 0.034817 \n",
468
+ "8 -0.030168 0.039412 0.044993 0.000578 -0.025124 0.034191 \n",
469
+ "9 -0.030137 0.006779 0.054854 0.029937 0.070214 0.041565 \n",
470
+ "10 -0.091150 0.001324 0.053866 -0.083904 0.037684 0.002314 \n",
471
+ "11 -0.019502 0.050040 -0.029175 0.005498 0.152892 0.024720 \n",
472
+ "12 0.085355 -0.007875 0.030402 -0.029012 0.001888 -0.000133 \n",
473
+ "\n",
474
+ "[13 rows x 384 columns]"
475
+ ]
476
+ },
477
+ "execution_count": 41,
478
+ "metadata": {},
479
+ "output_type": "execute_result"
480
+ }
481
+ ],
482
+ "source": [
483
+ "import pandas as pd\n",
484
+ "embeddings = pd.DataFrame(output)\n",
485
+ "embeddings"
486
+ ]
487
+ },
488
+ {
489
+ "cell_type": "code",
490
+ "execution_count": 49,
491
+ "id": "9ac9b882-df78-4bda-8ae5-257171d9890c",
492
+ "metadata": {},
493
+ "outputs": [],
494
+ "source": [
495
+ "embeddings.to_csv(\"embeddings.csv\", index=False)"
496
+ ]
497
+ },
498
+ {
499
+ "cell_type": "code",
500
+ "execution_count": 55,
501
+ "id": "6d573657-d483-441b-afbb-643f487815c5",
502
+ "metadata": {},
503
+ "outputs": [
504
+ {
505
+ "data": {
506
+ "text/plain": [
507
+ "tensor([[-8.9692e-02, -7.1678e-02, -6.4658e-02, -2.5273e-02, -2.5160e-02,\n",
508
+ " 9.5493e-02, 6.0537e-02, 6.5189e-03, 7.0210e-02, 1.6540e-02,\n",
509
+ " 3.1756e-02, 3.7128e-02, -3.0189e-02, 1.2188e-01, 4.2055e-03,\n",
510
+ " 4.7994e-02, 9.5993e-02, 2.8378e-02, 6.5093e-02, -3.7466e-02,\n",
511
+ " 1.8294e-02, -1.3735e-02, 6.9921e-02, 1.0683e-02, -2.6517e-02,\n",
512
+ " -6.4150e-03, -1.4047e-02, -3.0414e-02, -1.2173e-01, -8.3550e-02,\n",
513
+ " 4.4605e-02, 1.8618e-02, -4.5440e-02, -5.3226e-02, -5.2821e-02,\n",
514
+ " 6.1405e-02, -5.6014e-03, -6.7444e-02, -2.9687e-02, -3.2697e-02,\n",
515
+ " -9.0033e-02, -5.4642e-03, 7.9094e-02, -1.6152e-02, 9.2060e-02,\n",
516
+ " -2.1775e-02, 3.0855e-02, -2.7018e-02, 5.1785e-02, 2.2410e-02,\n",
517
+ " 4.5925e-03, 6.0932e-03, -6.1588e-02, -4.3769e-04, 1.4080e-02,\n",
518
+ " -1.0000e-01, -5.5338e-02, -4.2764e-02, 3.1288e-02, -8.6337e-02,\n",
519
+ " -1.2676e-03, -1.8121e-03, -4.2850e-03, -2.9365e-02, 3.6735e-02,\n",
520
+ " -6.6461e-03, 5.2725e-02, -4.1446e-02, -1.7163e-02, 5.2195e-02,\n",
521
+ " -3.5301e-02, -1.1078e-02, -8.1348e-03, -6.7892e-02, -7.6523e-02,\n",
522
+ " -4.1602e-02, -2.3622e-02, -3.7206e-02, -9.2386e-02, -4.3152e-02,\n",
523
+ " 4.9173e-02, -1.2231e-01, -1.2079e-01, 2.5151e-02, 2.3995e-02,\n",
524
+ " -2.4697e-03, -1.4411e-02, -2.8515e-04, 5.7351e-03, 6.1428e-02,\n",
525
+ " -7.7035e-02, 3.1017e-02, -1.0668e-02, 8.4897e-02, -3.5265e-02,\n",
526
+ " -2.0904e-02, -1.8331e-02, -2.1771e-02, -4.5067e-02, 6.3914e-02,\n",
527
+ " 2.5410e-02, -1.0044e-02, -7.8166e-02, -3.2381e-02, 1.3421e-01,\n",
528
+ " -3.8063e-02, 1.1250e-01, -6.6807e-02, -2.6270e-02, 3.0373e-02,\n",
529
+ " -4.7775e-03, -7.2811e-02, 6.6593e-03, 3.0932e-02, 5.7442e-02,\n",
530
+ " 1.6413e-02, 8.1363e-02, 2.4339e-02, -3.8978e-02, 4.2294e-03,\n",
531
+ " 9.0345e-02, 1.3644e-02, 6.1808e-02, -7.1033e-03, -2.0219e-03,\n",
532
+ " -2.5045e-02, 4.6670e-02, -2.7020e-33, -3.0658e-02, -3.1585e-02,\n",
533
+ " 5.6400e-02, 3.3047e-02, 4.2517e-02, 1.6862e-02, -1.1733e-02,\n",
534
+ " -3.6467e-02, -1.9978e-02, 1.1683e-02, -1.1001e-01, -5.7765e-02,\n",
535
+ " -5.5602e-02, -1.1054e-02, 8.1563e-02, 4.0051e-02, -2.3544e-02,\n",
536
+ " 3.9336e-02, 2.9382e-02, -1.7138e-02, -6.1261e-02, 1.0746e-01,\n",
537
+ " -6.7021e-02, 7.3112e-03, -3.8741e-02, -1.1130e-02, -2.4723e-03,\n",
538
+ " 2.9728e-02, 2.0914e-03, -4.8236e-03, 2.8769e-02, -9.3932e-03,\n",
539
+ " -4.1794e-03, 6.4001e-02, 1.3524e-01, -3.2297e-02, -7.8227e-02,\n",
540
+ " -3.4412e-02, -3.1194e-02, 2.8607e-02, -3.1381e-02, 3.9271e-02,\n",
541
+ " -5.4559e-02, 4.3373e-02, 3.1618e-02, 3.2962e-02, 1.4340e-02,\n",
542
+ " 6.3454e-02, 1.2816e-02, 8.8069e-02, 9.7940e-03, 3.4391e-03,\n",
543
+ " 3.8793e-02, 9.7933e-03, -4.0707e-02, 2.9351e-02, 1.6331e-02,\n",
544
+ " -1.9151e-02, 4.2998e-02, 1.3868e-03, -1.5496e-02, 2.8651e-02,\n",
545
+ " -1.6117e-02, 4.8554e-02, -3.3424e-02, 3.7980e-02, 5.1681e-02,\n",
546
+ " 9.4712e-03, 2.1594e-02, -2.7505e-02, -3.4454e-02, 3.3451e-02,\n",
547
+ " 5.0620e-02, -6.9366e-02, 6.2185e-02, -1.2269e-02, 3.8187e-02,\n",
548
+ " -4.1367e-02, -7.7467e-02, -5.4399e-02, -8.7326e-02, -3.0441e-03,\n",
549
+ " -1.8627e-02, 4.1645e-02, -3.1147e-03, 8.9177e-03, -5.0913e-02,\n",
550
+ " -9.3077e-02, -4.5287e-03, 6.0444e-02, -1.0301e-01, -9.1961e-02,\n",
551
+ " 6.9155e-02, 3.0234e-02, 9.0851e-02, 3.2439e-33, 8.6552e-02,\n",
552
+ " -6.5429e-02, 7.8963e-03, 4.3653e-02, 5.5929e-02, 7.0854e-03,\n",
553
+ " -7.0919e-02, 1.4281e-04, 8.3507e-02, 6.8680e-02, -1.4401e-02,\n",
554
+ " -3.4416e-03, 4.6490e-02, 7.7277e-03, 1.1520e-01, -2.2469e-02,\n",
555
+ " 4.4533e-02, -4.1014e-02, 5.2622e-02, 2.5087e-02, 3.6982e-02,\n",
556
+ " 5.2463e-02, -3.0043e-02, -1.0178e-02, 3.0303e-02, 4.1595e-02,\n",
557
+ " -2.8276e-02, 3.7373e-02, -3.4403e-02, -1.0499e-02, -2.0811e-02,\n",
558
+ " -2.3120e-02, 4.5837e-02, 5.1766e-02, -5.1619e-02, 8.7256e-02,\n",
559
+ " 1.6761e-02, -2.1394e-03, 3.6348e-03, 5.0054e-02, 2.0227e-02,\n",
560
+ " -1.6015e-02, -2.1217e-02, 1.5421e-01, -1.3158e-02, -2.8398e-02,\n",
561
+ " -1.3689e-02, 4.7356e-02, -5.7805e-02, 9.0794e-03, -1.1677e-01,\n",
562
+ " 1.1524e-02, -7.1354e-02, -7.0080e-02, 7.9298e-02, 1.6545e-02,\n",
563
+ " 2.4228e-02, 6.2592e-03, -1.4449e-02, -1.2710e-02, -3.4715e-02,\n",
564
+ " 4.9897e-04, -5.4645e-02, 6.3109e-04, -1.5480e-02, 3.5777e-02,\n",
565
+ " 6.8206e-03, 1.9068e-02, -2.4766e-02, -1.0899e-02, -2.5103e-02,\n",
566
+ " -6.4506e-03, -5.4571e-02, 2.5454e-02, -9.5684e-03, -3.7722e-02,\n",
567
+ " 6.2204e-02, -1.7215e-02, 5.9117e-02, -3.8532e-02, 1.3672e-02,\n",
568
+ " 2.5865e-02, -1.5777e-02, 5.1845e-02, 1.2019e-02, 1.2119e-01,\n",
569
+ " -1.8528e-02, 1.3776e-02, 1.1833e-03, 8.2213e-02, 3.8837e-02,\n",
570
+ " 1.3432e-02, 1.3018e-01, -2.1637e-02, -8.7439e-02, -1.1291e-08,\n",
571
+ " -4.3203e-02, 1.0041e-01, 1.7602e-02, -6.4081e-02, -1.2244e-02,\n",
572
+ " -1.4865e-02, -7.1396e-02, 1.0025e-01, 3.0179e-02, 5.5649e-02,\n",
573
+ " 2.0928e-02, 5.4815e-03, 3.5794e-02, 3.0769e-02, -7.5556e-02,\n",
574
+ " 4.9906e-04, 3.8390e-02, -3.8530e-02, -4.8088e-02, 1.2520e-02,\n",
575
+ " 9.9632e-03, 3.6153e-03, 6.6720e-02, -5.6117e-02, -2.8780e-02,\n",
576
+ " 2.7026e-02, -4.5948e-02, -3.1805e-02, 3.7404e-02, 1.4018e-01,\n",
577
+ " 7.4267e-02, 5.3000e-03, -3.6980e-02, 1.1275e-03, -8.6605e-02,\n",
578
+ " -6.6038e-02, 4.8514e-02, 6.1135e-03, 5.5289e-03, -4.0952e-02,\n",
579
+ " -3.3284e-02, 4.5587e-02, 3.3399e-02, -5.0551e-02, 1.5164e-02,\n",
580
+ " 8.0977e-02, 3.3518e-02, -1.7935e-01, 4.1962e-02, -1.6916e-02,\n",
581
+ " 1.1325e-02, -4.0028e-02, -4.4969e-02, 8.2986e-02, 4.9503e-02,\n",
582
+ " 1.1134e-01, 5.6467e-03, 2.0734e-03, -3.6509e-02, 2.9235e-02,\n",
583
+ " 1.1157e-01, -8.2191e-02, -1.8864e-02, 3.1457e-02]])"
584
+ ]
585
+ },
586
+ "execution_count": 55,
587
+ "metadata": {},
588
+ "output_type": "execute_result"
589
+ }
590
+ ],
591
+ "source": [
592
+ "import torch\n",
593
+ "\n",
594
+ "question = [\"Best action movie?\"]\n",
595
+ "output = query(question)\n",
596
+ "\n",
597
+ "query_embeddings = torch.FloatTensor(output)\n",
598
+ "query_embeddings"
599
+ ]
600
+ },
601
+ {
602
+ "cell_type": "code",
603
+ "execution_count": null,
604
+ "id": "beb947b2-5cf2-42f8-bfc0-e2c5dd33ba49",
605
+ "metadata": {},
606
+ "outputs": [],
607
+ "source": []
608
+ },
609
+ {
610
+ "cell_type": "code",
611
+ "execution_count": null,
612
+ "id": "2ad5f317-769d-41b6-8dcb-eaf3983e1f8a",
613
+ "metadata": {},
614
+ "outputs": [],
615
+ "source": [
616
+ "\n"
617
+ ]
618
+ },
619
+ {
620
+ "cell_type": "code",
621
+ "execution_count": null,
622
+ "id": "833f206f-bd61-41ab-a79e-c0fdf52159d1",
623
+ "metadata": {},
624
+ "outputs": [],
625
+ "source": []
626
+ }
627
+ ],
628
+ "metadata": {
629
+ "kernelspec": {
630
+ "display_name": "Python 3 (ipykernel)",
631
+ "language": "python",
632
+ "name": "python3"
633
+ },
634
+ "language_info": {
635
+ "codemirror_mode": {
636
+ "name": "ipython",
637
+ "version": 3
638
+ },
639
+ "file_extension": ".py",
640
+ "mimetype": "text/x-python",
641
+ "name": "python",
642
+ "nbconvert_exporter": "python",
643
+ "pygments_lexer": "ipython3",
644
+ "version": "3.12.4"
645
+ }
646
+ },
647
+ "nbformat": 4,
648
+ "nbformat_minor": 5
649
+ }