pvduy commited on
Commit
d5b7807
1 Parent(s): 0fd3144

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
+
5
+ dataset = load_dataset("CarperAI/openai_summarize_tldr")
6
+
7
+ val_prompts = [sample["prompt"] for sample in dataset["valid"]]
8
+
9
+ kwargs = {
10
+ "max_new_tokens": 50,
11
+ "do_sample": True,
12
+ "top_k": 0,
13
+ "top_p": 0.95,
14
+ "temperature": 0.5
15
+ }
16
+
17
+ model = AutoModelForCausalLM.from_pretrained("pvduy/ppo_pythia6B_sample")
18
+ model.eval()
19
+ tokenizer = AutoTokenizer.from_pretrained("pvduy/ppo_pythia6B_sample")
20
+ tokenizer.pad_token_id = tokenizer.eos_token_id
21
+
22
+ count = 0
23
+
24
+ for prompt in val_prompts:
25
+ output_tk = tokenizer(prompt, return_tensors="pt")
26
+ outputs = model.generate(output_tk.input_ids, attention_mask=output_tk.attention_mask, **kwargs)
27
+ print("Prompt:", prompt)
28
+ print("Output:", tokenizer.decode(outputs[0], skip_special_tokens=True).split("TL;DR:")[1].strip())
29
+ print("=================================")
30
+ count += 1
31
+ if count == 10:
32
+ break