Skip to content

Commit 6e7ca65

Browse files
committed
Adds new parameters and request examples for chunking settings object
1 parent cd83682 commit 6e7ca65

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

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: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,33 @@ export class InferenceChunkingSettings {
288288
*/
289289
sentence_overlap?: integer
290290
/**
291-
* The chunking strategy: `sentence`, `word`, `none` or `recursive`. Learn more about chunking strategies in the External documentation.
291+
* This parameter is only applicable when using the `recursive` chunking strategy.
292+
*
293+
* Sets a predefined list of separators in the saved chunking settings based on the selected text type.
294+
* Values can be `markdown` or `plaintext`.
295+
*
296+
* Using this parameter is an alternative to manually specifying a custom `separators` list.
297+
*/
298+
separator_group: string
299+
/**
300+
* A list of strings used as possible split points when chunking text with the `recursive` strategy.
301+
*
302+
* Each string can be a plain string or a regular expression (regex) pattern.
303+
* The system tries each separator in order to split the text, starting from the first item in the list.
304+
*
305+
* After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
306+
* the `max_chunk_size` limit, to reduce the total number of chunks generated.
307+
*/
308+
separators: string[]
309+
/**
310+
* The chunking strategy: `sentence`, `word`, `none` or `recursive`.
311+
*
312+
* * If `strategy` is set to `recursive`, you must also specify:
313+
*
314+
* - `max_chunk_size`
315+
* - either `separators` or`separator_group`
316+
*
317+
* Learn more about different chunking strategies in the External documentation.
292318
* @server_default sentence
293319
* @ext_doc_id chunking-strategies
294320
*/

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ 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
}
1115
alternatives:
1216
- language: Python
@@ -19,6 +23,11 @@ alternatives:
1923
"service_settings": {
2024
"model_id": "rerank-english-v3.0",
2125
"api_key": "{{COHERE_API_KEY}}"
26+
},
27+
"chunking_settings": {
28+
"strategy": "recursive",
29+
"max_chunk_size": 200,
30+
"separator_group": "markdown"
2231
}
2332
},
2433
)
@@ -33,6 +42,11 @@ alternatives:
3342
model_id: "rerank-english-v3.0",
3443
api_key: "{{COHERE_API_KEY}}",
3544
},
45+
chunking_settings: {
46+
strategy: "recursive",
47+
max_chunk_size: 200,
48+
separator_group: "markdown"
49+
}
3650
},
3751
});
3852
- language: Ruby
@@ -45,6 +59,11 @@ alternatives:
4559
"service_settings": {
4660
"model_id": "rerank-english-v3.0",
4761
"api_key": "{{COHERE_API_KEY}}"
62+
},
63+
"chunking_settings": {
64+
"strategy": "recursive",
65+
"max_chunk_size": 200,
66+
"separator_group": "markdown"
4867
}
4968
}
5069
)
@@ -59,12 +78,17 @@ alternatives:
5978
"model_id" => "rerank-english-v3.0",
6079
"api_key" => "{{COHERE_API_KEY}}",
6180
],
81+
"chunking_settings" => [
82+
"strategy" => "recursive",
83+
"max_chunk_size" => 200,
84+
"separator_group" => "markdown"
85+
]
6286
],
6387
]);
6488
- language: curl
6589
code:
6690
'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
67-
''{"service":"cohere","service_settings":{"model_id":"rerank-english-v3.0","api_key":"{{COHERE_API_KEY}}"}}''
91+
''{"service":"cohere","service_settings":{"model_id":"rerank-english-v3.0","api_key":"{{COHERE_API_KEY}}"},"chunking_settings":{"strategy":"recursive","max_chunk_size":200,"separator_group":"markdown"}}''
6892
"$ELASTICSEARCH_URL/_inference/rerank/my-rerank-model"'
6993
- language: Java
7094
code: |
@@ -75,4 +99,7 @@ alternatives:
7599
.service("cohere")
76100
.serviceSettings(JsonData.fromJson("{\"model_id\":\"rerank-english-v3.0\",\"api_key\":\"{{COHERE_API_KEY}}\"}"))
77101
)
102+
.chunkingSettings(JsonData.fromJson(
103+
"{\"strategy\":\"recursive\",\"max_chunk_size\":200,\"separator_group\":\"markdown\"}"
104+
))
78105
);

0 commit comments

Comments
 (0)