🚀 Chonky modernbert base v1
Chonky は、テキストを意味のあるセマンティックなチャンクに賢く分割するトランスフォーマーモデルです。このモデルはRAGシステムで使用することができます。
🚀 クイックスタート
このモデルは、テキストを処理し、意味的に一貫したセグメントに分割します。これらのチャンクは、RAGパイプラインの一部として、埋め込みベースの検索システムや言語モデルに入力することができます。
⚠️ 重要提示
このモデルは、シーケンス長1024で微調整されています(デフォルトではModernBERTは最大8192のシーケンス長をサポートします)。
✨ 主な機能
- テキストを意味のあるセマンティックなチャンクに分割する機能。
- RAGシステムでの利用が可能。
💻 使用例
基本的な使用法
このモデルのための小さなPythonライブラリ chonky を作成しました。以下は使用例です。
from chonky import ParagraphSplitter
splitter = ParagraphSplitter(
model_id="mirth/chonky_modernbert_base_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.
--
高度な使用法
標準のNERパイプラインを使用してこのモデルを利用することもできます。
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
model_name = "mirth/chonky_modernbert_base_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}
]
📚 ドキュメント
学習データ
このモデルは、bookcorpusデータセットから段落を分割するように学習されています。
評価指標
トークンベースの評価指標は以下の通りです。
指標 |
値 |
F1 |
0.79 |
適合率 |
0.83 |
再現率 |
0.75 |
正解率 |
0.99 |
ハードウェア
このモデルは、単一のH100で数時間微調整されました。
📄 ライセンス
このモデルはMITライセンスの下で提供されています。