RecursiveCharacterChunkModel
Chunking model that recursively splits text using a prioritized list of separators.
Falls back to character-level splitting when no separator fits within the chunk size.
Parameters
- chunk_size : integer, default=
1000 - Size of each chunk in characters.
- chunk_overlap : integer, default=
100 - Number of characters to overlap between chunks. Must be less than chunk_size.
- separators : array, default=
['\n\n', '\n', '.', ' ', ''] - Ordered list of separators to use for splitting.
Methods
chunk_text(self, text: str) -> List[str]
RecursiveCharacterChunkModelSplit text into chunks using recursive separator-based splitting.
chunk_document(self, document: DashAI.back.models.RAG.documents.base_document.BaseDocument) -> Dict[int, DashAI.back.models.RAG.documents.chunk.Chunk]
BaseChunkingModelChunk a single document using the chunk_text method.
chunk_documents(self) -> Dict[int, Dict[int, DashAI.back.models.RAG.documents.chunk.Chunk]]
BaseChunkingModelChunk documents using the chunk_document method.
compute_chunks(self) -> None
BaseChunkingModelCompute chunks if not already done.
get_chunks(self) -> Dict[int, Dict[int, DashAI.back.models.RAG.documents.chunk.Chunk]]
BaseChunkingModelGet the chunks generated by the chunking model.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_id(self) -> int
BaseChunkingModelGet the ID of the chunking model.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
set_id(self, id: int) -> None
BaseChunkingModelSet the ID of the chunking model.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.