Skip to content

Commit 220fd40

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

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
@@ -87,6 +87,7 @@ ccr-put-follow,https://www.elastic.co/docs/api/doc/elasticsearch/operation/opera
8787
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,
8888
ccs-network-delays,https://www.elastic.co/docs/solutions/search/cross-cluster-search#ccs-network-delays,,
8989
ccs-privileges,https://www.elastic.co/docs/deploy-manage/remote-clusters/remote-clusters-cert#remote-clusters-privileges-ccs,,
90+
chunking-strategies,https://www.elastic.co/docs/explore-analyze/elastic-inference/inference-api#chunking-strategies,
9091
clean-up-snapshot-repo,https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore/self-managed#snapshots-repository-cleanup,,
9192
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,
9293
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
@@ -310,8 +310,35 @@ export class InferenceChunkingSettings {
310310
*/
311311
sentence_overlap?: integer
312312
/**
313-
* The chunking strategy: `sentence` or `word`.
313+
* This parameter is only applicable when using the `recursive` chunking strategy.
314+
*
315+
* Sets a predefined list of separators in the saved chunking settings based on the selected text type.
316+
* Values can be `markdown` or `plaintext`.
317+
*
318+
* Using this parameter is an alternative to manually specifying a custom `separators` list.
319+
*/
320+
separator_group: string
321+
/**
322+
* A list of strings used as possible split points when chunking text with the `recursive` strategy.
323+
*
324+
* Each string can be a plain string or a regular expression (regex) pattern.
325+
* The system tries each separator in order to split the text, starting from the first item in the list.
326+
*
327+
* After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
328+
* the `max_chunk_size` limit, to reduce the total number of chunks generated.
329+
*/
330+
separators: string[]
331+
/**
332+
* The chunking strategy: `sentence`, `word`, `none` or `recursive`.
333+
*
334+
* * If `strategy` is set to `recursive`, you must also specify:
335+
*
336+
* - `max_chunk_size`
337+
* - either `separators` or`separator_group`
338+
*
339+
* Learn more about different chunking strategies in the linked documentation.
314340
* @server_default sentence
341+
* @ext_doc_id chunking-strategies
315342
*/
316343
strategy?: string
317344
}

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)