Spaces:
Sleeping
Sleeping
Shankarm08
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,8 @@ import pdfplumber
|
|
6 |
|
7 |
# Initialize RAG components
|
8 |
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq")
|
9 |
-
retriever = RagRetriever.from_pretrained("facebook/
|
10 |
-
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq")
|
11 |
|
12 |
# Extract text from PDF
|
13 |
def extract_text_from_pdf(pdf_file):
|
@@ -54,7 +54,7 @@ if st.button("Get Response"):
|
|
54 |
combined_context += "\n" + csv_data.to_string()
|
55 |
|
56 |
# Generate response using RAG
|
57 |
-
inputs = tokenizer(user_input,
|
58 |
with torch.no_grad():
|
59 |
output = model.generate(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
60 |
response = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
|
|
|
6 |
|
7 |
# Initialize RAG components
|
8 |
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq")
|
9 |
+
retriever = RagRetriever.from_pretrained("facebook/wiki_dpr", use_dummy_dataset=True) # Correct usage of dataset
|
10 |
+
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever)
|
11 |
|
12 |
# Extract text from PDF
|
13 |
def extract_text_from_pdf(pdf_file):
|
|
|
54 |
combined_context += "\n" + csv_data.to_string()
|
55 |
|
56 |
# Generate response using RAG
|
57 |
+
inputs = tokenizer(user_input, return_tensors="pt", truncation=True)
|
58 |
with torch.no_grad():
|
59 |
output = model.generate(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
60 |
response = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
|