Moha782 commited on
Commit
e6843a0
·
verified ·
1 Parent(s): 08a0021

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- from transformers import RagTokenizer, RagRetriever
4
 
5
  """
6
  For more information on huggingface_hub Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
@@ -8,10 +8,8 @@ For more information on huggingface_hub Inference API support, please check the
8
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
  # Load the RAG tokenizer and retriever
11
- rag_tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq")
12
- rag_retriever = RagRetriever.from_pretrained(
13
- "facebook/rag-sequence-nq", index_name="apexcustoms.pdf", use_dummy_dataset=False, trust_remote_code=True
14
- )
15
 
16
  def respond(
17
  message,
@@ -39,9 +37,8 @@ def respond(
39
  stream=True,
40
  temperature=temperature,
41
  top_p=top_p,
42
- # Pass the RAG tokenizer and retriever to the client
43
- rag_tokenizer=rag_tokenizer,
44
- rag_retriever=rag_retriever,
45
  ):
46
  token = message.choices[0].delta.content
47
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ from transformers import RagRetriever, RagTokenizer
4
 
5
  """
6
  For more information on huggingface_hub Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
8
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
  # Load the RAG tokenizer and retriever
11
+ tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq")
12
+ retriever = RagRetriever.from_pretrained("facebook/rag-token-nq", index_name="apexcustoms", passages="apexcustoms.pdf")
 
 
13
 
14
  def respond(
15
  message,
 
37
  stream=True,
38
  temperature=temperature,
39
  top_p=top_p,
40
+ rag_retriever=retriever, # Pass the RAG retriever
41
+ rag_tokenizer=tokenizer, # Pass the RAG tokenizer
 
42
  ):
43
  token = message.choices[0].delta.content
44