Retrieval: find the sections that govern this ticket
With the index built, the next stage finds what applies to one ticket.
Rewrite the conversation into a query and filters
| The conversation, an invented example | |
|---|---|
| customer | Hi. I booked a place in Lisbon for next week and the host just cancelled on me. THREE DAYS before I arrive. |
| customer | This is not ok. I want every cent back, and I need somewhere to stay. |
| query, from a small, fast model | host cancelled 3 days before check-in, guest wants a full refund and help rebooking |
| filters | country Portugal, the booking date, guest, stays, contact reason: host cancellation |
Customers don't write queries. They write three paragraphs across several messages, half of it about how upset they are, sometimes in a language the policies aren't written in. So turn the conversation into two things before searching:
- a short standalone query
- structured filters: country, booking date, guest or host, product, and the contact reason
A small fast model does the rewrite, and a classifier can supply the contact reason. Airbnb's voice system runs that kind of classifier fast enough to be invisible: with parallel computing, its intent detection stays under 50 ms on average.
The rewrite is also the first defense against prompt injection, text in a message written to give the model orders. Part 6 covers it. It reduces the customer's message to the facts needed to search.
Then apply the filters inside the search, not after it. Say you retrieve the top 100 by similarity and then drop everything outside the guest's country. A selective filter can leave three results, or none.
So filter as part of the search. Or split the index by country and language, and search only the right part. At this index size, the parts are cheap.
In the editor, write post_filter(scored, country, fetch, k) and pre_filter(scored, country, k), then compare what each returns for Portugal. scored holds 1,000 chunks, best first, and only 3 of the top 100 are Portuguese (PT).