You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 340bb34
Browse filesBrowse the repository at this point in the historyBrowse files
docs(knowledge): one passage per unit recipe; name chunk_target the longest passage
Teach the markdown split's one-passage-per-unit shape in the knowledge
guide (one heading per unit, a derived field on the same record that
carries the index text, an optional top heading naming the document,
minChars as the merge threshold of a unit that does not fit), with a
pointer from the protocol's split section. Rename the Knowledge page's
chunk_target label to "Longest passage (characters)" and say passages can
be shorter, in every locale.
Claude-Session: https://claude.ai/code/session_01FEkQ5mDidoPNcFwxVX65bA
Co-Authored-By: Claude <noreply@anthropic.com>
fix(service-settings): the Knowledge page names `chunk_target` for what it is, the longest passage
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The Knowledge settings page labelled `knowledge.chunk_target`**Target chunk size**, while its help text, and the splitter that reads it, treat it as a maximum: no passage is longer, and many are shorter (under the `markdown` split, a section that fits is one passage of whatever length it has). The label now reads **Longest passage (characters)**, and the help text adds that passages can be shorter, in every locale the page ships (en, zh-CN, zh-Hant, ja-JP, ko, de, es-ES, fr, pt-BR, ru, ar). Earlier notes that name **Target chunk size** (the splitter, the knowledge skill) mean this same setting under its old label. The key, its default (800), its bounds and what reads it are unchanged.
11
+
12
+
What to do: nothing. A script or seed that writes `knowledge.chunk_target` keeps working.
Copy file name to clipboardExpand all lines: content/docs/ai/knowledge-rag.mdx
+46-1Lines changed: 46 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,7 +258,52 @@ source: {
258
258
-`markdown` cuts one section per heading; each passage begins with its heading path, which is embedded with it. A section that fits in one passage (its text together with the heading path it is given, within the length below) is one passage; only a section that does not fit is cut as `recursive` cuts, and `minChars` (default 200) merges the short pieces of that cut.
259
259
-`whole` keeps each document as one passage.
260
260
261
-
A passage is at most `split.maxChars` characters — else the **Knowledge → Target chunk size** setting, else 800 — and, when the adapter reports its embedder's input limit, within 80% of that limit by the shared token estimate below. A `whole` document over that budget is **removed from the index and reported** (`failed` and `failures` on the reindex result, an `error` log on the event sync), never truncated; because the estimate runs high, a `whole` document can use about 60% of the model's limit. The full rules are in [the protocol's split section](/docs/protocol/knowledge#35-the-split).
261
+
A passage is at most `split.maxChars` characters — else the **Knowledge → Longest passage** setting, else 800 — and, when the adapter reports its embedder's input limit, within 80% of that limit by the shared token estimate below. A `whole` document over that budget is **removed from the index and reported** (`failed` and `failures` on the reindex result, an `error` log on the event sync), never truncated; because the estimate runs high, a `whole` document can use about 60% of the model's limit. The full rules are in [the protocol's split section](/docs/protocol/knowledge#35-the-split).
262
+
263
+
### One passage per unit
264
+
265
+
Policies, regulations, contracts and manuals are made of units: an article, a numbered section, a question with its answer. A hit is most useful when it is one whole unit: not half of one, and not three of them. The `markdown` strategy gives exactly that once each unit is its own heading:
266
+
267
+
-**One heading per unit.** Write each unit as a Markdown heading at the start of its line (`## Article 12 Air travel`), with the unit's text under it. Bold text such as `**Article 12**` is not a heading, so every article under one real heading would share that one section. Keep a unit's sub-items as list items or plain lines, not headings: a sub-heading starts a section of its own, and with it a passage of its own.
268
+
-**A unit that fits is one passage.** When a unit's text together with its heading path fits within the passage length above, it is one passage, whatever `minChars` is. A table and the note right after it, written inside the same unit, stay in that passage.
269
+
-**A passage never holds two units.** Each section is split on its own, so short neighbouring units are never merged, and every passage begins with its unit's heading path (shortened when it is long, see below; the hit carries all of it as `headingPath`).
270
+
-**A unit that does not fit** is cut as `recursive` cuts, its pieces merged up to `minChars`, and every piece still begins with the unit's heading path. A table too long for one passage is cut between rows, each piece repeating the header row; a note after the table can then land in a different piece than the rows it explains.
271
+
-**`minChars` only merges the pieces of a unit that does not fit.** It is the merge threshold for that cut: pieces shorter than it are joined up to it. It is not a switch for one passage per unit, which needs no setting, and `minChars: 0` turns nothing off: a unit that fits is still one passage, and only the pieces of a unit that does not fit are left unmerged.
272
+
273
+
Most apps do not store their text in that shape: articles are bold paragraphs, or the text lives in rich text. Keep it as it is, and give the same record a second text field that holds the index text, the same content rewritten with one heading per unit, filled by the app each time the record is saved (in a record hook, for example). List only that field in `content`:
274
+
275
+
```ts
276
+
source: {
277
+
kind: 'object',
278
+
object: 'policy',
279
+
content: ['index_text'], // the derived field alone
280
+
metadataFields: ['department', 'status'],
281
+
split: { strategy: 'markdown', maxChars: 800 },
282
+
}
283
+
```
284
+
285
+
Keeping the index text on the same record, rather than in a second object with one row per unit, means a hit names the record people open, the search re-checks that record as the asking user, and `where` and `metadataFields` read the record's own fields. There is no second object to secure, keep in step with the first, or delete with it. The field is indexed like any other content field: its text is sent to the embedder, and a credential or internal field is never indexed.
286
+
287
+
**An optional top heading names the document.** The text the embedder sees is the passage: neither the record's title nor the department that owns it is in it unless the text says so. Starting the index text with one top-level heading that names them, with every unit one level below it, makes each passage's heading path begin with that heading:
288
+
289
+
```md
290
+
# Group travel policy · Finance department
291
+
292
+
## Article 1 Scope
293
+
Applies to every employee travelling on company business.
294
+
295
+
## Article 7 Hotel limits
296
+
| Region | Limit per night |
297
+
|---|---|
298
+
| Region 1 | 600 |
299
+
| Region 2 | 450 |
300
+
301
+
Region 1 means Beijing, Shanghai, Guangzhou and Shenzhen.
302
+
```
303
+
304
+
Article 7 is then one passage that begins `Group travel policy · Finance department > Article 7 Hotel limits`, the table and its note together, and a question that names the policy or the department matches it. Keep the top heading short: a heading path is written into the passage whole only while it leaves at least half of the passage length for text, and otherwise shortens to the unit's own heading (the hit's `headingPath` still lists all of it). A title that is already in the top heading needs no second `content` entry: a field listed before the index text would become a passage of its own, ahead of the first heading.
305
+
306
+
Moving an existing source to this shape changes its `content` and `split`, so its index is rebuilt once ([below](#when-the-model-or-the-split-changes-rebuild)), and the rebuild sends the whole source to the embedding provider again.
description: "Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model's input limit can lower it."},
75
+
description: "The longest a passage can be, in characters, when the knowledge service splits a document; passages can be shorter. A size set on a knowledge source itself wins; the embedding model's input limit can lower it."},
help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.',
689
+
label: 'أقصى طول للمقطع (أحرف)',
690
+
help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند، وقد تكون المقاطع أقصر. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.',
Copy file name to clipboardExpand all lines: packages/services/service-settings/src/translations/de.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -722,8 +722,8 @@ export const de: PlatformTranslationData = {
722
722
},
723
723
keys: {
724
724
chunk_target: {
725
-
label: 'Ziel-Chunkgröße (Zeichen)',
726
-
help: 'Längste Passage in Zeichen, wenn der Wissensdienst ein Dokument aufteilt. Eine an der Wissensquelle selbst gesetzte Größe hat Vorrang; das Eingabelimit des Embedding-Modells kann den Wert senken.',
725
+
label: 'Längste Passage (Zeichen)',
726
+
help: 'Längste Passage in Zeichen, wenn der Wissensdienst ein Dokument aufteilt; Passagen können kürzer sein. Eine an der Wissensquelle selbst gesetzte Größe hat Vorrang; das Eingabelimit des Embedding-Modells kann den Wert senken.',
help: 'Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model\'s input limit can lower it.'},
help: 'The longest a passage can be, in characters, when the knowledge service splits a document; passages can be shorter. A size set on a knowledge source itself wins; the embedding model\'s input limit can lower it.'},
description: 'Un valor definido en la propia fuente de conocimiento prevalece sobre estos valores predeterminados.'},
589
589
},
590
590
keys: {
591
-
chunk_target: {label: 'Tamaño objetivo de fragmento (caracteres)',
592
-
help: 'Longitud máxima de un pasaje, en caracteres, cuando el servicio de conocimiento divide un documento. Un tamaño fijado en la propia fuente tiene prioridad; el límite de entrada del modelo de embeddings puede reducirlo.'},
591
+
chunk_target: {label: 'Pasaje más largo (caracteres)',
592
+
help: 'Longitud máxima de un pasaje, en caracteres, cuando el servicio de conocimiento divide un documento; los pasajes pueden ser más cortos. Un tamaño fijado en la propia fuente tiene prioridad; el límite de entrada del modelo de embeddings puede reducirlo.'},
help: 'Longueur maximale d’un passage, en caractères, lorsque le service de connaissances découpe un document. Une taille fixée sur la source elle-même l’emporte ; la limite d’entrée du modèle d’embedding peut l’abaisser.',
734
+
label: 'Passage le plus long (caractères)',
735
+
help: 'Longueur maximale d’un passage, en caractères, lorsque le service de connaissances découpe un document ; un passage peut être plus court. Une taille fixée sur la source elle-même l’emporte ; la limite d’entrée du modèle d’embedding peut l’abaisser.',
0 commit comments