Skip to content

Commit d893d08

Browse files
kosabogileemthompo
authored andcommitted
[9.1] Adds new 'none' and 'recursive' chunking strategies to Inference APIs (#4841)
* Adds new chunking strategies * Adds external link * Adds a sentence to point to the link * Resolves merge conflict * Update specification/inference/_types/Services.ts Co-authored-by: Liam Thompson <[email protected]> --------- Co-authored-by: Liam Thompson <[email protected]> (cherry picked from commit ba5cf21)
1 parent 58698ce commit d893d08

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

specification/_doc_ids/table.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ccr-put-follow,https://www.elastic.co/docs/api/doc/elasticsearch/operation/opera
8585
ccr-resume-auto-follow-pattern,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-resume-auto-follow-pattern,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/ccr-resume-auto-follow-pattern.html,
8686
ccs-network-delays,https://www.elastic.co/docs/solutions/search/cross-cluster-search#ccs-network-delays,,
8787
ccs-privileges,https://www.elastic.co/docs/deploy-manage/remote-clusters/remote-clusters-cert#remote-clusters-privileges-ccs,,
88+
chunking-strategies,https://www.elastic.co/docs/explore-analyze/elastic-inference/inference-api#chunking-strategies,
8889
clean-up-snapshot-repo,https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore/self-managed#snapshots-repository-cleanup,,
8990
clear-repositories-metering-archive-api,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-clear-repositories-metering-archive,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/clear-repositories-metering-archive-api.html,
9091
clear-scroll-api,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-clear-scroll,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/clear-scroll-api.html,

specification/_types/mapping/ChunkingSettings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import { OverloadOf } from '@spec_utils/behaviors'
2424
export class ChunkingSettings implements OverloadOf<InferenceChunkingSettings> {
2525
strategy: string
2626

27+
separator_group: string
28+
29+
separators: string[]
30+
2731
max_chunk_size: integer
2832

2933
overlap?: integer

specification/inference/_types/Services.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,35 @@ export class InferenceChunkingSettings {
298298
*/
299299
sentence_overlap?: integer
300300
/**
301-
* The chunking strategy: `sentence` or `word`.
301+
* This parameter is only applicable when using the `recursive` chunking strategy.
302+
*
303+
* Sets a predefined list of separators in the saved chunking settings based on the selected text type.
304+
* Values can be `markdown` or `plaintext`.
305+
*
306+
* Using this parameter is an alternative to manually specifying a custom `separators` list.
307+
*/
308+
separator_group: string
309+
/**
310+
* A list of strings used as possible split points when chunking text with the `recursive` strategy.
311+
*
312+
* Each string can be a plain string or a regular expression (regex) pattern.
313+
* The system tries each separator in order to split the text, starting from the first item in the list.
314+
*
315+
* After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
316+
* the `max_chunk_size` limit, to reduce the total number of chunks generated.
317+
*/
318+
separators: string[]
319+
/**
320+
* The chunking strategy: `sentence`, `word`, `none` or `recursive`.
321+
*
322+
* * If `strategy` is set to `recursive`, you must also specify:
323+
*
324+
* - `max_chunk_size`
325+
* - either `separators` or`separator_group`
326+
*
327+
* Learn more about different chunking strategies in the linked documentation.
302328
* @server_default sentence
329+
* @ext_doc_id chunking-strategies
303330
*/
304331
strategy?: string
305332
}

specification/inference/put/examples/request/InferencePutExample1.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ value: |-
77
"model_id": "rerank-english-v3.0",
88
"api_key": "{{COHERE_API_KEY}}"
99
}
10+
"chunking_settings": {
11+
"strategy": "recursive",
12+
"max_chunk_size": 200,
13+
"separator_group": "markdown"
1014
}

0 commit comments

Comments
 (0)