ericsorides commited on
Commit
7e671af
·
1 Parent(s): 83d2c87

Added position_ids input

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