LangChain + Docugami Webinar

The Document Engineering Company
LangChain Webinar: Lessons from
Deploying LLMs with LangSmith
Jean Paoli @jeanpaoli
Taqi Jaffri @tjaffri
Mike Palmer
Zubin Wadia @zubinwadia
Topics
1. Intros
2. Real-World Challenges using LLMs with Documents
i. Real documents are more than flat Text
ii. Documents are Knowledge Graphs
iii. Building Complex Chains with the LangChain Expression Language
iv. Debugging Complex Chain Failures in Production
3. Summary: End to end LLM Ops
… deploy / run / trace / correct / finetune / repeat
Who we are...
• Generative AI for Business Documents. Founded 2018.
• Leverage open source and our own LLMs trained on millions of business documents to create a full
XML data representation of complex documents in their entirety, delivering immediate value to frontline
business users.
• Document as data can be used to generate insights and reports, create new documents, or drive line-
of-business applications. Free trial at www.docugami.com/trial
• Customers in many sectors, including insurance, real estate, health, professional services.
Jean Paoli
Co-founder, CEO
Pioneer in document engineering;
co-creator of XML, .docx, .xlsx, .pptx;
started four $1B+ businesses at Microsoft
Mike Palmer
Co-founder, Head of Technologies
Senior engineering manager at
Microsoft; co-created Microsoft
InfoPath.
Zubin Wadia
Product Manager
Making documents matter to people and
systems – 100+ products over 20 years. MIT,
ImageWork, CiviGuard.
Taqi Jaffri
Co-founder, Head of Product
Principal Product Manager at
Microsoft; co-created the AI driving
Microsoft presence in physical stores.
Challenge 1: Real documents are more than flat text
Real Documents are Structurally Complex: Headings, Lists, Tables, Headers/Footers, Complex Reading Orders, Figures, etc.
Mitigations:
1. Structurally chunk the
document to find
structural elements.
2. Stitch together reading
order flow with language
models.
3. Sub-chunk for RAG using
document structural
elements rather than
simple tiling or text
splitting.
Challenge 2: Documents are Knowledge Graphs
Document structures and spatial relationships contain semantics that are often lost in simple text-based retrieval
Mitigations:
1. XML hierarchical
Knowledge Graph
representation for
inherent per-
document
semantics added to
vector store for
RAG
2. Schema
normalization
across sets of
similar documents
Example XML hierarchical Knowledge Graph
Represents structural relationships as well as per-chunk semantic labels
Retrieval Augmented Generation (RAG) w/ Semantic Chunk
Metadata from Docugami XML
Vector DB
Knowledge Base e.g.,
business documents
Step 1: Indexing / Ingestion
Embedding Model
converts chunks to
embeddings
Data Loader reads
text from
Knowledge Base
and creates chunks
Vector DB offers
fast lookup of
chunks
semantically
similar to any
given string, e.g.
a question
Question
Step 2: Querying
Similar Chunks in Knowledge
Base (possibly contain
answers)
-- improved with additional
information from Docugami
XML Knowledge Graph
Chat
History
Answer
(sourced in
Knowledge
Base)
Metadata from
Docugami XML
LangSmith
Run
traces
Challenges 1 & 2
CODE WALK-THROUGH
https://rebrand.ly/docugami_semantic_rag
Challenge 3: Building Complex Chains with the LangChain
Expression Language
Real-world chains can get complicated with parallel branches, output parsers, few shot examples, conditional sub-chains, etc.
Question
“What were the
total midmarket
gross sales for
Mexico in
2014?”
Generate
SQL Query
SQL DB
(read-only)
Table
schema and
sample rows
Run SQL
Query
Explainers
(in parallel)
Result
Explainer
Query
Explainer
(for non-
technical
users)
SELECT SUM("Gross
Sales") FROM
financial_data WHERE
Segment = "Midmarket"
AND Country = "Mexico"
AND Year = 2014;
Syntax
Error?
(pysqlite3.dbapi2.O
perationalError) no
such table:
financial_data
Attempt
Fixup
SELECT SUM("Gross
Sales") FROM "Financial
Data" WHERE Segment =
"Midmarket" AND Country
= "Mexico" AND Year =
2014;
"[(451890.0,)]"
The total
midmarket gross
sales for Mexico
in 2014 were
$451,890.
Sum of 'Gross
Sales' for the
'Midmarket' segment
in Mexico for the
year 2014.
Sample code: https://rebrand.ly/docugami_complex_chain
Challenge 3
LANGSMITH WALK-THROUGH
https://smith.langchain.com/public/ab8ef1ec-46d1-4d1f-980a-
6dcc8f1943e0/r
Challenge 4: Debugging Complex Chain Failures in Production
Identifying what went wrong, where…
Common Failures:
1. Invalid SQL that could not
be automatically fixed,
leading to chain failure
2. Token overflow (table
schema too large)
3. LLM rate limit reached
4. LLM call failed with GPU
OOM (for self-hosted
models)
5. Exception in custom python
RunnableLambda
6. Exception in custom output
parser
TIP: If you have a link to a detailed call stack for an exception, you can add it to the failed run as
metadata for later investigation. You can also add other information useful to investigate the
failure later.
TIP: Name all runnable lambdas and pass config to conditionally-invoked runnables to correctly link and
name. Reference: cookbook | example
1. Deploy Model (we self-host a custom LLM)
2. Regularly look at failed and user-disliked runs
3. Add some problematic runs to dataset
a) Failed runs e.g. with syntax errors
b) Runs with negative user feedback
4. Fix runs in dataset
a) Tip: use larger LLM to propose fixes
b) Tip: validate that fixes are syntactically correct e.g. by checking SQL syntax
5. Add some examples to few shot set for in-context learning
6. Fine tune model on updated dataset
7. Redeploy (go back to #1)
Summary: Docugami’s End to end LLM Ops with LangChain
+ LangSmith
Q&A
The Document Engineering Company
Docugami API
1.Docs: https://help.docugami.com/home/docugami-api
2.Things to try:
a) Upload docs (DOCX, DOC, digital or scanned PDF)
b) Download processed XML (with semantic metadata tags)
c) Build reports to identify key chunks
d) Use the LlamaHub Docugami loader to load docs for RAG, with
report metadata
3.Free trials available!
Example: Extracting Custom Data from a Document Set
Improved significantly via structural chunking and key metadata associated with all chunks
Example: Authoring Assistance Based on Your Documents
Improved significantly via structural chunking and key metadata associated with all chunks
Example: Workflows Triggered by Auto-Extracted Data
Improved significantly via structural chunking and key metadata associated with all chunks
1 von 18

Recomendados

5010 von
50105010
5010Arjun Kumar Marya
103 views7 Folien
Reengineering PDF-Based Documents Targeting Complex Software Specifications von
Reengineering PDF-Based Documents Targeting Complex Software SpecificationsReengineering PDF-Based Documents Targeting Complex Software Specifications
Reengineering PDF-Based Documents Targeting Complex Software SpecificationsMoutasm Tamimi
163 views30 Folien
Retrieval Augmented Generation in Practice: Scalable GenAI platforms with k8s... von
Retrieval Augmented Generation in Practice: Scalable GenAI platforms with k8s...Retrieval Augmented Generation in Practice: Scalable GenAI platforms with k8s...
Retrieval Augmented Generation in Practice: Scalable GenAI platforms with k8s...Mihai Criveti
253 views16 Folien
Advantages And Disadvantages Of Text Clustering von
Advantages And Disadvantages Of Text ClusteringAdvantages And Disadvantages Of Text Clustering
Advantages And Disadvantages Of Text ClusteringSandra Anderson
3 views50 Folien
Introductionto Xm Lmessaging von
Introductionto Xm LmessagingIntroductionto Xm Lmessaging
Introductionto Xm LmessagingLiquidHub
416 views22 Folien
Tech challenges in a large scale agile project von
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile projectHarald Soevik
565 views10 Folien

Más contenido relacionado

Similar a LangChain + Docugami Webinar

Application Of A Solid Foundation von
Application Of A Solid FoundationApplication Of A Solid Foundation
Application Of A Solid FoundationDawn Robertson
2 views77 Folien
Use Case Patterns for LLM Applications (1).pdf von
Use Case Patterns for LLM Applications (1).pdfUse Case Patterns for LLM Applications (1).pdf
Use Case Patterns for LLM Applications (1).pdfM Waleed Kadous
242 views50 Folien
Document Based Data Modeling Technique von
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling TechniqueCarmen Sanborn
4 views77 Folien
Google File System von
Google File SystemGoogle File System
Google File Systemvivatechijri
52 views6 Folien
A Case Study Of A Reusable Component Collection von
A Case Study Of A Reusable Component CollectionA Case Study Of A Reusable Component Collection
A Case Study Of A Reusable Component CollectionJennifer Strong
5 views6 Folien
Tech leaders guide to effective building of machine learning products von
Tech leaders guide to effective building of machine learning productsTech leaders guide to effective building of machine learning products
Tech leaders guide to effective building of machine learning productsGianmario Spacagna
2.2K views58 Folien

Similar a LangChain + Docugami Webinar(20)

Use Case Patterns for LLM Applications (1).pdf von M Waleed Kadous
Use Case Patterns for LLM Applications (1).pdfUse Case Patterns for LLM Applications (1).pdf
Use Case Patterns for LLM Applications (1).pdf
M Waleed Kadous242 views
Document Based Data Modeling Technique von Carmen Sanborn
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling Technique
Carmen Sanborn4 views
A Case Study Of A Reusable Component Collection von Jennifer Strong
A Case Study Of A Reusable Component CollectionA Case Study Of A Reusable Component Collection
A Case Study Of A Reusable Component Collection
Jennifer Strong5 views
Tech leaders guide to effective building of machine learning products von Gianmario Spacagna
Tech leaders guide to effective building of machine learning productsTech leaders guide to effective building of machine learning products
Tech leaders guide to effective building of machine learning products
Gianmario Spacagna2.2K views
Practical machine learning von Faizan Javed
Practical machine learningPractical machine learning
Practical machine learning
Faizan Javed250 views
Adopting AnswerModules ModuleSuite von AnswerModules
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuite
AnswerModules426 views
Mit302 web technologies von smumbahelp
Mit302 web technologiesMit302 web technologies
Mit302 web technologies
smumbahelp125 views
Designing a Generative AI QnA solution with Proprietary Enterprise Business K... von IRJET Journal
Designing a Generative AI QnA solution with Proprietary Enterprise Business K...Designing a Generative AI QnA solution with Proprietary Enterprise Business K...
Designing a Generative AI QnA solution with Proprietary Enterprise Business K...
IRJET Journal28 views
Building and deploying LLM applications with Apache Airflow von Kaxil Naik
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
Kaxil Naik101 views

Último

JioEngage_Presentation.pptx von
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptxadmin125455
8 views4 Folien
predicting-m3-devopsconMunich-2023.pptx von
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptxTier1 app
8 views24 Folien
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... von
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Lisi Hocke
35 views124 Folien
Using Qt under LGPL-3.0 von
Using Qt under LGPL-3.0Using Qt under LGPL-3.0
Using Qt under LGPL-3.0Burkhard Stubert
13 views11 Folien
Bootstrapping vs Venture Capital.pptx von
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
15 views17 Folien
Transport Management System - Shipment & Container Tracking von
Transport Management System - Shipment & Container TrackingTransport Management System - Shipment & Container Tracking
Transport Management System - Shipment & Container TrackingFreightoscope
5 views3 Folien

Último(20)

JioEngage_Presentation.pptx von admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254558 views
predicting-m3-devopsconMunich-2023.pptx von Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... von Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Bootstrapping vs Venture Capital.pptx von Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic15 views
Transport Management System - Shipment & Container Tracking von Freightoscope
Transport Management System - Shipment & Container TrackingTransport Management System - Shipment & Container Tracking
Transport Management System - Shipment & Container Tracking
Freightoscope 5 views
How Workforce Management Software Empowers SMEs | TraQSuite von TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuiteHow Workforce Management Software Empowers SMEs | TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuite
TraQSuite6 views
AI and Ml presentation .pptx von FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8714 views
Airline Booking Software von SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
Top-5-production-devconMunich-2023-v2.pptx von Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app6 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... von TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views
Electronic AWB - Electronic Air Waybill von Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 5 views
Understanding HTML terminology von artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar57 views

LangChain + Docugami Webinar

  • 1. The Document Engineering Company LangChain Webinar: Lessons from Deploying LLMs with LangSmith Jean Paoli @jeanpaoli Taqi Jaffri @tjaffri Mike Palmer Zubin Wadia @zubinwadia
  • 2. Topics 1. Intros 2. Real-World Challenges using LLMs with Documents i. Real documents are more than flat Text ii. Documents are Knowledge Graphs iii. Building Complex Chains with the LangChain Expression Language iv. Debugging Complex Chain Failures in Production 3. Summary: End to end LLM Ops … deploy / run / trace / correct / finetune / repeat
  • 3. Who we are... • Generative AI for Business Documents. Founded 2018. • Leverage open source and our own LLMs trained on millions of business documents to create a full XML data representation of complex documents in their entirety, delivering immediate value to frontline business users. • Document as data can be used to generate insights and reports, create new documents, or drive line- of-business applications. Free trial at www.docugami.com/trial • Customers in many sectors, including insurance, real estate, health, professional services. Jean Paoli Co-founder, CEO Pioneer in document engineering; co-creator of XML, .docx, .xlsx, .pptx; started four $1B+ businesses at Microsoft Mike Palmer Co-founder, Head of Technologies Senior engineering manager at Microsoft; co-created Microsoft InfoPath. Zubin Wadia Product Manager Making documents matter to people and systems – 100+ products over 20 years. MIT, ImageWork, CiviGuard. Taqi Jaffri Co-founder, Head of Product Principal Product Manager at Microsoft; co-created the AI driving Microsoft presence in physical stores.
  • 4. Challenge 1: Real documents are more than flat text Real Documents are Structurally Complex: Headings, Lists, Tables, Headers/Footers, Complex Reading Orders, Figures, etc. Mitigations: 1. Structurally chunk the document to find structural elements. 2. Stitch together reading order flow with language models. 3. Sub-chunk for RAG using document structural elements rather than simple tiling or text splitting.
  • 5. Challenge 2: Documents are Knowledge Graphs Document structures and spatial relationships contain semantics that are often lost in simple text-based retrieval Mitigations: 1. XML hierarchical Knowledge Graph representation for inherent per- document semantics added to vector store for RAG 2. Schema normalization across sets of similar documents
  • 6. Example XML hierarchical Knowledge Graph Represents structural relationships as well as per-chunk semantic labels
  • 7. Retrieval Augmented Generation (RAG) w/ Semantic Chunk Metadata from Docugami XML Vector DB Knowledge Base e.g., business documents Step 1: Indexing / Ingestion Embedding Model converts chunks to embeddings Data Loader reads text from Knowledge Base and creates chunks Vector DB offers fast lookup of chunks semantically similar to any given string, e.g. a question Question Step 2: Querying Similar Chunks in Knowledge Base (possibly contain answers) -- improved with additional information from Docugami XML Knowledge Graph Chat History Answer (sourced in Knowledge Base) Metadata from Docugami XML LangSmith Run traces
  • 8. Challenges 1 & 2 CODE WALK-THROUGH https://rebrand.ly/docugami_semantic_rag
  • 9. Challenge 3: Building Complex Chains with the LangChain Expression Language Real-world chains can get complicated with parallel branches, output parsers, few shot examples, conditional sub-chains, etc. Question “What were the total midmarket gross sales for Mexico in 2014?” Generate SQL Query SQL DB (read-only) Table schema and sample rows Run SQL Query Explainers (in parallel) Result Explainer Query Explainer (for non- technical users) SELECT SUM("Gross Sales") FROM financial_data WHERE Segment = "Midmarket" AND Country = "Mexico" AND Year = 2014; Syntax Error? (pysqlite3.dbapi2.O perationalError) no such table: financial_data Attempt Fixup SELECT SUM("Gross Sales") FROM "Financial Data" WHERE Segment = "Midmarket" AND Country = "Mexico" AND Year = 2014; "[(451890.0,)]" The total midmarket gross sales for Mexico in 2014 were $451,890. Sum of 'Gross Sales' for the 'Midmarket' segment in Mexico for the year 2014. Sample code: https://rebrand.ly/docugami_complex_chain
  • 11. Challenge 4: Debugging Complex Chain Failures in Production Identifying what went wrong, where… Common Failures: 1. Invalid SQL that could not be automatically fixed, leading to chain failure 2. Token overflow (table schema too large) 3. LLM rate limit reached 4. LLM call failed with GPU OOM (for self-hosted models) 5. Exception in custom python RunnableLambda 6. Exception in custom output parser TIP: If you have a link to a detailed call stack for an exception, you can add it to the failed run as metadata for later investigation. You can also add other information useful to investigate the failure later. TIP: Name all runnable lambdas and pass config to conditionally-invoked runnables to correctly link and name. Reference: cookbook | example
  • 12. 1. Deploy Model (we self-host a custom LLM) 2. Regularly look at failed and user-disliked runs 3. Add some problematic runs to dataset a) Failed runs e.g. with syntax errors b) Runs with negative user feedback 4. Fix runs in dataset a) Tip: use larger LLM to propose fixes b) Tip: validate that fixes are syntactically correct e.g. by checking SQL syntax 5. Add some examples to few shot set for in-context learning 6. Fine tune model on updated dataset 7. Redeploy (go back to #1) Summary: Docugami’s End to end LLM Ops with LangChain + LangSmith
  • 13. Q&A
  • 15. Docugami API 1.Docs: https://help.docugami.com/home/docugami-api 2.Things to try: a) Upload docs (DOCX, DOC, digital or scanned PDF) b) Download processed XML (with semantic metadata tags) c) Build reports to identify key chunks d) Use the LlamaHub Docugami loader to load docs for RAG, with report metadata 3.Free trials available!
  • 16. Example: Extracting Custom Data from a Document Set Improved significantly via structural chunking and key metadata associated with all chunks
  • 17. Example: Authoring Assistance Based on Your Documents Improved significantly via structural chunking and key metadata associated with all chunks
  • 18. Example: Workflows Triggered by Auto-Extracted Data Improved significantly via structural chunking and key metadata associated with all chunks