IniziaInizia gratis

Getting started with text splitting

Time to start splitting! You've been provided with a statement about RAG stored in the string variable text. Your job is to split this string on occurrences of the '.' character. Take a look at the splitting results to see how this strategy performed.

Questo esercizio fa parte del corso

Retrieval Augmented Generation (RAG) with LangChain

Visualizza il corso

Istruzioni dell'esercizio

  • Define a LangChain character text splitter that will split on the '.' character with a chunk size of 75 and chunk overlap of 10.
  • Split text using the text_splitter you defined.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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])
Modifica ed esegui il codice