OCR+RAG: End-to-End system (Vision Grid Transformer)
30 Sep 2024 | Development
Git Repository
https://github.com/finddme/OCR_RAG_vgt_lightGBM/tree/main
Improvement
yolo 기반 ocr-rag 문제점 개선
-
문제점 1. 일반적인 보고서/논문 형식의 pdf layout에 대한 detection 성능은 좋지만 구성이 일반적인 형식과 다른 경우 layout을 탐지하지 못함
-> 해결 방법: 모델 교체
-
문제점 2. 속도
-> 해결 방법:
- 주요 병목 지점 확인 (pdf image 변환 부분, bounding box 그리는 부분)
- 참조한 page만 변환.
- 해상도 낮춤 DPI 조절
- PIL은 이미지 처리 속도가 느림. NumPy와 OpenCV 사용.
- ProcessPoolExecutor로 여러 페이지 병렬 처리
+ VGT, Yolo 모델 설명
Process

Illustrated by the author
-
--- Save Input File ---
: 입력 파일 저장(이미 있으면 pass)
-
--- Start Graph ---
: langgraph 시작
-
--- PDF processing ---
: pdf 처리 시작
-
--- Synchronizing vecotr DB ---
/ --- check DB ---
: vector DB 저장 전 중복 없이 synchronizing
-
--- PDF not exist, OCR start---
: DB에 저장된 내용 없으면 OCR 시작
만약 pdf가 이미 저장되어 있다면 --- PDF exist, calss name: ['bxynpioi']---
pdf 이름과 mapping된 vector DB class를 통해 바로 retrieval 시작
-
--- PDF PROCESSING ---
/ --- OCR done ---
: OCR 완료
-
--- vecotr DB store complete ---
: ocr 결과 vector DB 저장
-
--- weaviate save complete, calss name: bxynpioi---
: 랜덤 class명으로 저장
-
--- RETRIEVE from Vector Store DB ---
: 입력 query에 대해 db 검색
-
--- GENERATE Answer ---
: 답변 생성
-
--- Visualization ---
: 참조 chunk 시각화
Demo
표 정보 retreival

Create by author
- Query: 2022년부터 2024년 매출액 알려줘
- Response :
문서에 따르면 삼성SDI의 매출액은 다음과 같습니다:
2022년 매출액: 20,124 십억원
2023년 매출액: 22,708 십억원
2024년 예상 매출액: 18,987 십억원
- 참조 표

Create by author
일반적인 형식이 아닌 경우
- 가로형 pdf + 그림 내부 text에 대한 retreival

Create by author
- 형식 없는 pdf

Create by author
Git Repository
https://github.com/finddme/OCR_RAG_vgt_lightGBM/tree/main
Improvement
yolo 기반 ocr-rag 문제점 개선
-
문제점 1. 일반적인 보고서/논문 형식의 pdf layout에 대한 detection 성능은 좋지만 구성이 일반적인 형식과 다른 경우 layout을 탐지하지 못함
-> 해결 방법: 모델 교체
-
문제점 2. 속도
-> 해결 방법:
- 주요 병목 지점 확인 (pdf image 변환 부분, bounding box 그리는 부분)
- 참조한 page만 변환.
- 해상도 낮춤 DPI 조절
- PIL은 이미지 처리 속도가 느림. NumPy와 OpenCV 사용.
- ProcessPoolExecutor로 여러 페이지 병렬 처리
+ VGT, Yolo 모델 설명
Process
-
--- Save Input File ---
: 입력 파일 저장(이미 있으면 pass) -
--- Start Graph ---
: langgraph 시작 -
--- PDF processing ---
: pdf 처리 시작 -
--- Synchronizing vecotr DB ---
/--- check DB ---
: vector DB 저장 전 중복 없이 synchronizing -
--- PDF not exist, OCR start---
: DB에 저장된 내용 없으면 OCR 시작만약 pdf가 이미 저장되어 있다면
--- PDF exist, calss name: ['bxynpioi']---
pdf 이름과 mapping된 vector DB class를 통해 바로 retrieval 시작 -
--- PDF PROCESSING ---
/--- OCR done ---
: OCR 완료 -
--- vecotr DB store complete ---
: ocr 결과 vector DB 저장 -
--- weaviate save complete, calss name: bxynpioi---
: 랜덤 class명으로 저장 -
--- RETRIEVE from Vector Store DB ---
: 입력 query에 대해 db 검색 -
--- GENERATE Answer ---
: 답변 생성 -
--- Visualization ---
: 참조 chunk 시각화
Demo
표 정보 retreival
- Query: 2022년부터 2024년 매출액 알려줘
- Response :
문서에 따르면 삼성SDI의 매출액은 다음과 같습니다: 2022년 매출액: 20,124 십억원 2023년 매출액: 22,708 십억원 2024년 예상 매출액: 18,987 십억원
- 참조 표
일반적인 형식이 아닌 경우
- 가로형 pdf + 그림 내부 text에 대한 retreival
- 형식 없는 pdf