🚀 生成的な固有表現認識のための負例の再考
GNERは、生成的な固有表現認識(Generative Named Entity Recognition) フレームワークです。このフレームワークは、未見のエンティティドメインに対するゼロショット能力を向上させます。LLaMAとFlan - T5という2つの代表的な生成モデルに対する実験では、学習プロセスに負例を組み込むことで大幅な性能向上が得られることが示されています。結果として得られたGNER - LLaMAとGNER - T5モデルは、それぞれ$F_1$スコアで8ポイントと11ポイントの改善を達成し、最先端のアプローチを大きく上回っています。コードとモデルは公開されています。
🚀 クイックスタート
GNERは、生成的な固有表現認識のための革新的なフレームワークで、未見のエンティティドメインに対するゼロショット性能を向上させます。以下のリンクから、コード、論文、モデル、再現材料、Jupyterノートブックの例を入手できます。
✨ 主な機能
- 生成的な固有表現認識フレームワークで、未見のエンティティドメインに対するゼロショット能力を強化。
- 学習プロセスに負例を組み込むことで、性能を大幅に向上。
- 複数のモデルを公開し、最先端のアプローチを上回る性能を達成。
📦 インストール
依存関係をインストールするには、以下のコマンドを実行します。
pip install torch datasets deepspeed accelerate transformers protobuf
💻 使用例
基本的な使用法
以下はGNER - T5
を使用した簡単な推論の例です。
>>> import torch
>>> from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
>>> tokenizer = AutoTokenizer.from_pretrained("dyyyyyyyy/GNER-T5-xxl")
>>> model = AutoModelForSeq2SeqLM.from_pretrained("dyyyyyyyy/GNER-T5-xxl", torch_dtype=torch.bfloat16).cuda()
>>> model = model.eval()
>>> instruction_template = "Please analyze the sentence provided, identifying the type of entity for each word on a token-by-token basis.\nOutput format is: word_1(label_1), word_2(label_2), ...\nWe'll use the BIO-format to label the entities, where:\n1. B- (Begin) indicates the start of a named entity.\n2. I- (Inside) is used for words within a named entity but are not the first word.\n3. O (Outside) denotes words that are not part of a named entity.\n"
>>> sentence = "did george clooney make a musical in the 1980s"
>>> entity_labels = ["genre", "rating", "review", "plot", "song", "average ratings", "director", "character", "trailer", "year", "actor", "title"]
>>> instruction = f"{instruction_template}\nUse the specific entity tags: {', '.join(entity_labels)} and O.\nSentence: {sentence}"
>>> inputs = tokenizer(instruction, return_tensors="pt").to("cuda")
>>> outputs = model.generate(**inputs, max_new_tokens=640)
>>> response = tokenizer.decode(outputs[0], skip_special_tokens=True)
>>> print(response)
"did(O) george(B-actor) clooney(I-actor) make(O) a(O) musical(B-genre) in(O) the(O) 1980s(B-year)"
📚 ドキュメント
事前学習済みモデル
LLaMA (7B) とFlan - T5 (base, large, xl, xxl) をベースにした5つのGNERモデルを公開しています。
モデル |
パラメータ数 |
ゼロショット平均$F_1$ |
教師付き平均$F_1$ |
🤗 HuggingFace ダウンロードリンク |
GNER - LLaMA |
7B |
66.1 |
86.09 |
リンク |
GNER - T5 - base |
248M |
59.5 |
83.21 |
リンク |
GNER - T5 - large |
783M |
63.5 |
85.45 |
リンク |
GNER - T5 - xl |
3B |
66.1 |
85.94 |
リンク |
GNER - T5 - xxl |
11B |
69.1 |
86.15 |
リンク |
📄 ライセンス
このプロジェクトはApache - 2.0ライセンスの下で公開されています。
引用
@misc{ding2024rethinking,
title={Rethinking Negative Instances for Generative Named Entity Recognition},
author={Yuyang Ding and Juntao Li and Pinzheng Wang and Zecheng Tang and Bowen Yan and Min Zhang},
year={2024},
eprint={2402.16602},
archivePrefix={arXiv},
primaryClass={cs.CL}
}