Werken met Hugging Face
Jacob H. Marquez
Lead Data Engineer
$$
$$
Vraag: "What is the total revenue of Q3?"


$$
$$
$$
$$
US-Employee_Policy.pdf$$
$$
$$

from pypdf import PdfReader# Load the PDF file reader = PdfReader("US-Employee_Policy.pdf")# Extract text from all pages document_text = "" for page in reader.pages:document_text += page.extract_text()
Welcome to the US Employee Policy document...
# Load the question-answering pipeline qa_pipeline = pipeline( task="question-answering", model="distilbert-base-cased-distilled-squad")question = "How many volunteer days are offered annually?"# Get the answer from the QA pipeline result = qa_pipeline(question=question, context=document_text)print(f"Answer: {result['answer']}")
Answer: 1
$$
PdfReader van pypdf om PDF's te laden en lezen.pages en .extract_text() naar document_textquestion-answering-pijplijn opquestion en context door aan de pijplijn

Werken met Hugging Face