Shankarm08 commited on
Commit
34d53c3
1 Parent(s): 59720f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,13 +1,16 @@
1
  import streamlit as st
2
  import torch
3
- from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
4
  import pandas as pd
5
  import pdfplumber
 
6
 
7
- # Load the RAG model and tokenizer
8
- tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq", use_auth_token=True)
9
- retriever = RagRetriever.from_pretrained("facebook/wiki_dpr", use_auth_token=True)
10
- model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever, use_auth_token=True)
 
 
 
11
 
12
  # Function to extract text from a PDF file
13
  def extract_text_from_pdf(pdf_file):
@@ -60,3 +63,4 @@ if st.button("Get Response"):
60
  response = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
61
  st.write("### Response:")
62
  st.write(response)
 
 
1
  import streamlit as st
2
  import torch
 
3
  import pandas as pd
4
  import pdfplumber
5
+ from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
6
 
7
+ # Ensure you are logged in with `huggingface-cli login`
8
+ token = "YOUR_HUGGINGFACE_TOKEN" # Optional if you have logged in via CLI
9
+
10
+ # Load the tokenizer and model for RAG
11
+ tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq", use_auth_token=token)
12
+ retriever = RagRetriever.from_pretrained("facebook/wikipedia-dpr", use_auth_token=token)
13
+ model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever, use_auth_token=token)
14
 
15
  # Function to extract text from a PDF file
16
  def extract_text_from_pdf(pdf_file):
 
63
  response = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
64
  st.write("### Response:")
65
  st.write(response)
66
+