-
Hi Guys, i have been stuck with this, i hope someone can help me. Firstofall, you guys did a really good job building this package and its really helpful, also this is the first time i am seeking help (i am a new developer). Hope i get answer on this. So i have been trying to change the Node IDs (id_). from llama_index.core import SimpleDirectoryReader Now i have used the code below to successfully build nodes: from llama_index.core.node_parser import TokenTextSplitter But the thing is i can change Node IDs if i try something like: But i dont want to do something like this, because that way i am not able to change the node IDs in the "nodes[0].relationships". I also dont want to build nodes relationships from scratch because that is really confusing, otherwise i think we can specify the node IDs while manually constructing Nodes. But i dont want to build relationships manually which is confusing. So is their a way all these nodes IDs (the ones in the relationsips also) get updated while i use TokenTextSplitter and IngestionPipeline? or is their someother way to do this? Please help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
🤖 Hey @saadk8, great to see you diving into LlamaIndex and reaching out for help! Always here to lend a hand. I'm glad to hear that you're finding the LlamaIndex package useful. To change the Node IDs, you can provide your own function to the Here's an example of how you can do this: def my_id_func(index, document):
return f"my-new-node-id-{index}"
text_splitter = TokenTextSplitter(
separator="\n\nQuestion:",
chunk_size=512,
chunk_overlap=0,
id_func=my_id_func, # Use your custom function here
)
pipeline = IngestionPipeline(
transformations=[text_splitter],
)
nodes = pipeline.run(
documents=documents,
in_place=True,
show_progress=True,
) In this example, Please note that the You can find more information about this in the TokenTextSplitter class in the LlamaIndex repository. I hope this helps! If you have any other questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
🤖
Hey @saadk8, great to see you diving into LlamaIndex and reaching out for help! Always here to lend a hand.
I'm glad to hear that you're finding the LlamaIndex package useful. To change the Node IDs, you can provide your own function to the
id_func
parameter when you create an instance ofTokenTextSplitter
. This function will be used to generate the IDs for all nodes, including those in relationships.Here's an example of how you can do this: