jimwyattTK commited on
Commit
752d595
·
verified ·
1 Parent(s): 7936069

Upload 5 files

Browse files
notebook/._notebook-demo_LICENSE.txt ADDED
Binary file (4.1 kB). View file
 
notebook/._notebook-demo_README.md ADDED
Binary file (4.1 kB). View file
 
notebook/notebook-demo_LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tokuhn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
notebook/notebook-demo_README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TSMPD Search Demo Notebook
2
+
3
+ This directory contains a working Jupyter notebook that demonstrates semantic product search on the TSMPD-US-Public v1.0 dataset.
4
+
5
+ ## What's Inside
6
+ - `tsmpd_search_demo.ipynb`: A step-by-step demo of embedding-based search using `faiss` and `sentence-transformers`.
7
+
8
+ ## Features
9
+ - Load SBERT embeddings from parquet chunks
10
+ - Build and query a FAISS index for nearest neighbor search
11
+ - Explore how consumers might search across 355k+ small U.S. stores
12
+
13
+ ## Setup
14
+ To run this notebook, install the following:
15
+ ```bash
16
+ pip install faiss-cpu polars sentence-transformers
17
+ ```
18
+
19
+ ## Licensing
20
+ Code in this notebook is licensed under the MIT License.
notebook/personal shopper demo.ipynb ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "e255d061-b87e-41d1-bdec-75717c311031",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stderr",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
14
+ " from .autonotebook import tqdm as notebook_tqdm\n",
15
+ "[15:15:29] Use pytorch device_name: mps\n",
16
+ "[15:15:29] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2\n",
17
+ "Batches: 100%|████████████████████████████████████| 1/1 [00:02<00:00, 2.42s/it]\n",
18
+ "[15:15:33] Shard 1/37 → loading tsmpd_public_000.parquet\n",
19
+ "[15:15:35] rows = 250,000 | load = 2.0s\n",
20
+ "[15:15:48] processed in 14.7s best_min=0.5414\n",
21
+ "[15:15:48] Shard 2/37 → loading tsmpd_public_001.parquet\n",
22
+ "[15:15:49] rows = 250,000 | load = 1.2s\n",
23
+ "[15:15:59] processed in 11.3s best_min=0.5506\n",
24
+ "[15:15:59] Shard 3/37 → loading tsmpd_public_002.parquet\n",
25
+ "[15:16:01] rows = 250,000 | load = 1.2s\n",
26
+ "[15:16:10] processed in 10.9s best_min=0.5990\n",
27
+ "[15:16:10] Shard 4/37 → loading tsmpd_public_003.parquet\n",
28
+ "[15:16:11] rows = 250,000 | load = 1.2s\n",
29
+ "[15:16:20] processed in 9.7s best_min=0.5990\n",
30
+ "[15:16:20] Shard 5/37 → loading tsmpd_public_004.parquet\n",
31
+ "[15:16:21] rows = 250,000 | load = 1.2s\n",
32
+ "[15:16:30] processed in 10.4s best_min=0.6122\n",
33
+ "[15:16:30] Shard 6/37 → loading tsmpd_public_005.parquet\n",
34
+ "[15:16:32] rows = 250,000 | load = 1.2s\n",
35
+ "[15:16:40] processed in 9.9s best_min=0.6491\n",
36
+ "[15:16:40] Shard 7/37 → loading tsmpd_public_006.parquet\n",
37
+ "[15:16:41] rows = 250,000 | load = 1.2s\n",
38
+ "[15:16:50] processed in 9.6s best_min=0.6491\n",
39
+ "[15:16:50] Shard 8/37 → loading tsmpd_public_007.parquet\n",
40
+ "[15:16:51] rows = 250,000 | load = 1.2s\n",
41
+ "[15:16:59] processed in 9.5s best_min=0.6491\n",
42
+ "[15:16:59] Shard 9/37 → loading tsmpd_public_008.parquet\n",
43
+ "[15:17:01] rows = 250,000 | load = 1.2s\n",
44
+ "[15:17:10] processed in 10.5s best_min=0.6528\n",
45
+ "[15:17:10] Shard 10/37 → loading tsmpd_public_009.parquet\n",
46
+ "[15:17:11] rows = 250,000 | load = 1.2s\n",
47
+ "[15:17:20] processed in 10.4s best_min=0.6528\n",
48
+ "[15:17:20] Shard 11/37 → loading tsmpd_public_010.parquet\n",
49
+ "[15:17:22] rows = 250,000 | load = 1.3s\n",
50
+ "[15:17:30] processed in 10.1s best_min=0.6528\n",
51
+ "[15:17:30] Shard 12/37 → loading tsmpd_public_011.parquet\n",
52
+ "[15:17:32] rows = 250,000 | load = 1.3s\n",
53
+ "[15:17:40] processed in 9.6s best_min=0.6741\n",
54
+ "[15:17:40] Shard 13/37 → loading tsmpd_public_012.parquet\n",
55
+ "[15:17:41] rows = 250,000 | load = 1.2s\n",
56
+ "[15:17:50] processed in 9.6s best_min=0.6859\n",
57
+ "[15:17:50] Shard 14/37 → loading tsmpd_public_013.parquet\n",
58
+ "[15:17:51] rows = 250,000 | load = 1.2s\n",
59
+ "[15:17:59] processed in 9.6s best_min=0.6859\n",
60
+ "[15:17:59] Shard 15/37 → loading tsmpd_public_014.parquet\n",
61
+ "[15:18:00] rows = 250,000 | load = 1.2s\n",
62
+ "[15:18:10] processed in 10.6s best_min=0.6859\n",
63
+ "[15:18:10] Shard 16/37 → loading tsmpd_public_015.parquet\n",
64
+ "[15:18:11] rows = 250,000 | load = 1.2s\n",
65
+ "[15:18:19] processed in 9.5s best_min=0.6980\n",
66
+ "[15:18:19] Shard 17/37 → loading tsmpd_public_016.parquet\n",
67
+ "[15:18:21] rows = 250,000 | load = 1.2s\n",
68
+ "[15:18:29] processed in 9.8s best_min=0.6980\n",
69
+ "[15:18:29] Shard 18/37 → loading tsmpd_public_017.parquet\n",
70
+ "[15:18:30] rows = 250,000 | load = 1.2s\n",
71
+ "[15:18:39] processed in 10.0s best_min=0.6980\n",
72
+ "[15:18:39] Shard 19/37 → loading tsmpd_public_018.parquet\n",
73
+ "[15:18:40] rows = 250,000 | load = 1.2s\n",
74
+ "[15:18:49] processed in 9.7s best_min=0.6980\n",
75
+ "[15:18:49] Shard 20/37 → loading tsmpd_public_019.parquet\n",
76
+ "[15:18:50] rows = 250,000 | load = 1.2s\n",
77
+ "[15:18:59] processed in 9.7s best_min=0.6980\n",
78
+ "[15:18:59] Shard 21/37 → loading tsmpd_public_020.parquet\n",
79
+ "[15:19:00] rows = 250,000 | load = 1.2s\n",
80
+ "[15:19:09] processed in 10.5s best_min=0.7070\n",
81
+ "[15:19:09] Shard 22/37 → loading tsmpd_public_021.parquet\n",
82
+ "[15:19:10] rows = 250,000 | load = 1.2s\n",
83
+ "[15:19:19] processed in 9.8s best_min=0.7070\n",
84
+ "[15:19:19] Shard 23/37 → loading tsmpd_public_022.parquet\n",
85
+ "[15:19:20] rows = 250,000 | load = 1.2s\n",
86
+ "[15:19:31] processed in 11.6s best_min=0.7070\n",
87
+ "[15:19:31] Shard 24/37 → loading tsmpd_public_023.parquet\n",
88
+ "[15:19:32] rows = 250,000 | load = 1.3s\n",
89
+ "[15:19:41] processed in 10.2s best_min=0.7070\n",
90
+ "[15:19:41] Shard 25/37 → loading tsmpd_public_024.parquet\n",
91
+ "[15:19:42] rows = 250,000 | load = 1.2s\n",
92
+ "[15:19:50] processed in 9.5s best_min=0.7070\n",
93
+ "[15:19:50] Shard 26/37 → loading tsmpd_public_025.parquet\n",
94
+ "[15:19:52] rows = 250,000 | load = 1.2s\n",
95
+ "[15:20:00] processed in 9.9s best_min=0.7070\n",
96
+ "[15:20:00] Shard 27/37 → loading tsmpd_public_026.parquet\n",
97
+ "[15:20:01] rows = 250,000 | load = 1.2s\n",
98
+ "[15:20:12] processed in 11.5s best_min=0.7070\n",
99
+ "[15:20:12] Shard 28/37 → loading tsmpd_public_027.parquet\n",
100
+ "[15:20:13] rows = 250,000 | load = 1.2s\n",
101
+ "[15:20:22] processed in 10.1s best_min=0.7070\n",
102
+ "[15:20:22] Shard 29/37 → loading tsmpd_public_028.parquet\n",
103
+ "[15:20:23] rows = 250,000 | load = 1.3s\n",
104
+ "[15:20:32] processed in 10.1s best_min=0.7070\n",
105
+ "[15:20:32] Shard 30/37 → loading tsmpd_public_029.parquet\n",
106
+ "[15:20:33] rows = 250,000 | load = 1.2s\n",
107
+ "[15:20:43] processed in 11.1s best_min=0.7070\n",
108
+ "[15:20:43] Shard 31/37 → loading tsmpd_public_030.parquet\n",
109
+ "[15:20:44] rows = 250,000 | load = 1.2s\n",
110
+ "[15:20:55] processed in 11.6s best_min=0.7070\n",
111
+ "[15:20:55] Shard 32/37 → loading tsmpd_public_031.parquet\n",
112
+ "[15:20:56] rows = 250,000 | load = 1.2s\n",
113
+ "[15:21:06] processed in 10.9s best_min=0.7070\n",
114
+ "[15:21:06] Shard 33/37 → loading tsmpd_public_032.parquet\n",
115
+ "[15:21:07] rows = 250,000 | load = 1.2s\n",
116
+ "[15:21:19] processed in 13.5s best_min=0.7070\n",
117
+ "[15:21:19] Shard 34/37 → loading tsmpd_public_033.parquet\n",
118
+ "[15:21:20] rows = 250,000 | load = 1.3s\n",
119
+ "[15:21:31] processed in 12.0s best_min=0.7070\n",
120
+ "[15:21:31] Shard 35/37 → loading tsmpd_public_034.parquet\n",
121
+ "[15:21:32] rows = 250,000 | load = 1.2s\n",
122
+ "[15:21:41] processed in 10.3s best_min=0.7070\n",
123
+ "[15:21:41] Shard 36/37 → loading tsmpd_public_035.parquet\n",
124
+ "[15:21:43] rows = 250,000 | load = 1.2s\n",
125
+ "[15:21:52] processed in 10.3s best_min=0.7070\n",
126
+ "[15:21:52] Shard 37/37 → loading tsmpd_public_036.parquet\n",
127
+ "[15:21:52] rows = 86 | load = 0.0s\n",
128
+ "[15:21:52] processed in 0.0s best_min=0.7070\n",
129
+ "[15:21:52] Finished query in 380.9s\n"
130
+ ]
131
+ },
132
+ {
133
+ "data": {
134
+ "text/html": [
135
+ "<div>\n",
136
+ "<style scoped>\n",
137
+ " .dataframe tbody tr th:only-of-type {\n",
138
+ " vertical-align: middle;\n",
139
+ " }\n",
140
+ "\n",
141
+ " .dataframe tbody tr th {\n",
142
+ " vertical-align: top;\n",
143
+ " }\n",
144
+ "\n",
145
+ " .dataframe thead th {\n",
146
+ " text-align: right;\n",
147
+ " }\n",
148
+ "</style>\n",
149
+ "<table border=\"1\" class=\"dataframe\">\n",
150
+ " <thead>\n",
151
+ " <tr style=\"text-align: right;\">\n",
152
+ " <th></th>\n",
153
+ " <th>score</th>\n",
154
+ " <th>uid</th>\n",
155
+ " <th>vendor</th>\n",
156
+ " <th>title</th>\n",
157
+ " <th>paragraph</th>\n",
158
+ " </tr>\n",
159
+ " </thead>\n",
160
+ " <tbody>\n",
161
+ " <tr>\n",
162
+ " <th>0</th>\n",
163
+ " <td>0.751176</td>\n",
164
+ " <td>34985afc-0e36-4e1a-8494-1e9d06cf57ac</td>\n",
165
+ " <td>jxmdaudio</td>\n",
166
+ " <td>Active Noise Cancelling Headphones Wireless Over Ear Bluetooth Headphones</td>\n",
167
+ " <td>Active Noise Cancelling Headphones Wireless Over Ear Bluetooth Headphones by jxmdaudio - $39.99 . Limited quantityFirst come First served. Professional Active Noise Cancelling Technology Proprietary 40mm Large-aperture Drivers. High-quality Built-in Microphone and NFC Technology. The Professional Protein Earpad and 90 Swiveling Earcups. A built-in 600mAh battery won't allow your headphones power off, you can enjoy your world without noise for 30 hours' long time.</td>\n",
168
+ " </tr>\n",
169
+ " <tr>\n",
170
+ " <th>1</th>\n",
171
+ " <td>0.741887</td>\n",
172
+ " <td>5ed011c5-8fb7-41b0-b6cc-b469f67e29dc</td>\n",
173
+ " <td>Distritech</td>\n",
174
+ " <td>SONY WIRELESS NOISE CANCELING OVERHEAD HEADPHONES, MIDNIGHT BLUE</td>\n",
175
+ " <td>SONY WIRELESS NOISE CANCELING OVERHEAD HEADPHONES, MIDNIGHT BLUE by Distritech - $173.00 . WIRELESS NOISE CANCELING OVERHEAD HEADPHONES</td>\n",
176
+ " </tr>\n",
177
+ " <tr>\n",
178
+ " <th>2</th>\n",
179
+ " <td>0.719547</td>\n",
180
+ " <td>ba329fd4-07c8-4fc6-bbc8-11c37ac7f615</td>\n",
181
+ " <td>likistor</td>\n",
182
+ " <td>Wireless Noise-Cancelling Headphones</td>\n",
183
+ " <td>Wireless Noise-Cancelling Headphones by likistor - $59.99 . SPECIFICATIONS Style: Headphone. Vocalism Principle: Dynamic Material: ABS Hign-concerned Chemical: none Communication: True Wireless Volume Control: Yes Category: Earphones &amp;amp; Headphones Number Of Drivers: 2 Active Noise-Cancellation: Yes Waterproof: No Wireless Type: bluetooth Control Button: Yes Is wireless: Yes Charging Method: cable Battery Capacity[mAh]: 100 Maximum wireless range[m]: &amp;lt;10m</td>\n",
184
+ " </tr>\n",
185
+ " <tr>\n",
186
+ " <th>3</th>\n",
187
+ " <td>0.708177</td>\n",
188
+ " <td>5994bc56-967a-494e-8011-553826b5a5b1</td>\n",
189
+ " <td>CatoGifts</td>\n",
190
+ " <td>Noise Cancelling Wireless Headset</td>\n",
191
+ " <td>Noise Cancelling Wireless Headset by CatoGifts - $42.04 . Experience Crystal Clear Sound with Our Noise Cancelling Wireless HeadsetImmerse yourself in superior audio quality with our noise cancelling wireless headset. Designed to block out external noise, it lets you enjoy your favorite music, podcasts, and calls with unparalleled clarity and precision.Elevate Your Listening Experience with Our Noise Cancelling Wireless HeadsetTake your audio experience to the next level with our noise cancelling wireless headset. Whether you're commuting, working, or relaxing at home, this headset provides an immersive soundscape free from distractions.Enjoy Uninterrupted Sound with Our Noise Cancelling Wireless HeadsetSay goodbye to background noise and hello to uninterrupted sound with our noise cancelling wireless headset. Its advanced technology ensures you hear every detail, making it perfect for music lovers and professionals alike.Stay Connected and Focused with Our Noise Cancelling Wireless HeadsetMaintain focus and stay connected wherever you are with our noise cancelling wireless headset. Its wireless design offers freedom of movement, while the noise cancelling feature ensures you stay immersed in your audio world without interruption.</td>\n",
192
+ " </tr>\n",
193
+ " <tr>\n",
194
+ " <th>4</th>\n",
195
+ " <td>0.707036</td>\n",
196
+ " <td>b3291e0e-a5d1-4d08-9c3e-e4c0f85276f2</td>\n",
197
+ " <td>IVY DUCK</td>\n",
198
+ " <td>Wireless Bluetooth Noise Cancelling Headphones</td>\n",
199
+ " <td>Wireless Bluetooth Noise Cancelling Headphones by IVY DUCK - $59.99-$69.99 . Experience Uninterrupted Sound with Our Waterproof Wireless Bluetooth Noise-Cancelling Headphones Experience premium sound without the premium price with these advanced Wireless Bluetooth Noise-Cancelling Headphones. While other high-end brands may cost a fortune, our headphones deliver superior noise cancellation and crisp, clear audio at a fraction of the price. Enjoy all-day comfort with a lightweight design and long-lasting battery life, ensuring you get the most out of every listening session. Elevate your audio experience today with top-tier performance and unbeatable value! Advanced Noise-Cancelling Technology: Immerse yourself in your favourite tunes with state-of-the-art active noise-cancelling technology. Block out distractions and enjoy crystal-clear sound, whether youre on a noisy commute or in a bustling caf. High-Fidelity Sound: Experience rich, detailed audio with deep bass and clear highs. Our advanced drivers ensure you hear every note, making these headphones perfect for music lovers and audiophiles alike. Seamless Bluetooth Connectivity: Enjoy wireless freedom with the latest Bluetooth technology. Pair effortlessly with your devices and maintain a stable connection for uninterrupted listening. Long Battery Life: Stay powered throughout the day with an impressive battery life. Whether youre traveling or working, these headphones keep you connected and entertained for hours on end. Comfortable Fit: Designed with ergonomics in mind, these headphones feature plush ear cushions and an adjustable headband for a personalised, comfortable fit. Wear them all day without discomfort. Built-in Microphone &amp;amp; Controls: Take calls and manage your music with ease using the integrated microphone and intuitive controls. Switch tracks, adjust volume, and answer calls with a simple touch. Premium Build Quality: Crafted with high-quality materials, these headphones offer durability and a sleek, modern design. They are built to withstand daily use while looking stylish. Foldable Design: For added convenience, the headphones feature a foldable design, making them easy to store and transport. Perfect for on-the-go lifestyles! Experience superior sound with our Wireless Bluetooth Noise-Cancelling Headphones. Engineered for immersive audio, these premium headphones offer crystal-clear sound and advanced noise cancellation, elevating your listening experience to new heights. Perfect for audiophiles and casual listeners alike, they blend luxury and performance effortlessly. Upgrade your audio with the ultimate in comfort and style today!</td>\n",
200
+ " </tr>\n",
201
+ " </tbody>\n",
202
+ "</table>\n",
203
+ "</div>"
204
+ ],
205
+ "text/plain": [
206
+ " score uid vendor \\\n",
207
+ "0 0.751176 34985afc-0e36-4e1a-8494-1e9d06cf57ac jxmdaudio \n",
208
+ "1 0.741887 5ed011c5-8fb7-41b0-b6cc-b469f67e29dc Distritech \n",
209
+ "2 0.719547 ba329fd4-07c8-4fc6-bbc8-11c37ac7f615 likistor \n",
210
+ "3 0.708177 5994bc56-967a-494e-8011-553826b5a5b1 CatoGifts \n",
211
+ "4 0.707036 b3291e0e-a5d1-4d08-9c3e-e4c0f85276f2 IVY DUCK \n",
212
+ "\n",
213
+ " title \\\n",
214
+ "0 Active Noise Cancelling Headphones Wireless Over Ear Bluetooth Headphones \n",
215
+ "1 SONY WIRELESS NOISE CANCELING OVERHEAD HEADPHONES, MIDNIGHT BLUE \n",
216
+ "2 Wireless Noise-Cancelling Headphones \n",
217
+ "3 Noise Cancelling Wireless Headset \n",
218
+ "4 Wireless Bluetooth Noise Cancelling Headphones \n",
219
+ "\n",
220
+ " paragraph \n",
221
+ "0 Active Noise Cancelling Headphones Wireless Over Ear Bluetooth Headphones by jxmdaudio - $39.99 . Limited quantityFirst come First served. Professional Active Noise Cancelling Technology Proprietary 40mm Large-aperture Drivers. High-quality Built-in Microphone and NFC Technology. The Professional Protein Earpad and 90 Swiveling Earcups. A built-in 600mAh battery won't allow your headphones power off, you can enjoy your world without noise for 30 hours' long time. \n",
222
+ "1 SONY WIRELESS NOISE CANCELING OVERHEAD HEADPHONES, MIDNIGHT BLUE by Distritech - $173.00 . WIRELESS NOISE CANCELING OVERHEAD HEADPHONES \n",
223
+ "2 Wireless Noise-Cancelling Headphones by likistor - $59.99 . SPECIFICATIONS Style: Headphone. Vocalism Principle: Dynamic Material: ABS Hign-concerned Chemical: none Communication: True Wireless Volume Control: Yes Category: Earphones &amp; Headphones Number Of Drivers: 2 Active Noise-Cancellation: Yes Waterproof: No Wireless Type: bluetooth Control Button: Yes Is wireless: Yes Charging Method: cable Battery Capacity[mAh]: 100 Maximum wireless range[m]: &lt;10m \n",
224
+ "3 Noise Cancelling Wireless Headset by CatoGifts - $42.04 . Experience Crystal Clear Sound with Our Noise Cancelling Wireless HeadsetImmerse yourself in superior audio quality with our noise cancelling wireless headset. Designed to block out external noise, it lets you enjoy your favorite music, podcasts, and calls with unparalleled clarity and precision.Elevate Your Listening Experience with Our Noise Cancelling Wireless HeadsetTake your audio experience to the next level with our noise cancelling wireless headset. Whether you're commuting, working, or relaxing at home, this headset provides an immersive soundscape free from distractions.Enjoy Uninterrupted Sound with Our Noise Cancelling Wireless HeadsetSay goodbye to background noise and hello to uninterrupted sound with our noise cancelling wireless headset. Its advanced technology ensures you hear every detail, making it perfect for music lovers and professionals alike.Stay Connected and Focused with Our Noise Cancelling Wireless HeadsetMaintain focus and stay connected wherever you are with our noise cancelling wireless headset. Its wireless design offers freedom of movement, while the noise cancelling feature ensures you stay immersed in your audio world without interruption. \n",
225
+ "4 Wireless Bluetooth Noise Cancelling Headphones by IVY DUCK - $59.99-$69.99 . Experience Uninterrupted Sound with Our Waterproof Wireless Bluetooth Noise-Cancelling Headphones Experience premium sound without the premium price with these advanced Wireless Bluetooth Noise-Cancelling Headphones. While other high-end brands may cost a fortune, our headphones deliver superior noise cancellation and crisp, clear audio at a fraction of the price. Enjoy all-day comfort with a lightweight design and long-lasting battery life, ensuring you get the most out of every listening session. Elevate your audio experience today with top-tier performance and unbeatable value! Advanced Noise-Cancelling Technology: Immerse yourself in your favourite tunes with state-of-the-art active noise-cancelling technology. Block out distractions and enjoy crystal-clear sound, whether youre on a noisy commute or in a bustling caf. High-Fidelity Sound: Experience rich, detailed audio with deep bass and clear highs. Our advanced drivers ensure you hear every note, making these headphones perfect for music lovers and audiophiles alike. Seamless Bluetooth Connectivity: Enjoy wireless freedom with the latest Bluetooth technology. Pair effortlessly with your devices and maintain a stable connection for uninterrupted listening. Long Battery Life: Stay powered throughout the day with an impressive battery life. Whether youre traveling or working, these headphones keep you connected and entertained for hours on end. Comfortable Fit: Designed with ergonomics in mind, these headphones feature plush ear cushions and an adjustable headband for a personalised, comfortable fit. Wear them all day without discomfort. Built-in Microphone &amp; Controls: Take calls and manage your music with ease using the integrated microphone and intuitive controls. Switch tracks, adjust volume, and answer calls with a simple touch. Premium Build Quality: Crafted with high-quality materials, these headphones offer durability and a sleek, modern design. They are built to withstand daily use while looking stylish. Foldable Design: For added convenience, the headphones feature a foldable design, making them easy to store and transport. Perfect for on-the-go lifestyles! Experience superior sound with our Wireless Bluetooth Noise-Cancelling Headphones. Engineered for immersive audio, these premium headphones offer crystal-clear sound and advanced noise cancellation, elevating your listening experience to new heights. Perfect for audiophiles and casual listeners alike, they blend luxury and performance effortlessly. Upgrade your audio with the ultimate in comfort and style today! "
226
+ ]
227
+ },
228
+ "metadata": {},
229
+ "output_type": "display_data"
230
+ }
231
+ ],
232
+ "source": [
233
+ "import glob, heapq, logging, os, time\n",
234
+ "import polars as pl\n",
235
+ "import pandas as pd\n",
236
+ "import numpy as np\n",
237
+ "from sentence_transformers import SentenceTransformer\n",
238
+ "from IPython.display import display\n",
239
+ "\n",
240
+ "# ─── logging config ───────────────────────────────────────────────────────────\n",
241
+ "logging.basicConfig(\n",
242
+ " level=logging.INFO,\n",
243
+ " format=\"[%(asctime)s] %(message)s\",\n",
244
+ " datefmt=\"%H:%M:%S\"\n",
245
+ ")\n",
246
+ "\n",
247
+ "# ─── helper: cosine similarity ────────────────────────────────────────────────\n",
248
+ "def cosine_batch(q_vec: np.ndarray, mat: np.ndarray) -> np.ndarray:\n",
249
+ " q_norm = q_vec / np.linalg.norm(q_vec)\n",
250
+ " mat_norm = mat / np.linalg.norm(mat, axis=1, keepdims=True)\n",
251
+ " return mat_norm @ q_norm\n",
252
+ "\n",
253
+ "# ─── model & shards ───────────────────────────────────────────────────────────\n",
254
+ "MODEL_NAME = \"sentence-transformers/all-MiniLM-L6-v2\"\n",
255
+ "encoder = SentenceTransformer(MODEL_NAME)\n",
256
+ "SHARDS = sorted(glob.glob(\"tsmpd_public_*.parquet\"))\n",
257
+ "\n",
258
+ "# ─── streaming search ─────────────────────────────────────────────────────────\n",
259
+ "def search_streaming(query: str, top_k: int = 10) -> pd.DataFrame:\n",
260
+ " q_vec = encoder.encode(query, convert_to_numpy=True).astype(\"float32\")\n",
261
+ "\n",
262
+ " best = [] # heap of (score, uid, vendor, title, paragraph)\n",
263
+ " heapq.heapify(best)\n",
264
+ "\n",
265
+ " for idx, shard in enumerate(SHARDS, 1):\n",
266
+ " t0 = time.perf_counter()\n",
267
+ " logging.info(f\"Shard {idx}/{len(SHARDS)} → loading {os.path.basename(shard)}\")\n",
268
+ "\n",
269
+ " tbl = pl.read_parquet(\n",
270
+ " shard,\n",
271
+ " columns=[\"uid\", \"vendor\", \"title\", \"paragraph\", \"embedding\"]\n",
272
+ " )\n",
273
+ " logging.info(f\" rows = {tbl.height:,} | load = {time.perf_counter() - t0:.1f}s\")\n",
274
+ "\n",
275
+ " embs = np.vstack(tbl[\"embedding\"].to_list()).astype(\"float32\")\n",
276
+ " sims = cosine_batch(q_vec, embs)\n",
277
+ "\n",
278
+ " for i, score in enumerate(sims):\n",
279
+ " item = (\n",
280
+ " float(score),\n",
281
+ " tbl[\"uid\"][i],\n",
282
+ " tbl[\"vendor\"][i],\n",
283
+ " tbl[\"title\"][i],\n",
284
+ " tbl[\"paragraph\"][i],\n",
285
+ " )\n",
286
+ " if len(best) < top_k:\n",
287
+ " heapq.heappush(best, item)\n",
288
+ " elif score > best[0][0]:\n",
289
+ " heapq.heapreplace(best, item)\n",
290
+ "\n",
291
+ " logging.info(\n",
292
+ " f\" processed in {time.perf_counter() - t0:.1f}s \"\n",
293
+ " f\"best_min={best[0][0]:.4f}\"\n",
294
+ " )\n",
295
+ " del tbl, embs, sims # free mem per shard\n",
296
+ "\n",
297
+ " if not best:\n",
298
+ " return pd.DataFrame()\n",
299
+ "\n",
300
+ " best_sorted = sorted(best, key=lambda x: x[0], reverse=True)\n",
301
+ " scores, uids, vendors, titles, paras = zip(*best_sorted)\n",
302
+ "\n",
303
+ " return pd.DataFrame({\n",
304
+ " \"score\": scores,\n",
305
+ " \"uid\": uids,\n",
306
+ " \"vendor\": vendors,\n",
307
+ " \"title\": titles,\n",
308
+ " \"paragraph\": paras\n",
309
+ " })\n",
310
+ "\n",
311
+ "# ─── run a test query ─────────────────────────────────────────────────────────\n",
312
+ "query = \"wireless noise cancelling headphones\"\n",
313
+ "start = time.perf_counter()\n",
314
+ "hits = search_streaming(query, top_k=5)\n",
315
+ "elapsed = time.perf_counter() - start\n",
316
+ "logging.info(f\"Finished query in {elapsed:.1f}s\")\n",
317
+ "\n",
318
+ "# display full text in each column\n",
319
+ "pd.set_option(\"display.max_colwidth\", None)\n",
320
+ "display(hits)\n"
321
+ ]
322
+ },
323
+ {
324
+ "cell_type": "code",
325
+ "execution_count": null,
326
+ "id": "d6261abe-ce70-43db-9cea-328fb12933d6",
327
+ "metadata": {},
328
+ "outputs": [],
329
+ "source": []
330
+ }
331
+ ],
332
+ "metadata": {
333
+ "kernelspec": {
334
+ "display_name": "Python 3 (ipykernel)",
335
+ "language": "python",
336
+ "name": "python3"
337
+ },
338
+ "language_info": {
339
+ "codemirror_mode": {
340
+ "name": "ipython",
341
+ "version": 3
342
+ },
343
+ "file_extension": ".py",
344
+ "mimetype": "text/x-python",
345
+ "name": "python",
346
+ "nbconvert_exporter": "python",
347
+ "pygments_lexer": "ipython3",
348
+ "version": "3.13.2"
349
+ }
350
+ },
351
+ "nbformat": 4,
352
+ "nbformat_minor": 5
353
+ }