ericsorides commited on
Commit
8439993
·
1 Parent(s): d783610

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
@@ -82,8 +82,11 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
82
  inputs_dict = {}
83
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
84
  inputs_dict['attention_mask'] = first_attention
 
 
 
85
  for name in inputs_names:
86
- if name == 'input_ids' or name == 'attention_mask': continue
87
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 256], dtype="float16")
88
  index = 0
89
  new_token = np.array([10])
@@ -114,6 +117,9 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
114
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
115
  elif name == 'attention_mask':
116
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
 
 
 
117
  else:
118
  old_name = name.replace("past_key_values", "present")
119
  inputs_dict[name] = outs_dictionary[old_name][:, :, next_index-old_j:context-window+(next_index - old_j), :]
 
82
  inputs_dict = {}
83
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
84
  inputs_dict['attention_mask'] = first_attention
85
+ index_pos = sum(first_attention[0])
86
+ 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)
87
+ inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
88
  for name in inputs_names:
89
+ if name == 'input_ids' or name == 'attention_mask' or name == 'position_ids' or name == 'tree_attention': continue
90
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 256], dtype="float16")
91
  index = 0
92
  new_token = np.array([10])
 
117
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
118
  elif name == 'attention_mask':
119
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
120
+ elif name == 'position_ids':
121
+ 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)
122
+ elif name == 'tree_attention': continue
123
  else:
124
  old_name = name.replace("past_key_values", "present")
125
  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:7f0b6d9073a461ac39fb33c236db3c0328ccfa69a5d567c25336a2cc11cdad8f
3
- size 1499912
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b1550b18ad4ddcc6cdafc492558d9efc1cef4e640f782af2303920df798294d
3
+ size 1486454