モデル概要
モデル特徴
モデル能力
使用事例
🚀 クックー 🐦 [Github]
クックーモデルファミリーは、論文 Cuckoo: An IE Free Rider Hatched by Massive Nutrition in LLM's Nest で説明されている抽出型質問応答モデルです。
クックーは、大規模言語モデルの次のトークン予測パラダイムを模倣した小規模(3億パラメータ)の情報抽出(IE)モデルです。語彙からの検索ではなく、クックーは与えられた入力コンテキスト内でトークンにタグ付けすることで次のトークンを予測します。下図のようにです。
クックーは、以前のIE事前学習とは大きく異なり、あらゆるテキストリソースを利用して自身を強化することができます。特に、LLM用に整理されたデータを無料で利用することができます!
現在、以下のデータセットで事前学習されたクックーのチェックポイントをオープンソースで公開しています。
-
C4から変換された1億の次のトークン抽出(NTE)インスタンス。(Cuckoo-C4 🐦)
-
Cuckoo-C4 + 教師付き微調整データセットであるTuluV3から変換された260万の次のトークン抽出(NTE)インスタンス。(Cuckoo-C4-Instruct 🐦🛠️)
-
Cuckoo-C4-Instruct + MultiNERD、MetaIE、NuNER、MRQA(SQuAD、DROPを除く)。(Cuckoo-C4-Rainbow 🌈🐦🛠️)
-
Cuckoo-C4-Rainbow + 複数のNERデータセット、WizardLMデータセット、複数の選択肢質問応答データセット、MMLU、SQuAD、DROP、MNLI、SNLI。(Cuckoo-C4-Super-Rainbow 🦸🌈🐦🛠️)
✨ 主な機能
🚀 性能デモンストレーション
クックーを使って、あらゆるIEタスクに対する想像を超えた適応効率を体験してください!
CoNLL2003 | BioNLP2004 | MIT-Restaurant | MIT-Movie | 平均 | CoNLL2004 | ADE | 平均 | SQuAD | SQuAD-V2 | DROP | 平均 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
OPT-C4-TuluV3 | 50.24 | 39.76 | 58.91 | 56.33 | 50.56 | 47.14 | 45.66 | 46.40 | 39.80 | 53.81 | 31.00 | 41.54 |
RoBERTa | 33.75 | 32.91 | 62.15 | 58.32 | 46.80 | 34.16 | 2.15 | 18.15 | 31.86 | 48.55 | 9.16 | 29.86 |
MRQA | 72.45 | 55.93 | 68.68 | 66.26 | 65.83 | 66.23 | 67.44 | 66.84 | 80.07 | 66.22 | 54.46 | 66.92 |
MultiNERD | 66.78 | 54.62 | 64.16 | 66.30 | 60.59 | 57.52 | 45.10 | 51.31 | 42.85 | 50.99 | 30.12 | 41.32 |
NuNER | 74.15 | 56.36 | 68.57 | 64.88 | 65.99 | 65.12 | 63.71 | 64.42 | 61.60 | 52.67 | 37.37 | 50.55 |
MetaIE | 71.33 | 55.63 | 70.08 | 65.23 | 65.57 | 64.81 | 64.40 | 64.61 | 74.59 | 62.54 | 30.73 | 55.95 |
Cuckoo 🐦🛠️ | 73.60 | 57.00 | 67.63 | 67.12 | 66.34 | 69.57 | 71.70 | 70.63 | 77.47 | 64.06 | 54.25 | 65.26 |
└─ 事前学習のみ 🐦 | 72.46 | 55.87 | 66.87 | 67.23 | 65.61 | 68.14 | 69.39 | 68.77 | 75.64 | 63.36 | 52.81 | 63.94 |
└─ 事後学習のみ | 72.80 | 56.10 | 66.02 | 67.10 | 65.51 | 68.66 | 69.75 | 69.21 | 77.05 | 62.39 | 54.80 | 64.75 |
Rainbow Cuckoo 🌈🐦🛠️ | 79.94 | 58.39 | 70.30 | 67.00 | 68.91 | 70.47 | 76.05 | 73.26 | 86.57 | 69.41 | 64.64 | 73.54 |
(Super Rainbow Cuckoo 🦸🌈🐦🛠️ は、CoNLL2004とADEを除くトレーニングセットを使用して性能を向上させています)
CoNLL2003 | BioNLP2004 | MIT-Restaurant | MIT-Movie | 平均 | CoNLL2004 | ADE | 平均 | SQuAD | SQuAD-V2 | DROP | 平均 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Super Rainbow Cuckoo 🦸🌈🐦🛠️ | 88.38 | 68.33 | 76.79 | 69.39 | 75.22 | 72.96 | 80.06 | 76.51 | 89.54 | 74.52 | 74.89 | 79.65 |
⚡ 次のトークン抽出でのクックーの素早い体験
ゼロショット抽出には、最強のSuper Rainbow Cuckoo 🦸🌈🐦🛠️ を使用することをおすすめします。以下のケースを case_next_tokens_extraction.py
で直接実行することができます。
1️⃣ まず、モデルとトークナイザーをロードします。
from transformers import AutoModelForTokenClassification, AutoTokenizer
import torch
import spacy
nlp = spacy.load("en_core_web_sm")
device = torch.device("cuda:0")
path = f"KomeijiForce/Cuckoo-C4-Super-Rainbow"
tokenizer = AutoTokenizer.from_pretrained(path)
tagger = AutoModelForTokenClassification.from_pretrained(path).to(device)
2️⃣ 次のトークン抽出関数を定義します。
def next_tokens_extraction(text):
def find_sequences(lst):
sequences = []
i = 0
while i < len(lst):
if lst[i] == 0:
start = i
end = i
i += 1
while i < len(lst) and lst[i] == 1:
end = i
i += 1
sequences.append((start, end+1))
else:
i += 1
return sequences
text = " ".join([token.text for token in nlp(text)])
inputs = tokenizer(text, return_tensors="pt").to(device)
tag_predictions = tagger(**inputs).logits[0].argmax(-1)
predictions = [tokenizer.decode(inputs.input_ids[0, seq[0]:seq[1]]).strip() for seq in find_sequences(tag_predictions)]
return predictions
3️⃣ 抽出のために関数を呼び出しましょう!
基本的な使用法
text = "Tom and Jack went to their trip in Paris."
for question in [
"What is the person mentioned here?",
"What is the city mentioned here?",
"Who goes with Tom together?",
"What do Tom and Jack go to Paris for?",
"Where does George live in?",
]:
prompt = f"User:\n\n{text}\n\nQuestion: {question}\n\nAssistant:"
predictions = next_tokens_extraction(prompt)
print(question, predictions)
以下のような結果が得られます。
What is the person mentioned here? ['Tom', 'Jack']
What is the city mentioned here? ['Paris']
Who goes with Tom together? ['Jack']
What do Tom and Jack go to Paris for? ['trip']
Where does George live in? []
ここで、[] はクックーが抽出する次のトークンがないと判断したことを示しています。
高度な使用法
passage = f'''Ludwig van Beethoven (17 December 1770 – 26 March 1827) was a German composer and pianist. He is one of the most revered figures in the history of Western music; his works rank among the most performed of the classical music repertoire and span the transition from the Classical period to the Romantic era in classical music. His early period, during which he forged his craft, is typically considered to have lasted until 1802. From 1802 to around 1812, his middle period showed an individual development from the styles of Joseph Haydn and Wolfgang Amadeus Mozart, and is sometimes characterised as heroic. During this time, Beethoven began to grow increasingly deaf. In his late period, from 1812 to 1827, he extended his innovations in musical form and expression.'''
for question in [
"What are the people mentioned here?",
"What is the job of Beethoven?",
"How famous is Beethoven?",
"When did Beethoven's middle period showed an individual development?",
]:
text = f"User:\n\n{passage}\n\nQuestion: {question}\n\nAssistant:"
predictions = next_tokens_extraction(text)
print(question, predictions)
以下のような結果が得られます。
What are the people mentioned here? ['Ludwig van Beethoven', 'Joseph Haydn', 'Wolfgang Amadeus Mozart']
What is the job of Beethoven? ['composer and pianist']
How famous is Beethoven? ['one of the most revered figures in the history of Western music']
When did Beethoven's middle period showed an individual development? ['1802']
知識クイズ
for obj in ["grass", "sea", "fire", "night"]:
text = f"User:\n\nChoices:\nred\nblue\ngreen.\n\nQuestion: What is the color of the {obj}?\n\nAssistant:\n\nAnswer:"
predictions = next_tokens_extraction(text)
print(obj, predictions)
以下のような結果が得られます。
grass ['green']
sea ['blue']
fire ['red']
night []
これは、クックーが妥当なスパンを抽出しているわけではなく、コンテキストを理解する知識を持っていることを示しています。
🎯 フェデレーション学習
クックー 🐦 は、独自のタスクへのフェデレーション学習の専門家です。CoNLL2003を例にとると、bash run_downstream.sh conll2003.5shot KomeijiForce/Cuckoo-C4-Rainbow
を実行すると、models/cuckoo-conll2003.5shot
に微調整されたモデルが得られます。次に、python eval_conll2003.py
スクリプトでモデルをベンチマークすると、F1性能が約80になることがわかります。
機械読解(SQuAD)への適応をトレーニングすることもできます。bash run_downstream.sh squad.32shot KomeijiForce/Cuckoo-C4-Rainbow
を実行すると、models/cuckoo-squad.32shot
に微調整されたモデルが得られます。次に、python eval_squad.py
スクリプトでモデルをベンチマークすると、F1性能が約88になることがわかります。
独自のタスクを微調整するには、Jsonlinesファイルを作成する必要があります。各行には {"words": [...], "ner": [...]} が含まれている必要があります。例えば:
{"words": ["I", "am", "John", "Smith", ".", "Person", ":"], "ner": ["O", "O", "B", "I", "O", "O", "O"]}
これは、"John Smith" が次のトークンとして予測されることを示しています。
以下に示すいくつかのプロンプトを参考にすることができます。
タイプ | ユーザー入力 | アシスタント応答 |
---|---|---|
エンティティ | ユーザー: [コンテキスト] 質問: [ラベル] は何ですか? | アシスタント: 回答: [ラベル] は |
関係(殺害) | ユーザー: [コンテキスト] 質問: [エンティティ] は誰を殺害しましたか? | アシスタント: 回答: [エンティティ] は |
関係(居住) | ユーザー: [コンテキスト] 質問: [エンティティ] はどこに住んでいますか? | アシスタント: 回答: [エンティティ] は |
関係(勤務) | ユーザー: [コンテキスト] 質問: [エンティティ] は誰のために働いていますか? | アシスタント: 回答: [エンティティ] は |
関係(位置) | ユーザー: [コンテキスト] 質問: [エンティティ] はどこに位置していますか? | アシスタント: 回答: [エンティティ] は |
関係(拠点) | ユーザー: [コンテキスト] 質問: [エンティティ] はどこに拠点を置いていますか? | アシスタント: 回答: [エンティティ] は |
関係(副作用) | ユーザー: [コンテキスト] 質問: [エンティティ] の副作用は何ですか? | アシスタント: 回答: [エンティティ] の副作用は |
クエリ | ユーザー: [コンテキスト] 質問: [質問] | アシスタント: 回答: |
命令(エンティティ) | ユーザー: [コンテキスト] 質問: [ラベル] は何ですか? ([命令]) | アシスタント: 回答: [ラベル] は |
命令(クエリ) | ユーザー: [コンテキスト] 質問: [質問] ([命令]) | アシスタント: 回答: |
独自の下流データセットを構築した後、my_downstream.json
に保存し、bash run_downstream.sh my_downstream KomeijiForce/Cuckoo-C4-Rainbow
コマンドを実行します。models/cuckoo-my_downstream
に適応されたクックーが見つかります。
🪽 独自のクックーを飛ばそう
nte_data_collection.py
ファイルには、テキストをNTEインスタンスに変換するスクリプトが含まれています。これはC4を例にとっており、変換結果は cuckoo.c4.example.json
で確認できます。このスクリプトは、エンティティ、クエリ、質問などの他のリソースに簡単に適応できるように設計されており、独自のデータをNTEに変換して、独自のクックーを飛ばすことができます!run_cuckoo.sh
スクリプトを実行して、事前学習の例を試してみてください。
python run_ner.py \
--model_name_or_path roberta-large \
--train_file cuckoo.c4.example.json \
--output_dir models/cuckoo-c4-example \
--per_device_train_batch_size 4 \
--gradient_accumulation_steps 16 \
--num_train_epochs 1 \
--save_steps 1000 \
--learning_rate 0.00001 \
--do_train \
--overwrite_output_dir
models/cuckoo-c4-example
に例のクックーモデルが得られます。事前学習に使用するデータが少なすぎると、性能が良くない場合があります。nte_data_collection.py
内のハイパーパラメータを調整するか、独自のリソースの変換を変更して、より良い事前学習性能を実現することができます。
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。
🐾 引用
@article{DBLP:journals/corr/abs-2502-11275,
author = {Letian Peng and
Zilong Wang and
Feng Yao and
Jingbo Shang},
title = {Cuckoo: An {IE} Free Rider Hatched by Massive Nutrition in {LLM}'s Nest},
journal = {CoRR},
volume = {abs/2502.11275},
year = {2025},
url = {https://doi.org/10.48550/arXiv.2502.11275},
doi = {10.48550/arXiv.2502.11275},
eprinttype = {arXiv},
eprint = {2502.11275},
timestamp = {Mon, 17 Feb 2025 19:32:20 +0000},
biburl = {https://dblp.org/rec/journals/corr/abs-2502-11275.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}









