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 sur 18

Recommandé

5010 par
50105010
5010Arjun Kumar Marya
103 vues7 diapositives
Reengineering PDF-Based Documents Targeting Complex Software Specifications par
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 vues30 diapositives
Retrieval Augmented Generation in Practice: Scalable GenAI platforms with k8s... par
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
256 vues16 diapositives
Advantages And Disadvantages Of Text Clustering par
Advantages And Disadvantages Of Text ClusteringAdvantages And Disadvantages Of Text Clustering
Advantages And Disadvantages Of Text ClusteringSandra Anderson
3 vues50 diapositives
Introductionto Xm Lmessaging par
Introductionto Xm LmessagingIntroductionto Xm Lmessaging
Introductionto Xm LmessagingLiquidHub
416 vues22 diapositives
Tech challenges in a large scale agile project par
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 vues10 diapositives

Contenu connexe

Similaire à LangChain + Docugami Webinar

Application Of A Solid Foundation par
Application Of A Solid FoundationApplication Of A Solid Foundation
Application Of A Solid FoundationDawn Robertson
2 vues77 diapositives
Use Case Patterns for LLM Applications (1).pdf par
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
245 vues50 diapositives
Document Based Data Modeling Technique par
Document Based Data Modeling TechniqueDocument Based Data Modeling Technique
Document Based Data Modeling TechniqueCarmen Sanborn
4 vues77 diapositives
Google File System par
Google File SystemGoogle File System
Google File Systemvivatechijri
52 vues6 diapositives
A Case Study Of A Reusable Component Collection par
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 vues6 diapositives
Tech leaders guide to effective building of machine learning products par
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 vues58 diapositives

Similaire à LangChain + Docugami Webinar(20)

Use Case Patterns for LLM Applications (1).pdf par 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 Kadous245 vues
A Case Study Of A Reusable Component Collection par 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
Tech leaders guide to effective building of machine learning products par 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 vues
Practical machine learning par Faizan Javed
Practical machine learningPractical machine learning
Practical machine learning
Faizan Javed250 vues
Adopting AnswerModules ModuleSuite par AnswerModules
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuite
AnswerModules426 vues
Mit302 web technologies par smumbahelp
Mit302 web technologiesMit302 web technologies
Mit302 web technologies
smumbahelp125 vues
Designing a Generative AI QnA solution with Proprietary Enterprise Business K... par 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 vues
Building and deploying LLM applications with Apache Airflow par 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 Naik102 vues

Dernier

Techstack Ltd at Slush 2023, Ukrainian delegation par
Techstack Ltd at Slush 2023, Ukrainian delegationTechstack Ltd at Slush 2023, Ukrainian delegation
Techstack Ltd at Slush 2023, Ukrainian delegationViktoriiaOpanasenko
7 vues4 diapositives
Quality Engineer: A Day in the Life par
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the LifeJohn Valentino
10 vues18 diapositives
Chat GPTs par
Chat GPTsChat GPTs
Chat GPTsGene Leybzon
13 vues36 diapositives
.NET Deserialization Attacks par
.NET Deserialization Attacks.NET Deserialization Attacks
.NET Deserialization AttacksDharmalingam Ganesan
7 vues50 diapositives
Agile 101 par
Agile 101Agile 101
Agile 101John Valentino
13 vues20 diapositives
Ports-and-Adapters Architecture for Embedded HMI par
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMIBurkhard Stubert
35 vues19 diapositives

Dernier(20)

Ports-and-Adapters Architecture for Embedded HMI par Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile... par Stefan Wolpers
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
Stefan Wolpers44 vues
Dapr Unleashed: Accelerating Microservice Development par Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
predicting-m3-devopsconMunich-2023.pptx par Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app10 vues
aATP - New Correlation Confirmation Feature.pptx par EsatEsenek1
aATP - New Correlation Confirmation Feature.pptxaATP - New Correlation Confirmation Feature.pptx
aATP - New Correlation Confirmation Feature.pptx
EsatEsenek1222 vues
Automated Testing of Microsoft Power BI Reports par RTTS
Automated Testing of Microsoft Power BI ReportsAutomated Testing of Microsoft Power BI Reports
Automated Testing of Microsoft Power BI Reports
RTTS11 vues
How Workforce Management Software Empowers SMEs | TraQSuite par TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuiteHow Workforce Management Software Empowers SMEs | TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuite
TraQSuite7 vues
ADDO_2022_CICID_Tom_Halpin.pdf par TomHalpin9
ADDO_2022_CICID_Tom_Halpin.pdfADDO_2022_CICID_Tom_Halpin.pdf
ADDO_2022_CICID_Tom_Halpin.pdf
TomHalpin96 vues
Bootstrapping vs Venture Capital.pptx par Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic16 vues

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