ericsorides
commited on
Commit
•
9f30d4e
1
Parent(s):
13e854b
Added position_ids input
Browse files- README.md +5 -1
- model.onnx +2 -2
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, 128], 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, 128], 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:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b76a7fdaa214299d54e9311c131cbe7a1b92970a2d4b4cc47b5fd9888bc6db1f
|
3 |
+
size 6294179
|