ericsorides
commited on
Commit
•
ba666d7
1
Parent(s):
4c4b82f
Added position_ids input
Browse files- README.md +5 -1
- 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:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6548022a5206fee50721f80a2b209be08ee00c0eb75f6ec3036ce5c29c3b181c
|
3 |
+
size 3326332
|