WhoBuilt

Building Context-Aware Reasoning Applications with LangChain and LangSmith

Nov 1, 2023· 19 min· 3.6K views·Watch on YouTube

Speaker

Harrison Chase of LangChain speaks at the AI Engineering Summit about building context-aware reasoning applications and the engineering tools needed to develop them.

Give models the context they need

Chase describes four ways to provide context: instruction prompts, few-shot examples, retrieval-augmented generation, and fine-tuning. Instructions guide how a model should behave, while retrieved material gives it facts to use in an answer. Examples can convey tone or structured formats, and fine-tuning extends that approach with many more examples.

Choose how much reasoning to delegate

Chase lays out a progression from fixed code and single model calls to chains, routers, and looping agents. Chains follow known steps and can insert retrieved knowledge between calls; routers select among prompts, models, or tools. Agents add cycles in which the model chooses actions and whether to continue, while more autonomous designs leave more of the sequence to the model.

Debug the application as a system

Chase identifies orchestration, data engineering, and prompt engineering as core challenges. Chains offer control over steps, while agents can adapt to unexpected inputs, so teams should experiment with architectures and inspect tool calls. LangChain supports prototyping and data handling, while LangSmith helps teams inspect traces, retrieved documents, and fully assembled prompts, then experiment with prompts and model providers.

Build evaluation data and feedback loops

Chase says evaluation is difficult because teams often lack both datasets and useful metrics for unstructured outputs. He recommends building datasets from human labels, production traffic, or LLM-generated examples, and using output review to develop intuition. LLM-assisted evaluation, user feedback, behavioral signals such as link clicks, and A/B tests can help track performance.

Make room for collaboration

Chase sees context work often involving data engineers and reasoning work involving people who can specify the desired application, such as product managers or subject matter experts. He says the right skill sets for AI engineering and ways to support collaboration across those roles remain unsettled. He closes by emphasizing that these systems are early and require substantial engineering.

Takeaways

  • Start with the simplest reasoning architecture that fits the task, then compare it with alternatives.
  • Use examples to specify tone and structured output when written instructions are hard to make precise.
  • Inspect retrieved data and the complete prompt at each model call, especially after multiple application steps.
  • Build evaluation datasets from labeled examples, production traffic, or generated cases as the application develops.
  • Track user feedback and behavior over time, and use A/B tests to compare application performance.

Mentioned in this talk

Search inside this talk

What was claimed 7

  • feature
    GPT-4: Strong reasoning
    “or GPT-4 because it's really good at reasoning”
    YouTube
    Unverified1 source· Talk
  • feature
    Claude: Long context window
    “you might want to use Claude because of its long context window”
    YouTube
    Unverified1 source· Talk
  • feature
    Voyager: Tools can be added and a skill set built up over time
    “tools are added and a skill set of tools is built up over time”
    YouTube
    Unverified1 source· Talk
  • feature
    LangSmith: Visibility into tool and language-model call sequences for debugging complex applications
    “LangSmith provides visibility into what’s happening as these applications become more complex”
    YouTube
    Unverified1 source· Talk
  • feature
    LangSmith: Debugging data passed to language models
    “LangSmith is useful for debugging what the data looks like by the time it reaches the language model”
    YouTube
    Unverified1 source· Talk
  • feature
    LangChain: Open-source modules for loading and transforming data
    “LangChain has open-source modules for loading and transforming data”
    YouTube
    Unverified1 source· Talk
  • feature
    LangSmith: Open, edit, and experiment with language-model calls in a playground
    “open any particular language model call at any point, view it in a playground, edit it, and experiment”
    YouTube
    Unverified1 source· Talk

Related talks