Commit 
							
							·
						
						494f28a
	
1
								Parent(s):
							
							f5dc736
								
Added position_ids input
Browse files- README.md +5 -1
 - model.onnx +2 -2
 
    	
        README.md
    CHANGED
    
    | 
         @@ -92,9 +92,11 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence, 
     | 
|
| 92 | 
         
             
                inputs_dict = {}
         
     | 
| 93 | 
         
             
                inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
         
     | 
| 94 | 
         
             
                inputs_dict['attention_mask'] = first_attention
         
     | 
| 
         | 
|
| 
         | 
|
| 95 | 
         
             
                inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
         
     | 
| 96 | 
         
             
                for name in inputs_names:
         
     | 
| 97 | 
         
            -
                    if name == 'input_ids' or name == 'attention_mask' or name == 'tree_attention': continue
         
     | 
| 98 | 
         
             
                    inputs_dict[name] = np.zeros([1, n_heads, context-window, 64], dtype="float16")
         
     | 
| 99 | 
         
             
                index = 0
         
     | 
| 100 | 
         
             
                new_token = np.array([10])
         
     | 
| 
         @@ -126,6 +128,8 @@ def generate_text(model_path, prompt, tokenizer, max_gen_tokens, total_sequence, 
     | 
|
| 126 | 
         
             
                            inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
         
     | 
| 127 | 
         
             
                        elif name == 'attention_mask':
         
     | 
| 128 | 
         
             
                            inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
         
     | 
| 
         | 
|
| 
         | 
|
| 129 | 
         
             
                        elif name == 'tree_attention': continue
         
     | 
| 130 | 
         
             
                        else:
         
     | 
| 131 | 
         
             
                            old_name = name.replace("past_key_values", "present")
         
     | 
| 
         | 
|
| 92 | 
         
             
                inputs_dict = {}
         
     | 
| 93 | 
         
             
                inputs_dict['input_ids'] = actual_input[:, :window].reshape(1, window).numpy()
         
     | 
| 94 | 
         
             
                inputs_dict['attention_mask'] = first_attention
         
     | 
| 95 | 
         
            +
                index_pos = sum(first_attention[0])
         
     | 
| 96 | 
         
            +
                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)
         
     | 
| 97 | 
         
             
                inputs_dict['tree_attention'] = np.triu(-65504*np.ones(total_sequence), k= 1).astype('float16').reshape(1, 1, total_sequence, total_sequence)
         
     | 
| 98 | 
         
             
                for name in inputs_names:
         
     | 
| 99 | 
         
            +
                    if name == 'input_ids' or name == 'attention_mask' or name == 'position_ids' or name == 'tree_attention': continue
         
     | 
| 100 | 
         
             
                    inputs_dict[name] = np.zeros([1, n_heads, context-window, 64], dtype="float16")
         
     | 
| 101 | 
         
             
                index = 0
         
     | 
| 102 | 
         
             
                new_token = np.array([10])
         
     | 
| 
         | 
|
| 128 | 
         
             
                            inputs_dict['input_ids']= total_input[:, j:next_index].reshape(1, window)
         
     | 
| 129 | 
         
             
                        elif name == 'attention_mask':
         
     | 
| 130 | 
         
             
                            inputs_dict['attention_mask'] = np.concatenate((np.zeros((1, total_sequence-next_index), dtype = 'int64'), np.ones((1, next_index), dtype = 'int64')), axis=1)
         
     | 
| 131 | 
         
            +
                        elif name == 'position_ids':
         
     | 
| 132 | 
         
            +
                            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)
         
     | 
| 133 | 
         
             
                        elif name == 'tree_attention': continue
         
     | 
| 134 | 
         
             
                        else:
         
     | 
| 135 | 
         
             
                            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:f9df6825085c109f584ed664cb40f8ebbd2e52471c1bb8f5326f20cc25ec997c
         
     | 
| 3 | 
         
            +
            size 1084347
         
     |