mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-13 16:38:26 +08:00
Refactor: enhance graphrag - part 2 (#14972)
### What problem does this PR solve? 1. expose batch_chunk_token_size for configuration 2. retrieve chunks when build subgraph for the doc, not retreive all docs chunks at the begining 3. get all chunks for a document, used to be hard coded 10000 4. delete not used method run_graphrag ### Type of change - [x] New Feature (non-breaking change which adds functionality) - [x] Refactoring Follow on: #14617
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { FormLayout } from '@/constants/form';
|
||||
import { DocumentParserType } from '@/constants/knowledge';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -12,6 +13,7 @@ import { useCallback, useMemo } from 'react';
|
||||
import { useFormContext, useWatch } from 'react-hook-form';
|
||||
import { EntityTypesFormField } from '../entity-types-form-field';
|
||||
import { FormContainer } from '../form-container';
|
||||
import { SliderInputFormField } from '../slider-input-form-field';
|
||||
import {
|
||||
FormControl,
|
||||
FormField,
|
||||
@@ -191,6 +193,19 @@ const GraphRagItems = ({
|
||||
)}
|
||||
/>
|
||||
|
||||
<SliderInputFormField
|
||||
name="parser_config.graphrag.batch_chunk_token_size"
|
||||
label={t('graphRagBatchChunkTokenSize')}
|
||||
tooltip={t('graphRagBatchChunkTokenSizeTip')}
|
||||
max={8196}
|
||||
min={512}
|
||||
step={1}
|
||||
defaultValue={4096}
|
||||
layout={FormLayout.Horizontal}
|
||||
sliderTestId="ds-settings-graph-batch-chunk-token-size-slider"
|
||||
numberInputTestId="ds-settings-graph-batch-chunk-token-size-input"
|
||||
></SliderInputFormField>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="parser_config.graphrag.resolution"
|
||||
|
||||
@@ -89,6 +89,7 @@ interface Parentchild {
|
||||
}
|
||||
|
||||
interface Graphrag {
|
||||
batch_chunk_token_size?: number;
|
||||
entity_types: string[];
|
||||
method: string;
|
||||
use_graphrag: boolean;
|
||||
|
||||
@@ -67,6 +67,7 @@ interface Raptor {
|
||||
}
|
||||
|
||||
interface GraphRag {
|
||||
batch_chunk_token_size?: number;
|
||||
community?: boolean;
|
||||
entity_types?: string[];
|
||||
method?: string;
|
||||
|
||||
@@ -903,6 +903,9 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
|
||||
Light: (Default) Use prompts provided by github.com/HKUDS/LightRAG to extract entities and relationships. This option consumes fewer tokens, less memory, and fewer computational resources.</br>
|
||||
General: Use prompts provided by github.com/microsoft/graphrag to extract entities and relationships.</br>
|
||||
NER: Use spaCy NER and rule-based keyword extraction to extract entities and relationships. No LLM is required for extraction itself, making it fast and resource-efficient.`,
|
||||
graphRagBatchChunkTokenSize: 'Batch chunk token size',
|
||||
graphRagBatchChunkTokenSizeTip:
|
||||
'The token limit for each batch of chunks sent to the LLM for knowledge graph entity and relation extraction. Not applied to NER.',
|
||||
resolution: 'Entity resolution',
|
||||
resolutionTip: `An entity deduplication switch. When enabled, the LLM will combine similar entities - e.g., '2025' and 'the year of 2025', or 'IT' and 'Information Technology' - to construct a more accurate graph`,
|
||||
community: 'Community reports',
|
||||
|
||||
@@ -818,6 +818,9 @@ export default {
|
||||
graphRagMethodTip: `Light:实体和关系提取提示来自 GitHub - HKUDS/LightRAG:“LightRAG:简单快速的检索增强生成”<br>
|
||||
General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于图的模块化检索增强生成 (RAG) 系统<br>
|
||||
NER:使用 spaCy NER 和基于规则的关键词提取来抽取实体和关系,无需 LLM 参与提取过程,速度快且资源消耗低`,
|
||||
graphRagBatchChunkTokenSize: '批量chunk token 大小',
|
||||
graphRagBatchChunkTokenSizeTip:
|
||||
'发送给 LLM 进行知识图谱实体和关系抽取时,每批文本块的 token 上限。NER 不适用。',
|
||||
resolution: '实体归一化',
|
||||
resolutionTip: `解析过程会将具有相同含义的实体合并在一起,从而使知识图谱更简洁、更准确。应合并以下实体:特朗普总统、唐纳德·特朗普、唐纳德·J·特朗普、唐纳德·约翰·特朗普`,
|
||||
community: '社区报告生成',
|
||||
|
||||
@@ -70,6 +70,12 @@ export const formSchema = z
|
||||
method: z.string().optional(),
|
||||
resolution: z.boolean().optional(),
|
||||
community: z.boolean().optional(),
|
||||
batch_chunk_token_size: z
|
||||
.number()
|
||||
.int()
|
||||
.min(512)
|
||||
.max(8196)
|
||||
.optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
|
||||
@@ -103,6 +103,7 @@ export default function DatasetSettings() {
|
||||
use_graphrag: true,
|
||||
entity_types: initialEntityTypes,
|
||||
method: MethodValue.Light,
|
||||
batch_chunk_token_size: 4096,
|
||||
},
|
||||
metadata: {
|
||||
type: 'object',
|
||||
|
||||
Reference in New Issue
Block a user