ericsorides commited on
Commit
4cbfe39
·
1 Parent(s): 7d8bd60

Added position_ids input

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