🚀 チョンキーディスティルベルトベース(アンケースド)v1
Chonky は、テキストを意味のあるセマンティックなチャンクに賢く分割するトランスフォーマーモデルです。このモデルはRAGシステムで使用できます。
🚀 クイックスタート
このモデルは、テキストを処理し、意味的にまとまったセグメントに分割します。これらのチャンクは、RAGパイプラインの一部として、埋め込みベースの検索システムや言語モデルに入力することができます。
✨ 主な機能
- テキストを意味のあるセマンティックなチャンクに分割する。
- RAGシステムでの使用が可能。
📦 インストール
このモデルには、小さなPythonライブラリ chonky が用意されています。
💻 使用例
基本的な使用法
from chonky import ParagraphSplitter
splitter = ParagraphSplitter(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("--")
高度な使用法
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
model_name = "mirth/chonky_distilbert_uncased_1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
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': 0.89515704, 'word': 'deep.', 'start': 333, 'end': 338},
{'entity_group': 'separator', 'score': 0.61160326, 'word': '.', 'start': 652, 'end': 653}
]
📚 ドキュメント
学習データ
このモデルは、bookcorpusデータセットの段落を分割するように学習されました。
評価指標
指標 |
値 |
F1 |
0.7 |
適合率 |
0.79 |
再現率 |
0.63 |
正解率 |
0.99 |
ハードウェア
モデルは2x1080tiでファインチューニングされました。
📄 ライセンス
このモデルはMITライセンスの下で提供されています。