ericsorides commited on
Commit
2393f6b
·
1 Parent(s): b5495a3

Added position_ids input

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