Top
Best
New

Posted by softwaredoug 3 days ago

Don't classify, hallucinate(softwaredoug.com)
168 points | 71 comments
Sharlin 3 hours ago|
I can’t believe programming is now at the stage where advice like "first have the computer give you totally wrong answers, then just find a function that maps the wrong answers to the correct ones!" is a thing.
pie_flavor 1 hour ago||
> On two occasions I have been asked, – "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

He clearly didn't know enough about vector embeddings.

Xirdus 1 hour ago||
Unironically, LLM is absolutely amazing at giving you the right answers when you put in wrong input, compared to every other algorithm ever invented.
speerer 2 hours ago|||
This is so similar to human decision-making though. First I my innate experience to approximate to what I expect is right, then I map that to the truth.

It's the same for so many things:

- reading documentation (what do I expect this function to be called?)

- finding clothes in a shop (something long-sleeved and light)

- picking the fridge for dinner

- finding a book in the library...

so many analogues where I'm not coming cold to a choice.

philipov 1 hour ago|||
If information is totally wrong then all you have to do is invert it to get the truth. What was it that Sherlock Holmes said? The problem ends up being that it often takes a tremendous number of counterexamples to eliminate everything that is impossible.

Worse is when you don't know whether the answers you have are totally wrong.

agos 3 hours ago|||
the trick is that it's not totally wrong to start with
addandsubtract 2 hours ago|||
If there is no truth, there is no wrong.
devmor 1 hour ago|||
This been the case for a long time!

The entire problem of search is that the user has the wrong data and wants to use it to receive the correct data. That was the start, not the state we’ve ended up at - it is unironically how we got to LLMs.

willturman 2 hours ago||
I can't believe people spend their lives finding lazier ways to classify a bunch of objects that will end up heaped in dormitory dumpsters across the US next spring.
kgeist 3 hours ago||
A common case I have is when you don't have classifications to begin with. For example, you need to find what users complain about most. I take embeddings of all records, then cluster the embeddings into semantic groups, then ask an LLM to take a random sample from each clustered group and create a classification for that group.

This method is sensitive to the thresholds (what is the maximum distance between embeddings for them to be still considered part of the same semantic group), so I run it all in an agentic loop where an agent tries different thresholds and clustering algorithms until it's satisfied with the result, plus it may deduplicate some groups.

I run it all on self-hosted hardware, so it costs nothing to leave it running for, like, a night, and as a bonus, none of the corporate data leaves the office. I think a rigid set of manually created classifications may not capture all the possible classifications that can exist. Needs a review by a human, though.

alexpotato 3 hours ago|
I worked on spam classification for litigation targeting in the early days of CANSPAM [0] enforcement.

We had a similar problem where you can literally millions of email that we were pretty sure came from only a limited set of bad actors.

We first started classifying emails into buckets by From, mailserver relay chains etc as that's all we had to to go on.

Over time, those buckets got linked to spammer signatures and then we narrowed down from there.

Fascinating to see this happening nowadays with LLMs.

pu_pe 3 hours ago||
Nice trick. Couldn't you embed the query though, compare it to the embedding of the categories, then ship only categories that are close to it in the prompt to a smaller model?
kgeist 2 hours ago||
It's basically a variation of HyDE (Hypothetical Document Embeddings), and the rationale is that the embedding of the query is not necessarily close to the embedding of the answer. If you generate a hallucinated answer, it can line up with the actual document better (in the embedding space, via BM25, or hybrid).

But honestly, it only works for common knowledge that's already in the LLM. If the target document contains very niche or private information, then the hallucinated answer's embedding can be even farther away than the query's.

liampulles 36 minutes ago|||
It might be a little worse, but it will definitely be way cheaper.
softwaredoug 3 hours ago|||
Yes absolutely that's another good trick.

Even better is to search the corpus first with like naive BM25 / embedding search, aggregate over top N to get most representative categories, then have the LLM categorize in that set.

vessenes 3 hours ago|||
Agreed that you almost certainly can just embed the original with most modern embedding models.
tantalor 3 hours ago||
Yeah I had the same question. What's the point of the intermediate step?
Majromax 4 hours ago||
> In the notebook, I compute a MiniLM embedding of every real Wayfair classification. I compute the embedding of the fake, hypothetical embedding from the LLM. I then dot product the fake embedding into the real ones to find the most similar. Producing: [the right answer]

Isn't this begging the question that the hallucinated classification will be more selective with respect to the real schema than the query itself? What would the dot product of <E(search query), E(schema)> have given?

Even if that is too vague, smaller LLMs are capable rerankers; return the top N matching true categories and ask for a contextual ordering.

softwaredoug 3 hours ago|
Yes what you're describing is a classic way of doing query understanding.

I've found, though, getting it in the language of the vocabulary has generally improved performance.

Further, when searching for "blue shoes" you want to separate the color from the item type. So its useful to have a dumb LLM do this for you. And with the LLM in the loop, its further useful to get it into the language of the taxonomy to improve embedding retrieval accuracy.

There are of course many ways to skin the cat here :)

cimi_ 2 hours ago||
I did something similar 10 years ago, but instead of llms I used word2vec to calculate a embeddings of product descriptions and map those to existing categories. The LLM approach is very likely better, but I'm curious what the cost difference is.
arjie 3 hours ago||
Prompt expansion of input to extra categories makes sense if your embedding isn’t working well. But on its own, why use the LLM at all? I think you could have demonstrated the original step first and then shown that it’s useful.
eka1 5 hours ago||
Did you validate this by running a A/B test? Main question is were you able to classify back into your known categories correctly all the time, or did the errors compound from the llm hallucination plus embedding search
softwaredoug 5 hours ago|
Using a Nano model, a tad worse than shipping a vocabulary to a larger OpenAI model. (And it’s an huge improvement on not classifying the queries at all).

But no classification is perfect. In search in particular, you will also want to have places for manual intervention for high priority queries.

jingpostmedia 4 hours ago||
[flagged]
amitpoonia19xyz 3 hours ago||
This is basically HyDE (Hypothetical Document Embeddings), no? I had tried this approach in the past, worked with limited success.
memjay 3 hours ago||
We have this running in production. Can get pretty expensive and slow. We are trying to replace this with cheaper and faster methods that don’t hammer our LLM and elastic search endpoints as much.
kaycebasques 1 hour ago||
https://arxiv.org/abs/2212.10496 for others like me hearing about HyDE for the first time
piterrro 4 hours ago||
I would propose the following, query vector store for 10 closest categories based on a query, feed it to an LLM, in the prompt ask it to produce a single digit 0-9 representing the number of the most appropriate choice. Use plain text prompt, dont inflate token count with JSON. There you go, you just drastically reduced the output pricing.

Additionally you could experiment with a reranker instead of an LLM or after reranking take top-3 results and then feed to LLM as input in order to reduce input token costs.

jddj 4 hours ago|||
Or press 9 to hear these options again
virgil_disgr4ce 3 hours ago||
Your call is important to us. Please listen carefully, as our menu options have changed.
cesargstn 4 hours ago||
good this yeah
iandanforth 3 hours ago|
No? This is just giving up and hoping.
motoxpro 3 hours ago||
Is there a solution you are using to solve this that is more accurate and cost effective? I'm working through it now so would be curious
runarberg 3 hours ago||
Is scraping and putting this in a structured format too inaccurate or expensive?
motoxpro 2 hours ago||
That's the whole problem. If you have tons (100s of thousands or more) of labels, then you have "structured" data, but how do you correctly classify that scraped item into the correct label?

Putting all the labels into the LLM is super expensive per call when you have millions of items to classify.

You can't reduce the number of labels becasue they are correctly organizes/structured. This class of problem exists in many different domains.

runarberg 2 hours ago||
100s of thousand? In that case I would label about a 100 by hand and train a supervised learning model.

This problem has also been solved for 3 decades now.

chrisjj 3 hours ago||
No change from regular chatbot coding, then.
More comments...