Entitybert
EntityBERTは、英語テキストの命名エンティティ認識(NER)タスク用に設計された、軽量級で微調整されたTransformerモデルです。
Downloads 121
Release Time : 6/10/2025
Model Overview
このモデルはbert - miniアーキテクチャに基づいており、人物、組織、場所、日付など36種類のエンティティタイプを効率的に認識でき、情報抽出、チャットボット、検索強化などのアプリケーションシナリオに適しています。
Model Features
軽量級設計
モデルのサイズは約15MBで、リソースが限られた環境でのデプロイに適しています。
多エンティティ認識
人物、組織、場所、日付など36種類のエンティティタイプの認識をサポートします。
高効率性能
テストセットでF1スコア0.85、正確率0.91を達成しました。
微調整が容易
完全なトレーニングスクリプトを提供し、特定のドメインに対する微調整をサポートします。
Model Capabilities
命名エンティティ認識
情報抽出
テキスト分析
Use Cases
情報抽出
ニュースエンティティ抽出
ニュース記事から人物、組織、場所などの重要な情報を抽出します。
ニュースの重要な情報を構造化して保存
レポート分析
研究レポート内の日付、金額などのエンティティを自動的に認識します。
レポートの重要なデータを迅速に抽出
スマートアシスタント
チャットボット
ユーザーのクエリ内のエンティティを認識することで、対話理解能力を向上させます。
より正確な対話応答
検索強化
エンティティに基づく意味検索機能を実現します。
より正確な検索結果
知識管理
知識グラフ構築
テキストからエンティティ関係を抽出し、構造化知識を構築します。
自動化された知識グラフ構築
🚀 🌟EntityBERTモデル🌟
EntityBERTモデルは、軽量で微調整されたトランスフォーマーモデルで、英語テキストの固有表現認識(NER)に特化しています。情報抽出やチャットボット、検索機能の強化などのアプリケーションに最適です。
🚀 クイックスタート
推論コード
以下のPythonコードを使用して、NERを実行できます。
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# モデルとトークナイザーをロード
tokenizer = AutoTokenizer.from_pretrained("boltuix/EntityBERT")
model = AutoModelForTokenClassification.from_pretrained("boltuix/EntityBERT")
# 入力テキスト
text = "Elon Musk launched Tesla in California on March 2025."
inputs = tokenizer(text, return_tensors="pt")
# 推論を実行
with torch.no_grad():
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=-1)
# 予測をラベルにマッピング
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
label_map = model.config.id2label
labels = [label_map[p.item()] for p in predictions[0]]
# 結果を表示
for token, label in zip(tokens, labels):
if token not in tokenizer.all_special_tokens:
print(f"{token:15} → {label}")
サンプル出力
Elon → B-PERSON
Musk → I-PERSON
launched → O
Tesla → B-ORG
in → O
California → B-GPE
on → O
March → B-DATE
2025 → I-DATE
. → O
必要条件
pip install transformers torch pandas pyarrow
- Python: 3.8以上
- ストレージ: モデルの重みに約15MB
- オプション: 評価に
seqeval
、GPUアクセラレーションにcuda
✨ 主な機能
モデルの詳細
説明
boltuix/EntityBERT
モデルは、boltuix/bert-mini
ベースモデルをベースに構築された、固有表現認識(NER) 用の軽量で微調整されたトランスフォーマーモデルです。効率性を重視して最適化されており、英語テキスト内の36種類のエンティティタイプ(人物、組織、場所、日付など)を識別できます。情報抽出、チャットボット、検索機能の強化などのアプリケーションに最適です。
- データセット: boltuix/conll2025-ner (143,709エントリ、6.38MB)
- エンティティタイプ: 36種類のNERタグ(18種類のエンティティカテゴリとB-/I-タグ + O)
- 学習例: 約115,812 | 検証: 約15,680 | テスト: 約12,217
- ドメイン: ニュース、ユーザー生成コンテンツ、研究コーパス
- タスク: 文レベルとドキュメントレベルのNER
- バージョン: v1.0
情報
- 開発者: Boltuix
- ライセンス: Apache-2.0
- 言語: 英語
- タイプ: トランスフォーマーベースのトークン分類
- 学習日: 2025年6月11日以前
- ベースモデル:
boltuix/bert-mini
- パラメータ: 約440万
- サイズ: 約15MB
リンク
- モデルリポジトリ: boltuix/EntityBERT (プレースホルダー、正しいURLで更新してください)
- データセット: boltuix/conll2025-ner (プレースホルダー、正しいURLで更新してください)
- Hugging Faceドキュメント: Transformers
- デモ: 近日公開
NERのユースケース
直接的なアプリケーション
- 情報抽出: 記事、ブログ、レポートから名前(👤 PERSON)、場所(🌍 GPE)、日付(🗓️ DATE)を識別します。
- チャットボットとバーチャルアシスタント: エンティティを認識することで、ユーザーのクエリ理解を向上させます。
- 検索機能の強化: エンティティベースの意味検索を可能にします(例: “2025年のパリに関するニュース”)。
- 知識グラフ: 🏢 ORGや👤 PERSONなどのエンティティを接続する構造化グラフを構築します。
下流タスク
- ドメイン適応: 医療 🩺、法律 📜、金融 💸 などの専門分野のNER用に微調整します。
- 多言語拡張: 英語以外の言語用に再学習します。
- カスタムエンティティ: ニッチなドメイン(例: 製品ID、株価銘柄)に適応させます。
制限事項
- 英語のみ: デフォルトでは英語テキストに限定されます。
- ドメインバイアス:
boltuix/conll2025-ner
で学習されており、ニュースや正式なテキストに有利な傾向があり、非公式またはソーシャルメディアのコンテンツでは性能が低下する可能性があります。 - 汎化能力: データセットに含まれていないまれなまたは高度に文脈依存するエンティティの識別に苦労する可能性があります。
📦 インストール
pip install transformers torch pandas pyarrow seqeval
- Python: 3.8以上
- ストレージ: モデルに約15MB、データセットに約6.38MB
- オプション: GPUアクセラレーションにNVIDIA CUDA
ダウンロード手順 📥
- モデル: boltuix/EntityBERT
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# モデルとトークナイザーをロード
tokenizer = AutoTokenizer.from_pretrained("boltuix/EntityBERT")
model = AutoModelForTokenClassification.from_pretrained("boltuix/EntityBERT")
# 入力テキスト
text = "Elon Musk launched Tesla in California on March 2025."
inputs = tokenizer(text, return_tensors="pt")
# 推論を実行
with torch.no_grad():
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=-1)
# 予測をラベルにマッピング
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
label_map = model.config.id2label
labels = [label_map[p.item()] for p in predictions[0]]
# 結果を表示
for token, label in zip(tokens, labels):
if token not in tokenizer.all_special_tokens:
print(f"{token:15} → {label}")
📚 ドキュメント
エンティティラベル
このモデルは、boltuix/conll2025-ner
データセットの36種類のNERタグをサポートしており、BIOタグ付け方式 を使用しています。
- B-: エンティティの開始
- I-: エンティティの内部
- O: エンティティ外
タグ名 | 目的 | 絵文字 |
---|---|---|
O | 任意の固有表現の外(例: “the”、“is”) | 🚫 |
B-CARDINAL | 基数の開始(例: “1000”) | 🔢 |
B-DATE | 日付の開始(例: “January”) | 🗓️ |
B-EVENT | イベントの開始(例: “Olympics”) | 🎉 |
B-FAC | 施設の開始(例: “Eiffel Tower”) | 🏛️ |
B-GPE | 地理政治的エンティティの開始(例: “Tokyo”) | 🌍 |
B-LANGUAGE | 言語の開始(例: “Spanish”) | 🗣️ |
B-LAW | 法律または法的文書の開始(例: “Constitution”) | 📜 |
B-LOC | GPEではない場所の開始(例: “Pacific Ocean”) | 🗺️ |
B-MONEY | 貨幣価値の開始(例: “$100”) | 💸 |
B-NORP | 国籍/宗教/政治グループの開始(例: “Democrat”) | 🏳️ |
B-ORDINAL | 序数の開始(例: “first”) | 🥇 |
B-ORG | 組織の開始(例: “Microsoft”) | 🏢 |
B-PERCENT | パーセンテージの開始(例: “50%”) | 📊 |
B-PERSON | 人物の名前の開始(例: “Elon Musk”) | 👤 |
B-PRODUCT | 製品の開始(例: “iPhone”) | 📱 |
B-QUANTITY | 数量の開始(例: “two liters”) | ⚖️ |
B-TIME | 時間の開始(例: “noon”) | ⏰ |
B-WORK_OF_ART | 芸術作品の開始(例: “Mona Lisa”) | 🎨 |
I-CARDINAL | 基数の内部 | 🔢 |
I-DATE | 日付の内部(例: “2025” in “January 2025”) | 🗓️ |
I-EVENT | イベント名の内部 | 🎉 |
I-FAC | 施設名の内部 | 🏛️ |
I-GPE | 地理政治的エンティティの内部 | 🌍 |
I-LANGUAGE | 言語名の内部 | 🗣️ |
I-LAW | 法的文書のタイトルの内部 | 📜 |
I-LOC | 場所の内部 | 🗺️ |
I-MONEY | 貨幣価値の内部 | 💸 |
I-NORP | NORPエンティティの内部 | 🏳️ |
I-ORDINAL | 序数の内部 | 🥇 |
I-ORG | 組織名の内部 | 🏢 |
I-PERCENT | パーセンテージの内部 | 📊 |
I-PERSON | 人物の名前の内部 | 👤 |
I-PRODUCT | 製品名の内部 | 📱 |
I-QUANTITY | 数量の内部 | ⚖️ |
I-TIME | 時間表現の内部 | ⏰ |
I-WORK_OF_ART | 芸術作品のタイトルの内部 | 🎨 |
例:
テキスト: "Tesla opened in Shanghai on April 2025"
タグ: [B-ORG, O, O, B-GPE, O, B-DATE, I-DATE]
パフォーマンス
seqeval
を使用して、boltuix/conll2025-ner
のテスト分割(約12,217例)で評価されました。
指標 | スコア |
---|---|
🎯 精度 | 0.84 |
🕸️ 再現率 | 0.86 |
🎶 F1スコア | 0.85 |
✅ 正解率 | 0.91 |
注: パフォーマンスは、異なるドメインまたはテキストタイプで異なる場合があります。
学習設定
- ハードウェア: NVIDIA GPU
- 学習時間: 約1.5時間
- パラメータ: 約440万
- オプティマイザー: AdamW
- 精度: FP32
- バッチサイズ: 16
- 学習率: 2e-5
モデルの学習
boltuix/bert-mini
をboltuix/conll2025-ner
データセットで微調整して、EntityBERT
を再現または拡張できます。以下は簡略化された学習スクリプトです。
# 🛠️ Step 1: Install required libraries quietly
!pip install evaluate transformers datasets tokenizers seqeval pandas pyarrow -q
# 🚫 Step 2: Disable Weights & Biases (WandB)
import os
os.environ["WANDB_MODE"] = "disabled"
# 📚 Step 2: Import necessary libraries
import pandas as pd
import datasets
import numpy as np
from transformers import BertTokenizerFast
from transformers import DataCollatorForTokenClassification
from transformers import AutoModelForTokenClassification
from transformers import TrainingArguments, Trainer
import evaluate
from transformers import pipeline
from collections import defaultdict
import json
# 📥 Step 3: Load the CoNLL-2025 NER dataset from Parquet
# Download : https://huggingface.co/datasets/boltuix/conll2025-ner/blob/main/conll2025_ner.parquet
parquet_file = "conll2025_ner.parquet"
df = pd.read_parquet(parquet_file)
# 🔍 Step 4: Convert pandas DataFrame to Hugging Face Dataset
conll2025 = datasets.Dataset.from_pandas(df)
# 🔎 Step 5: Inspect the dataset structure
print("Dataset structure:", conll2025)
print("Dataset features:", conll2025.features)
print("First example:", conll2025[0])
# 🏷️ Step 6: Extract unique tags and create mappings
# Since ner_tags are strings, collect all unique tags
all_tags = set()
for example in conll2025:
all_tags.update(example["ner_tags"])
unique_tags = sorted(list(all_tags)) # Sort for consistency
num_tags = len(unique_tags)
tag2id = {tag: i for i, tag in enumerate(unique_tags)}
id2tag = {i: tag for i, tag in enumerate(unique_tags)}
print("Number of unique tags:", num_tags)
print("Unique tags:", unique_tags)
# 🔧 Step 7: Convert string ner_tags to indices
def convert_tags_to_ids(example):
example["ner_tags"] = [tag2id[tag] for tag in example["ner_tags"]]
return example
conll2025 = conll2025.map(convert_tags_to_ids)
# 📊 Step 8: Split dataset based on 'split' column
dataset_dict = {
"train": conll2025.filter(lambda x: x["split"] == "train"),
"validation": conll2025.filter(lambda x: x["split"] == "validation"),
"test": conll2025.filter(lambda x: x["split"] == "test")
}
conll2025 = datasets.DatasetDict(dataset_dict)
print("Split dataset structure:", conll2025)
# 🪙 Step 9: Initialize the tokenizer
tokenizer = BertTokenizerFast.from_pretrained("boltuix/bert-mini")
# 📝 Step 10: Tokenize an example text and inspect
example_text = conll2025["train"][0]
tokenized_input = tokenizer(example_text["tokens"], is_split_into_words=True)
tokens = tokenizer.convert_ids_to_tokens(tokenized_input["input_ids"])
word_ids = tokenized_input.word_ids()
print("Word IDs:", word_ids)
print("Tokenized input:", tokenized_input)
print("Length of ner_tags vs input IDs:", len(example_text["ner_tags"]), len(tokenized_input["input_ids"]))
# 🔄 Step 11: Define function to tokenize and align labels
def tokenize_and_align_labels(examples, label_all_tokens=True):
"""
Tokenize inputs and align labels for NER tasks.
Args:
examples (dict): Dictionary with tokens and ner_tags.
label_all_tokens (bool): Whether to label all subword tokens.
Returns:
dict: Tokenized inputs with aligned labels.
"""
tokenized_inputs = tokenizer(examples["tokens"], truncation=True, is_split_into_words=True)
labels = []
for i, label in enumerate(examples["ner_tags"]):
word_ids = tokenized_inputs.word_ids(batch_index=i)
previous_word_idx = None
label_ids = []
for word_idx in word_ids:
if word_idx is None:
label_ids.append(-100) # Special tokens get -100
elif word_idx != previous_word_idx:
label_ids.append(label[word_idx]) # First token of word gets label
else:
label_ids.append(label[word_idx] if label_all_tokens else -100) # Subwords get label or -100
previous_word_idx = word_idx
labels.append(label_ids)
tokenized_inputs["labels"] = labels
return tokenized_inputs
# 🧪 Step 12: Test the tokenization and label alignment
q = tokenize_and_align_labels(conll2025["train"][0:1])
print("Tokenized and aligned example:", q)
# 📋 Step 13: Print tokens and their corresponding labels
for token, label in zip(tokenizer.convert_ids_to_tokens(q["input_ids"][0]), q["labels"][0]):
print(f"{token:_<40} {label}")
# 🔧 Step 14: Apply tokenization to the entire dataset
tokenized_datasets = conll2025.map(tokenize_and_align_labels, batched=True)
# 🤖 Step 15: Initialize the model with the correct number of labels
model = AutoModelForTokenClassification.from_pretrained("boltuix/bert-mini", num_labels=num_tags)
# ⚙️ Step 16: Set up training arguments
args = TrainingArguments(
"boltuix/bert-ner",
eval_strategy="epoch", # Changed evaluation_strategy to eval_strategy
learning_rate=2e-5,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
num_train_epochs=1,
weight_decay=0.01,
report_to="none"
)
# 📊 Step 17: Initialize data collator for dynamic padding
data_collator = DataCollatorForTokenClassification(tokenizer)
# 📈 Step 18: Load evaluation metric
metric = evaluate.load("seqeval")
# 🏷️ Step 19: Set label list and test metric computation
label_list = unique_tags
print("Label list:", label_list)
example = conll2025["train"][0]
labels = [label_list[i] for i in example["ner_tags"]]
print("Metric test:", metric.compute(predictions=[labels], references=[labels]))
# 📉 Step 20: Define function to compute evaluation metrics
def compute_metrics(eval_preds):
"""
Compute precision, recall, F1, and accuracy for NER.
Args:
eval_preds (tuple): Predicted logits and true labels.
Returns:
dict: Evaluation metrics.
"""
pred_logits, labels = eval_preds
pred_logits = np.argmax(pred_logits, axis=2)
predictions = [
[label_list[p] for (p, l) in zip(prediction, label) if l != -100]
for prediction, label in zip(pred_logits, labels)
]
true_labels = [
[label_list[l] for (p, l) in zip(prediction, label) if l != -100]
for prediction, label in zip(pred_logits, labels)
]
results = metric.compute(predictions=predictions, references=true_labels)
return {
"precision": results["overall_precision"],
"recall": results["overall_recall"],
"f1": results["overall_f1"],
"accuracy": results["overall_accuracy"],
}
# 🚀 Step 21: Initialize and train the trainer
trainer = Trainer(
model,
args,
train_dataset=tokenized_datasets["train"],
eval_dataset=tokenized_datasets["validation"],
data_collator=data_collator,
tokenizer=tokenizer,
compute_metrics=compute_metrics
)
trainer.train()
# 💾 Step 22: Save the fine-tuned model
model.save_pretrained("boltuix/bert-ner")
tokenizer.save_pretrained("tokenizer")
# 🔗 Step 23: Update model configuration with label mappings
id2label = {str(i): label for i, label in enumerate(label_list)}
label2id = {label: str(i) for i, label in enumerate(label_list)}
config = json.load(open("boltuix/bert-ner/config.json"))
config["id2label"] = id2label
config["label2id"] = label2id
json.dump(config, open("boltuix/bert-ner/config.json", "w"))
# 🔄 Step 24: Load the fine-tuned model
model_fine_tuned = AutoModelForTokenClassification.from_pretrained("boltuix/bert-ner")
# 🛠️ Step 25: Create a pipeline for NER inference
nlp = pipeline("token-classification", model=model_fine_tuned, tokenizer=tokenizer)
# 📝 Step 26: Perform NER on an example sentence
example = "On July 4th, 2023, President Joe Biden visited the United Nations headquarters in New York to deliver a speech about international law and donated $5 million to relief efforts."
ner_results = nlp(example)
print("NER results for first example:", ner_results)
# 📍 Step 27: Perform NER on a property address and format output
example = "This page contains information about the property located at 1275 Kinnear Rd, Columbus, OH, 43212."
ner_results = nlp(example)
# 🧹 Step 28: Process NER results into structured entities
entities = defaultdict(list)
current_entity = ""
current_type = ""
for item in ner_results:
entity = item["entity"]
word = item["word"]
if word.startswith("##"):
current_entity += word[2:] # Handle subword tokens
elif entity.startswith("B-"):
if current_entity and current_type:
entities[current_type].append(current_entity.strip())
current_type = entity[2:].lower()
current_entity = word
elif entity.startswith("I-") and entity[2:].lower() == current_type:
current_entity += " " + word # Continue same entity
else:
if current_entity and current_type:
entities[current_type].append(current_entity.strip())
current_entity = ""
current_type = ""
# Append final entity if exists
if current_entity and current_type:
entities[current_type].append(current_entity.strip())
# 📤 Step 29: Output the final JSON
final_json = dict(entities)
print("Structured NER output:")
print(json.dumps(final_json, indent=2))
ヒント
- ハイパーパラメータ:
learning_rate
(1e-5から5e-5)またはnum_train_epochs
(2 - 5)を実験してみてください。 - GPU: より高速な学習に
fp16=True
を使用してください。 - カスタムデータ: カスタムNERデータセット用にスクリプトを修正してください。
予想される学習時間
- NVIDIA GPU(例: T4)で約115,812例、3エポック、バッチサイズ16で約1.5時間。
二酸化炭素排出量
- 排出量: 約40g CO₂eq(GPUで1.5時間の場合、ML Impactツールで推定)
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下でライセンスされています。
Indonesian Roberta Base Posp Tagger
MIT
これはインドネシア語RoBERTaモデルをファインチューニングした品詞タグ付けモデルで、indonluデータセットで訓練され、インドネシア語テキストの品詞タグ付けタスクに使用されます。
シーケンスラベリング
Transformers Other

I
w11wo
2.2M
7
Bert Base NER
MIT
BERTを微調整した命名エンティティ識別モデルで、4種類のエンティティ(場所(LOC)、組織(ORG)、人名(PER)、その他(MISC))を識別できます。
シーケンスラベリング English
B
dslim
1.8M
592
Deid Roberta I2b2
MIT
このモデルはRoBERTaをファインチューニングしたシーケンスラベリングモデルで、医療記録内の保護対象健康情報(PHI/PII)を識別・除去します。
シーケンスラベリング
Transformers Supports Multiple Languages

D
obi
1.1M
33
Ner English Fast
Flairに組み込まれた英語の高速4クラス固有表現認識モデルで、Flair埋め込みとLSTM-CRFアーキテクチャを使用し、CoNLL-03データセットで92.92のF1スコアを達成しています。
シーケンスラベリング
PyTorch English
N
flair
978.01k
24
French Camembert Postag Model
Camembert-baseをベースとしたフランス語の品詞タグ付けモデルで、free-french-treebankデータセットを使用して学習されました。
シーケンスラベリング
Transformers French

F
gilf
950.03k
9
Xlm Roberta Large Ner Spanish
XLM - Roberta - largeアーキテクチャに基づいて微調整されたスペイン語の命名エンティティ認識モデルで、CoNLL - 2002データセットで優れた性能を発揮します。
シーケンスラベリング
Transformers Spanish

X
MMG
767.35k
29
Nusabert Ner V1.3
MIT
NusaBert-v1.3を基にインドネシア語NERタスクでファインチューニングした固有表現認識モデル
シーケンスラベリング
Transformers Other

N
cahya
759.09k
3
Ner English Large
Flairフレームワークに組み込まれた英語の4種類の大型NERモデルで、文書レベルのXLM - R埋め込みとFLERT技術に基づいており、CoNLL - 03データセットでF1スコアが94.36に達します。
シーケンスラベリング
PyTorch English
N
flair
749.04k
44
Punctuate All
MIT
xlm - roberta - baseを微調整した多言語句読点予測モデルで、12種類の欧州言語の句読点自動補完に対応しています。
シーケンスラベリング
Transformers

P
kredor
728.70k
20
Xlm Roberta Ner Japanese
MIT
xlm-roberta-baseをファインチューニングした日本語固有表現認識モデル
シーケンスラベリング
Transformers Supports Multiple Languages

X
tsmatz
630.71k
25
Featured Recommended AI Models
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers Supports Multiple Languages

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers English

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム Chinese
R
uer
2,694
98