liveBook · Manning

Outlier detection

As explained in How Large Language Models Work

Outlier detection is the identification of observations that are unusual relative to the prevailing pattern in data.

Outlier detection finds observations that are unusual compared with the prevailing pattern. For text, it can flag requests that differ sharply from the other available texts. It is also called novelty detection. section 4.4 section 8.3.1

A typical embedding-based workflow treats detection as a classic machine-learning task:

  • Represent texts as embeddings, numeric vectors whose values change little for similar meanings, even when the wording differs. section 8.3.1
  • Compare each vector with the rest of the collection to find texts dissimilar from essentially all other texts. section 8.3.1
  • Use algorithms such as Isolation Forests or Local Outlier Factor (LoF) rather than asking an LLM alone to judge novelty. section 8.3.1 section 8.3.2

Novel customer-support problems

A support system can turn a customer's problem into an embedding and compare it with problems linked to known solutions. It may offer relevant guidance while the customer waits, but a failed or uncertain match should allow the customer to contact a person. This uses outlier detection as part of a larger system rather than relying on generated output alone. section 8.3.2

Detection is not a guaranteed safety net. Novel requests are difficult to identify without errors, and false judgments can produce a poor user experience. Restricting users to finite prompts or approved data sources is presented as safer than trying to detect every failure afterward. section 4.4

Figure 8.4 LLMs produce numeric vectors known as embeddings as an intrinsic part of their function-ing. The utility of these embeddings is dependent on the fact that these numbers only change a little bit when given similar text. The two example tests here will have similar embeddings, and thus, their plots look similar, even though they don’t share any of the same words. This is a powerful feature that was present in older machine learning techniques.
figure

Use the figure to see why semantically similar texts can occupy nearby positions in an embedding space despite sharing no words. section 8.3.1

How How Large Language Models Work covers it

How deep it goes
Defines text dissimilarity, names two algorithms, and sketches embedding workflows, but does not derive detection mechanics.
Examples
Uses contrarian customers, novel problems, unusual requests, and customer-support comparisons with known solutions.
What it assumes
Assumes basic familiarity with LLM inputs and outputs, while introducing embeddings as numeric representations for text.
What you can do after
Diagnose unusual texts with embeddings and classic algorithms while retaining prevention or human escalation for uncertain cases.
How it connects
Connects embeddings, machine learning, clustering, information visualization, classification, regression, and human fallback.

Also explained in

Compare how 2 books explain outlier detection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.