Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions kag/common/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,12 @@ def init_env(config_file: str = None):
else:
msg = "Done init config from local file"
logger.debug(msg)
os.environ[KAGConstants.ENV_KAG_PROJECT_ID] = str(KAG_PROJECT_CONF.project_id)
os.environ[KAGConstants.ENV_KAG_PROJECT_HOST_ADDR] = str(KAG_PROJECT_CONF.host_addr)
if KAG_PROJECT_CONF.project_id:
os.environ[KAGConstants.ENV_KAG_PROJECT_ID] = str(KAG_PROJECT_CONF.project_id)
if KAG_PROJECT_CONF.host_addr:
os.environ[KAGConstants.ENV_KAG_PROJECT_HOST_ADDR] = str(
KAG_PROJECT_CONF.host_addr
)
if len(KAG_CONFIG.all_config) > 0:
dump_flag = os.getenv(KAGConstants.ENV_KAG_DEBUG_DUMP_CONFIG)
if dump_flag is not None and dump_flag.strip() == "1":
Expand Down
2 changes: 1 addition & 1 deletion kag/examples/FinAlibaba/kag_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ kag_solver_pipeline:
executors:
- *retriever
generator:
type: llm_generator
type: llm_index_generator
llm_client: *chat_llm
generated_prompt:
type: default_multi_hop_generator
Expand Down
25 changes: 21 additions & 4 deletions kag/examples/baike/kag_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ graph_api: &graph_api
type: openspg_graph_api #kag.solver.tools.graph_api.impl.openspg_graph_api.OpenSPGGraphApi



kg_cs: &kg_cs
type: kg_cs_open_spg
priority: 0
path_select:
type: exact_one_hop_select
graph_api: *graph_api
Expand All @@ -87,9 +89,14 @@ kg_cs: &kg_cs
recognition_threshold: 0.9
exclude_types:
- Chunk
- AtomicQuery
- KnowledgeUnit
- Summary
- Outline
- Doc

kg_fr: &kg_fr
type: kg_fr_open_spg
type: kg_fr_knowledge_unit
top_k: 20
graph_api: *graph_api
search_api: *search_api
Expand All @@ -111,12 +118,18 @@ kg_fr: &kg_fr
recognition_threshold: 0.8
exclude_types:
- Chunk
- AtomicQuery
- KnowledgeUnit
- Summary
- Outline
- Doc

rc: &rc
type: rc_open_spg
vector_chunk_retriever:
type: vector_chunk_retriever_legacy
type: vector_chunk_retriever
vectorize_model: *vectorize_model
score_threshold: 0.65
search_api: *search_api
graph_api: *graph_api
search_api: *search_api
Expand All @@ -135,12 +148,16 @@ kag_hybrid_executor: &kag_hybrid_executor_conf

kag_output_executor: &kag_output_executor_conf
type: kag_output_executor
llm_module: *chat_llm

kag_deduce_executor: &kag_deduce_executor_conf
type: kag_deduce_executor
llm_module: *chat_llm

py_code_based_math_executor: &py_code_based_math_executor_conf
type: py_code_based_math_executor
llm: *openie_llm
llm: *chat_llm


kag_solver_pipeline:
type: kag_static_pipeline
Expand All @@ -157,7 +174,7 @@ kag_solver_pipeline:
- *kag_deduce_executor_conf
- *kag_output_executor_conf
generator:
type: llm_generator
type: llm_index_generator
llm_client: *chat_llm
generated_prompt:
type: default_refer_generator_prompt
Expand Down
94 changes: 54 additions & 40 deletions kag/examples/baike/schema/BaiKe.schema
Original file line number Diff line number Diff line change
@@ -1,110 +1,122 @@
namespace BaiKe

SemanticConcept(语义概念): EntityType
properties:
desc(内容): Text
index: Text
isA(上位): SemanticConcept

ArtificialObject(人造物体): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): ArtificialObject
officialName(标准名): ArtificialObject

Astronomy(天文学): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Astronomy
officialName(标准名): Astronomy

Building(建筑): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Building
officialName(标准名): Building

Creature(生物): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Creature
officialName(标准名): Creature

Concept(概念): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Concept
officialName(标准名): Concept

Date(日期): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Date
officialName(标准名): Date

GeographicLocation(地理位置): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): GeographicLocation
officialName(标准名): GeographicLocation

Keyword(关键词): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Keyword
officialName(标准名): Keyword

Medicine(药物): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text

semanticType(语义类型): SemanticConcept
synonyms(同义词): Medicine
officialName(标准名): Medicine

NaturalScience(自然科学): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): NaturalScience
officialName(标准名): NaturalScience

Organization(组织机构): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Organization
officialName(标准名): Organization

Person(人物): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Person
officialName(标准名): Person

Transport(运输): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Transport
officialName(标准名): Transport

Works(作品): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text

Others(其他): EntityType
properties:
desc(描述): Text
index: TextAndVector
semanticType(语义类型): Text
index: Text
semanticType(语义类型): SemanticConcept
synonyms(同义词): Works
officialName(标准名): Works

Event(事件): EventType
properties:
Expand All @@ -118,8 +130,10 @@ Event(事件): EventType
type(事件类型): Text
index: Text


SemanticConcept(语义概念): EntityType
Others(其他): EntityType
properties:
desc(内容): Text
index: Text
desc(描述): Text
index: TextAndVector
semanticType(语义类型): SemanticConcept
synonyms(同义词): Others
officialName(标准名): Others
32 changes: 18 additions & 14 deletions kag/examples/csqa/kag_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ chain_vectorizer:

kg_cs: &kg_cs
type: kg_cs_open_spg
priority: 0
path_select:
type: exact_one_hop_select
graph_api: *graph_api
Expand All @@ -90,6 +91,11 @@ kg_cs: &kg_cs
recognition_threshold: 0.9
exclude_types:
- Chunk
- AtomicQuery
- KnowledgeUnit
- Summary
- Outline
- Doc

kg_fr: &kg_fr
type: kg_fr_open_spg
Expand All @@ -114,28 +120,24 @@ kg_fr: &kg_fr
recognition_threshold: 0.8
exclude_types:
- Chunk
- AtomicQuery
- KnowledgeUnit
- Summary
- Outline
- Doc

rc: &rc
type: rc_open_spg
vector_chunk_retriever:
type: vector_chunk_retriever_legacy
type: vector_chunk_retriever
vectorize_model: *vectorize_model
score_threshold: 0.65
search_api: *search_api
graph_api: *graph_api
search_api: *search_api
vectorize_model: *vectorize_model
top_k: 20

kag_merger:
type: kg_merger
top_k: 20
llm_module: *chat_llm
summary_prompt:
type: default_thought_then_answer
vectorize_model: *vectorize_model
graph_api: *graph_api
search_api: *search_api

kag_hybrid_executor: &kag_hybrid_executor_conf
type: kag_hybrid_retrieval_executor
retrievers:
Expand All @@ -144,19 +146,21 @@ kag_hybrid_executor: &kag_hybrid_executor_conf
- *rc
merger:
type: kag_merger
enable_summary: true
enable_summary: true

kag_output_executor: &kag_output_executor_conf
type: kag_output_executor
llm_module: *chat_llm

kag_deduce_executor: &kag_deduce_executor_conf
type: kag_deduce_executor

llm_module: *chat_llm

py_code_based_math_executor: &py_code_based_math_executor_conf
type: py_code_based_math_executor
llm: *chat_llm


kag_solver_pipeline:
type: kag_static_pipeline
planner:
Expand All @@ -172,7 +176,7 @@ kag_solver_pipeline:
- *kag_deduce_executor_conf
- *kag_output_executor_conf
generator:
type: llm_generator
type: llm_index_generator
llm_client: *chat_llm
generated_prompt:
type: default_refer_generator_prompt
Expand Down
Loading