ericsorides commited on
Commit
608c808
·
1 Parent(s): 5988c45

Model without scatter and with tree

Browse files
Files changed (2) hide show
  1. README.md +7 -1
  2. model.onnx +2 -2
README.md CHANGED
@@ -85,8 +85,11 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
85
  inputs_dict = {}
86
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
87
  inputs_dict['attention_mask'] = first_attention
 
 
 
88
  for name in inputs_names:
89
- if name == 'input_ids' or name == 'attention_mask': continue
90
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 256], dtype="float16")
91
  index = 0
92
  new_token = np.array([10])
@@ -118,6 +121,9 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
118
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
119
  elif name == 'attention_mask':
120
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
 
 
 
121
  else:
122
  old_name = name.replace("past_key_values", "present")
123
  inputs_dict[name] = outs_dictionary[old_name][:, :, next_index-old_j:context-window+(next_index - old_j), :]
 
85
  inputs_dict = {}
86
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
87
  inputs_dict['attention_mask'] = first_attention
88
+ index_pos = sum(first_attention[0])
89
+ inputs_dict['position_ids'] = np.concatenate((np.zeros([1, total_sequence - index_pos], dtype = 'int64'), np.arange(index_pos, dtype = 'int64').reshape(1, index_pos)), axis=1)
90
+ inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
91
  for name in inputs_names:
92
+ if name == 'input_ids' or name == 'attention_mask' or name == 'position_ids' or name == 'tree_attention': continue
93
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 256], dtype="float16")
94
  index = 0
95
  new_token = np.array([10])
 
121
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
122
  elif name == 'attention_mask':
123
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
124
+ elif name == 'position_ids':
125
+ inputs_dict['position_ids'] = np.concatenate((np.zeros([1, total_sequence - next_index], dtype = 'int64'), np.arange(next_index, dtype = 'int64').reshape(1, next_index)), axis=1)
126
+ elif name == 'tree_attention': continue
127
  else:
128
  old_name = name.replace("past_key_values", "present")
129
  inputs_dict[name] = outs_dictionary[old_name][:, :, next_index-old_j:context-window+(next_index - old_j), :]
model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d8848652046a570dcd8251a89aee4a777fcc5b3e3c4587e99cdf0f1d30db890c
3
- size 1367584
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c30a63cbd750cd6e1168423313223b424d70838a5286201a836f0379d3f4f39c
3
+ size 1354436