I made this app using transformers and huggingface:
from pathlib import Path
from typing import Union
from pypdf import PdfReader
from transformers import pipeline
question_answerer = pipeline(task="question-answering", model="deepset/tinyroberta-squad2")
question="Έχω ασφάλεια αυτοκινήτου, και είναι ασρφαλισμένο σε περίπτωση φωτιάς (=πυρκαγιάς), τι χρήματα παίρνω?"
def get_text_from_pdf(pdf_file: Union[str, Path]) -> str:
"""Read the PDF from the given path and return a string with its entire content."""
reader = PdfReader(pdf_file)
# Extract text from all pages
full_text = ""
for page in reader.pages:
full_text += page.extract_text()
return full_text
pdf_text = get_text_from_pdf("./pdf.pdf")
answer = question_answerer(question, pdf_text)
print(answer)
But taking the response is slow. So made me having these questions:
- Is model running locally or remotely?
- Do I need a GPU to run this model in a decent time?
What is the recommended GPU requirements in o4r5der for the script above to run?