From 6607a234abc013591237d34f1aa38312db370b72 Mon Sep 17 00:00:00 2001 From: "li.fangtian.od" Date: Thu, 29 May 2025 15:29:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8E=A8=E7=90=86?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=AD=E7=9A=84=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../embedding/jina-embeddings-v2-base-zh/infer.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/infer.py b/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/infer.py index d21a875ad8..76d8b0f25d 100644 --- a/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/infer.py +++ b/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/infer.py @@ -127,14 +127,15 @@ def rewrite_JinaBertGLUMLP_forward(model): def forward(hidden_states: torch.Tensor) -> torch.Tensor: residual_connection = hidden_states # compute the activation - hidden_states = self.gated_layers(hidden_states) + hidden_states = model.gated_layers(hidden_states) gated, non_gated = hidden_states.chunk(2, dim=2) - hidden_states = self.act(gated) * non_gated - hidden_states = self.dropout(hidden_states) + hidden_states = model.act(gated) * non_gated + hidden_states = model.dropout(hidden_states) # multiply by the second matrix - hidden_states = self.wo(hidden_states) + hidden_states = model.wo(hidden_states) # add the residual connection and post-LN - hidden_states = self.layernorm(hidden_states + residual_connection) + hidden_states = model.layernorm(hidden_states + residual_connection) + return hidden_states model.forward = forward @@ -147,7 +148,7 @@ def modify_model(model): model.npu().eval().half() -if name == '__main__': +if __name__ == '__main__': args = parse_args() torch_npu.npu.set_compile_mode(jit_compile=False) @@ -179,4 +180,4 @@ if name == '__main__': ['How is the weather today?', '今天天气怎么样?', ], convert_to_tensor=True) - print(f'E2E time = {(time.time() - start) / args.loop *1000}ms') + print(f'E2E time = {(time.time() - start) / args.loop *1000}ms') \ No newline at end of file -- Gitee From 8d609edf733c65c32da402189fd497f9d61b1dc7 Mon Sep 17 00:00:00 2001 From: lifangtian Date: Thu, 29 May 2025 07:44:15 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=9B=B4=E6=AD=A3?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../built-in/embedding/jina-embeddings-v2-base-zh/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/README.md b/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/README.md index 2e1dcb199d..0e91701736 100644 --- a/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/README.md +++ b/ACL_PyTorch/built-in/embedding/jina-embeddings-v2-base-zh/README.md @@ -31,7 +31,7 @@ | CANN | 8.1.RC1 | 包含kernels包和toolkit包 | | Python | 3.10 | - | | PyTorch | 2.5.1 | - | - | Ascend Extension PyTorch | 2.5.1.post2 | - | + | Ascend Extension PyTorch | 2.5.1 | - | | 说明:Atlas 800I A2 推理卡和Atlas 300I DUO 推理卡请以CANN版本选择实际固件与驱动版本。 | \ | \ | @@ -80,7 +80,7 @@ 2. 安装依赖 ``` - pip3 install transformers==4.35.2 + pip3 install transformers==4.35.2 torch==2.5.1 torch_npu==2.5.1 protobuf numpy==1.26.4 decorator attrs psutil scipy ``` -- Gitee