Intégration de chargeurs de documents

Développement d'applications LLM avec LangChain

Jonathan Bennion

AI Engineer & LangChain Contributor

Génération à enrichissement contextuel (RAG)

  • Utilisez les intégrations pour récupérer des informations pertinentes à intégrer dans le prompt.

Un flux de travail RAG classique.

Développement d'applications LLM avec LangChain

Étapes du développement RAG

Le flux de travail général du RAG : un chargeur de documents, un diviseur de documents et le processus de stockage et de récupération.

Développement d'applications LLM avec LangChain

Chargeurs de documents LangChain

  • Classes conçues pour charger et configurer des documents en vue de leur intégration dans le système
  • Chargeurs de documents pour les types de fichiers courants : .pdf, .csv
  • Chargeurs tiers : S3, .ipynb, .wav

document-loader.jpg

1 https://python.langchain.com/docs/integrations/document_loaders
Développement d'applications LLM avec LangChain

Chargeurs de documents PDF

  • Nécessite l'installation du paquet 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
reproduce the tables and figures in this paper solely for use in [...]
Développement d'applications LLM avec LangChain

Chargeurs de documents 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
confederation: CONCACAF
population_share: [...]
Développement d'applications LLM avec LangChain

Chargeurs de documents HTML

  • Nécessite l'installation du paquet 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
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'}
Développement d'applications LLM avec LangChain

Passons à la pratique !

Développement d'applications LLM avec LangChain

Preparing Video For Download...