jordiclive commited on
Commit
2b6e7e3
·
1 Parent(s): b0199df

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Experimental 20B instruction tuned model based on gpt-neox-20b.
2
+ ```
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+ import torch
5
+
6
+ name = "jordiclive/instruction-tuned-gpt-neox-20b"
7
+ model = AutoModelForCausalLM.from_pretrained(name, device_map=chip_map, torch_dtype=torch.float16)# load_in_8bit=True )
8
+ tokenizer = AutoTokenizer.from_pretrained(name)
9
+
10
+ def generate_from_model(model, tokenizer):
11
+ encoded_input = tokenizer(text, return_tensors='pt')
12
+ output_sequences = model.generate(
13
+ input_ids=encoded_input['input_ids'].cuda(0),
14
+ do_sample=True,
15
+ max_new_tokens=35,
16
+ num_return_sequences=1,
17
+ top_p=0.95,
18
+ temperature=0.5,
19
+ penalty_alpha=0.6,
20
+ top_k=4,
21
+ output_scores=True,
22
+ return_dict_in_generate=True,
23
+ repetition_penalty=1.03,
24
+ eos_token_id=0,
25
+ use_cache=True
26
+ )
27
+ gen_sequences = output_sequences.sequences[:, encoded_input['input_ids'].shape[-1]:]
28
+ for sequence in gen_sequences:
29
+ new_line=tokenizer.decode(sequence, skip_special_tokens=True)
30
+ print(new_line)
31
+
32
+ text = "User: Will big tech A.I be adulterated with advertisement?\n\nOA:"
33
+ generate_from_model(model,tokenizer)
34
+ ```