分类体系
在定义的分类法或选择层次结构上下文中执行分类任务。
标注配置
您可以通过以下几种方式定义分类体系:
- 用户自定义标签 - 使用
Choice标签手动定义您的分类体系。这是模板中的默认配置。 - 外部分类法 - 使用JSON格式文件或API定义您的分类法。此选项为大规模分类法提供更好的性能。
在这两种选项中,都需要以下标签:
标注配置必须包裹在
View标签内。Include the data type you are working with. The example template is classifying text, but the
Taxonomytag can also be used with audio, image, HTML, paragraphs, time series, and video.<Text name="text" value="$text"/>使用
Taxonomy标签向用户展示层级选项。<Taxonomy name="taxonomy" toName="text">
分类法作为标注工具
通常,标签用于执行分类任务。但是,如果您设置labeling="true",则可以将分类选择应用于文本中的区域。这对于NER项目特别有用。
请注意,labeling参数仅在使用了或对象标签时受支持。

使用嵌套Choice标签定义的分类体系
使用Choice标签来指定分类体系。在Choice标签下嵌套选项以创建分类体系中的层级。
<View>
<Text name="text" value="$text"/>
<Taxonomy name="taxonomy" toName="text">
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Opossum" />
<Choice value="Extraterrestrial" />
</Choice>
</Taxonomy>
</View>
通过远程源定义的分类体系 - Beta测试版 🧪
您可以修改模板以调用外部分类法。外部分类法有两种类型:
要调用外部分类法,请移除Choice标签并指定apiUrl参数:
<Taxonomy name="taxonomy" toName="text" apiUrl="<YOUR_TAXONOMY_URL>" />
测试版功能
通过apiUrl调用外部分类法的功能目前处于测试阶段。
例如:
<View>
<Text name="text" value="$text"/>
<Taxonomy name="taxonomy" toName="text" apiUrl="https://cities-nu.vercel.app/full" />
</View>
远程分类必须使用JSON格式,其中条目需遵循以下结构:
| 属性 | 描述 |
|---|---|
items |
Required. The JSON resource should be structured as an object with the key items. See below for examples. |
value |
Required. This is what the user sees as an option to select. If you do not include an alias property, the value is exported in the annotation results. |
[alias] |
If included, the alias replaces the value property in the annotation results. The alias is not displayed in the labeling interface. This is useful when you have internal identifiers for your data. |
[children] |
Nested values within the taxonomy hierarchy. Use this when defining your taxonomy in a single JSON-formatted file. |
[isLeaf] |
Boolean value. Use this instead of children when working with an API taxonomy. The default is true. When explicitly set to false, the node is treated as a parent node. See below for more information. |
[hint] |
This string will appear as a tooltip to the user when they hover their cursor over the value. |
保护分类体系
apiUrl 必须能够被 Label Studio 访问。您可以通过以下几种方式实现:
该URL是公开的。
该URL托管在本地服务器上。
URL中包含用户名和密码,例如
http://username:password@example.com/。虽然这种情况下分类体系本身不是公开可访问的,但任何能查看项目标注配置的人都能看到这些凭据。标注者也可以通过浏览器开发者工具中的网络标签页查看这些凭据。
该URL指向您的私有云环境。这是最安全的选择。请参阅下方的使用带有外部分类法的云存储。
使用云存储与外部分类体系
将您的分类体系保存在与任务数据不同的存储桶中。
如果无法为分类体系使用单独的存储桶,请参阅下面的临时解决方案。
Follow these instructions 按照以下说明为Label Studio设置云存储。这应该是一个独立于其他存储连接的配置。
注意
不要同步此存储连接。如果同步,您将需要删除在同步分类法时自动创建的任务。
配置标注界面时,请根据您的云服务提供商使用适当的URL格式设置
apiUrl:gs://、s3://、azure-blob://。
关于设置云存储的注意事项
如果您对包含分类体系的存储连接执行同步操作,整个分类体系将被作为任务拉入Label Studio。根据分类体系的规模,这可能导致Label Studio性能严重下降。当您使用云存储同步来填充Label Studio任务时,这可能会带来问题。
针对此问题有以下几种解决方法:
- 同步后,直接删除任务即可。
- (推荐) 建立两个源存储连接和两个外部云存储桶。其中一个存储桶可存放需要同步用于标注任务的数据,另一个存储桶可存放分类体系(无需同步)。
- 建立两个源存储连接和一个外部云存储桶。然后在配置存储连接时使用正则表达式来包含/排除分类体系。
平面文件格式
基本要求是使用JSON格式,将分类结构包裹在items对象中,并为每个条目包含value属性。
在此示例中,您使用children来指定子节点。所有值都在单个请求中加载。
{
"items": [
{
"alias": "archaea01",
"hint": "Single-celled organisms",
"value": "Archaea"
},
{
"alias": "bacteria01",
"hint": "Prokaryotic microorganisms",
"value": "Bacteria"
},
{
"alias": "eukarya01",
"hint": "Basically everything else",
"value": "Eukarya",
"children": [
{
"alias": "eukarya01_b1",
"value": "Human"
},
{
"alias": "eukarya01_b2",
"value": "Opossum"
},
{
"alias": "eukarya01_b3",
"value": "Extraterrestrial"
}
]
}
]
}
API分类体系
使用此格式时,子节点仅在请求时加载。父节点通过"isLeaf": false指定,子节点则通过path参数调用。
例如,taxonomy_api_url?path=node1,其中node1是别名(如果指定)或值(如果未指定别名)。因此,您必须确保您的API支持path参数。
分类API规范
GET /?[path=value1]&[path=value2]&...&[path=valueN]
返回一个包含items键的JSON对象,其关联值为分类项列表。
如果提供了path查询参数,则返回valueN的直接子节点。请注意,对于范围1..N-1中的i,value[i+1]必须是value[i]的子节点。
{
"items": [ <List of taxonomy values> ]
}
分类项定义:
{
"alias": // Optional string, short name for use in output data and path values.
"value": // Required string, the displayed text for the taxonomy value.
// Used same way as `alias` if alias is not specified (i.e., in output data and path values).
"hint": // Optional string, text displayed when user hovers over taxonomy item.
"isLeaf": // Required boolean with default=false. Indicates whether this node has more children.
}
请参考以下分类示例 (https://cities-nu.vercel.app/labels2):
{
"items": [
{
"alias": "AF",
"value": "Africa",
"hint": "AF",
"isLeaf": false
},
{
"alias": "AN",
"value": "Antarctica",
"hint": "AN",
"isLeaf": false
},
{
"alias": "AS",
"value": "Asia",
"hint": "AS",
"isLeaf": false
},
{
"alias": "EU",
"value": "Europe",
"hint": "EU",
"isLeaf": false
},
{
"alias": "NA",
"value": "North America",
"hint": "NA",
"isLeaf": false
},
{
"alias": "OC",
"value": "Oceania",
"hint": "OC",
"isLeaf": false
},
{
"alias": "SA",
"value": "South America",
"hint": "SA",
"isLeaf": false
}
]
}
当用户展开"Africa"选项时,会发送以下请求来获取子级值:https://cities-nu.vercel.app/labels2?path=AF