From 340bb34988ddd7fa35944f1ca573233f11ced52b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 03:29:46 +0000 Subject: [PATCH] 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 --- .../38290-longest-passage-setting-label.md | 12 +++++ content/docs/ai/knowledge-rag.mdx | 47 ++++++++++++++++++- content/docs/protocol/knowledge.mdx | 10 +++- .../src/manifests/knowledge.manifest.ts | 4 +- .../service-settings/src/translations/ar.ts | 4 +- .../service-settings/src/translations/de.ts | 4 +- .../service-settings/src/translations/en.ts | 4 +- .../src/translations/es-ES.ts | 4 +- .../service-settings/src/translations/fr.ts | 4 +- .../src/translations/ja-JP.ts | 4 +- .../service-settings/src/translations/ko.ts | 2 +- .../src/translations/pt-BR.ts | 4 +- .../service-settings/src/translations/ru.ts | 4 +- .../src/translations/zh-CN.ts | 2 +- .../src/translations/zh-Hant.ts | 2 +- 15 files changed, 88 insertions(+), 23 deletions(-) create mode 100644 .changeset/38290-longest-passage-setting-label.md diff --git a/.changeset/38290-longest-passage-setting-label.md b/.changeset/38290-longest-passage-setting-label.md new file mode 100644 index 00000000000..436dae1b9a3 --- /dev/null +++ b/.changeset/38290-longest-passage-setting-label.md @@ -0,0 +1,12 @@ +--- +'@objectstack/service-settings': patch +--- + +fix(service-settings): the Knowledge page names `chunk_target` for what it is, the longest passage + +Clause-②: no +Metadata-protocol: none + +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. + +What to do: nothing. A script or seed that writes `knowledge.chunk_target` keeps working. diff --git a/content/docs/ai/knowledge-rag.mdx b/content/docs/ai/knowledge-rag.mdx index d6809c20960..97046fc497a 100644 --- a/content/docs/ai/knowledge-rag.mdx +++ b/content/docs/ai/knowledge-rag.mdx @@ -258,7 +258,52 @@ source: { - `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. - `whole` keeps each document as one passage. -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). +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). + +### One passage per unit + +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: + +- **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. +- **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. +- **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`). +- **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. +- **`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. + +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`: + +```ts +source: { + kind: 'object', + object: 'policy', + content: ['index_text'], // the derived field alone + metadataFields: ['department', 'status'], + split: { strategy: 'markdown', maxChars: 800 }, +} +``` + +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. + +**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: + +```md +# Group travel policy · Finance department + +## Article 1 Scope +Applies to every employee travelling on company business. + +## Article 7 Hotel limits +| Region | Limit per night | +|---|---| +| Region 1 | 600 | +| Region 2 | 450 | + +Region 1 means Beijing, Shanghai, Guangzhou and Shenzhen. +``` + +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. + +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. ## Embedder input limits diff --git a/content/docs/protocol/knowledge.mdx b/content/docs/protocol/knowledge.mdx index ae52bbcea19..de76d516e74 100644 --- a/content/docs/protocol/knowledge.mdx +++ b/content/docs/protocol/knowledge.mdx @@ -583,7 +583,7 @@ closing quote or bracket: 「他说:“好。”然后」 stays one sentence. clause wherever it stands, `;` only before whitespace. **How long a passage may be.** `maxChars` is the source's `split.maxChars`, -else the settings page's **Knowledge → Target chunk size** +else the settings page's **Knowledge → Longest passage** (`knowledge.chunk_target`), else 800. And when the adapter reports its embedder's `maxInputTokens`, every passage's token estimate (the shared `estimateTokens` from `@objectstack/spec/shared`) also stays within **80%** of @@ -594,6 +594,14 @@ the pieces of a section that does not fit, so `minChars: 0` still leaves a fitting section whole. The splitter never overlaps passages. +**One passage per unit.** Under `markdown`, text written with one heading +per unit (an article, a numbered section, a question with its answer) gives +one passage per unit that fits, and no passage ever holds two units; it +needs no `minChars` setting. Text stored in another shape is indexed through a +derived field on the same record that carries that rewrite, optionally under +one top heading that names the document; the recipe is in +[the knowledge guide](/docs/ai/knowledge-rag#one-passage-per-unit). + **`whole` over the limit.** A `whole` document whose estimate is over the 80% budget is **removed from the index and reported, never truncated**: `reindexSource` counts it in `failed` and names it in `failures` diff --git a/packages/services/service-settings/src/manifests/knowledge.manifest.ts b/packages/services/service-settings/src/manifests/knowledge.manifest.ts index 3e33b0a381f..5f4d5c7ad0e 100644 --- a/packages/services/service-settings/src/manifests/knowledge.manifest.ts +++ b/packages/services/service-settings/src/manifests/knowledge.manifest.ts @@ -70,9 +70,9 @@ const manifest = { // ── Indexing defaults ───────────────────────────────────────── { type: 'group', id: 'indexing', label: 'Indexing defaults', required: false, description: 'A value set on a knowledge source itself wins over these defaults.' }, - { type: 'number', key: 'chunk_target', label: 'Target chunk size (chars)', + { type: 'number', key: 'chunk_target', label: 'Longest passage (characters)', required: false, default: 800, min: 64, max: 8192, - 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." }, + 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." }, ], }; diff --git a/packages/services/service-settings/src/translations/ar.ts b/packages/services/service-settings/src/translations/ar.ts index 17c49cf22aa..540abaf74fc 100644 --- a/packages/services/service-settings/src/translations/ar.ts +++ b/packages/services/service-settings/src/translations/ar.ts @@ -686,8 +686,8 @@ export const ar: PlatformTranslationData = { }, keys: { chunk_target: { - label: 'الحجم المستهدف للمقطع (أحرف)', - help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.', + label: 'أقصى طول للمقطع (أحرف)', + help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند، وقد تكون المقاطع أقصر. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.', }, }, }, diff --git a/packages/services/service-settings/src/translations/de.ts b/packages/services/service-settings/src/translations/de.ts index 3905f42b820..4064ee7107c 100644 --- a/packages/services/service-settings/src/translations/de.ts +++ b/packages/services/service-settings/src/translations/de.ts @@ -722,8 +722,8 @@ export const de: PlatformTranslationData = { }, keys: { chunk_target: { - label: 'Ziel-Chunkgröße (Zeichen)', - 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.', + label: 'Längste Passage (Zeichen)', + 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.', }, }, }, diff --git a/packages/services/service-settings/src/translations/en.ts b/packages/services/service-settings/src/translations/en.ts index 8ca871f49a5..3dd1bb51e1e 100644 --- a/packages/services/service-settings/src/translations/en.ts +++ b/packages/services/service-settings/src/translations/en.ts @@ -422,8 +422,8 @@ export const en: PlatformTranslationData = { description: 'A value set on a knowledge source itself wins over these defaults.' }, }, keys: { - chunk_target: { label: 'Target chunk size (chars)', - 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.' }, + chunk_target: { label: 'Longest passage (characters)', + 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.' }, }, }, }, diff --git a/packages/services/service-settings/src/translations/es-ES.ts b/packages/services/service-settings/src/translations/es-ES.ts index a98cdbc2e3c..ccd536d41b5 100644 --- a/packages/services/service-settings/src/translations/es-ES.ts +++ b/packages/services/service-settings/src/translations/es-ES.ts @@ -588,8 +588,8 @@ export const esES: PlatformTranslationData = { description: 'Un valor definido en la propia fuente de conocimiento prevalece sobre estos valores predeterminados.' }, }, keys: { - chunk_target: { label: 'Tamaño objetivo de fragmento (caracteres)', - 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.' }, + chunk_target: { label: 'Pasaje más largo (caracteres)', + 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.' }, }, }, diff --git a/packages/services/service-settings/src/translations/fr.ts b/packages/services/service-settings/src/translations/fr.ts index dbf8e408224..0dc3019e693 100644 --- a/packages/services/service-settings/src/translations/fr.ts +++ b/packages/services/service-settings/src/translations/fr.ts @@ -731,8 +731,8 @@ export const fr: PlatformTranslationData = { }, keys: { chunk_target: { - label: 'Taille cible des morceaux (caractères)', - 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.', + label: 'Passage le plus long (caractères)', + 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.', }, }, }, diff --git a/packages/services/service-settings/src/translations/ja-JP.ts b/packages/services/service-settings/src/translations/ja-JP.ts index e8012e885b7..50ec98dbfb7 100644 --- a/packages/services/service-settings/src/translations/ja-JP.ts +++ b/packages/services/service-settings/src/translations/ja-JP.ts @@ -587,8 +587,8 @@ export const jaJP: PlatformTranslationData = { description: 'ナレッジソース自体に設定した値が、これらの既定値より優先されます。' }, }, keys: { - chunk_target: { label: '目標チャンクサイズ(文字数)', - help: 'ナレッジサービスがドキュメントを分割するときの、パッセージ 1 件あたりの最大文字数。ナレッジソース自身に設定したサイズが優先され、埋め込みモデルの入力上限によって小さくなることがあります。' }, + chunk_target: { label: 'パッセージの最大長(文字数)', + help: 'ナレッジサービスがドキュメントを分割するときの、パッセージ 1 件あたりの最大文字数。これより短いパッセージもあります。ナレッジソース自身に設定したサイズが優先され、埋め込みモデルの入力上限によって小さくなることがあります。' }, }, }, diff --git a/packages/services/service-settings/src/translations/ko.ts b/packages/services/service-settings/src/translations/ko.ts index d365b2c6e09..057b492b094 100644 --- a/packages/services/service-settings/src/translations/ko.ts +++ b/packages/services/service-settings/src/translations/ko.ts @@ -561,7 +561,7 @@ export const ko: PlatformTranslationData = { indexing: { title: '인덱싱 기본값', description: '지식 소스 자체에 설정한 값이 이 기본값보다 우선합니다.' }, }, keys: { - chunk_target: { label: '목표 청크 크기(자)', help: '지식 서비스가 문서를 나눌 때 구절 하나의 최대 문자 수입니다. 지식 소스 자체에 설정한 크기가 우선하며, 임베딩 모델의 입력 한도에 따라 더 작아질 수 있습니다.' }, + chunk_target: { label: '구절 최대 길이(자)', help: '지식 서비스가 문서를 나눌 때 구절 하나의 최대 문자 수이며, 구절은 이보다 짧을 수 있습니다. 지식 소스 자체에 설정한 크기가 우선하며, 임베딩 모델의 입력 한도에 따라 더 작아질 수 있습니다.' }, }, }, lifecycle: { diff --git a/packages/services/service-settings/src/translations/pt-BR.ts b/packages/services/service-settings/src/translations/pt-BR.ts index d95ce7d7e63..2491e3cf298 100644 --- a/packages/services/service-settings/src/translations/pt-BR.ts +++ b/packages/services/service-settings/src/translations/pt-BR.ts @@ -718,8 +718,8 @@ export const ptBR: PlatformTranslationData = { }, keys: { chunk_target: { - label: 'Tamanho-alvo da parte (caracteres)', - help: 'Tamanho máximo de um trecho, em caracteres, quando o serviço de conhecimento divide um documento. Um tamanho definido na própria fonte tem prioridade; o limite de entrada do modelo de embeddings pode reduzi-lo.', + label: 'Trecho mais longo (caracteres)', + help: 'Tamanho máximo de um trecho, em caracteres, quando o serviço de conhecimento divide um documento; os trechos podem ser mais curtos. Um tamanho definido na própria fonte tem prioridade; o limite de entrada do modelo de embeddings pode reduzi-lo.', }, }, }, diff --git a/packages/services/service-settings/src/translations/ru.ts b/packages/services/service-settings/src/translations/ru.ts index 2162eea0c76..bbc5dd9a5a6 100644 --- a/packages/services/service-settings/src/translations/ru.ts +++ b/packages/services/service-settings/src/translations/ru.ts @@ -731,8 +731,8 @@ export const ru: PlatformTranslationData = { }, keys: { chunk_target: { - label: 'Целевой размер фрагмента (символы)', - help: 'Наибольшая длина фрагмента в символах, когда служба знаний разбивает документ. Размер, заданный в самом источнике знаний, имеет приоритет; лимит ввода модели эмбеддингов может его уменьшить.', + label: 'Наибольшая длина фрагмента (символы)', + help: 'Наибольшая длина фрагмента в символах, когда служба знаний разбивает документ; фрагменты могут быть короче. Размер, заданный в самом источнике знаний, имеет приоритет; лимит ввода модели эмбеддингов может его уменьшить.', }, }, }, diff --git a/packages/services/service-settings/src/translations/zh-CN.ts b/packages/services/service-settings/src/translations/zh-CN.ts index f2bbcb2e616..fb46d4cfa62 100644 --- a/packages/services/service-settings/src/translations/zh-CN.ts +++ b/packages/services/service-settings/src/translations/zh-CN.ts @@ -618,7 +618,7 @@ export const zhCN: PlatformTranslationData = { indexing: { title: '索引默认值', description: '在知识源上单独设定的值优先于这些默认值。' }, }, keys: { - chunk_target: { label: '目标 chunk 大小(字符)', help: '知识服务切分文档时每个片段的最大字符数。知识源自身设置的大小优先;嵌入模型的输入上限可能将其调低。' }, + chunk_target: { label: '片段最大长度(字符)', help: '知识服务切分文档时每个片段的最大字符数,片段可以更短。知识源自身设置的大小优先;嵌入模型的输入上限可能将其调低。' }, }, }, diff --git a/packages/services/service-settings/src/translations/zh-Hant.ts b/packages/services/service-settings/src/translations/zh-Hant.ts index fc2a4a352eb..3f6da9c40e3 100644 --- a/packages/services/service-settings/src/translations/zh-Hant.ts +++ b/packages/services/service-settings/src/translations/zh-Hant.ts @@ -503,7 +503,7 @@ export const zhHant: PlatformTranslationData = { indexing: { title: '索引預設值', description: '在知識來源本身設定的值優先於這些預設值。' }, }, keys: { - chunk_target: { label: '目標區塊大小(字元)', help: '知識服務切分文件時每個片段的最大字元數。知識來源自身設定的大小優先;嵌入模型的輸入上限可能將其調低。' }, + chunk_target: { label: '片段最大長度(字元)', help: '知識服務切分文件時每個片段的最大字元數,片段可以更短。知識來源自身設定的大小優先;嵌入模型的輸入上限可能將其調低。' }, }, }, lifecycle: {