Wuttipong8146 commited on
Commit
3b832ea
·
verified ·
1 Parent(s): bc920c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -24,8 +24,8 @@ def extract_text_from_pdf(pdf_file):
24
  def answer_question(question, context):
25
  inputs = tokenizer.encode_plus(question, context, return_tensors="pt")
26
  answer_start_scores, answer_end_scores = model(**inputs)
27
- answer_start = torch.argmax(answer_start_scores.logits)
28
- answer_end = torch.argmax(answer_end_scores.logits) + 1
29
  answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(inputs['input_ids'][0][answer_start:answer_end]))
30
  return answer
31
 
@@ -49,7 +49,7 @@ if uploaded_file:
49
 
50
  qa_chain = ConversationalRetrievalChain(
51
  retriever=retriever,
52
- llm=None, # ถ้าคุณไม่ได้ใช้ HuggingFaceHub, ปรับให้เหมาะสม
53
  memory=memory
54
  )
55
 
 
24
  def answer_question(question, context):
25
  inputs = tokenizer.encode_plus(question, context, return_tensors="pt")
26
  answer_start_scores, answer_end_scores = model(**inputs)
27
+ answer_start = torch.argmax(answer_start_scores.start_logits)
28
+ answer_end = torch.argmax(answer_end_scores.end_logits) + 1
29
  answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(inputs['input_ids'][0][answer_start:answer_end]))
30
  return answer
31
 
 
49
 
50
  qa_chain = ConversationalRetrievalChain(
51
  retriever=retriever,
52
+ llm=None, # ลบ HuggingFaceHub เพราะไม่ได้ใช้งาน
53
  memory=memory
54
  )
55