Update.
This commit is contained in:
		
							parent
							
								
									b3df9e423c
								
							
						
					
					
						commit
						3db6e2c25b
					
				
							
								
								
									
										21
									
								
								Readme.md
								
								
								
								
							
							
						
						
									
										21
									
								
								Readme.md
								
								
								
								
							| 
						 | 
				
			
			@ -3,6 +3,27 @@
 | 
			
		|||
 | 
			
		||||
## data flow
 | 
			
		||||
 | 
			
		||||
                        query
 | 
			
		||||
                          |
 | 
			
		||||
                      tokenizer  -> input_ids
 | 
			
		||||
                          |
 | 
			
		||||
 rotary_pos_emb       embedding  ->  [1, 6, 4096]   
 | 
			
		||||
               \     /
 | 
			
		||||
               GLMBlock x 28  ->  [6, 1, 4096]    <━━━┓
 | 
			
		||||
                                                      ┃
 | 
			
		||||
                RMSNorm  ->  [6, 1, 4096]             ┃
 | 
			
		||||
                                                      ┃
 | 
			
		||||
                 [-1:]  ->  [1, 1, 4096]              ┃
 | 
			
		||||
                                                      ┃
 | 
			
		||||
                Linear  ->  [1, 1, 65024]             ┃
 | 
			
		||||
                                                      ┃
 | 
			
		||||
                softmax  ->  [1, 65024]               ┃
 | 
			
		||||
                                                      ┃
 | 
			
		||||
               multinomial  ->  [1]                   ┃
 | 
			
		||||
                                                      ┃
 | 
			
		||||
          cat([input_ids, next_tokens])            ━━━┛
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
input_ids = tokenizer.build_chat_input(query, history=history, role=role)
 | 
			
		||||
 | 
			
		||||
for:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,3 +55,23 @@ def DumpListToFile(list, name="list"):
 | 
			
		|||
    for d in list:
 | 
			
		||||
        f.writelines("%s" % d + os.linesep)
 | 
			
		||||
    f.close()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
prob_true = 0
 | 
			
		||||
prob_all = 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def ProbGE0(tensor: torch.tensor):
 | 
			
		||||
    global prob_true
 | 
			
		||||
    global prob_all
 | 
			
		||||
    m = tensor.ge(0)
 | 
			
		||||
    prob_true = prob_true + m.sum().item()
 | 
			
		||||
    prob_all = prob_all + math.prod(tensor.shape)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def DumpProb():
 | 
			
		||||
    global prob_true
 | 
			
		||||
    global prob_all
 | 
			
		||||
    print("prob_true : " + str(prob_true))
 | 
			
		||||
    print("prob_all : " + str(prob_all))
 | 
			
		||||
    print("prob : " + str((prob_true * 100) / prob_all) + "%")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,3 +11,8 @@ show.DumpTensorToImage(radata, "test.png")
 | 
			
		|||
 | 
			
		||||
radata = torch.randn(127, 127)
 | 
			
		||||
show.DumpTensorToLog(radata, "test.log")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
radata = torch.randn(127, 127) - 0.5
 | 
			
		||||
show.ProbGE0(radata)
 | 
			
		||||
show.DumpProb()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue