Show HN: Chonky – 텍스트 의미론적 청킹을 위한 신경망 접근 방식
요약
Chonky는 파인튜닝된 트랜스포머 모델을 활용하여 텍스트를 의미론적으로(semantically) 가장 적절한 청크(chunk)로 자동 분할하는 Python 라이브러리입니다. RAG (Retrieval-Augmented Generation) 시스템의 성능 향상에 필수적인 핵심 컴포넌트입니다. 사용자는 `ParagraphSplitter` 클래스를 통해 텍스트를 입력하고, 모델이 문맥적 의미 경계를 파악하여 고품질의 청크 배열을 얻을 수 있습니다. 특히 마크다운(markdown), XML, HTML 등 다양한 형식의 구조화된 문서에서
핵심 포인트
- Chonky는 트랜스포머 모델 기반으로 텍스트를 의미론적 청크로 분할하며, RAG 시스템에 최적화되어 있습니다.
- 다양한 형식(Markdown, XML, HTML)을 지원하는 `MarkupRemover` 클래스를 통해 구조화된 문서에서 순수 텍스트 추출이 용이합니다.
- 최신 모델인 `mirth/chonky_mmbert_small_multilingual_1`은 다국어 성능(예: 스페인어 0.91, 러시아어 0.97)에서 높은 수치를 기록했습니다.
- 성능 지표를 보면 Chonky의 모델들이 기존 SaT (Semantic Text Splitter)나 LangChain 등 다른 라이브러리 대비 월등히 높은 F1 점수를 보여줍니다.
Chonky는 파인튜닝된 트랜스포머 모델(transformer model)을 사용하여 텍스트를 의미 있는 의미론적 청크(semantic chunks)로 지능적으로 분할하는 Python 라이브러리입니다. 이 라이브러리는 RAG 시스템에 사용될 수 있습니다.
pip install chonky
from chonky import ParagraphSplitter
# 첫 실행 시 트랜스포머 모델을 다운로드합니다.
splitter = ParagraphSplitter(device="cpu")
# 또는 모델을 선택할 수 있습니다.
# 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.
The 사용 패턴은 다음과 같습니다: 모든 마크업 태그(markup tags)를 제거하여 순수 텍스트(pure text)를 생성한 다음 이 텍스트를 스플리터에 공급합니다. 이를 위해 헬퍼 클래스인 MarkupRemover가 있습니다 (이는 콘텐츠 형식을 자동으로 감지합니다):
from
AI 자동 생성 콘텐츠
본 콘텐츠는 HN AI Engineering의 원문을 AI가 자동으로 요약·번역·분석한 것입니다. 원 저작권은 원저작자에게 있으며, 정확한 내용은 반드시 원문을 확인해 주세요.
원문 바로가기