ericsorides commited on
Commit
8267ec3
·
1 Parent(s): 06a0d51

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