annotation_specs parse_attribute#
Description#
自然言語で書かれた属性追加ルールやアノテーション仕様の文章から、Annofabに追加する属性を解析します。
出力されるJSONは、 annofabcli annotation_specs add_attributes コマンドの --attribute_json 引数にそのまま指定できます。
このコマンドを実行するには、対象のラベルがアノテーション仕様に存在している必要があります。
新規でアノテーション仕様を作成する場合は、先に annotation_specs parse_label でラベルを追加してください。
Examples#
基本的な使い方#
車と歩行者には見切れ属性を追加してください。
車には天気属性をドロップダウンで追加し、晴れと雨を選べるようにしてください。
$ annofabcli-llm annotation_specs parse_attribute \
--annotation_specs_json_file annotation_specs.json \
--annotation_rule @rule.md
[
{
"attribute_type": "flag",
"attribute_name_en": "truncated",
"label_name_ens": [
"car",
"pedestrian"
],
"attribute_name_ja": "見切れ"
},
{
"attribute_type": "select",
"attribute_name_en": "weather",
"label_name_ens": [
"car"
],
"attribute_name_ja": "天気",
"choices": [
{
"choice_name_en": "sunny",
"choice_name_ja": "晴れ",
"is_default": true
},
{
"choice_name_en": "rainy",
"choice_name_ja": "雨",
"is_default": false
}
]
}
]
Annofabへ属性を追加する#
$ annofabcli-llm annotation_specs parse_attribute \
--project_id ${PROJECT_ID} \
--annotation_rule @rule.md \
--output attributes.json
$ annofabcli annotation_specs add_attributes \
--project_id ${PROJECT_ID} \
--attribute_json file://attributes.json
注釈
解析結果の途中経過は $HOME/.cache/annofab-cli-llm/temp/parse_attribute_* に出力されます。
Usage Details#
自然言語から追加対象の属性を解析します。
usage: annofabcli-llm annotation_specs parse_attribute [-h] [-m MODEL]
[--verbose] [--yes]
[--annofab_pat ANNOFAB_PAT]
(--annotation_specs_json_file ANNOTATION_SPECS_JSON_FILE |
-p PROJECT_ID)
--annotation_rule ANNOTATION_RULE
[-o OUTPUT]
[--no_interactive]
Named Arguments#
- --annotation_specs_json_file
annotation specs v3 のJSONファイルのパス
- -p, --project_id
AnnofabのプロジェクトID
- --annotation_rule
属性追加に関するアノテーションルールやアノテーション仕様の自然言語。先頭に`@`を指定すると、`@`以降をファイルパスとみなしてファイルの中身を読み込みます。
- -o, --output
出力先のファイルパス。指定しない場合は、標準出力に出力されます。
- --no_interactive
未解決テキストが存在しても、補足情報の入力を求めずに終了します。
global optional arguments#
- -m, --model
使用するLLMのモデルです。使用できるモデルは https://docs.litellm.ai/docs/providers を参照してください。
Default:
'openai/gpt-5.4-mini'- --verbose
詳細なログを出力します。
- --yes
確認メッセージに対して常に'yes'と回答したとみなします。確認メッセージが表示されません。
- --annofab_pat
AnnofabのPersonal Access Token