refa: simplify RAPTOR tree clustering and configuration (#17614)

This commit is contained in:
buua436
2026-08-03 17:46:50 +08:00
committed by GitHub
parent e290a0d476
commit 3e7cfbe052
32 changed files with 318 additions and 1356 deletions

View File

@@ -8,11 +8,17 @@ config:
kind: tree
raptor:
prompt: |-
Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
{cluster_content}
The above is the content you need to summarize.
Summarize the paragraphs below without inventing facts or changing numbers.
Output exactly two parts in the same language as the source:
1. First line: a concise title only.
2. Following lines: a concise summary of the content.
Do not output labels, Markdown headings, bullet points, or any other commentary.
Paragraphs:
{cluster_content}
max_token: 512
threshold: 0.1
clustering_threshold: 0.3
clustering_ratio: 0.5
# Entity / relation collections are not used by the tree kind but kept
# as empty stubs so the form schema's shared validators see a stable
# shape regardless of kind.

View File

@@ -345,9 +345,10 @@ def get_parser_config(chunk_method, parser_config):
"topn_tags": 3,
"raptor": {
"use_raptor": True,
"prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {cluster_content}\nThe above is the content you need to summarize.",
"max_token": 256,
"threshold": 0.1,
"prompt": "Summarize the paragraphs below without inventing facts or changing numbers.\nOutput exactly two parts in the same language as the source:\n1. First line: a concise title only.\n2. Following lines: a concise summary of the content.\nDo not output labels, Markdown headings, bullet points, or any other commentary.\n\nParagraphs:\n{cluster_content}",
"max_token": 512,
"clustering_threshold": 0.3,
"clustering_ratio": 0.5,
"max_cluster": 64,
"random_seed": 0,
},

View File

@@ -360,18 +360,16 @@ class RaptorConfig(Base):
str,
StringConstraints(strip_whitespace=True, min_length=1),
Field(
default="Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {cluster_content}\nThe above is the content you need to summarize."
default="Summarize the paragraphs below without inventing facts or changing numbers.\nOutput exactly two parts in the same language as the source:\n1. First line: a concise title only.\n2. Following lines: a concise summary of the content.\nDo not output labels, Markdown headings, bullet points, or any other commentary.\n\nParagraphs:\n{cluster_content}"
),
]
max_token: Annotated[int, Field(default=256, ge=1, le=2048)]
threshold: Annotated[float, Field(default=0.1, ge=0.0, le=1.0)]
max_token: Annotated[int, Field(default=512, ge=512, le=2048)]
clustering_threshold: Annotated[float, Field(default=0.3, ge=0.0, le=1.0)]
clustering_ratio: Annotated[float, Field(default=0.5, ge=0.0, le=1.0)]
max_cluster: Annotated[int, Field(default=64, ge=1, le=1024)]
random_seed: Annotated[int, Field(default=0, ge=0)]
scope: Annotated[Literal["file", "dataset"], Field(default="file")]
clustering_method: Annotated[Literal["gmm", "ahc"], Field(default="gmm")]
tree_builder: Annotated[Literal["raptor", "psi"], Field(default="raptor")]
auto_disable_for_structured_data: Annotated[bool, Field(default=True)]
ext: Annotated[dict, Field(default={})]
class GraphragConfig(Base):