Production LLM Systems: Document Processing and Real Estate Agent Co-pilot Case Studies

various · Tech · 2023 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production document-understanding RAG and real-estate agent copilot systems

Docugami and Rehat needed production LLM applications that could handle structurally complex enterprise documents or real-estate platform actions while remaining debuggable, reliable, cost-aware, and continuously improvable.

Constraints:

Architecture

The webinar presents two production patterns. Docugami builds a document-engineering stack with multimodal structure extraction, XML knowledge graphs, hierarchical chunks, self-querying retrieval, custom models on Kubernetes/Triton, and LangSmith traces/datasets for chain debugging and improvement. Rehat's Lucy moves from a structured chat agent to OpenAI function calling for more reliable tool calls, then wraps it in synthetic CI tests, LangSmith trace links, human QA curation, and planned fine-tuning datasets.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  enterprise-documents["Enterprise documents"] --> multimodal-structure-extractor["Multimodal structure extractor"]
  multimodal-structure-extractor["Multimodal structure extractor"] --> xml-knowledge-graph["XML knowledge graph"]
  xml-knowledge-graph["XML knowledge graph"] --> self-querying-retriever["Self-querying retriever"]
  self-querying-retriever["Self-querying retriever"] --> custom-document-models["Custom document models"]
  custom-document-models["Custom document models"] --> langsmith-traces["LangSmith traces"]
  lucy-copilot["Lucy copilot"] --> openai-function-calling["OpenAI function calling"]
  lucy-copilot["Lucy copilot"] --> synthetic-ci-tests["Synthetic CI tests"]
  openai-function-calling["OpenAI function calling"] --> langsmith-traces["LangSmith traces"]
  synthetic-ci-tests["Synthetic CI tests"] --> langsmith-traces["LangSmith traces"]
  synthetic-ci-tests["Synthetic CI tests"] --> human-qa-curation["Human QA curation"]
  human-qa-curation["Human QA curation"] --> fine-tuning-datasets["Fine-tuning datasets"]
  langsmith-traces["LangSmith traces"] --> fine-tuning-datasets["Fine-tuning datasets"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Enterprise documents Complex leases, insurance policies, contracts, and similar source material. Multimodal structure extractor
Multimodal structure extractor Detects headings, tables, paragraphs, floating boxes, and reading order across complex layouts. Enterprise documents, XML knowledge graph
XML knowledge graph Stores hierarchical chunks and semantic labels such as landlord, commencement date, and rentable area. Multimodal structure extractor, Self-querying retriever, Custom document models
Self-querying retriever Uses semantic labels and metadata filters to retrieve high-signal document chunks. XML knowledge graph, Custom document models
Custom document models Docugami-hosted models for document understanding, SQL/XQuery generation, and corrections. XML knowledge graph, Self-querying retriever, LangSmith traces, Fine-tuning datasets
Lucy copilot Conversational real-estate copilot that performs CRM, marketing, and platform actions. OpenAI function calling, Synthetic CI tests
OpenAI function calling Provides structured tool selection and output contracts for Lucy's platform actions. Lucy copilot, LangSmith traces
Synthetic CI tests Concurrent application-level test cases tagged with branch, commit, and suite metadata. Lucy copilot, LangSmith traces, Human QA curation
LangSmith traces Observability layer for debugging chains, reproducing failures, and building datasets. Custom document models, OpenAI function calling, Synthetic CI tests, Fine-tuning datasets
Human QA curation Human labeling and review that turns bad conversations or failed runs into training examples. Synthetic CI tests, Fine-tuning datasets
Fine-tuning datasets Curated corrected examples used to improve smaller models or prepare for GPT fine-tuning. Custom document models, LangSmith traces, Human QA curation

Data flow

For Docugami, documents are parsed into structural elements, stitched into reading order, labeled into an XML knowledge graph, retrieved by semantic and metadata filters, and passed through chains that can generate SQL, run it, fix failures, and explain results. For Rehat, a user request enters Lucy, the model selects platform functions through OpenAI function calling, test runs are tagged with commit and suite metadata, failures link to LangSmith traces, and curated examples feed future prompts or fine-tuning.

3 supporting quotes
“Using multimodal models (combining layout analysis with text extraction) to detect structural elements like headings, tables, paragraphs, and floating boxes”summary, stated
“Generating SQL from natural language using few-shot prompting”summary, stated
“Sending tags (commit hash, branch name, test suite name) to LangSmith for traceability”summary, stated

Why this architecture

Both systems reject generic one-shot prompting because the production problem lives in application structure. Docugami needs document topology and semantic labels before retrieval can work; Rehat needs reliable platform actions and application-level tests rather than model-only evals. LangSmith becomes the common debugging and dataset spine because failures occur inside chains, not just final answers.

3 supporting quotes
“This hierarchical awareness is critical for high-signal retrieval in RAG applications.”summary, stated
“Function calling embedded reasoning and structured output into the model itself, resulting in 3-4x latency improvements and much more reliable outputs.”summary, stated
“Both teams emphasized the importance of LangSmith for observability, debugging, and continuous improvement.”summary, stated

Models used: custom LLM · smaller custom models · 70B parameter models · GPT-3.5 · GPT-4 · OpenAI function calling models · multimodal models

Scale

Alternatives considered (roads not taken)

Naive text splitting for document RAG

Rejected because: Flat chunks lose document structure, reading order, and semantic relationships needed for precise retrieval.

“Standard text extraction and naive chunking approaches fail to capture the true structure of documents.”summary, stated

Full agent architecture for Docugami's chain

Rejected because: Agents consumed many tokens and smaller custom models were not tuned for agent syntax.

“They avoid full agent architectures because agents consume many tokens and smaller custom models are not tuned for agent syntax.”summary, stated

LangChain structured chat agent for Lucy

Rejected because: As tools grew, prompts became too slow and structured outputs were unreliable.

“this approach was too slow and produced unreliable structured outputs because the prompt grew very large as they added tools.”summary, stated

Model-level evaluation frameworks for Rehat

Rejected because: The team needed to evaluate the behavior of the full application, not a language model in isolation.

“LLM evaluation frameworks target language models, not applications built on top of them”summary, stated

Patterns

rag-retrieval (retrieval)

Docugami improves RAG by preserving document structure and semantic metadata so retrievers can filter by meaning rather than file names.

“With Docugami's enriched metadata (e.g., filtering by "landlord"), the retriever successfully finds relevant documents.”summary, stated

structured-output-contract (interface)

Rehat moved to OpenAI function calling because it embedded structured output and reasoning contracts into the model's tool interface.

“Function calling embedded reasoning and structured output into the model itself, resulting in 3-4x latency improvements and much more reliable outputs.”summary, stated

observability-tracing (operations)

Both teams use LangSmith traces to inspect chain steps, reproduce failures, link CI failures, and create datasets for improvement.

“LangSmith is essential for debugging these complex chains. The team demonstrated how to trace through each step—from input parsing to few-shot example selection to parallel explanation generation—and diagnose failures like context overflow or broken SQL that fix-up logic couldn't repair.”summary, stated

eval-driven-development (quality)

Rehat built a synthetic CI test pipeline, while Docugami regularly reviews failed/disliked runs and converts them into datasets.

“The pipeline provides statistical feedback—showing how many tests pass or fail for each use case—rather than binary yes/no results.”summary, stated

fine-tuning-adaptation (model-adaptation)

Docugami fine-tunes smaller production models from corrected examples; Rehat prepares fine-tuning infrastructure for future function-calling support.

“• Fine-tuning smaller models with corrected examples and redeploying”summary, stated

human-in-the-loop-gate (governance)

Human annotators, reviewers, and QA teams decide which runs are bad, fix examples, and turn them into reliable datasets.

“Currently, a human QA team makes the good/bad determination during hundreds of daily test conversations. They may later use LLM evaluators for scalability, but value human oversight during this phase.”summary, stated

Tradeoffs

Preserve document structure before retrieval

Chose Hierarchical XML knowledge graph chunks over Flat text extraction and naive chunking.

Rationale: Structured chunks let retrieval disambiguate semantically related fields that flat retrievers miss.

“This hierarchical awareness is critical for high-signal retrieval in RAG applications. Without it, a question like "What is the rentable area for the property owned by DHA group?" fails because standard retrievers cannot disambiguate references across the document.”summary, stated

Use LCEL-style chains rather than full agents for Docugami workflows

Chose Sophisticated chains with retry logic and parallel execution over Full agent architectures.

Rationale: The team wanted agent-like fix-up and branching without the token cost or syntax mismatch of agents for smaller custom models.

“Instead, they use LangChain Expression Language (LCEL) to build sophisticated chains with retry logic and parallel execution.”summary, stated

Move Lucy to OpenAI function calling

Chose Function calling with schema-constrained tool selection over LangChain structured chat agent.

Rationale: Function calling was faster and produced more reliable structured outputs as the tool count grew.

“The team initially built Lucy using LangChain's structured chat agent, which provided reasoning capabilities and structured outputs.”summary, stated
“The release of OpenAI's function calling capability was transformative. Function calling embedded reasoning and structured output into the model itself, resulting in 3-4x latency improvements and much more reliable outputs.”summary, stated

Use human QA before automated evaluators for Lucy

Chose Human good/bad determination and curated labels over Immediately scaling with LLM evaluators.

Rationale: The team valued human oversight while their product and failure modes were still being established.

“Currently, a human QA team makes the good/bad determination during hundreds of daily test conversations. They may later use LLM evaluators for scalability, but value human oversight during this phase.”summary, stated

Gotchas (what bit them)

Naive chunking breaks document RAG on complex layouts.

Root cause: Important semantic relationships can be visually separated across headings, tables, columns, and key-value structures.

Resolution: Use multimodal structure detection, reading-order stitching, hierarchical chunks, and XML semantic labels.

“a legal document may have inline headings, two-column layouts, tables spanning columns, and key-value pairs that are semantically related but visually separated.”summary, stated

Complex chains are hard to debug unless traces are intentionally readable.

Root cause: Failures can occur across parsing, example selection, SQL generation, fix-up logic, and parallel explanation steps.

Resolution: Instrument LangSmith traces with proper names and config so each step can be inspected and reproduced.

“The team emphasized that making LangSmith traces "look good and be actionable" is an art, including naming lambdas properly and passing config correctly”summary, stated

Function-calling prompt descriptions may not reliably control model behavior.

Root cause: The model follows JSON schemas better than natural language instructions in tool descriptions, and examples in tool descriptions can be ignored or cause hallucinations.

Resolution: Rely on schema design, parsing-error handling, fine-tuning or software patches for behaviors that prompting cannot fix.

“• The model follows JSON schemas well but ignores natural language instructions in tool descriptions”summary, stated

Application evaluation cannot be reduced to one deterministic test outcome.

Root cause: LLMs are nondeterministic and application behavior emerges from model, tools, prompts, and orchestration together.

Resolution: Run many synthetic cases concurrently and interpret statistical pass/fail trends by use case.

“• LLMs are non-deterministic, so individual test cases weren't reliable”summary, stated

Evaluation

Docugami evaluates by reviewing failed and disliked runs, adding them to datasets, using larger offline models to propose corrections, and validating corrected syntax before fine-tuning. Rehat evaluates the full application with synthetic concurrent tests, CI tags, LangSmith trace links, playground reproduction, and human QA curation.

Metrics: statistical test pass/fail counts by use case · failed runs · user-disliked runs · valid SQL or XQuery syntax · commit hash and branch traceability · hundreds of daily test conversations

3 supporting quotes
“• Regularly reviewing failed runs and user-disliked runs in LangSmith”summary, stated
“The pipeline provides statistical feedback—showing how many tests pass or fail for each use case—rather than binary yes/no results.”summary, stated
“• Linking failed tests directly to LangSmith traces for one-click debugging”summary, stated

Outcomes

The clearest numbers are Docugami's five years of document-engineering work, Rehat's 10-20 consolidated tools, 50 generated test requests per use case, hundreds of daily test conversations, and Docugami's 500-run/10% weekly few-shot refresh cadence.

3 supporting quotes
“without Docugami metadata, the self-querying retriever returns zero documents because it tries to filter on file names.”summary, stated
“Function calling embedded reasoning and structured output into the model itself, resulting in 3-4x latency improvements and much more reliable outputs.”summary, stated
“Both acknowledge that fine-tuning is essential for generalization—prompt engineering and few-shot learning can only take you so far.”summary, stated