RamAnanth1 commited on
Commit
d7f1630
·
1 Parent(s): dff33be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -10,11 +10,24 @@ device = 'cpu' # if you have a GPU
10
  tokenizer = T5Tokenizer.from_pretrained('stanfordnlp/SteamSHP-flan-t5-large')
11
  model = T5ForConditionalGeneration.from_pretrained('stanfordnlp/SteamSHP-flan-t5-large').to(device)
12
 
 
 
 
 
 
 
13
  def process():
14
- input_text = "POST: Instacart gave me 50 pounds of limes instead of 5 pounds... what the hell do I do with 50 pounds of limes? I've already donated a bunch and gave a bunch away. I'm planning on making a bunch of lime-themed cocktails, but... jeez. Ceviche? \n\n RESPONSE A: Lime juice, and zest, then freeze in small quantities.\n\n RESPONSE B: Lime marmalade lol\n\n Which response is better? RESPONSE"
 
 
 
 
 
 
15
  x = tokenizer([input_text], return_tensors='pt').input_ids.to(device)
16
  y = model.generate(x, max_new_tokens=1)
17
- return tokenizer.batch_decode(y, skip_special_tokens=True)[0]
 
18
 
19
  title = "Compare Instruction Models to see which one is more helpful"
20
  interface = gr.Interface(fn=process,
 
10
  tokenizer = T5Tokenizer.from_pretrained('stanfordnlp/SteamSHP-flan-t5-large')
11
  model = T5ForConditionalGeneration.from_pretrained('stanfordnlp/SteamSHP-flan-t5-large').to(device)
12
 
13
+ HF_TOKEN = os.getenv("HF_TOKEN")
14
+
15
+ OUTPUTS_DATASET = "HuggingFaceH4/instruction-pilot-outputs-filtered"
16
+
17
+ ds = load_dataset(OUTPUTS_DATASET, split="train", use_auth_token=HF_TOKEN)
18
+
19
  def process():
20
+ sample_ds = ds.shuffle().select(range(1))
21
+
22
+
23
+
24
+ df = pd.DataFrame.from_records(sample["filtered_outputs"])
25
+
26
+ input_text = "POST: "+ sample["prompt"]+ "\n\n RESPONSE A: Lime juice, and zest, then freeze in small quantities.\n\n RESPONSE B: Lime marmalade lol\n\n Which response is better? RESPONSE"
27
  x = tokenizer([input_text], return_tensors='pt').input_ids.to(device)
28
  y = model.generate(x, max_new_tokens=1)
29
+ prefered = tokenizer.batch_decode(y, skip_special_tokens=True)[0]
30
+ return sample["filtered_outputs"]
31
 
32
  title = "Compare Instruction Models to see which one is more helpful"
33
  interface = gr.Interface(fn=process,