diff --git a/Readme.md b/Readme.md index 0742e56..f1c42f4 100644 --- a/Readme.md +++ b/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: diff --git a/tools/show.py b/tools/show.py index 3c20d38..4fc731f 100644 --- a/tools/show.py +++ b/tools/show.py @@ -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) + "%") diff --git a/tools/test.py b/tools/test.py index 1ac2c75..0111b7b 100644 --- a/tools/test.py +++ b/tools/test.py @@ -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()