Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/KnowledgeXLab/LeanRAG
/ functions
Functions
195 in github.com/KnowledgeXLab/LeanRAG
⨍
Functions
195
◇
Types & classes
12
↓ 1 callers
Function
search_community
(entity_name,working_dir)
database_utils.py:388
↓ 1 callers
Function
search_nodes_link
(entity1,entity2,working_dir,level=0)
database_utils.py:296
↓ 1 callers
Function
search_vector_search
level_mode: 0: 原始节点 1: 聚合节点 2: 所有节点
database_utils.py:68
↓ 1 callers
Method
start_instance
启动ollama实例在特定GPU和端口上
CommonKG/llm_infer.py:30
↓ 1 callers
Function
test_setup_setup_logger
()
tools/logger_factory.py:145
↓ 1 callers
Function
triple_extraction
(chunks,use_llm_func,output_dir)
GraphExtraction/chunk.py:22
↓ 1 callers
Method
triple_json_format
(self, triple, doc_name="", source_id="")
CommonKG/triple.py:20
↓ 1 callers
Function
truncate_text
(text, max_tokens=4096)
build_graph.py:113
↓ 1 callers
Function
write_csv
写入CSV文件,支持多线程处理。 参数: - file_path (str): 文件路径。 - data (DataFrame): 要写入的CSV数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。
tools/io_file.py:489
↓ 1 callers
Function
write_json
写入JSON文件,支持多线程处理。 参数: - file_path (str): 文件路径。 - data (list): 要写入的JSON数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 -
tools/io_file.py:545
↓ 1 callers
Function
write_jsonl
写入JSONL文件,支持多线程处理。 参数: - file_path (str): 文件路径。 - data (list): 要写入的JSON数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。
tools/io_file.py:427
↓ 1 callers
Function
write_jsonl_multithread
使用多线程写入JSONL文件。 参数: - file_path (str): 文件路径。 - data (list): 要写入的JSON数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - c
tools/io_file.py:450
↓ 1 callers
Function
write_markdown
写入Markdown文件。 参数: - file_path (str): 文件路径。 - data (str): 要写入的Markdown内容。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 -
tools/io_file.py:688
↓ 1 callers
Function
write_txt
写入文本文件。 参数: - file_path (str): 文件路径。 - data (str): 要写入的数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - chunk_size (in
tools/io_file.py:369
↓ 1 callers
Function
write_txt_multithread
使用多线程写入文本文件。 参数: - file_path (str): 文件路径。 - data (str): 要写入的数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - chunk_siz
tools/io_file.py:390
↓ 1 callers
Function
write_xlsx
写入Excel文件。 参数: - file_path (str): 文件路径。 - data (DataFrame): 要写入的Excel数据。 - encoding (str): 写入文件的编码格式,默认为 'utf-8'。
tools/io_file.py:675
↓ 1 callers
Function
write_yaml
写入YAML文件。 参数: - file_path (str): 文件路径。 - data (dict): 要写入的YAML数据。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - encodin
tools/io_file.py:567
Method
__call__
(self, *args, **kwargs)
tools/_utils.py:227
Method
__init__
(self, url,ports, gpus, generate_model,startup_delay=30)
tools/utils.py:146
Method
__init__
(self, logger, level=logging.INFO)
tools/logger_factory.py:130
Method
__init__
(self, head, relation, tail)
CommonKG/triple.py:11
Method
__init__
(self, ports, gpus, base_url, startup_delay=5)
CommonKG/llm_infer.py:17
Method
__init__
(self, args)
CommonKG/llm_infer.py:60
Method
__init__
(self, doc_name, source_id, corpus)
CommonKG/corpus.py:46
Method
__init__
(self, args)
CommonKG/kg_score.py:21
Method
__init__
初始化打分类
CommonKG/kg_score.py:45
Method
__str__
(self)
CommonKG/triple.py:17
Function
_handle_single_entity_extraction
( record_attributes: list[str], chunk_key: str, )
_cluster_utils.py:303
Function
_handle_single_relationship_extraction
( record_attributes: list[str], chunk_key: str, )
_cluster_utils.py:324
Function
_process_paragraph_for_matching
Worker function to process a single paragraph for entity matching. Unpacks arguments, creates a Corpus object, and performs matching.
CommonKG/create_kg.py:333
Function
always_get_an_event_loop
()
tools/_utils.py:19
Function
check_test
(entities)
_cluster_utils.py:28
Function
check_test
(entities)
tools/utils.py:126
Function
compute_args_hash
(*args)
tools/_utils.py:176
Function
compute_mdhash_id
(content, prefix: str = "")
tools/_utils.py:148
Function
convert_response_to_json
Convert response string to JSON, with error handling and fallback to non-standard JSON extraction.
tools/_utils.py:102
Function
count_lines
(filename)
tools/tools.py:244
Function
custom_lower_fast
中英文兼容的小写转换
tools/utils.py:54
Function
decode_tokens_by_tiktoken
(tokens: list[int], model_name: str = "gpt-4o")
tools/_utils.py:128
Method
default_generate_text
(self, prompt, model="qwen-plus", temperature=0, max_tokens=4096, output_json=False)
CommonKG/llm_infer.py:123
Function
dicts_almost_equal
(dict1, dict2, tolerance=1e-6)
tools/utils.py:26
Function
embedding_init
(entities:list[dict])
build_graph.py:97
Function
evaluate_example
(query_file,result_file,output_file,dataset)
evaluate_score.py:92
Function
evaluate_item
(i, query, answer, benchmark, tokenizer)
evaluate_score.py:1
Function
extract_json_from_cluster
(s:str)
_cluster_utils.py:72
Function
file_split
(input_file, num)
tools/tools.py:198
Function
final_decro
Not using async.Semaphore to aovid use nest-asyncio
tools/_utils.py:235
Function
find_path
(entity1,entity2,working_dir,level,depth=5)
database_utils.py:249
Method
flush
(self)
tools/logger_factory.py:141
Method
generate_text
发送请求到选择的实例
tools/utils.py:178
Method
generate_text_asy
发送请求到选择的实例
tools/utils.py:223
Function
get_entities_from_triples
(infilename, outfilename, signpass=[])
tools/tools.py:280
Function
get_entities_from_wikidata
(infilename, outfilename1, outfilename2, outfilename3)
tools/tools.py:301
Method
get_tokens_cosumption
(self)
tools/utils.py:162
Function
is_word_boundary
自适应中英文词边界检测
tools/utils.py:59
Function
limit_async_func_call
Add restriction of maximum async calling times for a async func
tools/_utils.py:232
Function
list_of_list_to_csv
(data: list[list])
tools/_utils.py:197
Function
load_json
(file_name)
tools/_utils.py:157
Function
load_yaml_conf
(config_path)
CommonKG/config/set_config.py:7
Function
local_cluster_embeddings
( embeddings: np.ndarray, dim: int, num_neighbors: int = 10, metric: str = "cosine" )
_cluster_utils.py:193
Function
pack_user_ass_to_openai_messages
(*args: str)
tools/_utils.py:165
Method
parse_description_response
解析描述响应,生成六元组字符串
CommonKG/triple.py:91
Method
perform_clustering
(self, embeddings: np.ndarray, **kwargs)
_cluster_utils.py:349
Function
print_file
(infile, n=10)
tools/tools.py:234
Function
process_cluster
( use_llm_func, embeddings_func, \ clusters,label,nodes,community_report_prompt,\ relations,g
_cluster_utils.py:404
Function
process_llm_batch
处理单个批次的LLM请求
CommonKG/create_kg.py:34
Function
process_relation
( use_llm_func,community_report,maybe_edge,relations,generate_relations,\ cluster_cluster_relation_p
_cluster_utils.py:448
Function
process_single_description
处理单个三元组的描述抽取
CommonKG/create_kg.py:122
Function
process_triple
(file_path,output_path)
GraphExtraction/deal_triple.py:135
Function
read
根据文件扩展名读取文件内容,并自动判断是否使用多线程。 TODO: 修正多线程读取功能,暂不可用,所以阈值设置的很大 参数: - file_path (str): 文件路径。 - chunk_size (int): 当文件大于此大小时,使用多线程读取,单位
tools/io_file.py:20
Function
read_chunk
读取文件的某个块。 参数: - file_path (str): 文件路径。 - start (int): 起始字节位置。 - end (int): 结束字节位置。 - encoding (str): 文件编码格式,默认为 'utf-8'。
tools/io_file.py:151
Function
read_csv_chunk
读取CSV文件的某一块。 参数: - file_path (str): 文件路径。 - start (int): 起始字节位置。 - end (int): 结束字节位置。 - encoding (str): 文件编码格式,默认为 'utf-8'。
tools/io_file.py:218
Function
read_jsonl_chunk
读取JSONL文件的某一块。 参数: - file_path (str): 文件路径。 - start_line (int): 起始行。 - end_line (int): 结束行。 - encoding (str): 文件编码格式,默认为 'ut
tools/io_file.py:351
Function
remove_text_in_brackets
(input_file, output_file, strong_clean_flag = False)
tools/tools.py:37
Method
reset_token_cost
重置总的token消耗和API调用次数
tools/utils.py:158
Method
run_one
处理单个三元组
CommonKG/kg_score.py:141
Function
search_chunks
(working_dir,entity_set)
database_utils.py:325
Function
search_nodes
(entity_set,working_dir)
database_utils.py:339
Function
sort_large_file
( input_file, output_file, chunk_size=100000 )
tools/tools.py:83
Function
split_string_by_multi_markers
Split a string by multiple markers
tools/_utils.py:180
Function
str_full_to_half_width
(input_file, output_file)
tools/tools.py:161
Function
summarize_entity
(entity_name, description, summary_prompt, threshold, tokenizer)
GraphExtraction/deal_triple.py:14
Function
summarize_entity
(entity_name, description, summary_prompt, threshold, tokenizer)
CommonKG/deal_triple.py:13
Function
truncate_data
()
GraphExtraction/deal_triple.py:23
Function
truncate_list_by_token_size
Truncate a list of data by token size
tools/_utils.py:136
Function
truncate_text
(text, max_tokens=4096)
query_graph.py:45
Method
vllm_generate_text
使用vLLM生成文本
CommonKG/llm_infer.py:77
Function
wait_func
(*args, **kwargs)
tools/_utils.py:240
Function
wrap_embedding_func_with_attrs
Wrap a function with attributes
tools/_utils.py:254
Function
write
根据文件扩展名写入数据到文件,并自动判断是否使用多线程。 TODO: 修正多线程保存功能,暂不可用,所以阈值设置的很大 参数: - file_path (str): 文件路径。 - data (any): 要写入的数据。 - mode (str):
tools/io_file.py:58
Function
write_chunk
写入文本文件的某一块。 参数: - file_path (str): 文件路径。 - chunk (str): 要写入的文本块。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - encoding
tools/io_file.py:413
Function
write_csv_chunk
写入CSV文件的某一块。 参数: - file_path (str): 文件路径。 - chunk (DataFrame): 要写入的CSV数据块。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。
tools/io_file.py:532
Function
write_json
(json_obj, file_name)
tools/_utils.py:152
Function
write_jsonl_chunk
写入JSONL文件的某一块。 参数: - file_path (str): 文件路径。 - chunk (list): 要写入的数据块。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - enco
tools/io_file.py:473
Function
write_yaml_conf
(config_path, data)
CommonKG/config/set_config.py:14
← previous
101–195 of 195, ranked by callers