🚀 モダンBERT-large v1の強力なバージョン
Chonky は、テキストを意味のあるセマンティックなチャンクに賢く分割するトランスフォーマーモデルです。このモデルはRAGシステムで使用できます。
🚀 クイックスタート
このモデルは、テキストを処理して意味的にまとまりのあるセグメントに分割します。これらのチャンクは、RAGパイプラインの一部として、埋め込みベースの検索システムや言語モデルに入力できます。
⚠️ 重要提示
このモデルはシーケンス長1024で微調整されています(デフォルトではModernBERTは最大8192のシーケンス長をサポートします)。
✨ 主な機能
このモデルは、テキストを意味のあるチャンクに分割することができ、RAGシステムに適用可能です。
📦 インストール
このモデル用の小さなPythonライブラリを作成しました: chonky
💻 使用例
基本的な使用法
from chonky import ParagraphSplitter
splitter = ParagraphSplitter(
model_id="mirth/chonky_modernbert_large_1",
device="cpu"
)
text = """Before college the two main things I worked on, outside of school, were writing and programming. I didn't write essays. I wrote what beginning writers were supposed to write then, and probably still are: short stories. My stories were awful. They had hardly any plot, just characters with strong feelings, which I imagined made them deep. The first programs I tried writing were on the IBM 1401 that our school district used for what was then called "data processing." This was in 9th grade, so I was 13 or 14. The school district's 1401 happened to be in the basement of our junior high school, and my friend Rich Draves and I got permission to use it. It was like a mini Bond villain's lair down there, with all these alien-looking machines — CPU, disk drives, printer, card reader — sitting up on a raised floor under bright fluorescent lights."""
for chunk in splitter(text):
print(chunk)
print("--")
サンプル出力
Before college the two main things I worked on, outside of school, were writing and programming. I didn't write essays. I wrote what beginning writers were supposed to write then, and probably still are: short stories.
--
My stories were awful. They had hardly any plot, just characters with strong feelings, which I imagined made them deep. The first programs I tried writing were on the IBM 1401 that our school district used for what was then called "data processing."
--
This was in 9th grade, so I was 13 or 14. The school district's 1401 happened to be in the basement of our junior high school, and my friend Rich Draves and I got permission to use it.
--
It was like a mini Bond villain's lair down there, with all these alien-looking machines — CPU, disk drives, printer, card reader — sitting up on a raised floor under bright fluorescent lights.
--
高度な使用法
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
model_name = "mirth/chonky_modernbert_large_1"
tokenizer = AutoTokenizer.from_pretrained(model_name, model_max_length=1024)
id2label = {
0: "O",
1: "separator",
}
label2id = {
"O": 0,
"separator": 1,
}
model = AutoModelForTokenClassification.from_pretrained(
model_name,
num_labels=2,
id2label=id2label,
label2id=label2id,
)
pipe = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
text = """Before college the two main things I worked on, outside of school, were writing and programming. I didn't write essays. I wrote what beginning writers were supposed to write then, and probably still are: short stories. My stories were awful. They had hardly any plot, just characters with strong feelings, which I imagined made them deep. The first programs I tried writing were on the IBM 1401 that our school district used for what was then called "data processing." This was in 9th grade, so I was 13 or 14. The school district's 1401 happened to be in the basement of our junior high school, and my friend Rich Draves and I got permission to use it. It was like a mini Bond villain's lair down there, with all these alien-looking machines — CPU, disk drives, printer, card reader — sitting up on a raised floor under bright fluorescent lights."""
pipe(text)
サンプル出力
[
{'entity_group': 'separator', 'score': np.float32(0.91590524), 'word': ' stories.', 'start': 209, 'end': 218},
{'entity_group': 'separator', 'score': np.float32(0.6210419), 'word': ' processing."', 'start': 455, 'end': 468},
{'entity_group': 'separator', 'score': np.float32(0.7071036), 'word': '.', 'start': 652, 'end': 653}
]
📚 ドキュメント
学習データ
このモデルは、minipileとbookcorpusデータセットの段落を分割するように学習されています。
評価指標
minipileのトークンベースの評価指標:
指標 |
値 |
F1 |
0.85 |
精度 |
0.87 |
再現率 |
0.82 |
正解率 |
0.99 |
bookcorpusのトークンベースの評価指標:
指標 |
値 |
F1 |
0.79 |
精度 |
0.85 |
再現率 |
0.74 |
正解率 |
0.99 |
ハードウェア
このモデルは、単一のH100で数時間微調整されました。
📄 ライセンス
このモデルはMITライセンスの下で提供されています。