You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This demo application was built to show how Azure AI Document Intelligence and Azure Open AI Service can be used to increase the efficiency of document analysis.
5
+
6
+
You can create a new project and upload your pdf-documents to it. The documents will be analyzed with Azure AI Document Intelligence and the results will be stored in the project folder.
7
+
8
+
A FAISS Vector Search Index will be created for the documents and you can use similarity search to find relevant content in the documents and create a reduced version of the content to reduce the human effort for reading.
9
+
10
+
Tables and Key Value pairs that are found in the documents will be extracted and can also be viewed with the click of a button.
11
+
12
+
The reduced version of the content (a markdown version of all pages where similarity search found relevant content) can be used as context to ask questions about the documents with Azure Open AI ("gpt-35-turbo" or "text-davinci-003")
13
+
14
+
The application also provides Speech to text and Text to Speech functionality to make it easier to increase its accessibility (currently English and German)
15
+
16
+
Questions and Queries are stored in the topics subfolder of the project, so that you can easily reuse them i.e. for quantative prompt testing with prompt flow.
17
+
18
+
For a good demonstration I would suggest you import a set of documents and include information (topics) that you try to find in the documents and the pages that humans would normally look at to gather the information.
19
+
20
+
These pages can be used to set the ground truth for the topic. If the ground truth is set, the application will notify you if the pages that were found by the similarity search are part of the ground truth or not.
21
+
22
+
Based on the k value you can increase the likelyhood to find the relevant pages, but you will also increase the number of pages that are not relevant, so that the efficiency gain will be reduced.
23
+
24
+
However this is a great way to demonstrate the impact of proper prompts and k values on the results
25
+
26
+
## Prerequisites:
27
+
- Azure Subscription with the following resources:
28
+
- Azure AI Document Intelligence
29
+
- Azure Open AI
30
+
- Azure AI Speech
31
+
32
+
create a .env file and add the corresponding keys and endpoint information to file (see .env.example for an example)
33
+
34
+
## Installation:
35
+
I suggest to use conda to creata a virtual python environment
36
+
37
+
### Miniconda (example)
38
+
Install Miniconda according to the official documentation. (select add to PATH variable during installation)
39
+
https://conda.io/en/latest/miniconda.html
40
+
41
+
In your explorer navigate to the analyzer directory and rightclick
42
+
select open with conda prompt and in the prompt enter:
43
+
conda create --name document_analyzer python=3.11
44
+
45
+
### Install the required packages:
46
+
In your explorer navigate to the analyzer directory and rightclick and open a command prompt terminal
47
+
conda activate document_analyzer
48
+
Install the required packages with the following command:
49
+
pip install -r requirements.txt
50
+
51
+
## Running the application:
52
+
In your explorer navigate to the analyzer directory and rightclick and open a command prompt terminal
53
+
conda activate document_analyzer
54
+
Run the application with the following command:
55
+
streamlit run document_analyzer.py
56
+
The application will open in a webrowser window at http://localhost:8501/
57
+
58
+
## Setup:
59
+
### Project
60
+
You start by first creating a new project which will create a new folder in the projects folder
61
+
If you put a logo.png file inside of the project folder it will be used as the logo in the application. otherwise the default logo (img.png) will be used
62
+
63
+
### Documents
64
+
Now can upload your documents to the project
65
+
After that you can start the analysis with Azure AI Document Intelligence
66
+
Depending on the length of the document, the analysis can take several minutes
67
+
When the Analysis is finished you multiple JSON and md files are created inside the files subfolder of your project:
68
+
-*.json: contains the raw output of the analysis
69
+
-*.md: contains the full text of the document in markdown format
70
+
-*.pagecontent.json: contains the content of the pages in markdown format with the page number as the json key
71
+
-*.tables.md: contains the tables in markdown format
72
+
-*.keyvalues.json: contains the key values in json format with the page number as the json key
73
+
74
+
#### Chunks
75
+
Based on the anaysis results from Document Intelligence the paragraphs are used to chunk the document into smaller pieces:
76
+
The paragraphes wit sectionHeading role will be used to decide how to split the text. If the sections are larger than the token limit (default 512) the section will be split into smaller chunks.
77
+
78
+
### Topics
79
+
Now you can create topics which will create a new folder in the topics subfolder of your project
80
+
Inside of the topic folder there are different text files:
81
+
- queries.txt: contains the queries that you want to use for the Vecor Search
82
+
- questions.txt: contains the questions that you want to ask about the topic
83
+
- ground_truth.txt: contains the pages that humans would look at to answer the questions (for ground truth checking)
84
+
85
+
## Usage
86
+
### Sidebar
87
+
on the sidebar you can select the project and the document that you want to analyze
88
+
Now you can create or select a topic
89
+
90
+
### Document Viewer
91
+
On the Document viewer tab you can view the document (Page range or Full), the extracted tables and key values
92
+
93
+
### Context Query
94
+
On the Context Query tab you can enter a query and the application will search for the most relevant pages and display the content of the pages that are most relevant to the query. This is also the context that is used on the Question Answering tab
95
+
96
+
### Question Answering
97
+
The Question Answer tab allows you to ask questions about the context using text-davinci-003 or gpt-3-turbo from Azure Open AI
98
+
99
+
##Support
100
+
The application is provided as is without any support.
101
+
Feel free to use it as a starting point for your own application.
# Description: This script analyzes a document with the Form Recognizer Document Analysis API utilizing the General Document Model. The results are written to a json file to files/forms_result.json
0 commit comments