Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- PRESET_QUERIES.py +1 -1
- app.ipynb +104 -20
PRESET_QUERIES.py
CHANGED
@@ -20,6 +20,6 @@ Query_Doc_Map = {
|
|
20 |
],
|
21 |
|
22 |
'who is Daniel Ringel?': [
|
23 |
-
'CV/
|
24 |
]
|
25 |
}
|
|
|
20 |
],
|
21 |
|
22 |
'who is Daniel Ringel?': [
|
23 |
+
'CV/Ringel_Daniel_CV.docx'
|
24 |
]
|
25 |
}
|
app.ipynb
CHANGED
@@ -111,15 +111,15 @@
|
|
111 |
"name": "stderr",
|
112 |
"output_type": "stream",
|
113 |
"text": [
|
114 |
-
"100%|██████████| 1/1 [00:00<00:00,
|
115 |
]
|
116 |
},
|
117 |
{
|
118 |
"name": "stdout",
|
119 |
"output_type": "stream",
|
120 |
"text": [
|
121 |
-
"Transformers are a type of model architecture
|
122 |
-
"[Document(metadata={'source': '../../Data/
|
123 |
]
|
124 |
}
|
125 |
],
|
@@ -135,32 +135,116 @@
|
|
135 |
"metadata": {},
|
136 |
"outputs": [],
|
137 |
"source": [
|
138 |
-
"
|
139 |
-
"
|
140 |
-
"
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"
|
144 |
-
"
|
145 |
]
|
146 |
},
|
147 |
{
|
148 |
"cell_type": "code",
|
149 |
"execution_count": 7,
|
150 |
"metadata": {},
|
151 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
"source": [
|
153 |
-
"
|
154 |
-
"
|
155 |
-
"
|
156 |
"\n",
|
157 |
-
"
|
158 |
-
"
|
159 |
-
"
|
160 |
-
"
|
161 |
-
"
|
162 |
-
"
|
163 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
],
|
166 |
"metadata": {
|
|
|
111 |
"name": "stderr",
|
112 |
"output_type": "stream",
|
113 |
"text": [
|
114 |
+
"100%|██████████| 1/1 [00:00<00:00, 33.39it/s]\n"
|
115 |
]
|
116 |
},
|
117 |
{
|
118 |
"name": "stdout",
|
119 |
"output_type": "stream",
|
120 |
"text": [
|
121 |
+
"Transformers are a type of model architecture primarily used in natural language processing and computer vision tasks, characterized by their ability to process sequential data and capture contextual relationships through an attention mechanism. They serve as foundational models for large language models like OpenAI's GPT and image generation models like DALL-E. In marketing research, transformers have been employed for tasks such as analyzing consumer reviews, generating ideas, and studying market structures. Their application to specific datasets, like market basket data, offers opportunities to understand shopper behavior and optimize retail strategies.\n",
|
122 |
+
"[Document(metadata={'source': '../../Data/5 Working Papers/Ringel_Gabel_2024_Foundation_Model_for_Retail.pdf'}, page_content='in data. This capability gave rise to the term “foundation model,” describing large-scale,\\npretrained transformer models that serve as a base for fine-tuning across various downstream\\napplications (Bommasani et al. 2022). For example, transformers are key to the success\\nof large language models like OpenAI’s GPT and image generation models like DALL-E\\n(Brown 2020, Radford et al. 2021, Ramesh et al. 2021).\\nIn marketing research, transformers have become an increasingly popular choice for language\\nand image analysis tasks. Researchers used pretrained transformer models to create em-\\nbeddings for consumer reviews, generate ideas, identify market constructs, and even study\\nmarket structure (Puranam et al. 2021, Ringel 2023a, Li et al. 2024, Castelo et al. 2024).\\nApplications typically relied on off-the-shelf models and API services—operating within\\nthe constraints of pretrained models not explicitly optimized for marketing data—or minor'), Document(metadata={'source': '../../Data/5 Working Papers/Ringel_Gabel_2024_Foundation_Model_for_Retail.pdf'}, page_content='Applications typically relied on off-the-shelf models and API services—operating within\\nthe constraints of pretrained models not explicitly optimized for marketing data—or minor\\nadaptations of the learned models through fine-tuning to text and image data collected in\\nspecific applications. Recently, marketing research has started applying transformers to\\nmarketing-specific datasets. For example, Lu and Kannan (2024) apply transformers to\\nanalyze customer interactions across various touchpoints in an e-commerce setting.\\nOur research explores the adaptation of transformers to market basket data and retailing\\nanalytics. The analysis of purchase data is a cornerstone in retail analytics, used to un-\\nderstand shopper behavior, optimize product placement, and enhance promotions (Agrawal\\net al. 1993, Manchanda et al. 1999, Russell and Petersen 2000). Applying transformers\\nin retailing, specifically to market basket data, presents a promising opportunity for three'), Document(metadata={'source': '../../Data/5 Working Papers/Ringel_Gabel_2024_Foundation_Model_for_Retail.pdf'}, page_content='et al. 1993, Manchanda et al. 1999, Russell and Petersen 2000). Applying transformers\\nin retailing, specifically to market basket data, presents a promising opportunity for three\\nreasons. First, similar to language and images, the composition of a shopping basket is not\\nrandom, but baskets’ content reflects customer preferences and purchase intentions (Russell\\nand Kamakura 1997). Second, products often co-occur systematically, indicating underly-\\ning purchase complementarities (Manchanda et al. 1999). Third, the structure of market\\nbasket and loyalty card data is very similar to that of text and image data (Jacobs et al.\\n2016, Gabel and Timoshenko 2022). These three reasons support the idea that transform-\\ners and their attention mechanism, designed to capture contextual relationships, could be\\nwell-suited for analyzing shopping basket data.\\nOur work makes three contributions to marketing research. First, we show how to implement')]\n"
|
123 |
]
|
124 |
}
|
125 |
],
|
|
|
135 |
"metadata": {},
|
136 |
"outputs": [],
|
137 |
"source": [
|
138 |
+
"prompts = [\n",
|
139 |
+
" 'Who is daniel?',\n",
|
140 |
+
" 'Who is ringel?',\n",
|
141 |
+
" 'Who are you?',\n",
|
142 |
+
" 'What is your name?',\n",
|
143 |
+
" 'What is your job?',\n",
|
144 |
+
"]"
|
145 |
]
|
146 |
},
|
147 |
{
|
148 |
"cell_type": "code",
|
149 |
"execution_count": 7,
|
150 |
"metadata": {},
|
151 |
+
"outputs": [
|
152 |
+
{
|
153 |
+
"name": "stdout",
|
154 |
+
"output_type": "stream",
|
155 |
+
"text": [
|
156 |
+
"Response from routing: query_text: who is daniel? - best_match query: who is Daniel Ringel? - Doc: CV/Ringel_Daniel_CV.docx - similarity: 0.8395398648603472\n",
|
157 |
+
"Daniel M. Ringel is an Assistant Professor of Marketing at the University of North Carolina at Chapel Hill's Kenan-Flagler Business School. He holds a Ph.D. in Marketing from Goethe-University in Frankfurt, Germany. His research focuses on the intersection of marketing and artificial intelligence, particularly in advancing data-driven marketing through AI and machine learning. Daniel has received several awards for his contributions to the field, including the Weatherspoon Award for Excellence in MBA Teaching and various research and dissertation awards. He is actively involved in teaching, research, and presenting at conferences, with a strong emphasis on integrating AI into marketing practices.\n",
|
158 |
+
"../../Data/CV/Ringel_Daniel_CV.docx\n",
|
159 |
+
"\n",
|
160 |
+
"\n",
|
161 |
+
"\n",
|
162 |
+
"Response from routing: query_text: who is ringel? - best_match query: who is Daniel Ringel? - Doc: CV/Ringel_Daniel_CV.docx - similarity: 0.9999990992727665\n",
|
163 |
+
"Daniel M. Ringel is an Assistant Professor of Marketing at the Kenan-Flagler Business School, University of North Carolina at Chapel Hill. He has a Ph.D. in Marketing from Goethe-University Frankfurt, Germany, and has extensive experience in marketing, artificial intelligence, and data science. His research focuses on integrating marketing theory with AI applications to create insights into market dynamics and consumer behavior. Daniel is known for his innovative approaches to data-driven marketing and has received several awards, including the Weatherspoon Award for Excellence in MBA Teaching. He has published numerous journal articles and presented his work at various conferences. Additionally, he is actively involved in teaching and service activities at UNC Chapel Hill.\n",
|
164 |
+
"../../Data/CV/Ringel_Daniel_CV.docx\n",
|
165 |
+
"\n",
|
166 |
+
"\n",
|
167 |
+
"\n"
|
168 |
+
]
|
169 |
+
},
|
170 |
+
{
|
171 |
+
"name": "stderr",
|
172 |
+
"output_type": "stream",
|
173 |
+
"text": [
|
174 |
+
"100%|██████████| 1/1 [00:00<00:00, 32.43it/s]\n"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"name": "stdout",
|
179 |
+
"output_type": "stream",
|
180 |
+
"text": [
|
181 |
+
"Hello! I am Wagner, an assistant named after the character from Goethe’s Faust. In Goethe's work, Wagner serves as the loyal student and assistant to Faust. Similarly, I am dedicated to assisting with all things related to Daniel Rangel’s research in artificial intelligence and marketing. My role is to provide clear, structured, and accurate information based on his academic work and career, reflecting Daniel’s contributions to the field within a defined scope.\n",
|
182 |
+
"{'source': '../../Data/Who-is-Wagner-Chatbot-Response.docx'}\n",
|
183 |
+
"{'source': '../../Data/5 Working Papers/Matthe_Ringel_Skiera_2024_In_Search_of_Signals.pdf'}\n",
|
184 |
+
"\n",
|
185 |
+
"\n",
|
186 |
+
"\n"
|
187 |
+
]
|
188 |
+
},
|
189 |
+
{
|
190 |
+
"name": "stderr",
|
191 |
+
"output_type": "stream",
|
192 |
+
"text": [
|
193 |
+
"100%|██████████| 1/1 [00:00<00:00, 14.19it/s]\n"
|
194 |
+
]
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"name": "stdout",
|
198 |
+
"output_type": "stream",
|
199 |
+
"text": [
|
200 |
+
"Hello! My name is Wagner. I'm an assistant named after the character from Goethe’s Faust, dedicated to assisting with Daniel Rangel’s research in artificial intelligence and marketing.\n",
|
201 |
+
"{'source': '../../Data/Who-is-Wagner-Chatbot-Response.docx'}\n",
|
202 |
+
"{'source': '../../Data/5 Working Papers/Matthe_Ringel_Skiera_2024_In_Search_of_Signals.pdf'}\n",
|
203 |
+
"{'source': '../../Data/5 Working Papers/Ringel_Gabel_2024_Foundation_Model_for_Retail.pdf'}\n",
|
204 |
+
"\n",
|
205 |
+
"\n",
|
206 |
+
"\n"
|
207 |
+
]
|
208 |
+
},
|
209 |
+
{
|
210 |
+
"name": "stderr",
|
211 |
+
"output_type": "stream",
|
212 |
+
"text": [
|
213 |
+
"100%|██████████| 1/1 [00:00<00:00, 42.79it/s]\n"
|
214 |
+
]
|
215 |
+
},
|
216 |
+
{
|
217 |
+
"name": "stdout",
|
218 |
+
"output_type": "stream",
|
219 |
+
"text": [
|
220 |
+
"I am Wagner, an AI assistant dedicated to assisting with inquiries related to Daniel Rangel's research in artificial intelligence and marketing. My role is to provide clear, structured, and accurate information based on Daniel's academic work, including his published and working papers, CV, and research profile.\n",
|
221 |
+
"{'source': '../../Data/Who-is-Wagner-Chatbot-Response.docx'}\n",
|
222 |
+
"{'source': '../../Data/5 Working Papers/Matthe_Ringel_Skiera_2024_In_Search_of_Signals.pdf'}\n",
|
223 |
+
"\n",
|
224 |
+
"\n",
|
225 |
+
"\n"
|
226 |
+
]
|
227 |
+
}
|
228 |
+
],
|
229 |
"source": [
|
230 |
+
"for prompt in prompts:\n",
|
231 |
+
" response, source = chatbot.query_chatbot(prompt, k=15, rerank=True)\n",
|
232 |
+
" print(response)\n",
|
233 |
"\n",
|
234 |
+
" if type(source) == str:\n",
|
235 |
+
" print(source)\n",
|
236 |
+
" else:\n",
|
237 |
+
" for docs in source:\n",
|
238 |
+
" print(docs.metadata)\n",
|
239 |
+
" print('\\n\\n')"
|
240 |
]
|
241 |
+
},
|
242 |
+
{
|
243 |
+
"cell_type": "code",
|
244 |
+
"execution_count": null,
|
245 |
+
"metadata": {},
|
246 |
+
"outputs": [],
|
247 |
+
"source": []
|
248 |
}
|
249 |
],
|
250 |
"metadata": {
|