Document Analysis with Azure Document Intelligence and Open AI

Kaarel Kõrvemaa | Nov 9, 2024 min read

Overview

This project demonstrates how to use Azure Document Intelligence and OpenAI to analyze documents. The application is built using Streamlit. The solution leverages Azure’s Document Analysis Client to extract text from documents and OpenAI’s GPT-4o model to structure and analyze the extracted data.

Features

  • Document Upload: Users can upload documents in PDF, JPG, or PNG formats.
  • Text Extraction: The application uses Azure Document Intelligence to extract text from the uploaded documents.
  • Data Structuring: The extracted text is then sent to OpenAI’s GPT-4o model to structure the data into columns based on the content.
  • Interactive UI: The application provides an interactive user interface using Streamlit, making it easy to upload documents and view the results.

Installation

To run this application, you need to have Python installed on your machine. Follow the steps below to set up the project:

1. Clone the repository:

```sh
git clone https://github.com/kkaarel/-Azure-Document-Intelligence-and-Open-AI
```

2. Install the required packages:

```sh
pip install -r requirements.txt
```

3. Set up Azure and OpenAI credentials:

Create a Document Intelligence resource

Create and deploy an Azure OpenAI Service resource

Create a secrets.toml file in the .streamlit directory with the following content:

[secrets]
AZURE_OPENAI_API_KEY = "your_azure_openai_api_key"
AZURE_OPENAI_ENDPOINT = "your_azure_openai_endpoint"
DOCUMENTATIONAPI = "your_documentation_api_endpoint"
DOCUMENTATIONAPI_KEY = "your_documentation_api_key"
deploymentname = "your_deployment_name"

4. Now just run the code and you have your private document management system:

```sh
streamlit run app.py
```

Conclusion

Showcases the powerful capabilities of combining Azure Document Intelligence and OpenAI’s GPT-4o model to create a robust document analysis solution. By leveraging these technologies, users can easily extract, structure, and analyze data from various document formats, all within an interactive Streamlit application. This solution not only simplifies document management but also enhances data accessibility and usability.

Other Examples

This solution can be adapted to solve various problems, such as:

  • Invoice Processing: Automatically extract and organize data from invoices, making it easier to manage and analyze financial information.
  • Resume Screening: Extract key information from resumes and structure it for easier comparison and analysis during the hiring process.
  • Legal Document Analysis: Analyze and structure data from legal documents, contracts, and agreements to streamline legal workflows.
  • Research Paper Summarization: Extract and summarize key points from research papers, making it easier for researchers to review and reference relevant information.
  • Medical Record Management: Extract and organize patient information from medical records, improving data accessibility for healthcare providers.

By customizing the data extraction and structuring processes, this solution can be tailored to meet the specific needs of various industries and applications.