This strategy aims to improve the accuracy and context of retrieved content by balancing the use of smaller and larger text chunks during ingestion and synthesis.
The default ingestion process embeds a large text chunk for retrieval and uses the same chunk for synthesis. This approach can sometimes lead to inaccuracies and lack of context.
The Parent Document strategy addresses these limitations by:
-
This allows for more precise semantic similarity matching based on user queries. Smaller chunks are stored in a vector store. These smaller chunks are called childDocuments. They are expected to contain information at the paragraph level.
-
This "parent" document, which can be a partial or complete document, is stored in a document store. This larger chunk is called parentDocument. It is expected to preserve a broader scope of information.
-
This ensures that the retrieved context is comprehensive and semantically rich, allowing the LLM responsible for synthesis to perform better.
-
Smaller chunks (childDocuments) allow for more accurate matching based on user queries.
-
Larger parent documents (parentDocuments) provide a broader understanding of the retrieved content.
-
The LLM has more context to work with, leading to more accurate and relevant responses.
Chunking is a balancing act. You want to:
- Split documents into small chunks: This improves semantic similarity but can lead to loss of meaning or context.
- Keep documents long enough: This preserves context and semantics, but may not be as accurate for similarity matching.
The Parent Document strategy strikes this balance by using small and large chunks (childDocuments and parentDocuments).
To enable the Parent Document strategy, configure the following settings:
- useParentDocument: Set this boolean parameter to true in the Profile Metadata.
- Parent configuration: Configure the parent chunking strategy in the Index Section.
- ChildDocument configuration: Configure the child chunking strategy in the Profile Metadata.
The parent chunking strategy is configured in the Index Section; the following elements apply:
Parameter |
Description |
ChunkSize |
The size of the parent document chunk in characters. The default value is 1000 characters. Consider increasing this value to 5000 or 10000 characters when using the Parent Document strategy. |
ChunkOverlap |
The overlap between parent document chunks. |
The child chunking strategy has to be configured using these parameters in the Profile Metadata:
Parameter |
Description |
childK |
Parameter to search for documents in the VectorStore based on customer query; note that this does not exactly correspond to the number of final documents retrieved, as multiple child documents can point to the same parent. This upper-bound parameter is set by the k parameter (Document Count) and limits the number of final documents returned. |
chunkSize |
Size of the chunk in number of characters. |
chunkOverlap |
Overlap between child chunks. |
- Ingestion Cost: The Parent Document strategy can increase ingestion time due to the additional processing required.
- Child Chunk Size: You can use chunk sizes between 300 and 800 characters for splitting child documents.
A valid configuration to be used with the RAG Assistant API to create an assistant with the ParentDocument strategy could be the following:
"indexOptions":{
"chunks":{
"chunkSize": 8000,
"chunkOverlap": 0
},
"useParentDocument": true,
"childDocument": {
"childK":20,
"child":{
"chunkSize":300,
"chunkOverlap":50
}
}
....
To activate the Parent Document strategy in the RAG Assistant in Globant Enterprise AI Backoffice, first, go to the RAG Assistant row where you want to apply this strategy. Once there, click on UPDATE to open the Assistant settings and select the Retrieval tab. In this section, add the following settings in the Profile Metadata field:
{
"chat": {
"retriever": {
"useParentDocument": true,
"childDocument": {
"childK": 20,
"child": {
"chunkSize": 300,
"chunkOverlap": 50
}
}
}
}
}
The setting "childK": 20 defines that 20 child chunks will be considered for each query, while "chunkSize": 300 states that each chunk will have a size of 300 characters, and "chunkOverlap": 50 indicates that there will be an overlap of 50 characters between consecutive chunks.
Next, in the Index section, configure the following:
This setting is aligned with the strategy of handling long documents (Chunk Size of 5000 characters) and captures a larger amount of relevant content through a higher overlap (Chunk Overlap of 100 characters). This is good for optimizing both performance and retrieval accuracy, but it is always advisable to adjust these values according to the specific needs and results observed in the context of your application.
RAG Assistants API