RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
less text, better extraction (#1869)
Kevin Hudb8f83104f2f
diff --git a/graphrag/index.py b/graphrag/index.pyindex 92649aa1b3..a8e43eea7b 100644--- a/graphrag/index.py+++ b/graphrag/index.py@@ -75,10 +75,11 @@ def build_knowlege_graph_chunks(tenant_id: str, chunks: List[str], callback, entllm_bdl = LLMBundle(tenant_id, LLMType.CHAT, tenant.llm_id)ext = GraphExtractor(llm_bdl)left_token_count = llm_bdl.max_length - ext.prompt_token_count - 1024- left_token_count = max(llm_bdl.max_length * 0.8, left_token_count)+ left_token_count = max(llm_bdl.max_length * 0.6, left_token_count)assert left_token_count > 0, f"The LLM context length({llm_bdl.max_length}) is smaller than prompt({ext.prompt_token_count})"+ BATCH_SIZE=1texts, graphs = [], []cnt = 0threads = []@@ -86,15 +87,15 @@ def build_knowlege_graph_chunks(tenant_id: str, chunks: List[str], callback, entfor i in range(len(chunks)):tkn_cnt = num_tokens_from_string(chunks[i])if cnt+tkn_cnt >= left_token_count and texts:- for b in range(0, len(texts), 16):- threads.append(exe.submit(ext, ["\n".join(texts[b:b+16])], {"entity_types": entity_types}, callback))+ for b in range(0, len(texts), BATCH_SIZE):+ threads.append(exe.submit(ext, ["\n".join(texts[b:b+BATCH_SIZE])], {"entity_types": entity_types}, callback))texts = []cnt = 0texts.append(chunks[i])cnt += tkn_cntif texts:- for b in range(0, len(texts), 16):- threads.append(exe.submit(ext, ["\n".join(texts[b:b+16])], {"entity_types": entity_types}, callback))+ for b in range(0, len(texts), BATCH_SIZE):+ threads.append(exe.submit(ext, ["\n".join(texts[b:b+BATCH_SIZE])], {"entity_types": entity_types}, callback))callback(0.5, "Extracting entities.")graphs = []