ericsorides commited on
Commit
10632df
1 Parent(s): 16336b5

Added position_ids input

Browse files
Files changed (2) hide show
  1. README.md +5 -1
  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, 96], 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, 96], 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:bdda774e93822555bf9acbca5c52f7be1df93f0403fdcd61cdaf4ac919eab58c
3
- size 1390884
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c92a3a8f7fbbf3264ddf83c48c8615eed43ebbffefc5b29c9b9d791892054ee
3
+ size 1390240