시작하기무료로 시작하기

텍스트 분할 시작하기

이제 분할을 시작해 볼까요? 문자열 변수 text에는 RAG에 대한 설명이 담겨 있어요. 이 문자열을 '.' 문자가 나타나는 위치를 기준으로 분할해 보세요. 분할 결과를 확인하여 이 전략이 어떻게 동작하는지 살펴보세요.

이 연습은 강의의 일부입니다

LangChain을 활용한 RAG(검색 증강 생성)

강의 보기

연습 안내

  • '.' 문자를 기준으로 분할하고, 청크 크기는 75, 청크 중첩은 10으로 하는 LangChain 문자 텍스트 스플리터를 정의하세요.
  • 정의한 text_splitter를 사용해 text를 분할하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

text = '''RAG (retrieval augmented generation) is an advanced NLP model that combines retrieval mechanisms with generative capabilities. RAG aims to improve the accuracy and relevance of its outputs by grounding responses in precise, contextually appropriate data.'''

# Define a text splitter that splits on the '.' character
text_splitter = ____(
    ____,
    ____,  
    ____  
)

# Split the text using text_splitter
chunks = text_splitter.____
print(chunks)
print([len(chunk) for chunk in chunks])
코드 편집 및 실행