PhelixZhen commited on
Commit
fe34607
1 Parent(s): b281e4d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -1
README.md CHANGED
@@ -16,4 +16,47 @@ If you are a native English speaker, you might find these sentences uncomfortabl
16
 
17
  Anyway, this is a new attempt. It is trained on consumer-grade devices and without the guidance of professionals, so it's hard for us to expect it to perform exceptionally well.
18
 
19
- But we hope this will be the beginning of a new great exploration.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  Anyway, this is a new attempt. It is trained on consumer-grade devices and without the guidance of professionals, so it's hard for us to expect it to perform exceptionally well.
18
 
19
+ But we hope this will be the beginning of a new great exploration.
20
+
21
+ (We have released a preview version on February 24, 2024, and you can run it using the following code:
22
+
23
+ ```
24
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
25
+ import torch
26
+
27
+ device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
28
+
29
+ tokenizer = AutoTokenizer.from_pretrained('/mnt/n/save/tokenizer')
30
+ model = AutoModelForCausalLM.from_pretrained('/mnt/n/save/modelgen4/checkpoint-37920').to(device)
31
+ tokenizer.pad_token = tokenizer.eos_token
32
+
33
+ txt = 'A person with a cold should immediately'
34
+
35
+ # greedy search
36
+ gen_conf = GenerationConfig(
37
+ num_beams=1,
38
+ do_sample=True,
39
+ max_length=700,
40
+ no_repeat_ngram_size=6,
41
+ eos_token_id=tokenizer.eos_token_id,
42
+ pad_token_id=tokenizer.pad_token_id,
43
+ temperature=0.93,
44
+ top_k=36,
45
+ top_p=0.80
46
+ )
47
+
48
+ tokend = tokenizer.encode_plus(text=txt)
49
+ input_ids, attention_mask = torch.LongTensor([tokend.input_ids]).to(device), \
50
+ torch.LongTensor([tokend.attention_mask]).to(device)
51
+
52
+ outputs = model.generate(
53
+ inputs=input_ids,
54
+ attention_mask=attention_mask,
55
+ generation_config=gen_conf,
56
+
57
+ )
58
+
59
+ outs = tokenizer.decode(outputs[0].cpu().numpy(), clean_up_tokenization_spaces=True,)
60
+ print(outs)
61
+
62
+ ```