viethoangtranduong commited on
Commit
15b9b8a
1 Parent(s): d76b839

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -10
README.md CHANGED
@@ -48,28 +48,48 @@ This requires a GPU with 16GB memory.
48
  import torch
49
  import transformers
50
  from transformers import AutoTokenizer, AutoModelForCausalLM
 
51
 
52
- MIN_TRANSFORMERS_VERSION = '4.25.1'
53
-
54
- # check transformers version
55
- assert transformers.__version__ >= MIN_TRANSFORMERS_VERSION, f'Please upgrade transformers to version {MIN_TRANSFORMERS_VERSION} or higher.'
56
-
57
- # init
58
  tokenizer = AutoTokenizer.from_pretrained("snorkelai/RedPajama-7B-Chat-Curated")
59
  model = AutoModelForCausalLM.from_pretrained("snorkelai/RedPajama-7B-Chat-Curated", torch_dtype=torch.float16)
60
  model = model.to('cuda:0')
61
- # infer
62
- prompt = "<human>: Who is Alan Turing?\n<bot>:"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
64
  input_length = inputs.input_ids.shape[1]
65
  outputs = model.generate(
66
- **inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_p=0.7, top_k=50, return_dict_in_generate=True
67
  )
68
  token = outputs.sequences[0, input_length:]
69
  output_str = tokenizer.decode(token)
70
  print(output_str)
 
71
  """
72
- Alan Mathison Turing (23 June 1912 7 June 1954) was an English computer scientist, mathematician, logician, cryptanalyst, philosopher, mathematician, and theoretical biologist.
73
  """
74
  ```
75
 
 
48
  import torch
49
  import transformers
50
  from transformers import AutoTokenizer, AutoModelForCausalLM
51
+ ```
52
 
53
+ Example with RedPajama-7B-Chat-Curated
54
+ ```python
55
+ # Example 1 using RedPajama-7B-Chat-Curated
 
 
 
56
  tokenizer = AutoTokenizer.from_pretrained("snorkelai/RedPajama-7B-Chat-Curated")
57
  model = AutoModelForCausalLM.from_pretrained("snorkelai/RedPajama-7B-Chat-Curated", torch_dtype=torch.float16)
58
  model = model.to('cuda:0')
59
+
60
+ ## inference
61
+ prompt = "<human>: {EDIT_NEEDED}.\n<bot>:"
62
+ inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
63
+ input_length = inputs.input_ids.shape[1]
64
+ outputs = model.generate(
65
+ **inputs, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.7, top_k=50,
66
+ )
67
+ token = outputs.sequences[0, input_length:]
68
+ output_str = tokenizer.decode(token)
69
+ print(output_str)
70
+ """{EDIT_NEEDED}"""
71
+ ```
72
+
73
+ Comparing with RedPajama-INCITE-7B-Chat
74
+ ```python
75
+ # Example 1 using RedPajama-INCITE-7B-Chat
76
+ tokenizer = AutoTokenizer.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Chat")
77
+ model = AutoModelForCausalLM.from_pretrained("togethercomputer/RedPajama-INCITE-7B-Chat", torch_dtype=torch.float16)
78
+ model = model.to('cuda:0')
79
+
80
+ ## inference
81
+ prompt = "<human>: {EDIT_NEEDED}.\n<bot>:"
82
  inputs = tokenizer(prompt, return_tensors='pt').to(model.device)
83
  input_length = inputs.input_ids.shape[1]
84
  outputs = model.generate(
85
+ **inputs, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.7, top_k=50,
86
  )
87
  token = outputs.sequences[0, input_length:]
88
  output_str = tokenizer.decode(token)
89
  print(output_str)
90
+ """{EDIT_NEEDED}"""
91
  """
92
+
93
  """
94
  ```
95