Skip to content

Commit b46a969

Browse files
committed
RAG LLN NLP and Layout model
1 parent a11bef4 commit b46a969

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

articles/ai-services/document-intelligence/concept-retrieval-augumented-generation.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: azure-ai-document-intelligence
88
ms.topic: conceptual
99
ms.date: 12/15/2023
10-
ms.author: lajanuar
10+
ms.author: luzhan
1111
monikerRange: '>=doc-intel-3.0.0'
1212
---
1313

@@ -17,51 +17,59 @@ monikerRange: '>=doc-intel-3.0.0'
1717

1818
**This content applies to:** ![checkmark](media/yes-icon.png) **v4.0 (preview)**
1919

20-
Retrieval Augmented Generation (RAG) is a document generative AI solution that combines a pretrained Large Language Model (LLM) like ChatGPT with an external data retrieval system to generate an enhanced response incorporating new data outside of the original training data. Adding an information retrieval system to your applications enables you to chat with your documents, generate captivating content, and access the power of Azure OpenAI models for your data. You also have more control over the data used by the LLM as it formulates a response.
20+
## Introduction
2121

22-
## Azure AI Document Intelligence Layout model
22+
Retrieval Augmented Generation (RAG) is a document generative AI solution that combines a pretrained Large Language Model (LLM) like ChatGPT with an external data retrieval system to generate an enhanced response incorporating new data outside of the original training data. Adding an information retrieval system to your applications enables you to chat with your documents, generate captivating content, and access the power of Azure OpenAI models for your data. You also have more control over the data used by the LLM as it formulates a response.
2323

24-
The Document Intelligence [Layout model](concept-layout.md) is an advanced machine-learning based document analysis API. With semantic chunking, the layout model offers a comprehensive solution for advanced content extraction and document structure analysis capabilities. With the layout model, you can easily extract text and structural to divide large bodies of text into smaller, meaningful chunks based on semantic content rather than arbitrary splits. The extracted information can be conveniently outputted to Markdown format, enabling you to define your semantic chunking strategy based on the provided building blocks.
24+
The Document Intelligence [Layout model](concept-layout.md) is an advanced machine-learning based document analysis API. With semantic chunking, the Layout model offers a comprehensive solution for advanced content extraction and document structure analysis capabilities. With the Layout model, you can easily extract text and structural to divide large bodies of text into smaller, meaningful chunks based on semantic content rather than arbitrary splits. The extracted information can be conveniently outputted to Markdown format, enabling you to define your semantic chunking strategy based on the provided building blocks.
2525

2626
:::image type="content" source="media/rag/azure-rag-processing.png" alt-text="Screenshot depicting semantic chunking with RAG using Azure AI Document Intelligence":::
2727

28-
## Layout model and semantic chunking
28+
## Semantic chunking
2929

3030
Long sentences are challenging for natural language processing (NLP) applications. Especially when they're composed of multiple clauses, complex noun or verb phrases, relative clauses, and parenthetical groupings. Just like the human beholder, an NLP system also needs to successfully keep track of all the presented dependencies. The goal of semantic chunking is to find semantically coherent fragments of a sentence representation. These fragments can then be processed independently and recombined as semantic representations without loss of information, interpretation, or semantic relevance. The inherent meaning of the text is used as a guide for the chunking process.
3131

3232
Text data chunking strategies play a key role in optimizing the RAG response and performance. Fixed-sized and semantic are two distinct chunking methods:
3333

3434
* **Fixed-sized chunking**. Most chunking strategies used in RAG today are based on fix-sized text segments known as chunks. Fixed-sized chunking is quick, easy, and effective with text that doesn't have a strong semantic structure such as logs and data. However it isn't recommended for text that requires semantic understanding and precise context. The fixed-size nature of the window can result in severing words, sentences, or paragraphs impeding comprehension and disrupt the flow of information and understanding.
3535

36-
* **Semantic chunking**. This method divides the text into chunks based on semantic understanding. Division boundaries are focused on sentence subject and use significant computational algorithmically complex resources. However, it has the distinct advantage of maintaining semantic consistency within each chunk. It's useful for text summarization, sentiment analysis, and document classification tasks.
36+
* **Semantic chunking**. This method divides the text into chunks based on semantic understanding. Division boundaries are focused on sentence subject and use significant computational algorithmically complex resources. However, it has the distinct advantage of maintaining semantic consistency within each chunk. It's useful for text summarization, sentiment analysis, and document classification tasks.
3737

38-
## Semantic chunking with Document Intelligence layout model
38+
## Semantic chunking with Document Intelligence Layout model
3939

4040
Markdown is a structured and formatted markup language and a popular input for enabling semantic chunking in RAG (Retrieval augmented generation). You can use the Markdown content from the [Layout model](concept-layout.md) to split documents based on paragraph boundaries, create specific chunks for tables, and fine-tune your chunking strategy to improve the quality of the generated responses.
4141

42-
### Benefits of using the layout model
42+
### Benefits of using the Layout model
4343

4444
* **Simplified processing**. You can parse different document types, such as digital and scanned PDFs, images, office files (docx, xlsx, pptx), and HTML, with just a single API call.
4545

46-
* **Scalability and AI quality**. The layout model is highly scalable in Optical Character Recognition (OCR), table extraction, and [document structure analysis](concept-layout.md#document-layout-analysis). It supports [309 printed and 12 handwritten languages](language-support-ocr.md#model-id-prebuilt-layout) further ensuring high-quality results driven by AI capabilities.
46+
* **Scalability and AI quality**. The Layout model is highly scalable in Optical Character Recognition (OCR), table extraction, and [document structure analysis](concept-layout.md#document-layout-analysis). It supports [309 printed and 12 handwritten languages](language-support-ocr.md#model-id-prebuilt-layout) further ensuring high-quality results driven by AI capabilities.
47+
48+
* **Large learning model (LLM) compatibility**. The Layout model Markdown formatted output is LLM friendly and facilitates seamless integration into your workflows. You can turn any table in a document into Markdown format and avoid extensive effort parsing the documents for greater LLM understanding.
49+
50+
**Text image processed with Document Intelligence Studio using Layout model**
51+
52+
:::image type="content" source="media/rag/markdown-text-output.png" alt-text="Screenshot of newspaper article processed by Layout model and outputted to Markdown.":::
4753

48-
* **Large learning model (LLM) compatibility**. The layout model Markdown formatted output is LLM friendly and facilitates seamless integration into your workflows. You can turn any table in a document into Markdown format and avoid extensive effort parsing the documents for greater LLM understanding.
54+
**Table image processed with Document Intelligence Studio using Layout model**
4955

50-
**Text image processed with Document Intelligence studio using layout model**
56+
:::image type="content" source="media/rag/markdown-table-output.png" alt-text="Screenshot of table processed by Layout model and outputted to Markdown.":::
5157

52-
:::image type="content" source="media/rag/markdown-text-output.png" alt-text="Screenshot of newspaper article processed by layout model and outputted to Markdown.":::
58+
## Get started
5359

54-
**Table image processed with Document Intelligence studio using layout model**
60+
The Document Intelligence Layout model **2023-10-31-preview** supports the following development options:
5561

56-
:::image type="content" source="media/rag/markdown-table-output.png" alt-text="Screenshot of table processed by layout model and outputted to Markdown.":::
62+
* [Document Intelligence Studio](https://documentintelligence.ai.azure.com/studio)
5763

58-
## Get started with semantic chunking
64+
* [REST API](/rest/api/aiservices/document-models/analyze-document?view=rest-aiservices-2023-10-31-preview&branch=main&tabs=HTTP)
65+
66+
* [.NET, Java, JavaScript, and Python programming language SDKs.](sdk-overview-v4-0.md?view=doc-intel-4.0.0&tabs=csharp#supported-programming-languages)
5967

6068
**Ready to begin?**
6169

62-
### Document Intelligence studio
70+
### Document Intelligence Studio
6371

64-
You can follow the [Document Intelligence studio quickstart](quickstarts/try-document-intelligence-studio.md) to get started. Next, you can integrate Document Intelligence features with your own application using the sample code provided.
72+
You can follow the [Document Intelligence Studio quickstart](quickstarts/try-document-intelligence-studio.md) to get started. Next, you can integrate Document Intelligence features with your own application using the sample code provided.
6573

6674
* Start with the [Layout model](https://documentintelligence.ai.azure.com/studio/layout). You need to select the following **Analyze options** to use RAG in the studio:
6775

@@ -85,11 +93,11 @@ You can follow the [Document Intelligence studio quickstart](quickstarts/try-doc
8593

8694
* The Markdown content is presented in the right-pane window:
8795

88-
:::image type="content" source="media/rag/markdown-content.png" alt-text="Screenshot of the layout model markdown output in the Document Intelligence Studio.":::
96+
:::image type="content" source="media/rag/markdown-content.png" alt-text="Screenshot of the Layout model markdown output in the Document Intelligence Studio.":::
8997

9098
### SDK or REST API
9199

92-
* Follow the [Document Intelligence quickstart](quickstarts/get-started-sdks-rest-api.md) for your preferred programming language SDK or REST API. Use the layout model to extract content and structure from your documents.
100+
* Follow the [Document Intelligence quickstart](quickstarts/get-started-sdks-rest-api.md) for your preferred programming language SDK or REST API. Use the Layout model to extract content and structure from your documents.
93101

94102
* You can also check out GitHub repos for code samples and tips for analyzing a document in markdown output format.
95103

@@ -101,7 +109,7 @@ You can follow the [Document Intelligence studio quickstart](quickstarts/try-doc
101109

102110
## Build document chat with semantic chunking
103111

104-
* [Azure OpenAI on your data](../openai/concepts/use-your-data.md) enables you to run supported chat on your documents. Azure OpenAI on your data applies the Document Intelligence layout model to extract and parse document data by chunking long text based on tables and paragraphs. You can also customize your chunking strategy using [Azure OpenAI sample scripts](https://github.com/microsoft/sample-app-aoai-chatGPT/tree/main/scripts) located in our GitHub repo.
112+
* [Azure OpenAI on your data](../openai/concepts/use-your-data.md) enables you to run supported chat on your documents. Azure OpenAI on your data applies the Document Intelligence Layout model to extract and parse document data by chunking long text based on tables and paragraphs. You can also customize your chunking strategy using [Azure OpenAI sample scripts](https://github.com/microsoft/sample-app-aoai-chatGPT/tree/main/scripts) located in our GitHub repo.
105113

106114
* Azure AI Document Intelligence is now integrated with [LangChain](https://python.langchain.com/docs/integrations/document_loaders/azure_document_intelligence) as one of its document loaders. You can use it to easily load the data and output to Markdown format. This [notebook](https://microsoft.github.io/SynapseML/docs/Explore%20Algorithms/AI%20Services/Quickstart%20-%20Document%20Question%20and%20Answering%20with%20PDFs/) shows a simple demo for RAG pattern with Azure AI Document Intelligence as document loader and Azure Search as retriever in LangChain.
107115

@@ -118,13 +126,13 @@ If you're looking for a specific section in a document, you can use semantic chu
118126

119127
from azure.ai.documentintelligence import DocumentIntelligenceClient
120128
from azure.core.credentials import AzureKeyCredential
121-
129+
122130
endpoint = "https://<my-custom-subdomain>.cognitiveservices.azure.com/"
123131
credential = AzureKeyCredential("<api_key>")
124-
132+
125133
document_intelligence_client = DocumentIntelligenceClient(
126134
endpoint, credential)
127-
135+
128136
from langchain.document_loaders.doc_intelligence import DocumentIntelligenceLoader
129137
from langchain.text_splitter import MarkdownHeaderTextSplitter
130138
# Initiate Azure AI Document Intelligence to load the document and split it into chunks

0 commit comments

Comments
 (0)