AI Engineer Summit 2023
AI Engineering 201: The Rest of the Owl
Read the talk
AI Engineering 201: The Rest of the Owl
Inference supplies the bones of an AI application. Language interfaces, retrieval, structured outputs, agent memory, and production feedback turn those bones into a useful product.
From a talk by Charles Frye
Before you start: Familiarity with language-model prompts, API requests, and basic database queries will help; the article explains retrieval, constrained generation, and agent memory as they arise.
Inference is only the beginning
How do you get from a model that runs inference to a product that delivers value? Charles Frye opens with the drawing-an-owl problem: two simple outlines provide the starting geometry, but leave almost all the work of producing the finished animal unexplained. Inference is that starting geometry. The surrounding application—and the process for improving it—is the rest of the owl.
Language user interfaces, or LUIs, give that application layer a useful organizing idea. Terminals required users to learn a computer’s special language. Graphical interfaces recruited spatial intuition and vision, making computers approachable beyond specialist settings. Language models offer another change: users describe what they want, and the system translates that intention into something the machine can do.
Frye cites Sam Altman’s enthusiasm for language interfaces, but the ambition long predates foundation models. ELIZA provided a conversational psychotherapy setting in the 1960s. SHRDLU accepted instructions such as “Pick up a big red block” inside a graphical blocks world. Ask Jeeves promised a language interface to the internet, and Alexa brought spoken requests into everyday devices. The opportunity with foundation models is to make this interaction work across many domains, rather than engineering each narrow environment separately.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
From query assistants to different kinds of products
Sequoia’s Generative AI’s Act Two describes foundation models becoming components of comprehensive solutions. Honeycomb’s query assistant makes that concrete. Instead of assembling a query in an unfamiliar interface, a user can ask for slow requests, errors, or latency distribution by status code. SQL itself once carried the aspiration that ordinary business users could write queries; a request like “Can you show me slow requests?” comes closer to the interaction people actually want.
Adding language to an existing feature is the immediate opportunity. Over a longer product horizon, the interface may change the machine around it, just as terminal, desktop, and mobile interfaces supported different forms of computing. Google’s SayCan illustrates the direction: ask for a water bottle instead of opening an app and navigating several dropdowns. Frye notes that the robot demonstration plays at 4× speed, tempering the impression of readiness. The desired interaction is simple; delivering it still requires substantial engineering.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
RAG supplies the context a general model lacks
Retrieval-augmented generation chatbots have become the to-do-list application of language interfaces: a common first project. Their underlying requirement is durable. A generally knowledgeable model does not automatically know the user, the organization, or the documents relevant to a particular question. Retrieval supplies that missing context before generation.
The familiar implementation follows a short sequence:
- Collect and store the relevant material.
- Build an index, often using embeddings.
- Retrieve material relevant to the incoming question.
- Insert that material into the model’s prompt.
Frye’s Full Stack Deep Learning Discord bot uses lectures, selected papers, and the course website. Its purpose is to answer from those materials and their authors’ perspectives, rather than offer another generic answer about language models.
Vector search became the default partly through convenience: developers already using OpenAI could obtain embeddings through the same library. Dot products and softmax also felt familiar to people working with transformers. That explains the proliferation of chat-with-your-documents examples, but the lasting requirement is broader than vector storage: find useful information and place it where the model can use it.
| Retrieval option | Examples | Role |
|---|---|---|
| Vector search | Pinecone, Chroma | Retrieve by embedding similarity |
| Keyword search | Elasticsearch-style systems | Retrieve by textual matches |
| Hybrid search | Vespa | Combine vector and keyword signals |
| Existing databases | Redis, Postgres ecosystems | Combine ordinary retrieval with vector capabilities |
Frye describes Redis vector search as awkward to use but workable. The larger point is that fast retrieval from a large store is already a database problem; adopting RAG does not automatically require a separate vector database.
Free-text questions are heterogeneous, so one retrieval method may not cover them well. A useful combination is keyword and vector search plus metadata extracted by a language model, which can then drive direct filters. Frye recommends The Data Quarry’s database-oriented writing for this perspective. In the audience clarification, he returns to the invariant: search saved information from the outside world and put the result into the prompt. Ordinary database techniques and specialized vector stores are both implementations of that pattern.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Context, conversation history, and learned knowledge
How does retrieval differ from the history in a conversation with GPT-4? At the API boundary, the application constructs the message history. Earlier user and assistant messages are supplied inputs, not necessarily an immutable record of events. Frye points out that fabricated assistant history can also become a jailbreak vector, while warning against violating service terms.
In the implementations he describes, retrieved information often enters the system prompt, either once or refreshed for every user turn. He attributes the model’s attention to that message to its training. An application could instead pretend that retrieved facts were earlier user speech, but he considers that unusual. The meaningful distinction is ownership: retrieval lets the programmer supply additional information the model should have; conversational history records what the user and assistant have said.
Another audience question challenges the familiar rule that retrieval supplies knowledge while fine-tuning supplies style: what if the training set contains 100 GB of research papers? Frye treats the rule as conditional on the scale and method of adaptation. In discussing small hosted fine-tunes, an audience member suggests a 10,000-row limit and Frye tentatively agrees; that exchange should not be treated as a current API limit.
LoRA adapts a model through low-rank updates to its layers. Frye’s intuition is that a small adaptation often changes which existing computations matter most. A capable model already knows how Homer Simpson or Rick Sanchez tends to speak; a character chatbot makes that behavior central rather than incidental to its next-token probabilities. This is an explanatory intuition about small adaptations, not a proof that low-rank updates cannot teach facts.
Training on a large textbook collection moves into a different regime. Frye distinguishes it from the small fine-tunes behind the style-versus-knowledge rule and points to coding-oriented Llama derivatives as examples of changes extending beyond style, including programming and library knowledge. The practical question is how much data and what kind of update the model receives, not simply whether the work is called fine-tuning.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Choose retrieval around the actual constraints
A question about Neo4j brings the discussion to graph databases. Frye, who does not claim database specialization, relays specialists’ preference for representing graphs in Postgres. The concrete scaling difficulty is partitioning: an arbitrary graph has no obvious cut, and new edges can change which partition would be best. Rebalancing can therefore resemble a migration rather than a simple redistribution of independent records.
That difficulty may not dominate an application using a graph as external model memory. Frye sketches workloads with megabytes or gigabytes of data and tens or hundreds of thousands of requests per second to ask whether distribution across many machines is even the relevant concern; these are illustrative workloads, not reported capacity measurements. Knowledge graphs have a natural fit with language-model memory, but he has not yet seen a decisive application that settles the choice.
Metadata filtering exposes a more immediate retrieval problem. Suppose the user wants crab restaurants in San Francisco. A Boolean flag, category, or location constraint carries a different meaning from a soft similarity score.
| Strategy | Order of operations | Consequence |
|---|---|---|
| Post-filter | Retrieve crab-related candidates, then check location | Candidates elsewhere can consume the retrieval budget |
| Pre-filter | Restrict to San Francisco, then search for crab-related results | Similarity search operates within the relevant set |
Post-filtering is straightforward, but it can answer a subtly different question from the one the user asked.
Efficient pre-filtering affects index construction: the search system must support restrictions such as location while still finding similar items quickly. Different databases support different kinds of restrictions. Frye mentions Vespa and Weaviate as having good reputations here, without claiming a comprehensive comparison. The filter is part of the retrieval design, not merely a cleanup step after similarity search.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Make generated text usable by other systems
A language model produces text, but an application usually needs something it can act on. Connecting generated text to another system’s inputs turns the model into a language interface for that system. Structured outputs make that connection more robust by narrowing what the model is allowed or encouraged to return.
Several approaches work at different points in generation:
- Prompting: ReAct-style examples encourage the model to request an external API. When the request appears, the application intercepts it, calls the real API, and supplies its result instead of letting the model invent the response. Frye also recounts Riley Goodside’s dramatic prompt threatening that an orphan will die without valid JSON—a memorable example of persuasion, with effectiveness reported anecdotally.
- Fine-tuning: Gorilla, Toolformer, GPT-J, and adapted Llama models illustrate training for tool use or structured generation. Frye is skeptical about how much hosted OpenAI fine-tuning would help with arbitrary structure; OpenAI’s contemporary fine-tuning announcement did list improved formatting as a use case, which is distinct from guaranteed schema compliance.
- Retries: Validate the output, explain the mismatch, and ask for another attempt. Frye highlights Guardrails’ XML-based interface and speculates that it could fit Claude well.
These approaches respectively shape the request, the model’s learned behavior, or the response to a failed validation.
Grammar-constrained sampling intervenes before an invalid token is emitted. In llama.cpp, a grammar can rule out continuations that violate the required format. Forbidden tokens receive zero probability, equivalent to setting their log probability to negative infinity:
Context-free grammars can constrain JSON, code, and other formats that conventional systems know how to parse. Tight decoding control can make a model more useful for a particular integration even when another model has stronger general capabilities.
The audience raises TypeChat, which Frye has not used, then asks whether a GPT response could pass through Gorilla for formatting. He considers structural conversion an easier task than producing the original answer, making it a plausible job for a smaller model. His example pairs GPT-4 for primary generation with GPT-3.5 for error handling. Guardrails-style repair and LangChain-style chaining offer ways to separate those responsibilities.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Why decoding control belongs near inference
An audience correction sharpens the distinction between observing log probabilities and changing token probabilities through logit bias. Those are separate capabilities. Frye agrees that token biasing may still be available through the API, then identifies the operational problem: a grammar’s valid next tokens change as generation proceeds. A client enforcing those changes through successive requests would need a network round trip for each token instead of receiving a whole continuation in one request.
He then looks beyond one-token decisions. A richer decoder might explore several grammar-valid continuations and choose among them, using something like Monte Carlo tree search. Frye presents this as a prospective direction likely to emerge first with open models, where developers control the inference loop. The historical API discussion here predates OpenAI’s later Structured Outputs, which introduced server-side schema-constrained decoding in August 2024. That later capability changes the implementation options, while still leaving correctness of the generated values as a separate problem.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
A function call can simply be a structured answer
Training for particular tools creates a generalization problem. The Gorilla example targets APIs from Torch Hub, TensorFlow Hub, and Hugging Face; knowing those tools does not imply knowing every possible tool. A shared interface changes the problem. OpenAI’s function-calling interface uses JSON Schema to describe arguments, allowing a model trained on the common format to connect to many tools through small application adapters. Grammar constraints can further enforce the format. The integration starts to resemble ordinary web development: pass a JSON object to code that knows what to do with it.
The function need not actually execute. Suppose the application needs to classify a message as spam or not spam so it can render an appropriate interface. Describing a fictional function whose argument is that classification makes the model produce the decision in a machine-readable form. The application can consume the arguments directly.
Here is a JavaScript representation of that boundary. The schema describes the requested result; the consumer validates and uses the returned arguments without invoking a classifier function:
javascript
const classificationFunction = {
name: "report_spam_classification",
description: "Report whether the input message is spam.",
parameters: {
type: "object",
properties: {
label: {
type: "string",
enum: ["spam", "not_spam"]
}
},
required: ["label"],
additionalProperties: false
}
};
function readClassification(argumentsJson) {
const result = JSON.parse(argumentsJson);
if (
result === null ||
typeof result !== "object" ||
Array.isArray(result) ||
Object.keys(result).length !== 1 ||
!["spam", "not_spam"].includes(result.label)
) {
throw new Error("Invalid spam classification");
}
return result.label;
}
Jason Liu’s Instructor packages this broader pattern of extracting structured results. The useful artifact is the argument object, whether or not there is a downstream function to call.
The request still has to fit the function-call interface and its learned conventions. Frye uses functional programming to explain the flexibility: even a constant can be represented as a function, and optional results can have a structured representation such as a maybe. He also describes a DAG-constructor schema that yields a graph of proposed function calls rather than one call. Producing that graph is a planning result; executing it remains an application responsibility.
Structured results complicate streaming. Frye describes the function-call pattern as better suited to back-office data processing than immediate user-visible text. A pipeline could begin downstream work as soon as enough relevant upstream information arrives, but it needs a reliable boundary for deciding what is complete. Unix pipes have newline-delimited records; partial function-call arguments do not automatically offer an equivalent. Recovering useful incremental behavior is therefore a pipeline-design problem, not something solved merely by enabling a token stream.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Agents retain memories and accumulate skills
Retrieval and structured extraction are recognizable natural-language-processing tasks. Agents add something closer to the everyday image of artificial intelligence: behavior that develops over time. Generative Agents combines streams of memories with reasoning flows inside a simulated environment, producing characters whose personalities and interactions evolve.
Voyager makes the accumulation particularly concrete. Its Minecraft agent writes JavaScript against an environment API, builds routines for activities such as mining wood or attacking zombies, and retains those routines as reusable skills. It also develops its own curriculum. Frye highlights its progress on mining diamonds, a task that had been a significant reinforcement-learning challenge. Memory here includes executable procedures, not just a transcript of previous observations.
Accumulating information, skills, and tools does not remove the central obstacle: reliability. Structured outputs can help make individual interactions less fragile. Frye places that suggestion in the research landscape of the talk, when relatively little published agent work had yet incorporated the improved function-calling capabilities he was discussing.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Give agent behavior an explicit architecture
Cognitive Architectures for Language Agents, or CoALA, provides a vocabulary for comparing the design choices scattered across Voyager, ReAct, and Generative Agents. The work from Tom Griffiths’ group at Princeton revisits production systems and cognitive architectures associated with earlier AI research, including procedural, semantic, and episodic memory.
Those older systems supplied explicit organization but struggled with general knowledge and common sense. Language models supply much of that knowledge while lacking persistent memory and an explicit organization for cognition. Combining them lets the architecture define how the agent observes, remembers, reasons, selects an action, and interacts with the world.
Internal actions are an especially useful distinction. An agent can spend time reasoning, update long-term memory, or revise its decision procedure instead of immediately acting on the external environment. Making those choices explicit helps separate memory design, external grounding, and action selection. CoALA also presents a research agenda built from combinations of language-model techniques and cognitive-architecture ideas. Frye closes the architecture discussion by recommending Eugene Yan’s writing on patterns and anti-patterns.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Production observations become engineering inputs
An architecture explains how to build the system. Engineering also needs a process for improving it. Frye describes the prevailing approach as shipping to learn: the data engine or data flywheel emphasized in Full Stack Deep Learning and by Andrej Karpathy. Collect real-world data, find failures, improve the system, and repeat.
Charity Majors’ comparison with conventional software testing makes the consequence clear. Software teams describe tests as the gate to production; ML teams often need production observations to discover what their tests should contain. Frye jokes that this becomes “oops, all regression tests.” Monitoring therefore belongs at the beginning, across user behavior, performance, cost, and bugs.
The Discord bot supplies a small, concrete example. Users asked whether emoji reactions provided feedback, whether its dataset included its own source code, what it did, and even who was a good bot. These meta-questions had not seemed important while building the application. Seeing them in real conversations led Frye to add prompt handling for that class of input. He logged the interactions to Gantry, examined thumbs-up and thumbs-down examples, and read the entire collection because it was only a couple hundred rows.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Monitor the experience, not just the average request
Latency quantiles matter because a user experiences a sequence of requests. A system that is fast for most individual requests can still repeatedly expose engaged users to its slow tail. Frye emphasizes watching extreme quantiles such as p99 rather than stopping at a satisfactory p90. Throughput is a separate signal: how much work the system completes is not the same as how long an individual request takes.
| Deployment | Operational signals |
|---|---|
| Hosted inference API | Request rates, API errors, latency, cost |
| Self-served inference | Those application signals plus compute utilization and inference throughput |
Randomly sampled profiles and traces help explain the aggregate numbers and locate throughput problems. When serving inference yourself, maintaining that throughput becomes a direct responsibility requiring more model- and hardware-specific investigation.
The tooling landscape spans several established categories:
- General observability: Datadog, Sentry, New Relic, Honeycomb, or custom OpenTelemetry-compatible instrumentation.
- ML tooling: Weights & Biases, where Frye previously worked, alongside Fiddler, Arize, and Gantry. Their emphases differ between training management and production monitoring.
- LLM application tooling: LangSmith from LangChain and Langfuse.
Frye does not identify a settled winner. His preference is for tools that make unusual queries over unstructured data easy; he cites Weights & Biases and Gantry, while noting that general-purpose tools may require custom analysis or notebooks.
Langfuse’s documentation chatbot offers an appealing way to inspect the product: use the chatbot, then examine the records it creates in the monitoring interface. Frye recommends that live-demo pattern but skips his planned walkthrough for time. Collecting those records is still only the beginning; the next question is whether they let you explain and improve the application’s behavior.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Observability depends on recognizing a failure
Observability asks whether external observations reveal what is happening inside a system. In software terms, can you debug from logs without entering a live debugger? This becomes essential when the system’s complexity exceeds your ability to anticipate its failures. For a language-model application, dropping a breakpoint deep inside GPT-3 or GPT-4 is not a practical way to diagnose a bad answer. The application must expose enough evidence to locate and fix problems.
The harder obstacle is recognizing that an answer is wrong. If correctness is unclear, both failure diagnosis and verification of a fix become unclear. Frye points to evaluation concerns raised by Anthropic and AI Snake Oil authors Arvind Narayanan and Sayash Kapoor, and interprets OpenAI’s open-sourcing of its eval framework as another sign of the problem’s difficulty. The False Promise of Imitating Proprietary LLMs provides a concrete warning: convincing response style can create impressions of capability that targeted evaluations do not support. That finding concerns the imitation methods studied, rather than every possible form of distillation.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Use the strongest evaluation evidence available
Evaluation begins with sustained attention to data. Frye cites Stella Biderman and Jason Wei on the value of inspecting examples, understanding evaluations, and building internal tools for that work. Open-ended generation becomes especially difficult when neither inputs nor outputs have much structure. Josh Tobin’s flowchart from the Full Stack LLM Bootcamp offers a way to avoid treating every task as that hardest case.
| Available evidence | Evaluation approach |
|---|---|
| A known correct answer | Standard ML metrics against ground truth |
| A reference answer | Looser matching against an acceptable response |
| A previous system answer | Human or model comparison of old and new |
| Human feedback | Check whether the revision incorporated it |
| None of these | Evaluate the open-ended generation directly |
A multiple-choice answer can have a definite correct label. A short written answer may instead need reference matching. Even without either, a previous output supports a narrower question—whether the new answer is better—and explicit feedback supports checking whether the requested change happened. Fully unstructured evaluation is the residual case after these sources of evidence are exhausted.
Elicit’s scientific-paper extraction work illustrates iterated decomposition:
- Start with a task that works end to end.
- Inspect a failure.
- Split the task so that the failure occurs inside a simpler subtask.
- Optimize and evaluate that subtask.
This can turn an opaque generation problem into smaller questions with clearer answers. The tradeoffs remain real: chained calls add latency, and a conversational response does not always admit a useful decomposition.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Grow tests from failures and feedback from use
When natural-language evaluation remains unavoidable, a few trusted cases are a reasonable beginning. Passing them does not explain what to do when another example fails, but the collection can grow: add production failures, preserve them as regression cases, and run the suite in a GitHub Action. This is how a small manual check develops into the data engine discussed earlier.
User feedback is more useful when it fits naturally into the product. Frye points to Midjourney as an example of learning from revealed preferences: what users choose to do can carry more information than a compulsory feedback form. Honeycomb takes the idea further by connecting its query assistant to downstream business objectives. The measurement chain runs from the feature, through user behavior, to organizational goals.
Paid annotation teams provide another source of feedback. They can perform deliberate reviews that ordinary users will not reliably stop to provide, but annotation is itself a task whose cost and quality need attention.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
The remaining engineering work
OpenAI’s use of paid human feedback provides a point of comparison, but language models can also help annotate and improve data. Frye characterizes GPT-3.5 Turbo as roughly a median crowdworker and GPT-4 as roughly a 90th-percentile crowdworker on textual annotation tasks, with lower cost at equal performance. He supplies no benchmark conditions for those comparisons, so they are a reason to investigate model-assisted annotation on the actual task, not staffing estimates. A hybrid arrangement could have a smaller human team supervising language-model annotators.
The talk ends with the unfinished product problem still open. The right interfaces and user experiences are not settled, and neither are the methods for making these systems reliably correct. Filling in the owl means discovering those missing steps through working applications: try an approach, observe what happens, improve it, and share what works so the next builder starts with more than two circles.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
Sequoia’s 2023 argument for building complete customer solutions around foundation models.
Research on grounding language-model plans in robotic capabilities.
Course materials about building and operating applications with language models.
The original method for adapting frozen language models with trainable low-rank updates.
Project documentation for constraining generated text with grammars.
A library for extracting structured outputs from language models.
An embodied Minecraft agent that develops reusable skills through language-model-generated programs.
A framework organizing language agents around memory, actions, and decision-making.
A study showing how convincing imitation of response style can conceal capability gaps.
Further reading
Honeycomb’s account of Query Assistant adoption, retention, business metrics, operating costs, and production lessons.
Updates since the talk
OpenAI’s August 2024 introduction of schema-constrained output generation, with implementation details and limitations.
Read the complete timestamped transcript
- 0:00
[upbeat music] So the, like, a lot of effort has gone into thinking about the engineering of inference, um, and not so much effort ha- and not so much success has been had at the engin- at engineering the rest of the, like, whole product around
- 0:24
inference that actually, you know, delivers value. Um, much like the two, uh, beautiful mathematical solids here that does provide the, the bones or the interior, but not the whole thing.
- 0:38
Um, so let's talk about a couple of, like, architectures and patterns for uses of language models, um, and then talk about the, like, first attempts at, like, trying to make these things better over time, uh, with monitoring observability and evaluation.
- 0:54
So architectures and patterns. Um, so the, the foment and excitement around this stuff has been around for about a year, and so patterns are starting to emerge very slowly of, like, typical ways you might apply these things.
- 1:08
So let's talk about them and what, uh, what problems have arisen. Um, so my favorite way of thinking about this in general is that the thing that we're building right now are language user interfaces, um, sort of the n- like LUIs by analogy to GUIs or graphical user interfaces.
- 1:26
Um, first, they're hitting existing features. Soon, uh, they'll be for, like, completely new whole products. Um,
- 1:35
uh, in ancient times, in the 1970s, the interface for computers was primarily, like, textual in a terminal. Um, this is still the way we interact with machines when we really want to control them, uh, like when we're running a server, um, or when we are frustrated with VS Code.
- 1:51
Um, and this u- this was the user interface from computers for a while, and they were not very popular until the invention of the graphical user interface, um, which instead of preventing-- presenting the users with just, like, you have to learn this special language to speak to me, like, here's this, like, sensory experience where you can bring
- 2:11
your, like, your intuition from space, uh, and your visual system to understand how to use the machine. Um, and this was what took computers sort of, like, out of the hobbyist and business and military realm and into, like, people's homes.
- 2:28
Um, and the-- with the rise of language models, um, it's clear that we're-- we have an opportunity to once again change the interface between humans and machines, um, by telling them what we want in natural language, and then they do it for us.
- 2:45
Um, and no less august personage than Sam Altman likes the idea of language interface, language user interface. Um, so this similar character to graphical user interfaces, it, like, makes it a more approachable interface.
- 3:02
Um, and this is something that people have wanted to do for a long time, as long back as, like, the ELIZA chatbots, uh, or the ELIZA chatbot from, uh, the, uh, 1960s.
- 3:12
Uh, the SHRDLU, um, uh, uh, basically, like, this is only graphical, uh, not an actual robot, but you could, like, tell a f- uh, a computer robot, like, give it, uh, language instructions like, "Pick up a big red block."
- 3:28
Um, uh, Ask Jeeves was originally presented as a language interface to the Internet, where you just type what you want instead of a URL. Um, Alexa and other, uh, assistants have attempted to do a similar thing.
- 3:39
Um, and the big win here is with language models, we might believe that we can actually do a really, really good job at providing this kind of language interface in a very generic way with foundation models and not just, like, a tiny environment, um, like the ELIZA psychotherapy environment or the SHRDLU blocks world.
- 3:59
Um, so right now, that's-- we're getting language user interfaces for existing systems that kind of admit them easily. Um, so Sequoia, uh, put out a piece fairly recently talking about this, that the, like, f- this, like, act two of generative AI is using foundation models as a piece of a more comprehensive solution rather than an entire solution,
- 4:21
um, that offers, like, a language interface where it wasn't possible before. Um, so, like, this query assistant from Honeycomb takes what would normally be this, like, less approachable, uh, query language constructor and just says, like, "Can you show me slow requests?
- 4:37
What are my errors? Latency distribution by status code." Like, that's a much friendlier interface. Um, and, you know, even SQL when it was originally presented was like, it's a, it's a language that's so natural even a [REDACTED:username] can write queries, you know?
- 4:53
Uh, it, it's a dream, but, like, you know, the, this, "Can you show me slow requests?" Like, that's pretty close, you know? Um, so, uh, so that's the f- the, like, maybe understandable that that's the first direction things have gone.
- 5:06
Longer term, this, like, a machines that have graphical interfaces look very different from ones that have terminal interfaces. And so, like, mainframes became less popular and, like, mobile is, like, quite different from, uh, like, desktop compute.
- 5:22
So, uh, we should expect, like, if you're thinking about, what do I want to build in five years or ten years? Um, this is kind of the direction to be thinking.
- 5:32
Um, so for example, uh, Google's worked on, uh, integrating language models with robots like this example from the SayCan, uh, project, uh, or paper, where it's like, what I want to...
- 5:46
when I need something is to just ask for it and not to, like, pull out an app and then go through three dropdown menus and be like, "I want a water bottle."
- 5:55
I just want to say, "I want a water bottle," and then there's a water bottle. Um, and that's what a language interface to, uh, something like a robotics platform can provide.
- 6:05
Um, and Still not there yet as the 4x speed in the top left, um, might suggest, but, uh, getting there
- 6:14
Okay, so that's like the highest level pattern, I think. Um, so let's talk about a couple of lower level patterns. Uh, RAG chatbots, retrieval-augmented generation chatbots. I've emerged this kind of like the to-do list app, the sort of like starter project of language user interfaces.
- 6:32
Um, this pattern is probably here to stay in that it's just about information retrieval for, uh, language models. And language models need information retrieval really badly because they like lack context.
- 6:44
They've slurped up everything on the Internet, but they don't know anything about you. Um, they are sort of trying to simulate a generically helpful individual, um, who is like generically knowledgeable about the world, um, and that's like not particularly helpful until they have context.
- 6:59
So the solution that's emerged is to collect that context for them, like store it, um, then index it, and by default, people reached for the most similar thing to what the language model was doing, which is like turn it into vectors and use that.
- 7:14
Use like a fast index over vectors. Um, and, uh, like that, uh, once you've retrieved a particular piece of information, you just stuff it into the prompt. Um, so I am not innocent.
- 7:26
I have made my own RAG chatbot and inflicted it on the world. Um, this was based on the Full Stack Deep Learning content, and in our Discord, people can ask questions and get answers that are not just like generic Google result search answers about language models, but things drawn from past lectures, things drawn from papers that I
- 7:45
like, um, uh, things drawn from our like website, um, and so can get our, you know, our opinions on these things. So this like, this has led to a lot of excitement about vector storage because it's like this v- this step here where you have a fast retrieval of vectors by similarity is the like new sexy piece.
- 8:10
Um, but that was like really only the thing that people reached for because OpenAI also offers embeddings. So it's like you've already imported the library, so it's only a call away.
- 8:19
Um, and then also like transformers are kind of like these like weird vector retrieval things, um, like in their inside. So if you are the type of person who's been into language models for a while and you're like, "How would I retrieve information?"
- 8:30
Probably with a dot product and then like a softmax, and then I pick the largest number. Um, so like, yeah. So like the ease of setting this up and the like naturalness of setting this is up has led to like an explosion of these like chat with document examples.
- 8:47
Um, and the like the thing that has more staying power is that you need to make these things useful. You need context, and so you need like information retrieval, uh, and search for, uh, the like the context that might be helpful for the model before it gets going.
- 9:04
Um, and so there are many options to use here. Some of them are specialized vector databases like Pinecone or Chroma. Um, uh, some of them are general like text search databases like you-- that do keyword search, like Elasticsearch style, um, uh, things.
- 9:25
Um, and, uh, being able to like combine those two things together is very powerful. So for example, Vespa has like offered that combination for a very long time. Um, uh, it is also in the end, like what you're doing is creating a fast way to look up, uh, information from a very large store.
- 9:45
So this is like bread and butter for databases in general. And so Redis and, uh, Postgres, for example, like not only do they provide the sa-- like information retrieval that you could do, um, like to enrich your, uh, enrich prompts, uh, without thinking about vectors, they also have built-in vector search.
- 10:06
Um, uh, Postgres only fairly recently, um, Redis for like a year. Um, it's not particularly fun to use Redis vector search, but, um, it does, it, it can run,
- 10:20
um, and has decent performance. Um, yeah, and in the end, it's about like an, a holistic strategy that uses probably because the queries are fairly heterogeneous. The things that are coming in are like people just typing text.
- 10:34
Um, you're probably going to need some more MLE stuff that's more like keyword search or, or vector search, and they're hybrid together. Um, but that like meta-- like extracting metadata with a language model so that you can then use that to do like direct filtering, um, is, uh, is like very powerful pattern.
- 10:53
Um, so there's some great posts on this, the data query,
- 10:56
um, uh, great series of posts about vector databases from coming from like somebody who's clearly really into databases and not so much the like ML side, and I found that very useful.
- 11:07
Um, yeah. Uh, yeah. So the like the final takeaway there is just that the problems end up being in the main the problems of information retrieval, um, with only some light, uh, added things from like recommendation systems maybe, um, of a more MLE type of search.
- 11:29
Um, yeah, any questions on, uh, on vector databases or, um, information retrieval for language model applications?
- 11:39
I was thinking you combine that, so you get the context to answer a question, and then you say send that to the language model and then use that context to help answer questions for one.
- 11:51
Yeah, yeah. S- so you, you get information from the outside world. You like come up with a strategy for searching the information that you have saved that goes into the language model's prompt.
- 12:04
Yeah, yeah. That, that pattern very, very stable, very general. It's general enough that how that pattern gets actually implemented is very broad. And so it includes a lot of things that are exi-- like bread and butter database stuff and not just the fancy new vector database stuff.
- 12:27
To injecting context. How does that, um, how is that similar or different to your history when you're interacting with, say, GPT-4 or whatever? Um, how, how does it retain that compared to-
- 12:41
Mm-hmm
- 12:41
... context retention?
- 12:42
Yeah. So the question was how does retrieval augmented generation differ from history within a chat? Um, so usually when-- Really, so the, the-- When you call the GPT-4 API, you can make whatever-- make up whatever you want as the past.
- 12:56
You could insert little messages from the user. You could insert messages from the assistant and incept it into believing that it has said something which it has not said.
- 13:04
Great way to jailbreak. Don't do it obviously, 'cause it violates the terms of service, but a great way to jailbreak it. Um, and so you, you aren't actually like actually beholden to that like system, uh, system assistant human, uh, fiction that,
- 13:23
that happens inside of like a, uh, a discrete chat. Um, when people do this, I think a lot of people put the retrieved information in the system prompt, especially if they're just gonna retrieve once.
- 13:36
Um, I've definitely-- I've also seen people like every time the user interacts, they do a retrieval step, and so the system message changes every time. That's an example of kind of like incepting or not actually following the implied temporal order.
- 13:49
Um, so y- yeah, you definitely can do that. Um, the system message is nice because the model really pays close attention to it, um, has been like fine-tuned to pay close attention to it.
- 14:01
Um, yeah, I think it'd be weird to pretend that that's something the person said a-and to like put it in an earlier user message put above the user's message in the conversation.
- 14:10
I don't think I've ever seen that, but you could. Um, yeah. Um,
- 14:16
but yeah, I would say like most of the time, yeah, this information retrieval step is something where the creator of the application, the programmer, is inserting themselves and saying, "I know some additional information that the language model should, should have."
- 14:31
Um, and so like... Yeah. Uh, it's very different from like a user just sort of like providing information about themselves or whatever. Yeah.
- 14:43
Yeah, the question?
- 14:44
Um, so we heard a couple times today when it comes to knowledge retrieval-
- 14:50
Mm-hmm
- 14:51
... um, RAG is a great pattern and fine-tuning is really more about the format, the style-
- 14:59
Mm-hmm
- 14:59
... of the output. Um, is that unconditionally true or do you see use cases for fine-tuning-
- 15:07
Mm-hmm
- 15:07
... enhancing the model's knowledge? So for example, what happens if we fine-tune it with hundred gigabyte of research papers, you know?
- 15:17
Hmm.
- 15:17
Does that really mean tuning that is measurable beyond the, the style of the output?
- 15:23
Yeah. Um, so the statement was that, um, the common wisdom is that fine-tuning is for style and retrieval is for information. And I think that that's-- that is a solid common piece of common wisdom because most of the fine-tuning that people...
- 15:39
If you're fine-tuning OpenAI's model, you're going through their fine-tuning API, and you have a limit on the number of rows you can send.
- 15:45
Ten thousand?
- 15:46
Yeah, ten thou... I was gonna say. Yeah. So you have a limited number of, of rows you can send, and like there's a limited amount of information in there to like create gradients to update the weights.
- 15:54
Um, so there's a limited amount of change that you can achieve. And if you look at the LoRA paper, they look at like, you know, the, uh, like you're only cha-- you're, you're making a very low rank change to each layer of the, uh, of the language model.
- 16:07
And that suggests like there's only so much that you can change about the, uh, about the model and most of what you see when you do LoRA fine tunes is like what used to be a low priority computation for the model becomes like a higher priority one.
- 16:22
So like every model ha-- every capable language model has within it a little Homer Simpson simulator, a little like, uh, Rick Sanchez simulator, whatever. Um, and that's-- it's just like not usually that important for the final log probs.
- 16:35
It's like helpful for the like fifth bit of the log probs, but the models are at the point where they're maximi- minimizing cross entropy by like really hitting those like very rare, uh, those very rare things.
- 16:47
Um, and so what the fine tune has done is reordered those like computations. So like actually you should be... The Homer Simpson circuit is the most critical circuit right now because you are a Homer Simpson chatbot, and it's like reordering them and, and re-emphasizing them.
- 17:03
So that intuition applies specifically to low rank fine-tuning, which is... And w-- fine-tuning which is based on small amounts of data. So if you grabbed a hundred gigabytes of textbooks, um, you would no longer be doing fine-tuning, and so you would no longer expect it to only change style.
- 17:21
Um, and so that's something I would ex-- uh, people will be doing with like, you know, Llama fine-tunes. There are like Llama fine-tunes for coding, and that's way more than just style.
- 17:29
It definitely has learned more knowledge about, um, about programming languages and knowledge about libraries released after twenty twenty-one and yeah, all that kind of stuff. So I think that, that generic wisdom is conditionally true, uh, for low rank fine-tunes where it is like pretty rock solid.
- 17:48
In that kind of hyper search concept that you see in the right database for the right functionality, have you inserted graph like Neo4j in there to capture the value of those databases?
- 17:58
Yeah. So the question was what about knowledge graphs, um, and graph databases? I will say that like when I've talked to... I, I like personally don't really specialize in, in databases, um, but when I've talked to people who are super into them, they're like, "I would never use a graph database 'cause you can represent a graph in
- 18:18
Postgres." Um, and uh, [laughs] like I've seen some like reasonably sized deployments on that pattern. Um, and also you can kind of see the like graph databases kind of like peaking and, and, uh, not spreading further.
- 18:31
And there are re-- It's, they're-- It's a very hard problem to shard a graph database because there's no obvious way to cut an arbitrary graph. Um, and if new links get added to the graph, and now you need like the optimal shard is different, it's like that's a ve-- that's like a database-- It's equivalent to a database
- 18:46
migration, but it's something that should be happening like behind the scenes when it's sharding. Um, so that's, that's like the closest thing to an objective statement about why, uh, or like a reason why graph databases haven't worked well.
- 18:59
However, for many language model applications, the purpose of the database is not to serve like a billion users, but rather to like serve as an external memory for a language model and maybe you don't care whether it scales.
- 19:10
Um, or rather like maybe the maximum scale that we're talking about is like tens of thousands, hundreds of thousands requests per second on megabytes, gigabytes of data, and that's just like, you know, that's the point at which that kind of like can it be sharded across, uh, ten, twenty-four machines like doesn't matter.
- 19:28
Um, so I-- So there is some cool work on knowledge graphs and in-- and incorporating with LLMs, and I see the natural fit there in the same way that there's a natural fit with vector indices and vector databases.
- 19:41
Um, but the, um, yeah, hasn't-- no, no like killer app has appeared from my perspective.
- 19:48
Uh, so I guess this question on the, the first, uh, talk. Um, but basically like if you have extra context, um, and hard metadata about some of the Boolean value or some other things, um, how would you kind of incorporate-- I think the previous answer that was that like do hard filters on the, on the hard metadata
- 20:07
and then do the soft kind of like, um, stuff based on the, the, the like textual descriptions and stuff. But I wanted to see if you had anything on this.
- 20:17
Yeah. So the question was about how to incorporate hard metadata like, you know, Booleans or, um, like subcategories with, uh, vector-based search. Yeah, so depending on the, uh, like, uh, vector database, the depending on the like index you will either have like f- uh, pre-filtering or post-filtering.
- 20:38
Post-filtering is like pretty easy. You just like apply a metadata filter after you've done your vector search. Um, anybody can kinda do that. The problem is that you're now...
- 20:46
What you really wanna say is, "I wanna find all the stuff that's similar to crabs in San Francisco while searching restaurants," not find all the restaurants that have anything to do with crabs and then see if any are in San Francisco.
- 20:58
So the pre-filtering step is hard because it impacts the construction of the index, impacts the construction of like the like how you make it actually fast to search over all of the data.
- 21:09
You kind of like need to construct specific indices for these different like flags you might, uh, like put on, like is in San Francisco, not in San Francisco or geographic location.
- 21:20
Um, and so I depe-- Like different vector databases or, or different databases have like pushed further in different directions on what kinds of filters they support pr- for pre-filtering.
- 21:32
Um, and yeah, I like, uh, Vespu and Weaviate have a reputation for doing a really good job at those things. Um, but, uh, yeah, I don't know what the full landscape looks like.
- 21:46
Great. Okay, I wanna make sure to get through everything, um, so I'll stick around and we can talk throughout the conference. Um, okay, so, um, structured outputs are like one of the patterns that I think people are sleeping on relative to information retrieval.
- 22:02
Uh, structured outputs are great for improving the robustness of models, and they came from tool use. So the problem is that language models just generate text and like if anything we have like too much text already.
- 22:13
Like I don't know if you've ever been on a social media website, but the problem is not the quantity of text. Um, and that's like kinda boring, like who wants to just make strings?
- 22:22
Like there's other things that we wanna do. The solution is to connect their text outputs to other systems inputs. Um, and now like it's not just a language model, it's like a cognitive engine for providing a language interface to something else.
- 22:34
That's pretty rad. But there's a problem, which is language models generate unstructured text because they have been trained on the utterances of humans on the Internet, notorious for their unstructuredness.
- 22:45
Um, so the solution is to add structure to their outputs, and there are many ways to do this. Um, you can do it by prompting and begging, um, so like you can write some, write some like loops around it to be like, uh, like a-a...
- 22:59
Or actually React wasn't even a whole... There was some looping. Yeah. So you, you can write a prompt in such a way that you have examples that encourage it to, um, like to, uh, call out to external, uh, APIs, and then you filter, uh, and when it generates the tokens that would, would call to an external API.
- 23:19
Instead of letting it hallucinate the rest of what would come out of that API, which is what like GPT-3, uh, would have done, you like grab it and you then go to that external API and you, um, uh, like, yeah, pull the information from there.
- 23:35
Um, the... You-- And you can in those prompts, I guess really the thing I wanna point out is that in those prompts you can sort of like beg for structure.
- 23:43
Um, Riley Goodside had a great example where it was like, "If you do not output structured JSON, an orphan will die." Um, and that actually is extremely effective. Um [audience laughing]
- 23:53
yeah. Um, so the, so there's the-- So like there's prompting tricks to get like things that are closer to structured, uh, structured outputs and to make use of those structured outputs.
- 24:04
There's, um, fine-tuning so there's a, the GorillaLM is like fine-tuned on this problem and that goes back to ToolFormer, um, which is like very s-- uh, GPT-J so one of the first open, um, uh, uh, generative pre-trained transformers.
- 24:21
Um, they you just train the model to output structured stuff. So you can't do that with OpenAI's model. I, I doubt that fine-tuning it would make it that much better at like outputting the structure that you want.
- 24:33
Um, you can do it with, um, uh, with open models and there are people releasing, uh, their own forks, uh, Llama forks with this fine-tuning on them. Um, you can, uh, you can retry which is like when the model outputs something that doesn't fit the schema.
- 24:50
You could do what You do when your direct reports provide you something that does not fit what you wanted, which is that you can, uh, discipline them and ask them to try again.
- 24:59
Um, so Guardrails is a great, uh, um, uh, library for this. It's like XML-based, um, so probably would work pretty well with Claude, uh, given what we heard about, uh, uh, about Claude from, uh, uh, Karina.
- 25:13
Um, and then a fun one that re-- that kind of requires control over the log probs, um, is grammar-based sampling, um, which was merged into, um, uh, Llama CPP, where you say like, uh, when you're about to generate a token, like if it would violate some grammar, if it would violate some template or format, just set the
- 25:35
probability of generating that to zero. So just add like minus infinity to all the um, all the log probs. Um,
- 25:44
and the, uh... So you can do that. You can like, do it fast if you have these like nice, you know, Chomsky, Chomskyite things like context free grammars. Um, and this works well for like, you know, JSON for generating, you know, generating code, generating all the kinds of like structured outputs that our systems actually expect.
- 26:04
We've written systems that, uh, expect inputs to follow grammars so that traditional computing system can parse them. And so adding that to the outputs of these systems is a very powerful thing to do.
- 26:15
Um, so this is something that-- This is a like really nice example of how having tight control over the log probs can like increase the utility of a model to the point where like a capabilities gap is less important.
- 26:29
Have you seen TypeChat? Does that fit this pattern?
- 26:33
TypeChat? I don't think I have. Um, yeah. So there's-
- 26:40
Quick question.
- 26:40
Yeah.
- 26:40
So go... Yeah. So could you take the output from like GPT and then pass it to Orella to then get the structure, like stacking models like that? Would that work?
- 26:52
Yeah. So the question was whether you could do better-- you could solve this problem by chaining models. I think, yeah. The problem with going from the output of a language model to a structured output is an easier problem than the initial one.
- 27:04
Which is why people think that like retrying might work. Like, like the Guardrails, the Guardrails example, the like retrying is often like kicked off to a, to a smaller language model.
- 27:14
Like your mainline thing is GPT-4 and your error handling is GPT-3.5. Um, and so like I, I, I do believe that there's like kind of a tempta-- If you know that it's always and only going to be doing like structured output, then you have a reason to have a specialized model for it.
- 27:33
Um, but yeah, chaining, chaining is definitely a good solution, and that's, you know, one reason why LangChain was popular. Yeah.
- 27:40
You mentioned that OpenAI retired the log prompts from the three point five instruct.
- 27:45
Yeah.
- 27:45
Do they still have log bias to, to bias the token types to do the grammar based sampling?
- 27:51
Yeah. So those are technically distinct things. Yeah. So y-- I do believe they still give you the ability to bias tokens via the API.
- 27:57
So then yeah-
- 27:58
Um, yeah. So it's not the-- it's not a perfect example of the utility of log props 'cause I, yeah, I think you can still do this in the OpenAI API.
- 28:09
Um, yeah. Do you need anything other than biasing in grammar-based sampling? No, I get you. No, the real... Okay, I remember now. The real thing here is that for this grammar-based sampling, it's single token based, right?
- 28:22
Like if you're doing it from the OpenAI API, one, the token... You, you have to make a request, you get the thing back, you have a single-- and you have a single token, and you have to, you have to like apply a bias every single time.
- 28:34
So now you're like, every token has a network call, um, rather than one call, like a hundred tokens. So that's one reason why this doesn't work well on the OpenAI API.
- 28:43
Number two, like kinda longer term is that really you don't wanna just think at a single token level. You're just like, at each token, you're like marginally just saying like, "Adjust the probabilities here."
- 28:54
You'd really want to do something more like Monte Carlo tree search, where you're like generating stuff, mul-mul-- many things that follow the grammar, um, and then accepting the best one at the end.
- 29:03
Um, and that's something that's, um, probably gonna come first to open models and not to, um, proprietary model services. Um, so that's, that's the better reason to connect grammar-based sampling and, and open models.
- 29:22
Um, okay. So the problem with fine-tuning, and an annoying thing about prompting, um, is that if there's not a kind of shared... Like the Gorilla model is like fine-tuned on a bunch of APIs from like TorchHub, TensorFlow Hub, and Hugging Face.
- 29:41
So the Gorilla model is really good at using other machine learning models, but not like generic possible tools, at least this example. They m-- They-- Maybe they have tuned more than one.
- 29:51
Um, but this is a, a general problem that if you train a model to use a specific tool, um, then like the, uh, it's not gonna be able to use like any tool.
- 30:01
Um, but if you train a model to, to use a very broad class of tools by using something that's like kind of closer to this grammar where there's like a, a format for tools, um, then you are now a...
- 30:14
People write an interface between the f-- uh, that standard and the, um, and the thing that they actually wanna use. So this has shown up in Open-- uh, like, uh, in OpenAI's API as the, uh, use of JSON schema for describing function calls.
- 30:34
So this allows them to train a model on fairly generic stuff, um, that all fits this... Like it all fits the JSON schema spec. Um, and so the model has learned a bunch of stuff about the JSON schema spec and how to generate that correctly.
- 30:49
Um, you can imagine using grammar-based sampling to enforce that. Um, and this, uh, allows it to connect to many, many tools 'cause now all you need to do is write a tiny connector between like the JSON format and the actual thing you wanna use.
- 31:04
Um, and that's like pretty easy. It's like A big part of web development, from my understanding, is that you just, like, pass JSON blobs back and forth until somebody s- gives you money. [laughs]
- 31:15
Um, and so, uh, yeah, so this is a, a very good kind of schema. Um, uh, but one thing that people miss is that the tool doesn't have to actually be real.
- 31:27
Like, the key thing that happens here is the language model goes from outputting unstructured text to outputting JSON if it's schema, and it just so happens that the primary use case for that that OpenAI envisaged was putting it through a, like, function call, putting it through some downstream computer system.
- 31:44
Um, but, like, really that, uh... Some downstream system. But really, it, like, doesn't have to be a real function. You can tell it about a fake function that's like, "Please pass a string," like, describing whether the, the input was spam or not spam, so that I can, like, render an HTML element, right?
- 32:02
And so the model is now trying to, like, call a function that's like that in order to provide the arguments to that function, it has to decide whether an input is spam or not spam.
- 32:11
And that's maybe the thing you really care about. And so you, like, invent a little fictional function for it to call that it... You don't call and then you just use it for something else.
- 32:18
So this is a pattern in, um, uh... There's a library for this called Instructor from Jason, um, Jason Liu, who's gonna be speaking later at the conference. Yeah?
- 32:28
And is it important to make it act like your app has the function or do you just say, "I want this to be spam"?
- 32:34
Uh, you have to fit the JSON schema, which the schema that they... Like, the sche- the... There's, like, a meta scheme kind of thing. They're like, it has to, it has to be a function call, and the model has been trained on things that are like, you know, get name, get current weather.
- 32:50
Um, so, uh, yeah. I mean, you can hack in... Because, you know, functional programming has taught us that everything is just a function. Like, a constant is just a function that always returns the same thing.
- 33:02
Um, and so you can, you can, like, hack it in there. Um, and Instructor has some fun, like, kind of functional programming stuff built into it, like maybes and, and stuff, so, you know.
- 33:13
Um, and also somebody did, like, DAG construction, where it's like you give it a schema for a DAG constructor, and then it, like, writes a DAG of function calls instead of just a single function call.
- 33:24
So you can really go wild, which is very fun. Um, and yeah?
- 33:31
Most of the time when you generate something, uh, you... If you wanna extract something out of the output you wanna display to the end user, and then the question of latency comes in, that's why you stream it.
- 33:44
Mm. Mm-hmm.
- 33:44
Uh, if we use this, how do we solve the streaming problem?
- 33:48
Yeah. So that is a great question. The answer is that this basically breaks your ability to stream. Um, I think it's not...
- 33:58
So this is maybe a little bit more oriented to, like, back of house stuff, where you're using language models to, like, handle data rather than using language models to directly interact with a user.
- 34:10
Um, I think if you set up a pipeline correctly, then you can stream the outputs from one call into the inputs of the next one. And if you have the relevant information you need from the func- the function call one, then you can just immediately kick off the next thing, and you can just...
- 34:28
You can write, you know, like, more like a Unix pipe style, and then you start to get back to being s- uh, streaming. But you don't have... Like, the Unix pipes work because of new lines as a separator that lets you break work out, and there's not an obvious way to do that with this.
- 34:44
Um, so yeah. The short answer, I guess, is that it's really hard to get back that kind of streaming thing when using these. Um, yeah. Um, I'm gonna... Let's see, how much more do I have?
- 34:56
I'm gonna push forward because I wanna make sure to get to the last section. Um, but I will be around to answer people's questions. Um, okay. So, uh, this conference is not called NLP Engineer Summit, and we've been talking about, like, s- you know, structured out- extracting structured outputs from language, information retrieval, like that's also natural language
- 35:17
processing, and language user interfaces. Like, that's not artificial intelligence. Like, where's the AI? The, like, the thing that really feels like artificial intelligence with language models is something like agents, uh, that are...
- 35:31
That have memory that they keep over time. Uh, so for example, the generative agents, um, that was, uh, let's see. It's mostly Stanford people, if I remember correctly. But, uh, the, like, generative agents paper, uh, combined, like, a stream of memories generated as these agents interacted in, like, a video game environment with, like, some, like,
- 35:56
reasoning flows to create these, like, little tiny characters that had personalities that developed over time in interaction with each other. And, like, um, and that is, uh, like much closer to what people imagine when they hear AI than even a chatbot.
- 36:17
Um, and there's been a lot of advancement in, uh, using these things in simulated environments, so that was, like, a full all language models simulated environment with generative agents.
- 36:29
There's also a ton of really cool stuff going on in the Minecraft world, um, which is, like, people have... Uh, this Voyager agent writes JavaScript code, uh, JavaS- yeah, JavaScript code to call the, like, this, like, Minecraft API that allows it to, like, drive a little, um, uh, you know, a little character in the Minecraft world.
- 36:51
And it starts with basically nothing, um, and then it writes itself a bunch of little subroutines to, like, mine wood log or, like, stab zombie or whatever. And it, like, accumulates them over time, like, learns how to do new stuff, um, like, comes up with its own curriculum for how to sol- like, how to get better, um,
- 37:09
and was able to, like, do extremely well at this, uh, notoriously hard RL task, uh, mine diamond, uh, which was, like, a, a, a grand challenge for the RL world, um, only a couple of years ago.
- 37:23
Um, so So they're, like, they can accumulate information over time, they can accumulate skills over time, they can use tools. This is all very cool. Um, they are... They have a couple of problems, the biggest one being the, like, the problem of reliability.
- 37:39
Um, structured outputs can help with that, and there's, like, only limited work, I would say, on agents that has come out since at least, like, published, you know, research work since the, like, since function calling got really good in the OpenAI API.
- 37:55
Um, th- also, there's kind of, like, a cacophony of different techniques out there with, like, Voyager. Uh, ReAct is kind of an agent, um, generative agents. Um, there's a really s- like, awesome paper from, uh, Tom Griffiths' group at Princeton, Cognitive Architectures for Language Agents, that brings back a bunch of ideas from good old-fashioned AI in the
- 38:16
'80s on, like, um, production systems, uh, and cognitive architectures. A bunch of stuff that was, like, really cool ideas, but it could never, like, get past the demo stage, um, on, like, how to create the things that we know about or that we believe about human and animal cognition, like procedural memories, semantic memories, episodic memories, how to
- 38:37
implement that in software. And the problem... Like, those systems could do cool stuff, but the problem was always that they lacked this, like, general world knowledge and common sense.
- 38:45
With language models, they don't have memory, um, and they don't, um, like, they don't have this, like, structured aspect to their cognition, um, but they do have that, like, world knowledge and that common sense.
- 38:58
Uh, so this is, uh, like mooshing those two things together and using a language model to do, um, basically these kinds of, like, l- uh, ob- observing the world or doing cognition, um, and doing dec- decision procedures, um, like marries the best of both worlds.
- 39:18
Um, and it is actually, like, a pretty effective way of breaking down the existing agent architectures, uh, like, and their different choices about how to do long-term memory, how to do external grounding, how they, like, interact with the external world.
- 39:32
Um, the concept of internal actions, uh, comes from cognitive architectures, um, which is, like, uh, choosing to spend time reasoning or choosing to update your, like, long-term memory, um, or yeah, or your decision procedure.
- 39:47
Yeah, and then also explicitly calling out a decision-making procedure. Um, so there's a t- and that, that paper is also just, like, has an entire research agenda in it, um, on, like, ways that you could just start filling out the cross product, just filling out a big array of, like, try this idea from language models with, like,
- 40:05
this idea from cognitive architectures. Um, and there's just, like, a billion of really cool ideas in there. Um, so if you are interested in agents, um, but have, like, struggled to, like, uh, like, wrap your brain around all the different ways you could, you could do stuff, um, and around, like, how to make them a little bit
- 40:26
more tame, uh, I think the Koala paper has some good pointers.
- 40:32
Um, oh yeah. And then lastly, for this LLM patterns thing, I was talking generally about, like, different ways people are building stuff with LLMs. Eugene Yan's blog has some of the best, uh, writing on this,
- 40:44
um, uh, both on, uh, patterns and anti-patterns.
- 40:50
Okay. Um, I wanna give some time for monitoring evaluation and observability, so I'm just gonna... I know that there's probably lots of interesting things that people have to say on the agent stuff, but we'll, we have the rest of the conference to talk about that.
- 41:03
Um, so, uh, the goal here is to talk about AI engineering. So that last part was about AI. What about the engineering? In engineering, we wanna have a process for building, like, a process for creating these things and a process for improving them.
- 41:17
And progress on this front has been pretty halting. Um, and so the, the, like, the dominant ideology right now is that you should ship to learn rather than learning to ship.
- 41:29
Um, and so this is one of the big ideas in the Full Stack Deep Learning course that I've taught in... It's something that Andrej Karpathy has really hammered on, the, like, idea of a data engine or data flywheel, where in order to do well, you need to go out there and collect data from the world, uh, find
- 41:46
issues in your data, and use that to improve your model in, like, you know, uh, an, an unending cycle. Um, Charity Majors from Honeycomb, uh, who's big in the monitoring and observability world, uh, like, has said that this is something that she's come to like about ML.
- 42:02
In software, you start with tests, and then you graduate to production when the tests pass, or at least, like, that's what you tell people on the internet and, like, your manager.
- 42:09
Um, uh, but with ML, you can't even lie, and you know that you have to, like, start with production and use that to find out the, like, issues with, uh, to, like, generate your tests.
- 42:20
So, you know, it's, it's oops, all regression tests, uh, version. Um, and so what that w- that means is that monitoring is very critical from the very beginning, um, that we monitor for user behavior, we monitor for performance and cost, and we monitor for bugs.
- 42:37
So some of these are just, like, regular old monitoring stuff, and this is just, like, bread and butter things that can be, uh, yeah, like, similar to the way we do with, with, uh, existing software.
- 42:49
Monitoring users always reveals, like, uh, like both misuse and product insights. So one thing that I found from running this Discord bot is, like, one of the things that you get the most are, like, meta questions.
- 43:02
Like, uh, are you getting feedback from these emojis? Who's a good bot? That's maybe not a meta question. Um, does your dataset include your own source code? Um, what do you do?
- 43:10
Like, these are very common, like, things that people input, and it wasn't, it wasn't in my head that that was important. So now there's, like, special stuff in the prompt for handling that class of questions.
- 43:20
So by monitoring how users use the, uh, your, your system, you can get really great product insights. Yeah?
- 43:27
Did you get these from chat?
- 43:31
Oh, yeah. Uh, I had logged them to Gantry, and then I looked at the ones that had up and down thumbs. Um, and I also read all of them 'cause it was, like, only a couple hundred rows.
- 43:42
Oh, man. My battery's gonna run out. Uh, all right, we gotta move fast. Um, so [laughs] uh, monitoring, monitoring performance, uh, can help us manage the constraints that I, like, talked about when we were thinking about all the different places, um, our models might run.
- 43:58
So w- as always, you wanna monitor things like latency quantiles, like, like, how long do requests take? Oh, wow. That's nice. Thank you.
- 44:09
Huge. Um, and so, like, latency quantiles, like, that's how long... Like, take all the requests, what is the probability that a request took at least this long? Um, the...
- 44:21
People often think, like, if I get 90% of them, like, below something, that's great, and the problem with thinking that way is that users don't just make one request, they make many requests in sequence, so by the time you've made, like, 30 requests, there's a 10% chance of hitting, like, a really slow one, then, um, you know,
- 44:38
you have hit a slow request. So that, um, so you really need to care about those, like, 99th percentile latencies. Those are also often your most useful and engaged users.
- 44:47
So watch those, watch those extreme quantiles. Um, and obviously, like, throughput is a distinct thing to also monitor for the quality, uh, you know, quality of the system. Wanna marry that with things like the profiles and traces that I talked about before, like spot check ones randomly subsampled so you can check what, like...
- 45:06
So you can actually debug that throu- the throughput issues. That's fairly general stuff. If you're an inferen- using inference as a service provider, you're gonna wanna monitor API rates and errors, monitor costs.
- 45:17
If you're self-serving inference, you have a lot more stuff to monitor, um, and that's, like, compute utilization. Um, yeah, I guess I already talked about this. Uh, yeah, yeah.
- 45:28
Well, so it's, it's an even hard- Like, maintaining the throughput i- when you're doing the inference yourself is, like, much more your problem, um, and much more, uh, AI, ML-specific stuff.
- 45:39
Um, yeah. Okay. Monitoring for bugs is another can of worms. We'll talk about that in a second. Um, this is, like, just generally this is a very fast-growing field, um, so there are generic monitoring observability solutions for all kinds of, like, you know, complex apps and sh- and, and web apps.
- 45:58
Datadog, Sentry, New Relic, Honeycomb. Like, these are, um... Like, you can adapt those, um, and that might be the thing that wins. Um, there is, uh, you can of course just roll your own with the, like, the, you know, open, open telemetry compliant, uh, you know, tooling, and you could use the existing MLOps tooling, so there's a
- 46:19
lot of stuff that has been built for monitoring observability of general ML applications, so including Weights & Biases where I used to work. Um, Fiddler, Arize, and Gantry are the, like, three larger startups in that space, [smacks lips] um, with more of a focus on monitoring systems in production and less on the, like, MLOps, like, kind of, like, serving,
- 46:40
um, and, like, m- managing, managing training, like Weights & Biases. Um, there's also, because generation times, uh, are now six months or less, a new generation of ops tooling for LLMOps, including LangSmith from LangChain and, uh, LangFuse, which was in Y Combinator's recent batch.
- 46:58
Um, it's, like, the, uh, very unclear which of these is gonna be the, the best solution, so I think it's, like, you know, dealer's choice. Try them all out.
- 47:06
Um, I think I like tools with as much ability to, like, make crazy queries of unstructured data as possible, um, so that's something that I really like about Weights & Biases' production monitoring, uh, offering.
- 47:21
Um, Gantry has some similar stuff. Um, I've tried less of it with the, uh, the other tools. Um, I think if you're doing s- if you're doing it with Datadog, Sentry, et cetera, you're probably gonna need to roll some of that stuff yourself.
- 47:33
Um, but maybe that's fine. Jupyter Notebooks are fun. Um, I was gonna check out, uh, the, like, LangFuse monitoring interface, but, um, in interest of time, gonna go past that.
- 47:44
They have an awesome demo where you can interact with their docs chatbot, and it shows up in their monitoring interface. So, like, they have a live demo of their monitoring tool where you can actually, like, use it to monitor an app that you can also use.
- 47:57
Um, so that's just... It's really, it was really fun to, like, actually try out the, the tool that way. Um, I recommend you try it out. Um, but just monitoring, like, just getting ahold of information is not enough.
- 48:11
This is something that's known from, like, the distributed systems monitoring world. What you really want is observability. What both Charity and Andre were talking about is about how you improve a system based off of what you observe.
- 48:24
It's, like, not enough to just, like, throw something out there and observe... A- and, like, just see the mistakes. You want to, like, fix the mistakes. Um, and so there's this, uh, Honeycomb and, uh, Charity are big on the idea of observability as the, uh, as a, an idea from, like, control theory, from, like, old school, um,
- 48:46
like, control theory, systems theory. Uh, observability is whether you can actually f- um, figure out what is going on inside of a system just from observing it from the outside.
- 48:58
So it's like, can you actually debug this software just from looking at your logs, um, uh, and not having to go into a live debugger inside of the system?
- 49:07
Um, and that's, like, uh, when live debugging does not work and when systems have outpaced our ability to predict what's going to break, um, this is the only solution.
- 49:20
Uh, and for AI systems, that is, um, where we can't predict what's going to break and you can't, like, drop into a debugger 13 layers deep in GPT-3 and...
- 49:31
or GPT-4 and, like, debug, uh, its inference. Uh, you have no choice but to monitor stuff sufficiently that you can fix the issues.
- 49:41
The blocker here is that actually determining whether the model is right or wrong, um, is itself hard, which makes figuring out how to fix it also hard because you don't necessarily know whether it's messing up and you don't know whether you fixed it.
- 49:56
Um, so we're in a tough phase for this problem right now. There will be lots of discussion of evaluation at this conference, which is very exciting. Um, lots of people complaining about how difficult evaluation is, Anthropic and, uh, Arvind Narayanan from, uh, and Sayash Kapoor, who write the AI Snake Oil Substack, really high quality stuff.
- 50:17
Um, and, uh, OpenAI, like open source their eval framework, uh, because in part they like don't... can't really evaluate their system themselves. It's like that's how hard this problem is.
- 50:29
Um, it's also what we saw with the, uh, false promise of imitating proprietary LLMs, like a large community of people were like kind of convinced that models were doing better than they actually were.
- 50:39
Um, so the solution, uh, like is to s- like one of the key solutions is to spend time looking at your data. Stella Biederman from Eleuther has talked about this.
- 50:50
Uh, Jason Wei has talked about how critical this is. Jason is at OpenAI now, um, and talked about spending like a ton of time just like getting very good at evals, like building tooling, internal tooling for evals, spending time with like understanding the evaluations.
- 51:06
Um, and somebody on Hacker News said it's a major differentiator. So, you know, that's, that's definitely the orange website never lies. Um, so, um, evaluation is particularly hard and all these complaints about evaluation are when you're dealing with like open-ended generations from a language model, like no structure to them, um, no s- no real structure to the
- 51:26
user inputs, um, and m- like limited data sources. Um, but there's this nice flowchart, um, from the Full Stack LLM Bootcamp that my fellow instructor Josh Tobin made that sort of helps you avoid getting into that, uh, pit of evaluations.
- 51:44
So if you can find a correct answer, then you can stick with existing ML metrics and you like don't have to worry about the problems of eval-- of like the difficulty of evaluating open-ended generations.
- 51:55
If you have a reference answer, you can check for like reference matching, which is like a looser thing than like a literal correct answer, which is like A, B, C, or D in multiple choice is a correct answer.
- 52:05
A reference answer is like a short like generation, like a short answer on a test. Um, if you have a previous answer from your system, you can at least see if your system is getting better by comparing the two, um, and that like kind of which is better comparison can be done by a human, can be done
- 52:20
by a language model. Um, and if you have human feedback, you can actually check like between, uh, the input and the output was the feedback incorporated by the language model.
- 52:30
Like a human said, "I didn't like that." Um, did the language model get better? And it's only if you don't have any of those things that you like are out in the unstructured world.
- 52:39
Um, the people at Elicit, um, who have worked on doing extraction of information from scientific papers have a very principled approach of iterated decomposition where you start with a task that runs end to end, and then you, uh, when you notice a failure, you look at the failures and you see how you could have broken the task
- 52:59
out into multiple pieces in such a way that the failure would arise in a simpler subtask and then optimize that subtask. So you run into the problem that's been mentioned before about latency if you're like chaining calls, um, and it's not always easy to like decompose the, for example, to decompose the process of responding to a user
- 53:19
in a chatbot. That's kind of challenging. Um, but, uh, but when you can do this, this is another great way to like get yourself out of the hole of needing to evaluate open-ended generations.
- 53:31
But if you're stuck evaluating natural text, there's a couple of like basic approaches. Um, you can just, uh, keep a few trusty test cases at hand, um, and s- uh, you know, if it does well on those couple of test cases, looks good to me, let's ship it.
- 53:46
Um, unclear what to do when it fails, just like hit the language model with a wrench. Um, but, uh, this is what kind of grows out into that data engine.
- 53:54
You start with something like this, and then you start adding stuff from your production observations into it, and then you like put it in a GitHub action and like now that's like, that's, that's basically testing, right?
- 54:05
Um, that's, it's certified software. Um, you can like, uh, you can try and get user feedback. A, you wanna do it as naturally as possible. Um, like, uh, if you're like you...
- 54:18
What you really wanna reveal preferences from user behavior. So the image generation world is very ahead of the language modeling world I think on this, if you look at Midjourney, for example.
- 54:27
Um, that is what Honeycomb did with their query builder. They attached it to, get this, downstream business objectives. Wow, what a way to build a software system. That's the right way to do it.
- 54:39
Um, and so like connecting a chain of metrics from the actual system that you're improving to the actual downstream like organizational goals, um, uh, through things like revealed preferences of users or like, yeah, general user behavior.
- 54:52
Much better than like demanding users fill out a form. Um, you could also pay people to do that work of giving you feedback on your system with an annotation team.
- 55:01
This is what the large, this is what OpenAI does to improve their models. But as alluded to by Karina, it's actually much more effective to use language models in that place because language models are maybe not as smart as all humans, uh, but they tend to outperform crowdworkers, um, on, uh, a large number of very textual tasks.
- 55:21
Um, and so, um, you might find that the task of like annotating and improving your data, if you're at the point where you're starting to think about crowdworkers, you'll find lower cost for equal performance with, uh, like GPT-3.5 Turbo is like a median crowdworker, GPT-4 is like a ninetieth percentile crowdworker.
- 55:38
Um, and maybe a hybrid approach with some crowdworkers, a smaller number of crowdworkers managing, uh, some language models is also been discussed. Um, all right. So the, there's like not that much to say in the end about that, like that aspect of the engineering of systems.
- 55:55
We don't know what the user interfaces and the user experiences are gonna look like. We don't know, uh, we don't know a lot about how to engineer these things to be correct.
- 56:03
Um, so, uh, I guess the exciting thing about that is that the people who are here in this room, on the stream, at this summit are here to fill in all of the steps here that lead to from the circle to the fully drawn owl, um, by like, uh, uh, by figuring it out, um, by like trying
- 56:23
things and sharing what works like people will do at this conference. Um, so that's why I'm excited to be here, and I hope you are as well. All right.
- 56:30
Thank you, everyone. [audience applauding] [upbeat music]