File size: 13,888 Bytes
aa535a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25d3bd1
1d6c0c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yelp LLM Query Understanding</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <style>
        /* Use Inter font */
        body {
            font-family: 'Inter', sans-serif;
            background-color: #f8fafc; /* Light gray background */
        }
        /* Custom styles for arrows and boxes */
        .arrow {
            position: relative;
            width: 100%;
            height: 2px;
            background-color: #6b7280; /* Gray-500 */
            margin: 1.5rem 0;
        }
        .arrow::after {
            content: '';
            position: absolute;
            right: -1px;
            top: -4px;
            width: 0;
            height: 0;
            border-top: 5px solid transparent;
            border-bottom: 5px solid transparent;
            border-left: 8px solid #6b7280; /* Gray-500 */
        }
        .dashed-arrow {
            position: relative;
            width: 100%;
            height: 2px;
            background-image: linear-gradient(to right, #9ca3af 33%, rgba(255,255,255,0) 0%); /* Gray-400 dashed */
            background-position: bottom;
            background-size: 8px 2px;
            background-repeat: repeat-x;
            margin: 1rem 0;
        }
         .dashed-arrow::after {
            content: '';
            position: absolute;
            right: -1px;
            top: -4px;
            width: 0;
            height: 0;
            border-top: 5px solid transparent;
            border-bottom: 5px solid transparent;
            border-left: 8px solid #9ca3af; /* Gray-400 */
        }
        .highlight-topic { background-color: #bfdbfe; color: #1e40af; } /* Blue */
        .highlight-location { background-color: #bbf7d0; color: #15803d; } /* Green */
        .highlight-time { background-color: #fef08a; color: #a16207; } /* Yellow */
        .highlight-name { background-color: #fed7aa; color: #9a3412; } /* Orange */
        .highlight-question { background-color: #fbcfe8; color: #9d174d; } /* Pink */
        .highlight-spellcorrect { text-decoration: underline wavy #dc2626; } /* Red wavy underline */
        .tag {
            display: inline-block;
            padding: 0.1rem 0.4rem;
            border-radius: 0.25rem;
            font-size: 0.75rem;
            font-weight: 500;
            margin-right: 0.25rem;
            white-space: nowrap;
        }
        .llm-box {
            border: 2px solid #fbbf24; /* Amber-400 */
            background-color: #fefce8; /* Amber-50 */
        }
        .rag-box {
            border: 2px dashed #a5b4fc; /* Indigo-300 */
            background-color: #eef2ff; /* Indigo-50 */
        }
        .input-box, .output-box {
             border: 2px solid #9ca3af; /* Gray-400 */
             background-color: #ffffff; /* White */
        }
        .card {
            background-color: white;
            border-radius: 0.75rem; /* lg */
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
            padding: 1.5rem; /* p-6 */
            margin-bottom: 2rem; /* mb-8 */
        }
        .section-title {
            font-size: 1.5rem; /* text-2xl */
            font-weight: 600; /* font-semibold */
            margin-bottom: 1rem; /* mb-4 */
            color: #1f2937; /* Gray-800 */
        }
        .step-label {
            font-size: 0.875rem; /* text-sm */
            font-weight: 500; /* font-medium */
            color: #4b5563; /* Gray-600 */
            margin-bottom: 0.5rem; /* mb-2 */
            text-align: center;
        }
    </style>
</head>
<body class="p-4 md:p-8">

    <h1 class="text-3xl md:text-4xl font-bold text-center mb-8 md:mb-12 text-gray-900">
        Visualizing Yelp's LLM Query Understanding
    </h1>

    <div class="card">
        <h2 class="section-title">1. Query Segmentation & Spell Correction</h2>
        <p class="text-gray-700 mb-6">The LLM identifies and labels semantic parts of a search query, correcting misspellings simultaneously.</p>

        <div class="grid grid-cols-1 md:grid-cols-5 gap-4 items-start">
            <div class="flex flex-col items-center">
                <div class="step-label">Input Query</div>
                <div class="input-box p-3 rounded-lg w-full text-center shadow">
                    "healthy fod near me"
                </div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">LLM Processing</div>
                <div class="llm-box p-3 rounded-lg w-full text-center shadow mb-2">
                    <span class="font-semibold text-amber-700">LLM</span>
                    <div class="text-xs text-amber-600">(e.g., GPT-4 / Fine-tuned Model)</div>
                </div>
                 <div class="step-label mt-2">Retrieval Augmented Generation (RAG)</div>
                 <div class="rag-box p-2 rounded-lg w-full text-center shadow text-xs">
                    <span class="font-semibold text-indigo-700">RAG Input:</span>
                    <div class="text-indigo-600">Viewed Businesses: ["Salad Place", "Green Bowl"]</div>
                 </div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">Output Segmentation</div>
                <div class="output-box p-3 rounded-lg w-full text-center shadow">
                    <span class="tag highlight-topic">topic</span> <span class="highlight-spellcorrect">healthy food</span> <span class="tag highlight-location">location</span> near me
                    <div class="text-xs text-red-600 mt-1">[Spell Corrected: fod -> food]</div>
                </div>
            </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-5 gap-4 items-start mt-12 pt-8 border-t border-gray-200">
            <div class="flex flex-col items-center">
                <div class="step-label">Input Query</div>
                <div class="input-box p-3 rounded-lg w-full text-center shadow">
                    "pet-friendly sf restaurants open now"
                </div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">LLM Processing</div>
                <div class="llm-box p-3 rounded-lg w-full text-center shadow mb-2">
                    <span class="font-semibold text-amber-700">LLM</span>
                     <div class="text-xs text-amber-600">(e.g., GPT-4 / Fine-tuned Model)</div>
                </div>
                 <div class="h-12"></div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">Output Segmentation</div>
                <div class="output-box p-3 rounded-lg w-full text-center shadow">
                    <span class="tag highlight-topic">topic</span> pet-friendly <span class="tag highlight-location">location</span> sf <span class="tag highlight-topic">topic</span> restaurants <span class="tag highlight-time">time</span> open now
                </div>
            </div>
        </div>
         <p class="text-sm text-gray-600 mt-8">
            <span class="font-semibold">Benefit:</span> This segmentation helps refine search location (e.g., understanding "sf" means San Francisco), improve business name matching, and apply relevant filters automatically. Spell correction ensures misspelled queries still yield good results. RAG helps distinguish business names from topics/locations.
        </p>
    </div>

    <div class="card">
        <h2 class="section-title">2. Review Highlights Generation</h2>
        <p class="text-gray-700 mb-6">The LLM generates a list of related phrases for a query. These phrases are then used to find and highlight relevant snippets in user reviews, helping users quickly see why a business matches their search.</p>

        <div class="grid grid-cols-1 md:grid-cols-5 gap-4 items-start">
            <div class="flex flex-col items-center">
                <div class="step-label">Input Query</div>
                <div class="input-box p-3 rounded-lg w-full text-center shadow">
                    "dinner before a broadway show"
                </div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">LLM Processing</div>
                <div class="llm-box p-3 rounded-lg w-full text-center shadow mb-2">
                    <span class="font-semibold text-amber-700">LLM</span>
                     <div class="text-xs text-amber-600">(e.g., GPT-4 / Fine-tuned Model)</div>
                </div>
                 <div class="step-label mt-2">Retrieval Augmented Generation (RAG)</div>
                 <div class="rag-box p-2 rounded-lg w-full text-center shadow text-xs">
                    <span class="font-semibold text-indigo-700">RAG Input:</span>
                    <div class="text-indigo-600">Relevant Categories: [Theater District Restaurants, Pre-Theater Menus]</div>
                 </div>
            </div>

            <div class="flex items-center justify-center md:mt-10">
                 <div class="arrow w-16 md:w-full"></div>
            </div>

            <div class="flex flex-col items-center">
                <div class="step-label">Output: Expanded Phrases</div>
                <div class="output-box p-3 rounded-lg w-full text-left text-sm shadow">
                    <ul>
                        <li>- pre-show dinner</li>
                        <li>- theater district dining</li>
                        <li>- close to broadway</li>
                        <li>- quick bite before theater</li>
                        <li>- pre-theater menu</li>
                        <li>- convenient for shows</li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="mt-12 pt-8 border-t border-gray-200">
             <h3 class="text-lg font-semibold mb-3 text-gray-800 text-center">Application: Highlighting Review Snippets</h3>
             <div class="flex flex-col md:flex-row items-center justify-center gap-4">
                 <div class="output-box p-3 rounded-lg shadow text-sm w-full md:w-1/3">
                     <span class="font-semibold">Generated Phrase:</span> "pre-show dinner"
                 </div>
                 <div class="flex items-center justify-center">
                    <div class="dashed-arrow w-16 md:w-10 transform md:rotate-0 rotate-90"></div>
                 </div>
                 <div class="bg-gray-100 p-4 rounded-lg shadow w-full md:w-2/3">
                     <p class="text-sm text-gray-700 italic">"... came here for a <strong class='bg-yellow-200 px-1 rounded'>pre-show dinner</strong> and it was perfect! Fast service and delicious food, just steps away from the theater..."</p>
                     <p class="text-xs text-gray-500 mt-1">- User Review Snippet</p>
                 </div>
             </div>
        </div>

        <p class="text-sm text-gray-600 mt-8">
            <span class="font-semibold">Benefit:</span> By generating semantically related phrases (not just keywords), the LLM helps surface highly relevant review snippets, even if the user's exact query words aren't present. This significantly improves the user's ability to quickly assess if a business meets their specific needs (like needing a quick dinner near a theater). RAG helps tailor phrases based on typical business categories associated with the query.
        </p>
    </div>

     <div class="card bg-gradient-to-r from-blue-50 to-indigo-50">
        <h2 class="section-title text-blue-900">Overall Yelp LLM Process (Simplified)</h2>
        <div class="flex flex-col md:flex-row justify-between items-center gap-4 text-center">
            <div class="p-3 bg-white rounded-lg shadow flex-1">
                <div class="font-semibold text-blue-700 mb-1">1. Formulation & POC</div>
                <p class="text-xs text-gray-600">Define task, prototype with powerful LLM (e.g., GPT-4), test on head queries.</p>
            </div>
             <div class="text-blue-600 font-bold text-2xl mx-2">&rarr;</div>
            <div class="p-3 bg-white rounded-lg shadow flex-1">
                <div class="font-semibold text-blue-700 mb-1">2. Scaling Up</div>
                <p class="text-xs text-gray-600">Create golden dataset, fine-tune smaller/cheaper LLM (e.g., GPT4o-mini), pre-compute for high-volume queries.</p>
            </div>
             <div class="text-blue-600 font-bold text-2xl mx-2">&rarr;</div>
            <div class="p-3 bg-white rounded-lg shadow flex-1">
                <div class="font-semibold text-blue-700 mb-1">3. Production Rollout</div>
                 <p class="text-xs text-gray-600">Serve pre-computed results (cache), optionally use real-time smaller model (e.g., BERT/T5/GPT4o-mini) for tail queries.</p>
            </div>
        </div>
    </div>
</body>
</html>