ericsorides commited on
Commit
1dfdd70
1 Parent(s): adaebb5

Added position_ids input

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