From 4f8df4d85e14c6652fc5c1a050327120c53a69e8 Mon Sep 17 00:00:00 2001 From: Applevegetable <49542940+Applevegetable@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:12:30 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E5=B0=86=20grouped=5Fentities=3DTrue=20?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BA=20aggregation=5Fstrategy=3D"simple"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the pipeline function to use 'aggregation_strategy' instead of 'grouped_entities'. --- chapters/zh-CN/chapter1/3.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chapters/zh-CN/chapter1/3.mdx b/chapters/zh-CN/chapter1/3.mdx index 032430bfa..2a732b785 100644 --- a/chapters/zh-CN/chapter1/3.mdx +++ b/chapters/zh-CN/chapter1/3.mdx @@ -193,7 +193,7 @@ unmasker("This course will teach you all about models.", top_k=2) ```python from transformers import pipeline -ner = pipeline("ner", grouped_entities=True) +ner = pipeline("ner", aggregation_strategy="simple") ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") ``` ```python out @@ -205,7 +205,7 @@ ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") 在这里,模型正确地识别出 Sylvain 是一个人 (PER),Hugging Face 是一个组织 (ORG),而布鲁克林是一个位置 (LOC)。 -我们在创建 pipeline 的函数中传递的 `grouped_entities=True` 参数告诉 pipeline 将与同一实体对应的句子部分重新分组:这里模型正确地将“Hugging”和“Face”分组为一个组织,即使名称由多个词组成。事实上,正如我们即将在下一章看到的,预处理甚至会将一些单词分成更小的部分。例如, `Sylvain` 分割为了四部分: `S、##yl、##va` 和 `##in` 。在后处理步骤中,pipeline 成功地重新组合了这些部分。 +我们在创建 pipeline 的函数中传递的 `aggregation_strategy="simple"` 参数告诉 pipeline 将与同一实体对应的句子部分重新分组:这里模型正确地将“Hugging”和“Face”分组为一个组织,即使名称由多个词组成。事实上,正如我们即将在下一章看到的,预处理甚至会将一些单词分成更小的部分。例如, `Sylvain` 分割为了四部分: `S、##yl、##va` 和 `##in` 。在后处理步骤中,pipeline 成功地重新组合了这些部分。 > [!TIP] > ✏️**快来试试吧!**在模型中心(hub)搜索能够用英语进行词性标注(通常缩写为 POS)的模型。对于上面示例中的句子,这个词性标注的模型预测了什么? @@ -291,4 +291,4 @@ translator("Ce cours est produit par Hugging Face.") > [!TIP] > ✏️**快来试试吧!**搜索其他语言的翻译模型,尝试将前面的句子翻译成几种不同的语言。 -到目前为止显示的 pipeline 主要用于演示目的。它们是为特定任务而定制的,不能对他们进行自定义的修改。在下一章中,你将了解 `pipeline()` 函数内部的过程以及如何进行自定义的修改。 \ No newline at end of file +到目前为止显示的 pipeline 主要用于演示目的。它们是为特定任务而定制的,不能对他们进行自定义的修改。在下一章中,你将了解 `pipeline()` 函数内部的过程以及如何进行自定义的修改。