ericsorides commited on
Commit
bca82ef
·
1 Parent(s): bd194b1

Added position_ids input

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