[{"content":"RAG介绍 检索增强生成（Retrieval-Augmented Generation）技术是一种结合了检索和生成两个阶段的自然语言处理技术，它由** Facebook AI**团队在 2020 年提出。通常包括两个阶段：检索阶段和生成阶段。在检索阶段，从知识库中找出与问题最相关的知识，为后续的答案生成提供素材。在生成阶段，RAG会将检索到的知识内容作为输入，与问题一起输入到语言模型中进行生成。这样，生成的答案不仅考虑了问题的语义信息，还考虑了相关私有数据的内容。解决了以下几个问题：\n通过** Text2Vec** 检索的方式通过将生成的响应与现实世界的数据联系起来来减少幻觉。 大模型上下文长度有限，通过文本切片、知识检索，有效的将私域数据整合进大模型。 传统RAG流程与技术瓶颈 传统RAG核心流程如下：\n文档切分：根据关键字符切分、字符串长度、以及滑动窗口等等，围绕不同类型文本 ，可选择不同的切分策略。（优化手段：文本数据清洗等） 文档匹配与输入：使用Embedding模型进行文本词向量化处理，并使用余弦相似度召回和问题相关的文档。（优化手段：选择更好的Embedding模型；匹配后文本增强；重排序等等） 模型回答：将问题和召回的文本片段一起输入给大模型，生成最终的回复。(优化手段：后处理、用户意图判断等) 技术瓶颈包括以下两个方面：\n传统RAG 很难将信息串联起来：当一个问题的答案需要通过多个不同的信息片段，并通过它们共享的属性来连接，进而提供新的综合见解时，传统RAG表现得很差。 例如，在回答类似“如何通过现有的数据推断出新结论”这种问题时，基线 RAG 无法很好地处理这些散布在不同文档中的相关信息，它可能会遗漏一些关键联系点。\n传统 RAG 无法有效理解大型数据集或单一大文档的整体语义概念：当被要求在大量数据或复杂文档中进行总结、提炼和理解时，传统 RAG 往往表现不佳。 例如，如果问题要求对整个文档或多篇文档的主题进行总结和理解，传统 RAG 的简单向量检索方法可能无法处理文档间的复杂关系，导致对全局语义的理解不完整。\nGraphRAG介绍 项目简介 项目地址：https://github.com/microsoft/graphrag\n论文地址：https://arxiv.org/pdf/2404.16130\n论文标题： From Local to Global: A Graph RAG Approach to Query-Focused Summarization\n2024年2月微软研究院正式提出一种基于知识图谱的RAG方法——GraphRAG，这种新方法利用LLM基于私人数据集创建知识图谱。\n研究动机主要包括两点：\n当前的RAG是为了解决那些能够在文本片段中找到答案的问答任务而设计的，对于QFS (query focus summarization，使用自然语言对内容进行概括而非单纯地生成文本片段)任务不一定适用。 对于那些针对整个数据集进行提问的场景 (如：“这个数据集主要讲了哪些主要内容？”)，原有的RAG方法显然无法将所有数据放入上下文中并让大模型总结；即便能放入上下文窗口，由于lost in the middle (另一篇探索上下文信息丢失的论文)现象的存在，LLM总结效果不一定好。 主要有以下几个特性：\n基于图的检索：传统的 RAG 方法使用向量相似性进行检索，而 GraphRAG 引入了知识图谱来捕捉实体、关系及其他重要元数据，从而更有效地进行推理。 层次聚类：GraphRAG 使用 Leiden 技术进行层次聚类，将实体及其关系进行组织，提供更丰富的上下文信息来处理复杂的查询。 多模式查询：支持多种查询模式： 全局搜索：通过利用社区总结来进行全局性推理。 局部搜索：通过扩展相关实体的邻居和关联概念来进行具体实体的推理。 DRIFT 搜索：结合局部搜索和社区信息，提供更准确和相关的答案。 Prompt 调优：提供调优工具，帮助根据特定数据和需求调整查询提示，从而提高结果质量。 构建流程 GraphRAG过程主要涉及两个主要阶段：索引和查询，整体流程如下图所示：\n索引（Indexing）过程 Step 1. 文本切分（Text Unit Splitting）\nGraphRAG 需要处理的是一大篇文档或语料库。首先，它会将这些文档切分为 Text Units（文本单元），这些 Text Units 是对输入文档的细分，通常是按照段落、句子或固定长度的文本块来进行切分。 这样做的目的是为了便于对文本内容进行分析，尤其是当需要进行 实体识别 和 关系抽取 时，能够精准地关联到文档中的具体上下文。 Step 2. 实体识别（Entity Extraction）\n在文本切分之后，GraphRAG 会使用 大模型（如 OpenAI GPT 或其他 LLM） 对每个 Text Unit 进行处理，提取其中的 实体。这些实体通常是指文档中出现的人物、地点、组织、概念等信息。 实体识别的目的是构建 实体图谱（Entity Graph），将所有实体提取出来并为后续的关系挖掘和查询做准备。 Step 3. 关系挖掘（Relationship Extraction）\n关系挖掘是从文本中识别出实体之间的 关系，例如：谁与谁有关联、某个实体与另一个实体之间的关系是“属于”、“合作”、“对立”等。 通过这种关系提取，GraphRAG 可以构建 关系图谱（Relationship Graph），这些关系将有助于后续的 查询引擎 理解和推理。 Step 4. 文本嵌入（Text Embedding）\n在识别了文本中的实体和关系之后，GraphRAG 会利用 Embedding 模型将文本和实体表示为向量（vectors）。这些向量不仅包括了文本的语义信息，还能为后续的检索和查询提供高效的表示。 这些嵌入向量将存储在 向量数据库（如 LanceDB）中，为查询时提供快速的相似度搜索。 Step 5. 构建社区和层级结构（Community and Hierarchical Clustering）\n通过使用 图谱聚类算法（如 Leiden 算法），GraphRAG 会将不同的实体和关系分组，形成多个 社区（Community）。这些社区是根据实体之间的相似度或关系的密切程度进行划分的。 这种分组帮助 GraphRAG 更好地理解不同知识领域的结构，为查询时提供更具层次性的上下文信息。 Step 6. 生成索引文件（Indexing）\n完成上述步骤后，所有的 实体、关系、社区报告、文本单元等信息都会存储在磁盘上的 Parquet 文件中。 这些索引文件实际上就是构建好的 知识图谱，包括了文本内容、文本中涉及的实体和关系的结构化表示，并且这些文件是为后续的查询引擎和推理过程提供基础。 查询（Query）过程 索引完成后，用户可以通过不同的搜索模式进行查询：\n全局搜索：当我们想了解整个语料库或数据集的整体概况时，GraphRAG 可以利用 社区总结 来快速推理和获取信息。这种方式适用于大范围问题，如某个主题的总体理解。 局部搜索：如果问题关注于某个特定的实体，GraphRAG 会向该实体的 邻居（即相关实体）扩展搜索，以获得更详细和精准的答案。 DRIFT 搜索：这是对局部搜索的增强，除了获取邻居和相关概念，还引入了 社区信息 的上下文，从而提供更深入的推理和连接。 Prompt 调优\n为了获得最佳性能，GraphRAG 强烈建议进行 Prompt 调优，确保模型可以根据你的特定数据和查询需求进行优化，从而提供更准确和相关的答案。\n案例演示 构建索引 下面通过实际案例演示上述过程：\n（1）GraphRAG安装\nrequire python==3.12 pip install graphrag==0.5.0 （2）建立知识库存储目录\n!mkdir -p ./ragtest4/input/ ragtest4命名随意，input名称需固定，目录建立完成，将知识文档上传到该目录，这里通过《红楼梦》的前两回内容进行演示：\n（3）GraphRAG初始化，通过命令行执行以下命令\ngraphrag init --root ./ragtest4 （4）执行完成。生成prompts文件夹，.env文件和setting.yaml文件。\n（5）修改.env文件和setting.yaml配置文件。\n通过修改上述两个文件配置大模型和Embedding模型，演示使用的是GLM4-flash大模型+Ollama nomic-embed-text Embedding模型。\n.env文件配置GLM4的API-key setting.yaml配置如下： （6）prompts文件夹内为GraphRAG预定义prompt，用来提取实体、关系、生成社区报告等等。全英文，可参考以下项目，替换成中文。https://github.com/HolyFishhh/graphrag_zh_prompts\nentity_extraction： 用于从自然语言文本抽取实体与关系。 summarize_descriptions： 用于生成实体与关系的描述性文本。 community_report： 用于生成社区的摘要等报告信息。 claim_extraction： 这是一个可选动作，用来生成一些实体的辅助声明 （由 GRAPHRAG_CLAIM_EXTRACTION_ENABLED 参数控制）,这里忽略。 示例：****entity_extraction.txt\n（7）GraphRAG提供了prompt优化指令，可将预设的prompt中shot替换成跟文档内容相关的shot（可选，本案例未采用）\npython -m graphrag prompt-tune --config ./settings.yaml --root ./ --language Chinese --output ./prompts2 （8）构建索引\ngraphrag index --root ./ragtest4 出现以上提示，说明构建成功。12000字，大概构建了4分钟。构建成功后，各知识图谱相关数据集都保存在output文件夹中：\n包含：\n实体表（Nodes Table） 文件名：create_final_nodes.parquet 内容：知识图谱中的实体节点（例如：人、地点、组织）。 包含信息： 实体的名称（如 \u0026ldquo;John Doe\u0026rdquo;）。 实体的类别（如 \u0026ldquo;PERSON\u0026rdquo;, \u0026ldquo;ORGANIZATION\u0026rdquo;, \u0026ldquo;LOCATION\u0026rdquo;）。 与社区相关的信息（如实体所属的社区）。 实体的度数（degree），表示该实体在图谱中的连接数。 关系表（Relationships Table） 文件名：create_final_relationships.parquet 内容：知识图谱中实体之间的关系（即图谱的边）。 包含信息： 两个实体之间的关系描述（例如 \u0026ldquo;works for\u0026rdquo;, \u0026ldquo;lives in\u0026rdquo;）。 关系的强度（数值化，用于衡量关系的显著性或重要性）。 嵌入向量表（Entity Embedding Table） 文件名：create_final_entities.parquet 内容：实体的语义嵌入，用于表示实体的语义信息。 用途：支持语义搜索（通过嵌入计算实体之间的相似性）。 社区报告表（Community Reports Table） 文件名：create_final_community_reports.parquet 内容：社区的摘要信息。 用途：支持全局搜索（通过社区信息回答关于数据集整体的问题）。 文本单元表（Text Units Table） 文件名：create_final_text_units.parquet 内容：被切分的原始文本单元（TextUnits）。 用途：将知识图谱和原始文本结合，为 LLM 提供上下文支持。 社区表（Community Table） 文件名：create_final_Communities.parquet 内容：每个社区基本情况。 文件表（Documents Table） 文件名：create_final_documents.parquet 内容：用于记录所有参与知识图谱构建的文件情况。 结合实例解释一下每张表字段的含义：\n（一）文件表 create_final_documents.parquet\ndocuments_df = pd.read_parquet(\u0026#34;./output/create_final_documents.parquet\u0026#34;) documents_df create_final_documents.parquet保存文档内容，有个文档生成几行内容，每一行代表一个文档。\ntitle: 文档标题 text: 文档内容 text unit ids: 文档包含的文本单元id列表 （二）文本单元表create_final_text_units.parquet\n将所有文档内容进行切块，按照1200token进行切分。\ntext: 文本单元内容 n_tokens: token数量 document_ids: 所属文档id entitys_ids: 文本单元包含的实体id列表 relationship_ids: 文本单元包含的关系id列表 （三）实体嵌入表create_final_entities.parquet\ntitle: 实体名称 type: 实体类型 description: 实体描述 （四）实体表create_final_nodes.parquet\nid: 每个实体的唯一标识符，可以是数字或字符串。 human_readable_id: 人类可读的标识符，方便理解。 title: 实体的标题或名称（如文本中的人物、书籍名等）。 community: 实体所属的社区编号（我们假设所有实体目前都在社区-，后续聚类会更新）。 level: 假设目前所有实体的层级为-，后续会根据聚类结果填充。 degree: 假设实体之间的初步关系较少，因此度数比较低。 （五）关系表create_final_relationships.parquet\nsource：头实体。 target：尾实体。 description：关系的描述 weight：两个实体之间的关系紧密程度，通过提示词进行打分 combined_degree：两个实体度数相加 （六）社区表create_final_Communities.parquet\ncommunity：社区的编号，代表社区的分类或标识。 level：社区层级，表示社区的聚类粒度。较低的值表示更抽象的层级，较高的值表示更具体的细分社区。 title：社区的全称。 entitys_ids: 社区包含的实体id列表 relationship_ids: 社区包含的关系id列表 text_unit_ids: 社区包含的文本单元id列表 period：社区生成的时间戳。 size：社区的大小，实体个数。 （七）社区报告表create_final_community_reports.parquet\n**id**：每个社区的唯一标识符（UUID）。 **human_readable_id**：更容易理解的人类可读ID（数字化或短标识符）。 **community**：社区的编号，代表社区的分类或标识。 **level**：社区层级，表示社区的聚类粒度。较低的值表示更抽象的层级，较高的值表示更具体的细分社区。 **title**：社区的标题，对该社区的简要描述，用于表示该社区的主题核心。 **summary**：社区的摘要，对该社区内容的进一步扩展描述，解释其主题或涵盖的主要内容。 **full_content**：社区报告的完整内容，包括更详细的信息，可能包含标题、摘要、重要发现等。 **rank**：社区的排名或评分。可能用来表示社区的重要性、影响力或相关性。通过提示词进行打分。 **rank_explanation**：对排名的解释。 **findings**：社区的主要发现（JSON 格式），包含详细的解释或分析。 **full_content_json**：社区完整内容的 JSON 表示。如果需要以结构化方式处理社区内容，这个字段是关键。 **period**：报告生成的时间戳。 **size**：社区的大小，实体个数。 查询 这里介绍两种查询模式：Local模式和Global模式\nlocal search 的操作流程一般包含以下几个关键步骤：\n用户提交一个查询，进行向量化，查找与用户问题相关的前K个实体，如果查找到结果，按照实体id取出对应实体。~~~~ 构建与实体相关的上下文，包括：社区报告上下文、本地上下文（包括实体、关系）、文本单元上下文。 响应生成：将上述上下文和问题，传到预设的local_search_system_prompt 输入到大模型中，以产生最终的响应。 global search核心步骤可以分为2步：\nmap阶段：构建一个包含所有社区报告full_content、社区title的上下文，并且切分为多个预设大小的chunk。针对用户输入问题，根据每一个chunk，都生成一个针对query的中间答案 (intermediate answer)，同时模型需要对这个答案打分 (0-100)，用于表示该答案对生成最终答案的帮助程度。0分答案直接过滤。这个过程没有用向量embedding来匹配，而是并发调用大模型来完成的。 reduce阶段：对map中间响应的结果进行排序，然后放入LLM的上下文窗口，直至达到token限制。最后让LLM根据这些中间答案回答query，得到最终答案 (global answer)。 两种模式优缺点：\nlocal模式：\n高效性：由于只在局部范围内进行搜索，计算量相对较小，搜索速度较快。特别是对于大规模的图数据，Local Search 可以在较短的时间内找到一个较好的局部解。 局部最优性：虽然 Local Search 能够找到局部最优解，但不一定是全局最优解。这是因为它只考虑了局部的信息，没有对整个图进行全面的搜索。 对初始解敏感：搜索结果很大程度上取决于初始节点的选择。不同的初始节点可能会导致不同的局部最优解。 global模式：\n全局最优性：能够找到全局最优解，保证了解的质量。对于一些对解的质量要求较高的问题，Global Search 是一种可靠的选择。 计算量大：由于要对整个图进行搜索，计算量通常较大，搜索时间较长。特别是对于非常大规模的图数据，Global Search 可能会变得非常耗时。 鲁棒性强：不受初始解的影响，能够对整个图进行全面的探索，找到最优解的可能性较大。 命令行形式：\ngraphrag query --root ./ragtest4 --method local --query \u0026#34;请介绍下贾母\u0026#34; #local模式 !graphrag query --root ./ragtest4 --method global --query \u0026#34;请介绍下贾母\u0026#34; # global模式 代码形式：\n（1）local模式\nimport os import pandas as pd import tiktoken from graphrag.query.context_builder.entity_extraction import EntityVectorStoreKey from graphrag.query.indexer_adapters import ( read_indexer_entities, read_indexer_relationships, read_indexer_reports, read_indexer_text_units, ) from graphrag.query.input.loaders.dfs import ( store_entity_semantic_embeddings, ) from graphrag.query.llm.oai.chat_openai import ChatOpenAI from graphrag.query.llm.oai.embedding import OpenAIEmbedding from graphrag.query.llm.oai.typing import OpenaiApiType from graphrag.query.question_gen.local_gen import LocalQuestionGen from graphrag.query.structured_search.local_search.mixed_context import ( LocalSearchMixedContext, ) from graphrag.query.structured_search.local_search.search import LocalSearch from graphrag.vector_stores.lancedb import LanceDBVectorStore from IPython.display import Markdown, display INPUT_DIR = \u0026#34;./ragtest4/output\u0026#34; LANCEDB_URI = f\u0026#34;{INPUT_DIR}/lancedb\u0026#34; COMMUNITY_REPORT_TABLE = \u0026#34;create_final_community_reports\u0026#34; ENTITY_TABLE = \u0026#34;create_final_nodes\u0026#34; ENTITY_EMBEDDING_TABLE = \u0026#34;create_final_entities\u0026#34; RELATIONSHIP_TABLE = \u0026#34;create_final_relationships\u0026#34; TEXT_UNIT_TABLE = \u0026#34;create_final_text_units\u0026#34; COMMUNITY_LEVEL = 2 entity_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{ENTITY_TABLE}.parquet\u0026#34;) entity_embedding_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{ENTITY_EMBEDDING_TABLE}.parquet\u0026#34;) entities = read_indexer_entities(entity_df, entity_embedding_df, COMMUNITY_LEVEL) description_embedding_store = LanceDBVectorStore( collection_name=\u0026#34;default-entity-description\u0026#34;, ) description_embedding_store.connect(db_uri=LANCEDB_URI) entity_description_embeddings = store_entity_semantic_embeddings( entities=entities, vectorstore=description_embedding_store ) print(f\u0026#34;Entity count: {len(entity_df)}\u0026#34;) relationship_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{RELATIONSHIP_TABLE}.parquet\u0026#34;) relationships = read_indexer_relationships(relationship_df) print(f\u0026#34;Relationship count: {len(relationship_df)}\u0026#34;) report_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{COMMUNITY_REPORT_TABLE}.parquet\u0026#34;) reports = read_indexer_reports(report_df, entity_df, COMMUNITY_LEVEL) print(reports[0]) print(f\u0026#34;Report records: {len(report_df)}\u0026#34;) text_unit_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{TEXT_UNIT_TABLE}.parquet\u0026#34;) text_units = read_indexer_text_units(text_unit_df) print(f\u0026#34;Text unit records: {len(text_unit_df)}\u0026#34;) api_key = \u0026#34;**********************\u0026#34; llm_model = \u0026#34;glm-4-flash\u0026#34; embedding_model = \u0026#34;nomic-embed-text\u0026#34; llm = ChatOpenAI( api_key=api_key, model=llm_model, api_base=\u0026#34;https://open.bigmodel.cn/api/paas/v4/\u0026#34;, api_type=OpenaiApiType.OpenAI, max_retries=20, ) token_encoder = tiktoken.get_encoding(\u0026#34;cl100k_base\u0026#34;) text_embedder = OpenAIEmbedding( api_key=api_key, api_base=\u0026#34;http://localhost:11434/api\u0026#34;, api_type=OpenaiApiType.OpenAI, model=embedding_model, max_retries=20, ) context_builder = LocalSearchMixedContext( community_reports=reports, text_units=text_units, entities=entities, relationships=relationships, covariates=None, entity_text_embeddings=description_embedding_store, embedding_vectorstore_key=EntityVectorStoreKey.ID, text_embedder=text_embedder, token_encoder=token_encoder, ) local_context_params = { \u0026#34;text_unit_prop\u0026#34;: 0.5, \u0026#34;community_prop\u0026#34;: 0.1, \u0026#34;conversation_history_max_turns\u0026#34;: 5, \u0026#34;conversation_history_user_turns_only\u0026#34;: True, \u0026#34;top_k_mapped_entities\u0026#34;: 10, \u0026#34;top_k_relationships\u0026#34;: 10, \u0026#34;include_entity_rank\u0026#34;: True, \u0026#34;include_relationship_weight\u0026#34;: True, \u0026#34;include_community_rank\u0026#34;: True, \u0026#34;return_candidate_context\u0026#34;: True, \u0026#34;embedding_vectorstore_key\u0026#34;: EntityVectorStoreKey.ID, \u0026#34;max_tokens\u0026#34;: 12_000, } llm_params = { \u0026#34;max_tokens\u0026#34;: 2_000, \u0026#34;temperature\u0026#34;: 0.0, } search_engine = LocalSearch( llm=llm, context_builder=context_builder, token_encoder=token_encoder, llm_params=llm_params, context_builder_params=local_context_params, response_type=\u0026#34;multiple paragraphs\u0026#34;, ) result = await search_engine.asearch(\u0026#34;贾府有多少人\u0026#34;) print(result.response) # 很抱歉，您提供的数据表中没有包含关于贾府人数的具体信息。 # 因此，我无法根据现有数据回答贾府有多少人。 # 如果您能提供相关的数据或背景信息，我将很乐意帮助您分析。 (2) global模式\nfrom graphrag.query.indexer_adapters import ( read_indexer_communities, read_indexer_entities, read_indexer_reports, ) from graphrag.query.llm.oai.chat_openai import ChatOpenAI from graphrag.query.llm.oai.typing import OpenaiApiType from graphrag.query.structured_search.global_search.community_context import ( GlobalCommunityContext, ) from graphrag.query.structured_search.global_search.search import GlobalSearch COMMUNITY_TABLE = \u0026#34;create_final_communities\u0026#34; COMMUNITY_REPORT_TABLE = \u0026#34;create_final_community_reports\u0026#34; ENTITY_TABLE = \u0026#34;create_final_nodes\u0026#34; ENTITY_EMBEDDING_TABLE = \u0026#34;create_final_entities\u0026#34; community_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{COMMUNITY_TABLE}.parquet\u0026#34;) entity_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{ENTITY_TABLE}.parquet\u0026#34;) report_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{COMMUNITY_REPORT_TABLE}.parquet\u0026#34;) entity_embedding_df = pd.read_parquet(f\u0026#34;{INPUT_DIR}/{ENTITY_EMBEDDING_TABLE}.parquet\u0026#34;) communities = read_indexer_communities(community_df, entity_df, report_df) reports = read_indexer_reports(report_df, entity_df, COMMUNITY_LEVEL) entities = read_indexer_entities(entity_df, entity_embedding_df, COMMUNITY_LEVEL) context_builder = GlobalCommunityContext( community_reports=reports, communities=communities, entities=entities, token_encoder=token_encoder, ) context_builder_params = { \u0026#34;use_community_summary\u0026#34;: False, \u0026#34;shuffle_data\u0026#34;: True, \u0026#34;include_community_rank\u0026#34;: True, \u0026#34;min_community_rank\u0026#34;: 0, \u0026#34;community_rank_name\u0026#34;: \u0026#34;rank\u0026#34;, \u0026#34;include_community_weight\u0026#34;: True, \u0026#34;community_weight_name\u0026#34;: \u0026#34;occurrence weight\u0026#34;, \u0026#34;normalize_community_weight\u0026#34;: True, \u0026#34;max_tokens\u0026#34;: 12_000, \u0026#34;context_name\u0026#34;: \u0026#34;Reports\u0026#34;, } map_llm_params = { \u0026#34;max_tokens\u0026#34;: 1000, \u0026#34;temperature\u0026#34;: 0.0, \u0026#34;response_format\u0026#34;: {\u0026#34;type\u0026#34;: \u0026#34;json_object\u0026#34;}, } reduce_llm_params = { \u0026#34;max_tokens\u0026#34;: 2000, \u0026#34;temperature\u0026#34;: 0.0, } search_engine = GlobalSearch( llm=llm, context_builder=context_builder, token_encoder=token_encoder, max_data_tokens=12_000, map_llm_params=map_llm_params, reduce_llm_params=reduce_llm_params, allow_general_knowledge=False, json_mode=True, context_builder_params=context_builder_params, concurrent_coroutines=32, response_type=\u0026#34;multiple paragraphs\u0026#34;, ) result = await search_engine.asearch(\u0026#34;贾府有多少人\u0026#34;) print(result.response) # 贾府家族成员的人数众多，具体人数无法精确统计。根据不同分析师的报告，贾府家族成员至少有十几人， # 也可能有数十人。这些成员包括贾政、王氏、贾珠、小姐、宁国公、贾代化、贾敬、惜春、贾珍、 # 贾蓉、贾雨村、甄士隐、林如海、黛玉等，以及贾化、贾琏、贾环、贾赦、贾敏等人。 # 家族成员之间的关系复杂，涉及父子、夫妻、兄弟姐妹、亲戚等，且可能涉及官位继承、 # 家族荣誉和家庭关系，因此具体人数可能更多 # [Data: Reports (12, 27, 7, 14, 21, 6, 13, 26, 3, 30, 18, 23, 29, 22, 34), (33, 31, 35, 28, 32)]。 print( f\u0026#34;LLM calls: {result.llm_calls}. Prompt tokens: {result.prompt_tokens}. Output tokens: {result.output_tokens}.\u0026#34; ) ## LLM calls: 3. Prompt tokens: 25247. Output tokens: 1299. GraphRAG总结 （1）GraphRAG与传统的基准RAG模型相比，在多个评价指标上都展现了明显的优势。\nComprehensiveness 全面性：指的是回答的完整性，是否涵盖了问题的隐含上下文。GraphRAG不仅回答了问题的直接内容，还能从上下文中提取相关信息进行补充，提升回答的全面性。 Diversity多样性：指的是回答中是否包含了不同的观点或角度。GraphRAG在多样性上的表现优于传统的RAG，能够提供更多元的视角，这对于复杂问题尤为重要。 Empowerment 人类赋能（human enfranchisement）：指的是是否提供了支持性源材料或其他上下文信息，这对于验证答案的准确性至关重要。GraphRAG在这方面能够提供更多的上下文支持，帮助用户理解回答的背景。 最后再具体介绍评估方式。\n（2）GraphRAG索引的构建以及检索的开销较大（花费token数较多）。\nLightRAG介绍 项目简介 项目地址：https://github.com/HKUDS/LightRAG\n论文地址：https://arxiv.org/pdf/2410.05779\n论文标题： LIGHTRAG: SIMPLE AND FAST RETRIEVAL-AUGMENTED GENERATION\n2024年10月由香港大学和北京邮电大学团队提出，提出动机跟GraphRAG类似。\n构建流程 整体流程如下：\n索引阶段：\nR: 利用 LLM 在文本数据中识别实体（节点）及其关系（边）。 P: 构建键值对，每个索引键是一个单词或短语，能够实现高效检索，而相应的值是一个文本段落，总结来自外部数据的相关片段以辅助文本生成。 D:从原始文本的不同段中识别并合并相同的实体和关系，去除重复实体和关系，减少不必要的计算，提升处理速度。 查询阶段：\n双层检索：针对用户提的问题，提取high-level和low-level的关键词，支持5种检索模式\nnaive：传统RAG流程，用户问题匹配chunk，然后一起输入大模型。 local：从问题中提取low_level_keywords,high_level_keywords, 然后获取与low_level_keywords相关的实体上下文，关系上下文以及文本块上下文，一起输入大模型。 global：从问题中提取low_level_keywords,high_level_keywords, 然后获取与high_level_keywords相关的实体上下文，关系上下文以及文本块上下文，一起输入大模型。 hybrid: 从问题中提取low_level_keywords,high_level_keywords, 然后获取与low_level_keywords, high_level_keywords相关的实体上下文，关系上下文以及文本块上下文，一起输入大模型。 mix: 结合上述所有上下文，跟用户问题一起输入给大模型。 案例演示 索引构建 import os import asyncio from lightrag import LightRAG, QueryParam from lightrag.llm import openai_complete_if_cache, openai_embedding, ollama_embedding from lightrag.utils import EmbeddingFunc import numpy as np WORKING_DIR = \u0026#34;./dickens\u0026#34; if not os.path.exists(WORKING_DIR): os.mkdir(WORKING_DIR) async def llm_model_func( prompt, system_prompt=None, history_messages=[], keyword_extraction=False, **kwargs ) -\u0026gt; str: return await openai_complete_if_cache( \u0026#34;glm-4-flash\u0026#34;, prompt, system_prompt=system_prompt, history_messages=history_messages, api_key=\u0026#34;**********************\u0026#34;, base_url=\u0026#34;https://open.bigmodel.cn/api/paas/v4/\u0026#34;, **kwargs, ) async def embedding_func(texts: list[str]) -\u0026gt; np.ndarray: return await ollama_embedding( texts, embed_model=\u0026#34;nomic-embed-text\u0026#34;, host=\u0026#34;http://localhost:11434\u0026#34;, ) async def get_embedding_dim(): test_text = [\u0026#34;This is a test sentence.\u0026#34;] embedding = await embedding_func(test_text) # embedding_dim = embedding.shape[1] embedding_dim = len(embedding[0]) print(f\u0026#34;Detected embedding dimension: {embedding_dim}\u0026#34;) return embedding_dim # function test async def test_funcs(): result = await llm_model_func(\u0026#34;How are you?\u0026#34;) print(\u0026#34;llm_model_func: \u0026#34;, result) result = await embedding_func([\u0026#34;How are you?\u0026#34;]) print(\u0026#34;embedding_func: \u0026#34;, result) # await test_funcs() # 测试llm+Embedding模型 # await get_embedding_dim() embedding_dimension = await get_embedding_dim() print(f\u0026#34;Detected embedding dimension: {embedding_dimension}\u0026#34;) rag = LightRAG( working_dir=WORKING_DIR, llm_model_func=llm_model_func, embedding_func=EmbeddingFunc( embedding_dim=embedding_dimension, max_token_size=8192, func=lambda texts: embedding_func(texts), ), addon_params = {\u0026#34;language\u0026#34;: \u0026#34;Chinese\u0026#34;} ) with open(\u0026#34;./input/《红楼梦》 第一回 甄士隐梦幻识通灵 贾雨村风尘怀闺秀.txt\u0026#34;, \u0026#34;r\u0026#34;, encoding=\u0026#34;utf-8\u0026#34;) as f: text1 = f.read() with open(\u0026#34;./input/《红楼梦》 第二回 贾夫人仙逝扬州城　冷子兴演说荣国府.txt\u0026#34;, \u0026#34;r\u0026#34;, encoding=\u0026#34;utf-8\u0026#34;) as f: text2 = f.read() all_text = [text1,text2] await rag.ainsert(all_text) 构建完成，生成以向量库+知识图谱，如下图所示：\ngraph_chunk_entity_relation.graphml：知识图谱数据 vdb_chunks.json：文本块 （embedding） vdb_entities.json： 实体+实体描述 （embedding） vdb_relationships.json: 关键词+头实体+尾实体+关系描述 （embedding） 向量数据库：默认使用NanoVectorDBStorage\n图数据库：默认使用NetworkXStorage\n查询 from IPython.display import Markdown, display # 五种查询模式 result = await rag.aquery(\u0026#34;请介绍下贾母\u0026#34;, param=QueryParam(mode=\u0026#34;naive\u0026#34;)) display(Markdown(result)) result = await rag.aquery(\u0026#34;请介绍下贾母\u0026#34;, param=QueryParam(mode=\u0026#34;local\u0026#34;)) display(Markdown(result)) result = await rag.aquery(\u0026#34;请介绍下贾母\u0026#34;, param=QueryParam(mode=\u0026#34;global\u0026#34;)) display(Markdown(result)) result = await rag.aquery(\u0026#34;请介绍下贾母\u0026#34;, param=QueryParam(mode=\u0026#34;hybrid\u0026#34;)) display(Markdown(result)) result = await rag.aquery(\u0026#34;请介绍下贾母\u0026#34;, param=QueryParam(mode=\u0026#34;mix\u0026#34;)) display(Markdown(result)) LightRAG总结 LightRAG 在效率和有效性方面都表现出色，跟GraphRAG相比显著提高了信息检索和生成的速度和质量，同时降低了LLM推理的成本。 代码相较于GraphRAG易读。 检索阶段，相比GrapgRAG，消耗token数和调用大模型的次数大大减少，实验以Legal数据集为例进行评估，GraphRAG在检索过程中生成1,399个社区，其中610个二级社区用于实际检索。每个社区报告平均包含1,000个令牌，总共消耗610,000个令牌（610个社区×1,000个令牌/社区）。此外，GraphRAG需要逐个遍历社区，导致数百次API调用。相比之下，LightRAG在这个过程中使用少于100个令牌用于关键词生成和检索，并且整个过程仅需一次API调用。 增量更新：在处理新数据时，GraphRAG和LightRAG在实体和关系提取方面的开销相似，但是，当引入与Legal数据集相同大小的新数据集时，GraphRAG需要拆除现有的社区结构来纳入新的实体和关系，然后完全重新生成。这一过程每个社区报告大约需要5,000个令牌，对于1,399个社区，大约需要1,399×2×5,000个令牌，成本极高。而LightRAG可以无缝地将新提取的实体和关系集成到现有图中，无需完全重建，在增量更新过程中开销显著更低。 lightrag跟传统rag效率，论文中未明确比对，但是从技术流程来看，无论是索引阶段还是查询阶段，效率低于传统rag。 评估方式 GraphRAG：\n使用大模型进行评估在一篇论文中论述过，被证明是有效的：\nWang, J., Liang, Y., Meng, F., Sun, Z., Shi, H., Li, Z., Xu, J., Qu, J., and Zhou, J. (2023a). Is chatgpt\na good nlg evaluator? a preliminary study. arXiv preprint arXiv:2303.04048\nGraphRAG要求大模型根据数据集内容生成N个潜在用户，每个用户列出将使用此数据集执行的N个任务，然后，对于每个（用户、任务）组合，我们要求LLM生成N个问题，论文中N=5，也就是，针对每个数据集，一共生成125个问题。然后针对每个问题，让大模型从**Comprehensiveness 全面性，Diversity多样性，Empowerment 人类赋能**等方面评选出一个胜者，并给出原因。每个问题可以执行多次取平均。\nLightRAG计算方法类似：\n如上图所示，LightRAG评估数据集来自 UltraDomain，该数据集来源于428本大学教科书，涵盖了18个不同的领域，LightRAG论文实验中使用了四个领域的数据：农业、计算机、法律、混合。\nUltraDomain数据集：https://huggingface.co/datasets/TommyChien/UltraDomain\nLightRAG同样是通过大模型生成问题，每个领域生成125个问题，然后让大模型从四个维度（Comprehensive、Diversity、Empowerent、Overall（整体，评估前三个标准的累积表现，确定最佳整体表现））直接比较某两个RAG系统问题回答的效果，选出胜者。最后统计胜率。如下图红框所示：两两比较胜率相加都为100%。\n具体流程如下：\n生成问题 注意：此步骤只生成问题，不生成答案\nGiven the following description of a dataset: {total_description} Please identify 5 potential users who would engage with this dataset. For each user, list 5 tasks they would perform with this dataset. Then, for each (user, task) combination, generate 5 questions that require a high-level understanding of the entire dataset. Output the results in the following structure: - User 1: [user description] - Task 1: [task description] - Question 1: - Question 2: - Question 3: - Question 4: - Question 5: - Task 2: [task description] ... - Task 5: [task description] - User 2: [user description] ... - User 5: [user description] ... 生成的问题如下所示、\nHere are 5 potential users and their tasks with the dataset, along with 5 questions for each (user, task) combination: **User 1: Beekeeper/Researcher** - **Task 1: Monitor Bee Health** - Question 1: How does the dataset compare the prevalence of diseases like American Foulbrood and Chalkbrood across different regions and over time? - Question 2: Which factors (e.g., climate, forage availability, beekeeping practices) are most strongly associated with increased disease prevalence? - Question 3: How does the dataset compare the effectiveness of different treatments for Varroa mites across different regions? - Question 4: Are there any patterns in the timing of disease outbreaks that could be used to predict and prevent future outbreaks? - Question 5: How does the dataset compare the survival rates of honey bee colonies in different regions and over time? - **Task 2: Analyze Forage Availability** - Question 1: How does the dataset quantify the availability of different forage sources (e.g., flowering plants, trees, shrubs) across different regions and over time? - Question 2: Which forage sources are most important for honey bee nutrition and colony health? - Question 3: How does the dataset compare the timing and duration of forage availability across different regions? - Question 4: Are there any patterns in the availability of forage sources that could be used to optimize beekeeping practices? - Question 5: How does the dataset compare the impact of different land management practices (e.g., agriculture, forestry, urban development) on forage availability? - **Task 3: Study Bee Behavior** - Question 1: How does the dataset describe the foraging behavior of honey bees, including their preferred forage sources and foraging distances? - Question 2: Are there any patterns in the foraging behavior of honey bees that could be used to optimize beekeeping practices? - Question 3: How does the dataset compare the foraging behavior of different bee species? - Question 4: How does the dataset compare the foraging behavior of honey bees in different regions? - Question 5: How does the dataset compare the foraging behavior of honey bees over time? - **Task 4: Analyze Beekeeping Practices** - Question 1: How does the dataset compare different beekeeping practices (e.g., hive management, feeding, disease control) across different regions? - Question 2: Which beekeeping practices are most effective for maintaining colony health and productivity? - Question 3: Are there any patterns in the effectiveness of different beekeeping practices that could be used to optimize beekeeping practices? - Question 4: How does the dataset compare the economic viability of different beekeeping practices? - Question 5: How does the dataset compare the sustainability of different beekeeping practices? - **Task 5: Develop Predictive Models** - Question 1: Can the dataset be used to develop predictive models for honey bee colony health, disease prevalence, and forage availability? - Question 2: How accurate are the predictive models developed using the dataset? - Question 3: Can the predictive models be used to optimize beekeeping practices and improve honey bee health and productivity? - Question 4: Can the predictive models be used to identify potential threats to honey bee populations and develop mitigation strategies? - Question 5: How can the predictive models be improved and extended to other aspects of beekeeping and environmental monitoring? 大模型评估 ---Role--- You are an expert tasked with evaluating two answers to the same question based on three criteria: **Comprehensiveness**, **Diversity**, and **Empowerment**. ---Goal--- You will evaluate two answers to the same question based on three criteria: **Comprehensiveness**, **Diversity**, and **Empowerment**. - **Comprehensiveness**: How much detail does the answer provide to cover all aspects and details of the question? - **Diversity**: How varied and rich is the answer in providing different perspectives and insights on the question? - **Empowerment**: How well does the answer help the reader understand and make informed judgments about the topic? For each criterion, choose the better answer (either Answer 1 or Answer 2) and explain why. Then, select an overall winner based on these three categories. Here is the question: {query} Here are the two answers: **Answer 1:** {answer1} **Answer 2:** {answer2} Evaluate both answers using the three criteria listed above and provide detailed explanations for each criterion. Output your evaluation in the following JSON format: {{ \u0026#34;Comprehensiveness\u0026#34;: {{ \u0026#34;Winner\u0026#34;: \u0026#34;[Answer 1 or Answer 2]\u0026#34;, \u0026#34;Explanation\u0026#34;: \u0026#34;[Provide explanation here]\u0026#34; }}, \u0026#34;Empowerment\u0026#34;: {{ \u0026#34;Winner\u0026#34;: \u0026#34;[Answer 1 or Answer 2]\u0026#34;, \u0026#34;Explanation\u0026#34;: \u0026#34;[Provide explanation here]\u0026#34; }}, \u0026#34;Overall Winner\u0026#34;: {{ \u0026#34;Winner\u0026#34;: \u0026#34;[Answer 1 or Answer 2]\u0026#34;, \u0026#34;Explanation\u0026#34;: \u0026#34;[Summarize why this answer is the overall winner based on the three criteria]\u0026#34; }} }} ","permalink":"https://humyue.github.io/posts/graphrag-lightrag/","summary":"\u003ch1 id=\"rag介绍\"\u003eRAG介绍\u003c/h1\u003e\n\u003cp\u003e检索增强生成（Retrieval-Augmented Generation）技术是一种结合了检索和生成两个阶段的自然语言处理技术，它由** Facebook AI**团队在 2020 年提出。通常包括两个阶段：\u003cstrong\u003e检索阶段和生成阶段\u003c/strong\u003e。在检索阶段，从知识库中找出与问题最相关的知识，为后续的答案生成提供素材。在生成阶段，RAG会将检索到的知识内容作为输入，与问题一起输入到语言模型中进行生成。这样，生成的答案不仅考虑了问题的语义信息，还考虑了相关私有数据的内容。解决了以下几个问题：\u003c/p\u003e","title":"GraphRAG和LightRAG技术介绍"},{"content":"当我们计算卷积池化后的图像尺寸时，需要注意“VALID”和“SAME”两种Padding对应的输出尺寸计算方式不一样，下面就来说说具体的计算方式\n1. 当Padding为“VALID” 这种情况下，当你经过最后一步步长做卷积或池化运算，超出图像边界不会补‘0’，输出的形状为：⌈(W-F+1)/S⌉\n2. 当Padding为“SAME” 这种情况下，当你经过最后一步步长做卷积或池化运算，超出图像边界补‘0’，输出的形状为：⌈W/S⌉\n注意：W为输入的size，F为卷集核尺寸，S为步长，⌈⌉为向上取整符号。\n","permalink":"https://humyue.github.io/posts/two-padding/","summary":"\u003cp\u003e当我们计算卷积池化后的图像尺寸时，需要注意“VALID”和“SAME”两种Padding对应的输出尺寸计算方式不一样，下面就来说说具体的计算方式\u003c/p\u003e\n\u003ch3 id=\"1-当padding为valid\"\u003e1. 当Padding为“VALID”\u003c/h3\u003e\n\u003cp\u003e这种情况下，当你经过最后一步步长做卷积或池化运算，超出图像边界不会补‘0’，输出的形状为：⌈(W-F+1)/S⌉\u003c/p\u003e","title":"卷积神经网络中两种Padding方式的介绍"},{"content":"一、标题写法 # 一级标题 ## 二级标题 ### 三级标题 #### 四级标题 ##### 五级标题 ###### 六级标题 注：最好#和标题之间保留一个空格\n效果如下：\n一级标题 二级标题 三级标题 四级标题 五级标题 六级标题 二、列表写法 无序列表：\n- 列表一 - 列表二 - 列表三 或者 * 列表一 * 列表二 * 列表三 或者 + 列表一 + 列表二 + 列表三 三者效果一样，如下所示：\n列表一 列表二 列表三 有序列表：\n1. aaa 2. bbb 3. ccc 效果如下：\naaa bbb ccc 三、引用写法 \u0026gt; 锄禾日当午 \u0026gt; 汗滴禾下土 \u0026gt; 谁知盘中餐 \u0026gt; 粒粒皆辛苦 或者 \u0026gt; 一盏灯， 一片昏黄； 一简书， 一杯淡茶。 守着那一份淡定， 品读属于自己的寂寞。 保持淡定， 才能欣赏到最美丽的风景！ 保持淡定， 人生从此不再寂寞。 注：最好\u0026gt;和引用之间保留一个空格\n效果如下：\n锄禾日当午 汗滴禾下土 谁知盘中餐 粒粒皆辛苦\n四、粗体斜体写法 粗体写法:\n**粗体** 斜体写法:\n*斜体* 注：斜体星号和文本之间不能有空格，否则将当成列表处理了\n效果如下：\n粗体\n斜体\n五、代码引用 一行代码\n用``将代码包起来就行了 效果如下:\nSystem.out.println(\u0026quot;Hello world!\u0026quot;)\n多行代码\n用``` ```将代码包起来就行了 效果如下:\npublic class HelloWorld{ public static void main(String[] args){ System.out.println(\u0026#34;Hello world!\u0026#34;) ; } } 六、地址链接写法 [百度一下你就知道](http://www.baidu.com) 效果如下：\n百度一下你就知道\n七、图片链接写法 ![阿信](http://upload-images.jianshu.io/upload_images/2896168-e97a472df605788b.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 效果如下:\n也可以这样写:\n![阿信][1] [1]:http://upload-images.jianshu.io/upload_images/2896168-e97a472df605788b.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 同样的效果:\n八、表格写法 |左对齐|居中|右对齐| |-|:-:|-:| |aa|dd|gg| |bb|ee|hh| |cc|ff|ii| 显示效果如下:\n左对齐 居中 右对齐 aa dd gg bb ee hh cc ff ii 还可以这样写：\n左对齐|居中|右对齐 -|:-:|-: aa|dd|gg bb|ee|hh cc|ff|ii 显示效果一样:\n左对齐 居中 右对齐 aa dd gg bb ee hh cc ff ii 九、分割线 你可以在一行中用三个以上的星号、减号、底线来建立一个分隔线，行内不能有其他东西。你也可以在星号 或是减号中间插入空格。下面每种写法都可以建立分隔线： * * * *** ***** - - - --------------------------------------- 效果如下:\n","permalink":"https://humyue.github.io/posts/markdown/","summary":"\u003ch4 id=\"一标题写法\"\u003e一、标题写法\u003c/h4\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e# 一级标题\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e## 二级标题\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e### 三级标题\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e#### 四级标题\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e##### 五级标题\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e###### 六级标题\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003e\u003cem\u003e注：最好#和标题之间保留一个空格\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e效果如下：\u003c/code\u003e\u003c/p\u003e\n\u003ch1 id=\"一级标题\"\u003e一级标题\u003c/h1\u003e\n\u003ch2 id=\"二级标题\"\u003e二级标题\u003c/h2\u003e\n\u003ch3 id=\"三级标题\"\u003e三级标题\u003c/h3\u003e\n\u003ch4 id=\"四级标题\"\u003e四级标题\u003c/h4\u003e\n\u003ch5 id=\"五级标题\"\u003e五级标题\u003c/h5\u003e\n\u003ch6 id=\"六级标题\"\u003e六级标题\u003c/h6\u003e\n\u003ch4 id=\"二列表写法\"\u003e二、列表写法\u003c/h4\u003e\n\u003cp\u003e\u003ccode\u003e无序列表：\u003c/code\u003e\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e- 列表一\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e- 列表二\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e- 列表三\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e或者\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e* 列表一\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e* 列表二\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e* 列表三\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e或者\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e+ 列表一\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e+ 列表二\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e+ 列表三\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003e\u003ccode\u003e三者效果一样，如下所示：\u003c/code\u003e\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e列表一\u003c/li\u003e\n\u003cli\u003e列表二\u003c/li\u003e\n\u003cli\u003e列表三\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003ccode\u003e有序列表：\u003c/code\u003e\u003c/p\u003e","title":"Markdown快速入门"},{"content":" 个人简介 Mingyue Hu\n技能：Codeing Agent 职业：算法应用工程师、Agent应用工程师 联系我 扫描下方二维码，关注我的微信公众号\n","permalink":"https://humyue.github.io/about/","summary":"\u003cimg src=\"/img/head1.png\" width=\"100\" alt=\"阿信\" style=\"border-radius:50%;\"\u003e\n\u003ch3 id=\"个人简介\"\u003e个人简介\u003c/h3\u003e\n\u003cp\u003eMingyue Hu\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e技能：Codeing Agent\u003c/li\u003e\n\u003cli\u003e职业：算法应用工程师、Agent应用工程师\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"联系我\"\u003e联系我\u003c/h3\u003e\n\u003cp\u003e扫描下方二维码，关注我的微信公众号\u003c/p\u003e\n\u003cimg src=\"/img/gongzhonghao.jpg\"  alt=\"微信公众号\"\u003e","title":"关于"},{"content":"学习资源 力扣 Pytorch 中文网 - 端到端深度学习框架平台 PyTorch 官方教程中文版 动手学深度学习 TensorFlow 中文网 OpenCV-Python 中文教程 Python + OpenCV 实用教程 ","permalink":"https://humyue.github.io/collections/","summary":"\u003ch2 id=\"学习资源\"\u003e学习资源\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://leetcode-cn.com/\" target=\"_blank\" rel=\"noopener\"\u003e力扣\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://ptorch.com/\" target=\"_blank\" rel=\"noopener\"\u003ePytorch 中文网 - 端到端深度学习框架平台\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://pytorch.panchuang.net/\" target=\"_blank\" rel=\"noopener\"\u003ePyTorch 官方教程中文版\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://zh.gluon.ai/\" target=\"_blank\" rel=\"noopener\"\u003e动手学深度学习\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://tensorflow.google.cn/\" target=\"_blank\" rel=\"noopener\"\u003eTensorFlow 中文网\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.kancloud.cn/aollo/aolloopencv#/catalog\" target=\"_blank\" rel=\"noopener\"\u003eOpenCV-Python 中文教程\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://codec.wang/opencv-python/\" target=\"_blank\" rel=\"noopener\"\u003ePython + OpenCV 实用教程\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e","title":"收藏"},{"content":"《情书》—— [日] 岩井俊二 我把你的名字写在每一本书中，当作是写给你的情书。\n《白夜行》—— [日] 东野圭吾 无\n《圣女的救济》—— [日] 东野圭吾 无\n《红手指》—— [日] 东野圭吾 无\n《非暴力沟通》—— [美] 马歇尔·卢森堡 我从非暴力沟通中得到的感受更多的是理智。做任何事情之前保持清醒的头脑，倾听他人时，理智揣摩他人的观察、感受、需要、请求，从而表达自己的观察、感受、需要和请求。—— Humy\n《恶意》—— [日] 东野圭吾 读完整本书，不得不说对东野先生的强大的逻辑推理能力，以及细腻的人物刻画能力叹为观止。与以往推理小说不同，文中所描述的凶杀案，罪犯在一开始就对自己的罪刑供认不讳，但是却隐瞒了真实的作案动机，刻意引导警官跳入他精心设计的作案动机。但是最终还是被加贺发现了漏洞。进而通过一系列零碎的人物对话，慢慢的勾勒拼凑出野野口修真实的杀人动机——来自埋藏在心底的恶意。“恶意”两字虽然简单，却是发人深省的。在我们的生活中，以德报怨的例子有很多，这是说的过去的。但是以怨报德却是我们不能理解的，然而一旦产生恶意，nothing is impossible。恶意的产生却是非常容易的，可能来自嫉妒，也可能没有原因——就像文中说的“我就是看他不爽”。我将这些解释为人性的使然。—— Humy\n《嫌疑人X的献身》—— [日] 东野圭吾 石神对靖子的爱，我无法评判。不知道它对不对，值不值得。可能爱情真的是强求不来的吧，一个人不爱你，你做的再多也没用。于己，感动了自己，于他人，可能是一种负担。—— Humy\n《长安乱》—— 韩寒 无\n《解忧杂货店》—— [日] 东野圭吾 断断续续的看完这本书，有一个感受是，不得不佩服作者巧妙的构思，以一个未来人的口吻帮别人解决烦恼，最后还能巧妙的将所有故事串联起来。同时也让我明白了：我们所谓的烦恼，其实从心里是知道怎么解决的，大概只是有些事无法下定决心吧。—— Humy\n《你的孤独，虽败犹荣》—— 刘同 其实我一直不知道什么是孤独，也许孤独本身就没有一个准确的定义。这篇文章，作者用他这些年的一些经历，向我们阐述了他所理解的孤独。其中不乏共鸣点。然而，他并没有教我们如何摆脱孤独。也许，作者从一开始就认为孤独是我们人生所必须经历的，没有必要去摆脱它。只需要一个好的心态去面对它即可。但又有谁知道孤独何尝不是我们对生活的逃避呢？—— Humy\n《呐喊》—— 鲁迅 鲁迅先生心系中国，在那样一个人们观念陈旧，思想落后的年代，他用文字发出了他的呐喊，揭露了旧时代的种种。的确，只有文字才能救中国。如今，我们生活在一个和平的年代，人们思想文明得到很大提高，除了要珍惜现在生活的来之不易，更要时刻提醒自己，解放思想，对未来事物要有敏锐的洞察能力。—— Humy\n","permalink":"https://humyue.github.io/books/","summary":"\u003ch3 id=\"情书-日-岩井俊二\"\u003e《情书》—— [日] 岩井俊二\u003c/h3\u003e\n\u003cimg src=\"/img/books/11.jpg\" width=\"130\" alt=\"情书\" style=\"float:left;margin:0 16px 10px 0;border-radius:4px;\"\u003e\n\u003cblockquote\u003e\n\u003cp\u003e我把你的名字写在每一本书中，当作是写给你的情书。\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cdiv style=\"clear:both\"\u003e\u003c/div\u003e\n\u003ch3 id=\"白夜行-日-东野圭吾\"\u003e《白夜行》—— [日] 东野圭吾\u003c/h3\u003e\n\u003cimg src=\"/img/books/01.jpg\" width=\"130\" alt=\"白夜行\" style=\"float:left;margin:0 16px 10px 0;border-radius:4px;\"\u003e\n\u003cblockquote\u003e\n\u003cp\u003e无\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cdiv style=\"clear:both\"\u003e\u003c/div\u003e\n\u003ch3 id=\"圣女的救济-日-东野圭吾\"\u003e《圣女的救济》—— [日] 东野圭吾\u003c/h3\u003e\n\u003cimg src=\"/img/books/02.jpg\" width=\"130\" alt=\"圣女的救济\" style=\"float:left;margin:0 16px 10px 0;border-radius:4px;\"\u003e\n\u003cblockquote\u003e\n\u003cp\u003e无\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cdiv style=\"clear:both\"\u003e\u003c/div\u003e\n\u003ch3 id=\"红手指-日-东野圭吾\"\u003e《红手指》—— [日] 东野圭吾\u003c/h3\u003e\n\u003cimg src=\"/img/books/03.jpg\" width=\"130\" alt=\"红手指\" style=\"float:left;margin:0 16px 10px 0;border-radius:4px;\"\u003e\n\u003cblockquote\u003e\n\u003cp\u003e无\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cdiv style=\"clear:both\"\u003e\u003c/div\u003e\n\u003ch3 id=\"非暴力沟通-美-马歇尔卢森堡\"\u003e《非暴力沟通》—— [美] 马歇尔·卢森堡\u003c/h3\u003e\n\u003cimg src=\"/img/books/04.jpg\" width=\"130\" alt=\"非暴力沟通\" style=\"float:left;margin:0 16px 10px 0;border-radius:4px;\"\u003e\n\u003cblockquote\u003e\n\u003cp\u003e我从非暴力沟通中得到的感受更多的是理智。做任何事情之前保持清醒的头脑，倾听他人时，理智揣摩他人的观察、感受、需要、请求，从而表达自己的观察、感受、需要和请求。—— Humy\u003c/p\u003e\n\u003c/blockquote\u003e","title":"书单"}]