Document Loader integrieren

Entwickeln von LLM-Anwendungen mit LangChain

Jonathan Bennion

AI Engineer & LangChain Contributor

Retrieval Augmented Generation (RAG)

  • Nutzt Einbettungen (Embeddings), um relevante Informationen abzurufen und in den Prompt einzufügen.

Ein typischer RAG-Workflow.

Entwickeln von LLM-Anwendungen mit LangChain

RAG-Entwicklungsschritte

Der allgemeine RAG-Workflow: ein Dokumentenlader, ein Dokumentensplitter und der Speicher- und Abrufprozess.

Entwickeln von LLM-Anwendungen mit LangChain

LangChain document loaders

  • Klassen zum Laden und Konfigurieren von Dokumenten für die Integration in agentische Systeme
  • Dokument-Loader für gängige Dateiformate: .pdf, .csv
  • Loader von Drittanbietern: S3, .ipynb, .wav

document-loader.jpg

1 https://python.langchain.com/docs/integrations/document_loaders
Entwickeln von LLM-Anwendungen mit LangChain

PDF Document Loader

  • Setzt das installierte Paket pypdf voraus. Dieses kann wie folgt installiert werden: 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
reproduce the tables and figures in this paper solely for use in [...]
Entwickeln von LLM-Anwendungen mit LangChain

CSV Document Loader

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
confederation: CONCACAF
population_share: [...]
Entwickeln von LLM-Anwendungen mit LangChain

HTM Document Loader

  • Setzt das installierte Paket unstructured voraus. Dieses kann wie folgt installiert werden: 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
Search
Executive Order on the Safe, Secure,
and Trustworthy Development and Use of Artificial Intelligence
Home
Briefing Room

Presidential
Actions
By 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'}
Entwickeln von LLM-Anwendungen mit LangChain

Lass uns üben!

Entwickeln von LLM-Anwendungen mit LangChain

Preparing Video For Download...