ericsorides commited on
Commit
ff35a39
·
1 Parent(s): d74d787

Added position_ids input

Browse files
Files changed (2) hide show
  1. README.md +5 -1
  2. model.onnx +2 -2
README.md CHANGED
@@ -75,9 +75,11 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
75
  inputs_dict = {}
76
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
77
  inputs_dict['attention_mask'] = first_attention
 
 
78
  inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
79
  for name in inputs_names:
80
- if name == 'input_ids' or name == 'attention_mask' or name == 'tree_attention': continue
81
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 96], dtype="float16")
82
  index = 0
83
  new_token = np.array([10])
@@ -108,6 +110,8 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
108
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
109
  elif name == 'attention_mask':
110
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
 
 
111
  elif name == 'tree_attention': continue
112
  else:
113
  old_name = name.replace("past_key_values", "present")
 
75
  inputs_dict = {}
76
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
77
  inputs_dict['attention_mask'] = first_attention
78
+ index_pos = sum(first_attention[0])
79
+ 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)
80
  inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
81
  for name in inputs_names:
82
+ if name == 'input_ids' or name == 'attention_mask' or name == 'position_ids' or name == 'tree_attention': continue
83
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 96], dtype="float16")
84
  index = 0
85
  new_token = np.array([10])
 
110
  inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
111
  elif name == 'attention_mask':
112
  inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
113
+ elif name == 'position_ids':
114
+ 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)
115
  elif name == 'tree_attention': continue
116
  else:
117
  old_name = name.replace("past_key_values", "present")
model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9d223ba7a2bfbf887832f065cadcd6d11e776acc1cfb59550ac3654463a6ba14
3
- size 1389705
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81ceb07ef09a001da740cb879d01242890a927c2299473b7c22b0ffb06795973
3
+ size 1389061