saima730 commited on
Commit
1a75c78
·
verified ·
1 Parent(s): b996bc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,12 +1,17 @@
1
  import streamlit as st
2
- from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration, pipeline
3
 
4
  # Function to generate response using RAG (Retrieval-Augmented Generation)
5
  def generate_response_with_rag(txt):
6
  try:
7
  # Initialize the RAG model and tokenizer
8
  tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq")
9
- retriever = RagRetriever.from_pretrained("facebook/rag-token-nq", index_name="exact", use_dummy_dataset=True)
 
 
 
 
 
10
  model = RagSequenceForGeneration.from_pretrained("facebook/rag-token-nq")
11
 
12
  # Tokenize the input text
 
1
  import streamlit as st
2
+ from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
3
 
4
  # Function to generate response using RAG (Retrieval-Augmented Generation)
5
  def generate_response_with_rag(txt):
6
  try:
7
  # Initialize the RAG model and tokenizer
8
  tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq")
9
+ retriever = RagRetriever.from_pretrained(
10
+ "facebook/rag-token-nq",
11
+ index_name="exact",
12
+ use_dummy_dataset=True,
13
+ trust_remote_code=True # Allows loading the required dataset script
14
+ )
15
  model = RagSequenceForGeneration.from_pretrained("facebook/rag-token-nq")
16
 
17
  # Tokenize the input text