WhoBuilt

Building Blocks for LLM Systems & Products

Nov 2, 2023· 17 min· 6.0K views·Watch on YouTube

Speaker

Eugene Yan shares practical patterns for building LLM systems and products at an AI Engineer seminar, covering evaluations, retrieval-augmented generation, guardrails, and feedback.

Build task-specific evaluations

Evals help teams see whether prompt changes, retrieval, or fine-tuning improve a system, and make releases safer. Yan recommends starting with a small set, such as 40 domain questions, and choosing checks that fit the task: precision and recall for moderation, running generated SQL, or checking expected JSON fields. For open-ended outputs, model-based scoring can be costly, so human review remains useful as a final check.

Make retrieval useful to the model

Retrieval-augmented generation adds knowledge as context and can be cheaper than repeatedly fine-tuning to incorporate new information. But answer position matters: in an experiment with 20 short documents, accuracy was highest when the answer appeared first and fell below the no-retrieval result when it appeared in the middle. Yan also shows that models may force an answer from irrelevant context, and suggests ranking relevant documents highly and filtering out results below a relevance threshold.

Check factual consistency

Yan treats hallucination checks as production guardrails. One approach uses natural language inference to compare a document with its summary; checking sentence by sentence can catch errors that whole-document checks miss. Other options include comparing multiple generated summaries, as in SelfCheckGPT, or asking a strong model to score a summary, though Yan says simpler methods can be cheaper and more effective.

Turn product interactions into feedback

User feedback can inform both evaluations and fine-tuning data, but explicit ratings may be sparse and implicit signals can be noisy. A copied code snippet, for example, does not necessarily mean the code worked. Yan points to coding assistants, where accepting or rejecting suggestions creates repeated feedback, and Midjourney, where rerunning, varying, or upscaling an image signals different levels of user preference.

Apply existing tools and good UX

Yan closes by recommending automated evaluations on 30 or 100 examples so teams can run checks after prompt changes and iterate quickly. Existing tools such as BM25, metadata matching, and recommendation techniques like two-stage retrieval and ranking can improve results. Product UX also shapes how people use LLMs and how easily teams collect useful feedback.

Takeaways

  • Start with a small evaluation set tied to the product’s actual task, then automate repeatable checks.
  • Rank the strongest retrieved evidence near the top and filter context that is too irrelevant to use.
  • Check factual consistency at sentence level when a whole-summary score could hide a specific error.
  • Treat user actions as feedback signals, but validate them before using them as positive training examples.
  • Reuse established search and recommendation methods, and design UX that makes LLM use and feedback natural.

Mentioned in this talk

Search inside this talk

What was claimed 6

  • feature
    Eugene Yan: Presents four patterns: evaluations, retrieval-augmented generation, guardrails, and collecting feedback
    “Today I'm going to focus on four of those patterns”
    YouTube
    Unverified1 source· Talk
  • feature
    MMLU: Assesses language models on knowledge and reasoning
    “assesses LLMs on knowledge and reasoning”
    YouTube
    Unverified1 source· Talk
  • feature
    OpenAI Moderation API: Covers moderation categories including hate, harassment, and self-harm
    “hate, harassment, self-harm”
    YouTube
    Unverified1 source· Talk
  • metric
    SelfCheckGPT: Compares multiple generated summaries using n-gram overlap, BERTScore, or similar measures
    “check whether those summaries are similar to each other using n-gram overlap, BERTScore”
    YouTube
    Unverified1 source· Talk
  • feature
    Microsoft Copilot: Users can accept or reject a code suggestion, or move on to the next suggestion
    “You can either accept the code, reject the code, or move on to the next suggestion”
    YouTube
    Unverified1 source· Talk
  • feature
    Midjourney: Users can rerun a prompt, vary an image, or upscale it
    “you can rerun the prompt, vary the prompt, or upscale the image”
    YouTube
    Unverified1 source· Talk

Related talks