Find answers from the community

Updated 2 years ago

can I specify separators for TokenTextSplitter?

@kapa.ai can I specify separators for TokenTextSplitter?
k
2 comments
Please stand by @Quentin as I search the knowledge base. We are experiencing especially high traffic right now and might take longer than usual. :wave:
----------------------
Yes, you can specify separators for TokenTextSplitter. In the provided extracts, you can see an example of specifying a separator when creating a TokenTextSplitter instance:

Plain Text
from gpt_index.langchain_helpers.text_splitter import TokenTextSplitter
text_splitter = TokenTextSplitter(separator=" ", chunk_size=2048, chunk_overlap=20)


In this example, the separator is set to a single space " ". You can change the separator parameter to any string you'd like to use as a separator.

Source: GitHub - InsertDemo.ipynb (https://github.com/jerryjliu/gpt_index/tree/main/examples/paul_graham_essay/InsertDemo.ipynb)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord