Skip to Content
RAG with Python 쿡북 (Korean Edition)
book

RAG with Python 쿡북 (Korean Edition)

by Dominik Polzer
May 2026
Intermediate
378 pages
5h 49m
Korean
O'Reilly Media, Inc.
Content preview from RAG with Python 쿡북 (Korean Edition)

제3장. 데이터로드

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

기업 정보의80%는 비정형 데이터이며, 프레젠테이션, 문서, 이메일, 미디어 파일 등에 분산되어 있습니다. 그림 3-1은 일반적인 데이터 유형의 일부를 보여줍니다.

Pie chart showing distribution of data types in companies, with approximately 80% unstructured data (documents, presentations, emails) and 20% structured data (databases, spreadsheets)
그림 3-1. 기업 내 데이터의 일반적인 분포

이 장에서는 일반적인 데이터 소스를 임베딩하고 검색할 수 있는 텍스트로 변환하는 방법을 설명합니다. 대부분의 RAG 검색기는 텍스트 임베딩을 기반으로 작동하므로, 다양한 형식을 일관된 텍스트 표현으로 변환하는 것이 실질적인 첫 단계입니다.

그림 3-2는 RAG 시스템의 주요 구성 요소를 요약하여, 인덱싱 파이프라인(문서 로딩 및 처리)과 런타임 검색 흐름(관련 청크 검색 및 답변 생성)을 모두 보여줍니다.

Diagram illustrating the workflow of a RAG system, including the processes of loading and preprocessing documents, generating embeddings, and retrieving and generating answers using large language models.
그림 3-2. RAG 시스템의 구성요소

또한 이 장에서는 다양한 문서 유형에 대한 로딩 과정을 설명합니다.

경고

이 책은 기본 개념을 명확히 하기 위해 핵심 구성 요소를 처음부터 직접 구축합니다. 실제 운영 환경에서는 LangChain이나 LlamaIndex와 같은 오케스트레이션 프레임워크를 사용하면 개발 속도를 높일 수 있지만, 잦은 변경, 빠르게 진화하는 API, 추가적인 추상화 등 변수가 많아질 수 있습니다.

이러한 프레임워크를 사용하는 경우, 종속성 버전을 고정하고, 업그레이드 가이드를 따르며, 작은 어댑터 뒤에 프레임워크별 코드를 분리하십시오. 가장 안정적인 기반을 구축하려면, 대신 성숙한 범용 라이브러리 (예: pandas, NumPy, SQLAlchemy, Pydantic, Requests)에 의존하고, 프레임워크와의 결합 없이 RAG 로직을 테스트 가능하게 유지하십시오.

이 장의 모든 코드 예제는 책의 GitHub 저장소에서 확인할 수 있습니다.

3.1 Python에서 Word 파일 불러오기

문제

에서 Microsoft Word 파일을 RAG 시스템에 로드하고자 합니다.

해결책

요소 유형을 구분할 필요가 없을 때는 간단한 텍스트 추출을 위해 Python-docx를 사용하십시오. 요소에 대한 표적 처리를 위해 문서 구조(제목, 단락, 목록, 이미지)를 보존해야 할 때는 Unstructured를 사용하십시오.

그림 3-3은 Unstructured를 사용하여 문서를 불러올 때의 기본 과정을 보여줍니다. 이 과정은 문서를 텍스트 단락, 제목, 목록 또는 이미지와 같은 구조화된 요소로 분할합니다.

그림 3-3. Python-docx 또는 Unstructured를 통해 Word 파일불러오기 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Tips for Designing Effective Presentation Slide Decks

Tips for Designing Effective Presentation Slide Decks

Curtis Newbold
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho
How to Overcome a Power Deficit

How to Overcome a Power Deficit

Cyril Bouquet, Jean-Louis Barsoux

Publisher Resources

ISBN: 0642572383596