문서 질의응답

Hugging Face 활용하기

Jacob H. Marquez

Lead Data Engineer

문서 질의응답이란?

$$

  • 문서 내용에서 질문에 답변
  • 문서와 질문이 필요
  • 직접 답변 또는 요약 답변 제공

$$

질문: "Q3 총매출은 얼마입니까?"

문서

Hugging Face 활용하기

문서 질의응답 활용 사례

법무, 재무 및 지원 사례

$$

  • 📑 법무: 계약 조항 식별

$$

  • 💰 재무: 핵심 수치 추출

$$

  • 🤓 지원: 매뉴얼에서 답변 검색
Hugging Face 활용하기

문서 질의응답으로 HR 문의 자동화

$$

  • 📄 정보는 US-Employee_Policy.pdf에 저장

$$

  • 🤖 답변을 추출하는 시스템 구축

$$

  • 🕑 HR의 시간과 노력을 절감

$$

HR 팀이 과부하 상태

Hugging Face 활용하기

pypdf로 텍스트 추출하기

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...
Hugging Face 활용하기

Q&A 파이프라인 만들기

# 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
Hugging Face 활용하기

모두 연결하기

$$

  • 📄 PDF는 pypdfPdfReader로 로드합니다
  • 🔎 .pages, .extract_text()로 텍스트를 추출해 document_text에 저장
  • 🤔 question-answering 파이프라인 설정
  • ❓ 파이프라인에 questioncontext 전달
  • ⏰ 함수로 감싸 질의 자동화

문서 질의응답

HR 팀이 회사 문화를 구축

Hugging Face 활용하기

연습해 봅시다!

Hugging Face 활용하기

Preparing Video For Download...