Integración de cargadores de documentos

Desarrollo de aplicaciones LLM con LangChain

Jonathan Bennion

AI Engineer & LangChain Contributor

Generación aumentada por recuperación (RAG)

  • Utiliza incrustaciones para recuperar información relevante e integrarla en el prompt

Un flujo de trabajo típico de RAG.

Desarrollo de aplicaciones LLM con LangChain

Pasos del desarrollo de RAG

Flujo de trabajo general de RAG: un cargador de documentos, un divisor de documentos y el proceso de almacenamiento y recuperación.

Desarrollo de aplicaciones LLM con LangChain

Cargadores de documentos LangChain

  • Clases diseñadas para cargar y configurar documentos para la integración del sistema
  • Cargadores de documentos para tipos de archivos comunes: .pdf, .csv
  • Cargadores de terceros: S3, .ipynb, .wav

document-loader.jpg

1 https://python.langchain.com/docs/integrations/document_loaders
Desarrollo de aplicaciones LLM con LangChain

Cargador de documentos PDF

  • Requiere la instalación del paquete 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 [...]
Desarrollo de aplicaciones LLM con LangChain

Cargador de documentos 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: [...]
Desarrollo de aplicaciones LLM con LangChain

Cargador de documentos HTML

  • Requiere la instalación del paquete 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'}
Desarrollo de aplicaciones LLM con LangChain

¡Vamos a practicar!

Desarrollo de aplicaciones LLM con LangChain

Preparing Video For Download...