keerthi-balaji commited on
Commit
8e28d8f
1 Parent(s): a99b819

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,16 +1,20 @@
1
  from datasets import load_dataset
2
  import gradio as gr
3
  from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
 
4
 
5
  # Load the horoscope-chat dataset
6
  dataset = load_dataset("chloeliu/horoscope-chat", split="train")
7
 
8
- # Convert the dataset to a format that can be used by the retriever
 
 
 
9
  def prepare_docs(dataset):
10
  docs = []
11
  for data in dataset:
12
- question = data['question']
13
- answer = data['response']
14
  docs.append({
15
  "question": question,
16
  "answer": answer
 
1
  from datasets import load_dataset
2
  import gradio as gr
3
  from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
4
+ import torch
5
 
6
  # Load the horoscope-chat dataset
7
  dataset = load_dataset("chloeliu/horoscope-chat", split="train")
8
 
9
+ # Check dataset structure
10
+ print(dataset.column_names)
11
+
12
+ # Assuming 'input' and 'response' are the correct keys:
13
  def prepare_docs(dataset):
14
  docs = []
15
  for data in dataset:
16
+ question = data.get('input', '') # Safely access the 'input' field
17
+ answer = data.get('response', '') # Safely access the 'response' field
18
  docs.append({
19
  "question": question,
20
  "answer": answer