문서 로더 통합

LangChain으로 LLM 애플리케이션 개발하기

Jonathan Bennion

AI Engineer & LangChain Contributor

검색 증강 생성 (RAG)

  • 임베딩을 사용하여 관련 정보를 _검색_하고 프롬프트에 통합

일반적인 RAG 워크플로.

LangChain으로 LLM 애플리케이션 개발하기

RAG 개발 단계

일반적인 RAG 워크플로: 문서 로더, 문서 분할기, 저장 및 검색 프로세스.

LangChain으로 LLM 애플리케이션 개발하기

LangChain 문서 로더

  • 시스템 통합을 위해 문서를 _로드_하고 _구성_하는 클래스
  • 일반 파일 형식용 문서 로더: .pdf, .csv
  • 서드파티 로더: S3, .ipynb, .wav

document-loader.jpg

1 https://python.langchain.com/docs/integrations/document_loaders
LangChain으로 LLM 애플리케이션 개발하기

PDF 문서 로더

  • pypdf 패키지 설치 필요: pip install pypdf
from langchain_community.document_loaders import PyPDFLoader

loader = PyPDFLoader("path/to/file/attention_is_all_you_need.pdf")
data = loader.load()
print(data[0])
Document(page_content='Provided proper attribution is provided, Google hereby grants 
permission to\nreproduce the tables and figures in this paper solely for use in [...]
LangChain으로 LLM 애플리케이션 개발하기

CSV 문서 로더

from langchain_community.document_loaders.csv_loader import CSVLoader


loader = CSVLoader('fifa_countries_audience.csv')
data = loader.load()
print(data[0])
Document(page_content='country: United States\nconfederation: CONCACAF\npopulation_share: [...]
LangChain으로 LLM 애플리케이션 개발하기

HTML 문서 로더

  • unstructured 패키지 설치 필요: pip install unstructured
from langchain_community.document_loaders import UnstructuredHTMLLoader


loader = UnstructuredHTMLLoader("white_house_executive_order_nov_2023.html") data = loader.load()
print(data[0])
print(data[0].metadata)
page_content="To search this site, enter a search term\n\nSearch\n\nExecutive Order on the Safe, Secure,
and Trustworthy Development and Use of Artificial Intelligence\n\nHome\n\nBriefing Room\n\nPresidential
Actions\n\nBy the authority vested in me as President by the Constitution and the laws of the United
States of America, it is hereby ordered as follows: ..."

{'source': 'white_house_executive_order_nov_2023.html'}
LangChain으로 LLM 애플리케이션 개발하기

연습해 봅시다!

LangChain으로 LLM 애플리케이션 개발하기

Preparing Video For Download...