Yoxas commited on
Commit
ef9cf57
·
verified ·
1 Parent(s): 96bfdef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
  from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
4
 
5
  # Load the tokenizer and retriever
@@ -14,13 +15,14 @@ inputs = tokenizer(contexts, return_tensors='pt', padding=True, truncation=True)
14
  labels = tokenizer(responses, return_tensors='pt', padding=True, truncation=True)
15
 
16
  # Load your dataset
17
- df = pd.read_csv('your_dataset.csv')
18
 
19
  # Ensure the dataset has the required columns for RAG
20
  # For example, it should have 'context' and 'response' columns
21
  contexts = df['Abstract'].tolist()
22
  #responses = df['response'].tolist()
23
 
 
24
  def generate_response(input_text):
25
  input_ids = tokenizer([input_text], return_tensors='pt')['input_ids']
26
  outputs = model.generate(input_ids)
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import spaces
4
  from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
5
 
6
  # Load the tokenizer and retriever
 
15
  labels = tokenizer(responses, return_tensors='pt', padding=True, truncation=True)
16
 
17
  # Load your dataset
18
+ df = pd.read_csv('10kstats.csv')
19
 
20
  # Ensure the dataset has the required columns for RAG
21
  # For example, it should have 'context' and 'response' columns
22
  contexts = df['Abstract'].tolist()
23
  #responses = df['response'].tolist()
24
 
25
+ @spaces.GPU
26
  def generate_response(input_text):
27
  input_ids = tokenizer([input_text], return_tensors='pt')['input_ids']
28
  outputs = model.generate(input_ids)