ericsorides commited on
Commit
b31ad78
·
1 Parent(s): 588ef21

Added position_ids input

Browse files
Files changed (2) hide show
  1. README.md +5 -1
  2. model.onnx +2 -2
README.md CHANGED
@@ -80,9 +80,11 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence,
80
  inputs_dict = {}
81
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
82
  inputs_dict['attention_mask'] = first_attention
 
 
83
  inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
84
  for name in inputs_names:
85
- if name == 'input_ids' or name == 'attention_mask' or name == 'tree_attention': continue
86
  inputs_dict[name] = np.zeros([1, n_heads, context-window, 128], dtype="float16")
87
  index = 0
88
  new_token = np.array([10])
@@ -114,6 +116,8 @@ 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
  elif name == 'tree_attention': continue
118
  else:
119
  old_name = name.replace("past_key_values", "present")
 
80
  inputs_dict = {}
81
  inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
82
  inputs_dict['attention_mask'] = first_attention
83
+ index_pos = sum(first_attention[0])
84
+ 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)
85
  inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
86
  for name in inputs_names:
87
+ if name == 'input_ids' or name == 'attention_mask' or name == 'position_ids' or name == 'tree_attention': 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
  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
+ elif name == 'position_ids':
120
+ 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)
121
  elif name == 'tree_attention': continue
122
  else:
123
  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:c1288acb73b9930471c215ea999f33f42b53088e9ab9b596face1345081b3153
3
- size 2160078
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b7445c228ca6194e1a5941dc490976377bc73670739cc26348743a5795e8f0b
3
+ size 2159433