AI + 知识图谱 = GraphRAG:为企业构建更精准的聊天机器人

【Cursor+Playwright-MCP 实现 AI 自主功能测试】含实例代码脚本+保姆级教程 本文档详细介绍了如何使用 Cursor(AI 编程助手)和 Playwright-MCP 库实现基于 GPT 模型的自动化功能测试。文档从环境搭建开始,逐步指导读者如何通过 Playwright 进行浏览器自动化,并利用 Playwright-MCP 集成 GPT 模型生成测试计划、执行测试步骤及生成测试报告。核心步骤包括安装依赖、配置 OpenAI API 密钥、编写代码实现 AI 驱动的测试流程,以及生成详细的测试报告。通过本文档,读者可以快速掌握从 0 到 1 实现 AI 自主功能测试的全流程。 阅读详情

自从企业开始采用检索增强生成(Retrieval Augmented Generation,RAG)以来,这项技术已经取得了显著进步。正如我们所见,各组织不断探索创新方法以挖掘更多价值。尽管检索过程和搜索算法变得更快、更高效,但在处理复杂任务(如多步逻辑推导)或回答需要将分散信息点连接起来的复杂问题时,它们仍然存在局限性。

让我们通过一个真实的例子来进一步探讨这个主题:“1492 年圣诞节沉没的哥伦布船叫什么名字?”

一个标准的 RAG 系统通常会遵循以下步骤:

识别事件 :查找有关哥伦布船只及其沉船的信息。

确认日期 :验证圣诞节当天发生事件的船只。

确定名称 :提取特定船只的名称。

然而,第一个步骤往往会成为挑战,因为基础 RAG 系统主要依赖语义相似性进行文本检索。它们擅长找到相似的内容,但在连接多个事实以回答复杂问题时表现不足。当关键信息分散在不同文档中时,这些系统难以将其拼凑起来。传统解决方案(如为常见问题手动创建问答对)不仅成本高昂,而且不切实际。

为了解决这些局限性,微软研究院提出了一种创新性解决方案——GraphRAG。这种方法通过将知识图谱融入检索和生成过程,将 RAG 提升到了一个全新的高度。知识图谱通过将实体和关系以节点和边的形式保留下来,为数据创建了更丰富的表示。这就像将一团混乱的信息网转化为一张整齐有序的地图。看看下面的知识图谱,您会立刻明白,通过简单的图谱遍历,回答复杂问题变得多么轻松。是不是很神奇?

在这里插入图片描述

目录

  • • RAG 中的向量数据库与图数据库

  • • FalkorDB

  • • 前置条件

  • • 构建知识图谱

    • • 设置 FalkorDB
    • • 数据导入
  • • 查询知识图谱

    • • 自动化 Cypher 查询生成
    • • Cypher 查询输出分析
  • • 聊天机器人集成

  • • 总结

  • • 参考文献

RAG 中的向量数据库与图数据库

在 RAG 系统中,选择向量数据库还是图数据库完全取决于您正在解决的问题、系统架构需求和性能目标。以下是一些帮助您决策的见解:

向量数据库:

  • • 擅长多维数据表示和相似性搜索。
  • • 适用于图像处理、推荐系统和实时 RAG。
  • • 随数据量水平扩展。
  • • 局限性:可能因近似最近邻(ANN)算法和维度问题而影响准确性。

图数据库:

  • • 专注于管理复杂关系和互联数据。
  • • 最适合社交网络分析、欺诈检测和知识表示。
  • • 在基于关系的查询和遍历方面表现出色。
  • • 局限性:在处理复杂结构时可能面临可扩展性挑战和延迟问题。

FalkorDB

FalkorDB 是一款为 GraphRAG 应用高度优化的低延迟数据库解决方案。其基于 Redis 的架构提供了高性能的图数据库,利用内存处理技术和高效的内存使用,与基于磁盘存储的图数据库相比,显著加快了查询执行速度并降低了延迟。因此,它能够高效存储和查询数据点之间的复杂关系。此外,它支持各种 AI 框架(如 LangChain 和 LlamaIndex),增强了其在构建 AI 应用方面的功能。

在本文中,我将向您展示如何为 BFSI 行业定制 GraphRAG 驱动的聊天机器人。通过一个假设的银行作为例子,我将演示该技术如何高效管理复杂的金融数据并解决客户查询。

前置条件

本教程已使用以下 Python 库进行了测试。请在操作时验证版本:

datasets==3.1.0
falkordb==1.0.9
gradio==5.6.0
langchain-community==0.3.7
langchain-core==0.3.17
langchain-experimental==0.3.3
langchain-google-genai==2.0.4
langchain-openai==0.2.8
langchain-text-splitters==0.3.2
langchain==0.3.7
openai==1.54.4
pypdf==5.1.0

确保为您的 API 密钥设置环境变量:

os.environ["OPENAI_API_KEY"] = "APIKEY"

构建知识图谱

设置 FalkorDB

您可以通过云端或本地 Docker 设置连接 FalkorDB。

若要在本地设置 FalkorDB,请确保系统已安装 Docker。运行以下命令启动 FalkorDB:

docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:edge

或者,您可以通过 Docker Desktop 控制台启动容器。

在这里插入图片描述

要连接到云端,请创建一个账户并登录 FalkorDB 控制台。在仪表盘中,您可以创建一个 AWS 或 Google Cloud 实例并获取凭据。

在这里插入图片描述

数据导入

一旦 FalkorDB 启动,请定义并连接图数据库客户端。

import falkordb
from langchain_community.graphs importFalkorDBGraph
from langchain_community.graphs.graph_document importNode,Relationship


#For docker
graph =FalkorDBGraph(
    url="redis://localhost:6379", decode_responses=True
)


#For Cloud
graph =FalkorDBGraph(
    host="xxxx.cloud",
    username="your_falkordb_username",
    password="your_secret_password",
    port=52780,
    database="BFSI"
)

由于我们正在构建一个客户支持聊天机器人,我将使用一份银行手册,其中包含有关假设银行的全面信息。该数据集将演示聊天机器人如何处理有关银行产品和服务的复杂客户查询。当然,您也可以使用自己的数据集。

首先,从数据目录加载 PDF 文件。

from langchain_community.document_loaders import DirectoryLoader, PyPDFLoader

DOCS_PATH = "./data"

loader = DirectoryLoader(DOCS_PATH, glob="**/*.pdf", loader_cls=PyPDFLoader)

docs = loader.load()

本教程中,我将使用 OpenAI 的 LLM。以下是定义它的方法:

from langchain_openai import ChatOpenAI
llm = ChatOpenAI(temperature=0, model="gpt-4o-mini")

您可以手动创建知识图谱,也可以利用 LangChain 模块。

手动方法需要将文档拆分为块、识别节点和关系,并使用 Cypher 查询填充图谱。尽管有效,但它繁琐且耗时。以下是用于创建节点和关系的 Cypher 查询示例。

// Create Nodes for each label
CREATE (p:Program{id:'prog1'})
CREATE (fp:Financialproduct{id:'fin_prod1'})
CREATE (f:Feature{id:'feature1'})
CREATE (org:Organization{id:'org1'})
CREATE (s:Service{id:'service1'})


// Organization Relationships
CREATE (org)-[:MAINTAINS]->(f)
CREATE (org)-[:OFFERS]->(fp)
CREATE (org)-[:PROVIDES]->(f)
CREATE (org)-[:PROVIDES]->(s)
CREATE (org)-[:COMMITTED_TO]->(f)
CREATE (org)-[:DEVELOPS]->(p)
CREATE (org)-[:OFFERS]->(s)
CREATE (org)-[:OFFERS]->(p)


// Financial Product Relationships
CREATE (fp)-[:SECURE]->(org)
CREATE (fp)-[:INCLUDES]->(f)
CREATE (fp)-[:LINKED_TO]->(fp)
CREATE (fp)-[:MANAGED_THROUGH]->(f)
CREATE (fp)-[:HAS_FEATURE]->(f)
CREATE (fp)-[:OFFERS]->(p)


// Feature Relationships
CREATE (f)-[:OFFERED_BY]->(org)
CREATE (f)-[:PARTNERS_WITH]->(org)
CREATE (f)-[:INCLUDES]->(f)
CREATE (f)-[:ENCOURAGES]->(f)
CREATE (f)-[:COVERS]->(f)


// Program Relationships
CREATE (p)-[:INCLUDES]->(f)
CREATE (p)-[:OFFERS]->(fp)

在微软的 GraphRAG 版本中,提供给 LLM 的图谱提取提示如下所示:

-Goal-
Givenatextdocumentthatispotentiallyrelevanttothisactivityandalistofentitytypes,identifyallentitiesofthosetypesfromthetextandallrelationshipsamongtheidentifiedentities.


-Steps-
1.Identifyallentities.Foreachidentifiedentity,extract the following information:
-entity_name:Nameoftheentity,capitalized
-entity_type: One of the following types:[{entity_types}]
-entity_description:Comprehensivedescriptionoftheentity'sattributesandactivities
Formateachentityas("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description>


2.Fromtheentitiesidentifiedinstep1,identifyallpairsof(source_entity,target_entity)thatare*clearlyrelated*toeachother.
Foreachpairofrelatedentities,extract the following information:
-source_entity:nameofthesourceentity,asidentifiedinstep1
-target_entity:nameofthetargetentity,asidentifiedinstep1
-relationship_description:explanationastowhyyouthinkthesourceentityandthetargetentityarerelatedtoeachother
-relationship_strength:anumericscoreindicatingstrengthoftherelationshipbetweenthesourceentityandtargetentity
Formateachrelationshipas("relationship"{tuple_delimiter}<source_entity>{tuple_delimiter}<target_entity>{tuple_delimiter}<relationship_description>{tuple_delimiter}<relationship_strength>)


3.ReturnoutputinEnglishasasinglelistofalltheentitiesandrelationshipsidentifiedinsteps1and2.Use**{record_delimiter}**asthelistdelimiter.


4.Whenfinished,output {completion_delimiter}


<MultishotExamples>


-RealData-
######################
Entity_types: {entity_types}
Text: {input_text}
######################
Output:

为了简化,您可以将所需的 LLM 提供给 LangChain,让它完成剩下的工作。LLM 图谱转换器模块将负责为您创建知识图谱。让我解释一下背后的工作原理。

LLM 图谱转换器使用两种不同的方法来创建图谱:

  1. \1. 基于工具的模式:这是默认模式,适用于支持工具调用的任何 LLM。在此模式下,节点和关系被定义为类。
  2. \2. 基于提示的模式:这是备用模式,用于当 LLM 不支持工具调用时。在这种模式下,模型使用少样本学习从文本中提取实体及其关系。然后将这些数据解析为 JSON 格式以创建图节点和连接。
from langchain_experimental.graph_transformers import LLMGraphTransformer


graph_transformer = LLMGraphTransformer(llm=llm)
data = graph_transformer.convert_to_graph_documents(docs)
graph.add_graph_documents(data)

您可以指定自定义节点类型以限制图谱结构。如果不指定,LLM 将根据内容自动确定适当的节点类型。例如:

allowed_nodes = ["Organization", "FinancialProduct", "Feature", "Service", "Program"]
graph_transformer = LLMGraphTransformer(llm=llm, allowed_nodes=allowed_nodes)
data = graph_transformer.convert_to_graph_documents(docs)
graph.add_graph_documents(data)

创建图谱后,您可以检查其模式以验证结构。请注意,输出可能很长,因此不包括在此。

graph.refresh_schema()
print(graph.schema)

为了帮助您更好地理解我创建的知识图谱,以下是一个可视化表示:

在这里插入图片描述

查询知识图谱

尽管创建图数据库相对简单,但提取有意义的信息需要掌握像 Cypher 这样的查询语言。Cypher 是一种专为图数据库设计的声明式查询语言,使用模式匹配语法高效遍历节点和关系。FalkorDB 遵循 OpenCypher 格式。

以下是基于我们刚刚创建的知识图谱的 Cypher 查询示例:

results = graph.query("MATCH (sa:Financialproduct) RETURN sa")
content_list = []
for row in results:
    node = row[0]
    print(node)

查询返回银行提供的所有金融产品。

(:Financialproduct{id:"Savings Account"})
(:Financialproduct{id:"Savings_Account"})
(:Financialproduct{id:"Checking Account"})
(:Financialproduct{id:"Holiday-Themed Savings Incentives"})
(:Financialproduct{id:"Youth Savings Account"})

不同的图数据库以各种方式处理此类查询,可以通过直接实现或与 LangChain 等框架集成。例如,在 LangChain 中,可以通过以下方式执行查询:

from langchain.chains import FalkorDBQAChain


chain = FalkorDBQAChain.from_llm(llm=llm, graph=graph, cypher_prompt=cypher_generation_prompt, qa_prompt=chat_prompt, verbose=True,allow_dangerous_requests=True)
response = chain.run(input_user_prompt)

为了让您更清楚地了解背后的工作原理,我将实现一个自定义查询来演示底层机制。这将帮助您更直观地理解这些系统的后端运行逻辑。

在这里插入图片描述

自动化 Cypher 查询生成

我们需要结合一些提示工程以生成高质量的 Cypher 查询。目前,我们的实现使用精心设计的提示,将数据库模式(包括节点和关系)与用户查询结合起来。然而,总有改进的空间。您可以通过将工具调用与 OpenAI 集成或利用微调的语言模型来进一步优化查询生成。

以下是定义一个函数以优化模式提示的方法:

def format_schema_for_prompt(schema: Any)->str:
"""
    Format the graph schema into a clear, LLM-friendly string.
   
    Args:
        schema: Schema object from the graph database
       
    Returns:
        Formatted string representation of the schema
    """
try:
        nodes =set()
        relationships =[]

for item in schema:
ifhasattr(item,'start_node'):
                nodes.add(item.start_node)
                nodes.add(item.end_node)
                relationships.append({
'start': item.start_node,
'type': item.relationship_type,
'end': item.end_node
})

# Format the schema information
        formatted_output ="Node Types:\n"
for node insorted(nodes):
            formatted_output +=f"- {node}\n"

        formatted_output +="\nRelationships:\n"
for rel in relationships:
            formatted_output +=f"- {rel['start']} -[{rel['type']}]-> {rel['end']}\n"

return formatted_output

exceptExceptionas e:
# Fallback to returning raw schema if formatting fails
returnstr(schema)

格式化后的模式现在可以包含在提示模板中。

current_schema = graph.schema

formatted_schema = format_schema_for_prompt(current_schema)
 
system_prompt = f"""You are an expert at converting natural language questions into Cypher queries.
        The graph has the following schema:
       
        {formatted_schema}
       
        Return ONLY the Cypher query without any explanation or additional text.
        Make sure to use proper Cypher syntax and casing.
        Use the exact relationship types and node labels as shown in the schema."""

Cypher 查询输出分析

完成 Cypher 查询后,需要将结果传递给另一个 LLM。这种双 LLM 方法确保用户在聊天交互中收到清晰、上下文相关的信息,而不是原始数据库结果。

def format_results_for_llm(results: List)->str:
"""
    Format results in a way that's optimal for LLM analysis.


    Args:
        results: Processed query results


    Returns:
        Formatted string of results
    """
    output =""
for i, row inenumerate(results,1):
        output +=f"\nItem {i}:\n"
for item in row:
ifisinstance(item,dict):
                output +=f"Type: {item['type']}\n"
                output +="Properties:\n"
for key, value in item['properties'].items():
                    output +=f"  - {key}: {value}\n"
else:
                output +=f"Value: {item}\n"
        output +="---\n"
return output

分析提示可以结构化如下:

"""You are a financial services expert. Based on the graph query results provided,
        give a comprehensive analysis and explanation. Include relevant details about each item and how they relate
        to each other. If appropriate, suggest related products or services that might be relevant to the user.
        Format your response in a clear, structured way."""

现在,使用辅助函数并将其集成到主函数中。

def query_graph_with_llm(
    llm,
    graph,
    user_query: str,
    system_prompt=None,
    analysis_prompt: str = """You are a financial services expert. Based on the graph query results provided,
    give a comprehensive analysis and explanation. Include relevant details about each item and how they relate
    to each other. If appropriate, suggest related products or services that might be relevant to the user.
    Format your response in a clear, structured way."""
):
"""
    Query the knowledge graph using LLM-generated Cypher queries and analyze results.


    Args:
        llm: Language model instance
        graph: FalkorDB graph instance
        user_query: Natural language query from user
        analysis_prompt: Prompt for analyzing results


    Returns:
        Dict containing query results, metadata, and analysis
    """
try:
        current_schema = graph.schema
        formatted_schema = format_schema_for_prompt(current_schema)

        system_prompt =f"""You are an expert at converting natural language questions into Cypher queries.
        The graph has the following schema:
       
        {formatted_schema}
       
        Return ONLY the Cypher query without any explanation or additional text.
        Make sure to use proper Cypher syntax and casing.
        Use the exact relationship types and node labels as shown in the schema."""



        query_messages =[
{"role":"system","content": system_prompt},
{"role":"user","content":f"Convert this question to a Cypher query: {user_query}"}
]


        cypher_query = llm.predict_messages(query_messages).content


        cypher_query = re.sub(r'```cypher\s*|\s*```','', cypher_query).strip()



        results = graph.query(cypher_query)



        processed_results =[]
for row in results:
            row_data =[]
for item in row:
ifhasattr(item,'properties'):                      row_data.append({
'type': item.labels[0]ifhasattr(item,'labels')else item.type,
'properties':dict(item.properties)
})
else:
                    row_data.append(item)
            processed_results.append(row_data)



        results_text = format_results_for_llm(processed_results)


# Generate analysis using LLM
        analysis_messages =[
{"role":"system","content": analysis_prompt},
{"role":"user","content":f"User Question: {user_query}\n\nQuery Results:\n{results_text}\n\nPlease provide a comprehensive analysis of these results."}
]


        analysis = llm.predict_messages(analysis_messages).content


return{
'success':True,
'query': cypher_query,
'raw_results': processed_results,
'analysis': analysis,
'error':None,
'schema_used': formatted_schema          }


exceptExceptionas e:
return{
'success':False,
'query': cypher_query if'cypher_query'inlocals()elseNone,
'raw_results':None,
'analysis':None,
'error':str(e),
'schema_used': formatted_schema if'formatted_schema'inlocals()elseNone
        }

看起来不错!让我们测试一下这个函数。

query = "What financial products are available for young customers?"
results = query_graph_with_llm(llm, graph, query)
print(format_final_output(results))
CypherQuery:
MATCH (p:Product)<-[:AVAILABLE_FOR]-(c:Customer) WHERE c.age <30 RETURN p

Analysis:
Based on the query results regarding financial products available for young customers, we can analyze and categorize the offerings into several key areas.This analysis will help young customers understand their options and how these products can meet their financial needs.

### 1. **Savings Accounts**
-**YouthSavingsAccounts**:These accounts are specifically designed for young customers, often with lower minimum balance requirements and no monthly fees.They typically offer competitive interest rates to encourage saving from an early age.
-**Benefits**:Teaching financial responsibility, earning interest,and building a savings habit.

### 2. **Checking Accounts**
-**StudentCheckingAccounts**:Tailoredfor students, these accounts usually come with no monthly maintenance fees and free access to ATMs.They may also offer features like mobile banking and budgeting tools.
-**Benefits**:Easy access to funds, budgeting assistance,and financial management skills.

### 3. **Credit Cards**
-**SecuredCreditCards**:These are ideal for young customers looking to build credit.They require a cash deposit that serves as the credit limit, minimizing risk for the issuer.
-**StudentCreditCards**:Designedfor college students, these cards often have lower credit limits and rewards tailored to student spending (e.g., discounts on textbooks or dining).
-**Benefits**:Establishing a credit history, learning responsible credit use,and potential rewards.

### 4. **Investment Accounts**
-**CustodialAccounts**:For minors, these accounts allow parents or guardians to manage investments on behalf of the child until they reach adulthood.They can invest in stocks, bonds,or mutual funds.
-**Robo-Advisors**:Young customers can use robo-advisors to start investing with low fees and minimal initial investment.These platforms often provide automated portfolio management based on risk tolerance.
-**Benefits**:Early exposure to investing, potential for long-term growth,and financial literacy.

### 5. **Student Loans**
-**FederalStudentLoans**:These loans are available to students attending college and typically have lower interest rates and flexible repayment options.
-**PrivateStudentLoans**:Offered by banks and credit unions, these loans can help cover education costs not met by federal loans.
-**Benefits**:Access to higher education, potential for future earning increases,and various repayment options.

### 6. **Insurance Products**
-**HealthInsurance**:Young customers can often stay on their parents' health insurance plans until age 26, but they may also explore options through school or the marketplace.
   - **Renter's Insurance**:For young adults living independently, renter's insurance protects personal belongings and is often affordable.
   - **Benefits**: Financial protection against unexpected events and health-related expenses.

### 7. **Financial Education Resources**
   - **Workshops and Online Courses**: Many financial institutions offer free resources to educate young customers about budgeting, saving, and investing.
   - **Mobile Apps**: Budgeting apps can help young customers track their spending and savings goals.
   - **Benefits**: Empowering young customers with knowledge, improving financial literacy, and fostering responsible financial habits.

### **Conclusion and Recommendations**
Young customers have a variety of financial products tailored to their unique needs. It is essential for them to start with basic products like savings and checking accounts to build a solid financial foundation. As they progress, they can explore credit cards and investment accounts to enhance their financial literacy and creditworthiness.

**Related Products/Services Suggestions**:
- **Financial Planning Services**: Consider consulting with a financial advisor to create a personalized financial plan.
- **Budgeting Tools**: Utilize apps or software that help track expenses and savings goals.
- **Scholarship Search Services**: For students, finding scholarships can significantly reduce education costs.

By understanding these products and their interconnections, young customers can make informed decisions that will benefit their financial future.

聊天机器人集成

恭喜您完成了所有步骤!现在,让我们将所有内容整合到一个 Gradio 界面中。以下是您的 GraphRAG 驱动虚拟助手,随时为您服务。

在这里插入图片描述

总结

在本文中,我们了解了 GraphRAG 如何为企业提供客户支持聊天机器人。我已涵盖以下关键组件:构建知识图谱、为 Cypher 查询生成构建 LLM 驱动的管道,以及利用 FalkorDB 的功能创建高效、低延迟的 GraphRAG 系统。此方法展示了现代图数据库如何有效支持智能客户服务解决方案。

我还比较了 RAG 系统中图数据库与向量数据库的优劣,并演示了如何根据业务需求选择更适合的解决方案。为了进一步探索,建议您尝试创建更详细的知识图谱,以表示复杂的数据关系。您还可以试用 FalkorDB 的 graph-sdk,它能让这个过程更加简单。

完整代码请访问 GitHub:https://github.com/Ashish-Abraham/LLM-Boilerplate/blob/main/FalkorDB/FalkorDBGraphRAG.ipynb

参考文献

[1] FalkorDB Documentation (2024). Documentation(https://docs.falkordb.com/)

[2] LangChain Documentaion (2024). Documentation(https://python.langchain.com/docs/introduction/)

[3] OpenCypher (2024).Resources(https://opencypher.org/resources/)

[4] Microsoft Research., Darren Edge., Ha Trinh., Newman., Joshua B., Alex C., Steven T., Apurva Mody. (2024). From Local to Global: A Graph RAG Approach to Query-Focused Summarization. arXiv:2404.16130

[5] Tomaz Bratanic.Building Knowledge Graphs with LLM Graph Transformer (2024).Towards Data Science

​

如何学习AI大模型?

作为一名热心肠的互联网老兵,我决定把宝贵的AI知识分享给大家。 至于能学习到多少就看你的学习毅力和能力了 。我已将重要的AI大模型资料包括AI大模型入门学习思维导图、精品AI大模型学习书籍手册、视频教程、实战学习等录播视频免费分享出来。

这份完整版的大模型 AI 学习资料已经上传CSDN,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【保证100%免费】

一、全套AGI大模型学习路线

AI大模型时代的学习之旅:从基础到前沿,掌握人工智能的核心技能!

img

二、640套AI大模型报告合集

这套包含640份报告的合集,涵盖了AI大模型的理论研究、技术实现、行业应用等多个方面。无论您是科研人员、工程师,还是对AI大模型感兴趣的爱好者,这套报告合集都将为您提供宝贵的信息和启示。

img

三、AI大模型经典PDF籍

随着人工智能技术的飞速发展,AI大模型已经成为了当今科技领域的一大热点。这些大型预训练模型,如GPT-3、BERT、XLNet等,以其强大的语言理解和生成能力,正在改变我们对人工智能的认识。 那以下这些PDF籍就是非常不错的学习资源。

img

四、AI大模型商业化落地方案

img

作为普通人,入局大模型时代需要持续学习和实践,不断提高自己的技能和认知水平,同时也需要有责任感和伦理意识,为人工智能的健康发展贡献力量。

ET2012新版免狗免安装绿色软件 ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉, 立即下载

相关推荐

HEVC/VVC中R-Lambda码率控制算法原理

文章目录1. 比特分配1.1 GOP级比特分配1.2 帧级比特分配1.3 LCU级比特分配2. 码率控制2.1 λ的计算和更新2.2 参数QP的确定 VVC中码率控制算法沿用了HEVC中经典的R-λ码率控制模型,R-λ由中科大的李斌博士提出(详情参考JCTVC-K0103)。R-λ模型的基础为视频编码中 R(比特 bpp)和 D(失真 MSE)之间的双曲线模型,即 D(R)=CR−KD(R) = ...

Aidoneus_y 6144

GraphRAG中模板提示词中文版

目标活动-你是一名智能助手,帮助人类分析师分析文本文件中针对某些实体的声明。-目标-给定一个可能与此活动相关的文本文件、一个实体规范和一个声明描述,提取所有符合实体规范的实体及其针对这些实体的所有声明。-步骤-1. 提取所有符合预定义实体规范的命名实体。实体规范可以是实体名称列表或实体类型列表。2. 对于步骤1中识别的每个实体,提取所有与该实体相关的声明。声明需要符合指定的声明描述,并且实体应为声明的主语。对于每个声明,提取以下信息:- 主体:声明的主体实体名称,需大写。

weixin_46248339的博客 4103

ESP32-S3双模CMSIS-DAP调试器:USB+WiFi无线调试方案

CMSIS-DAP是ARM生态中标准化的嵌入式调试协议接口,广泛用于Keil、IAR、STM32CubeIDE等开发环境。其核心原理是通过SWD/JTAG物理层实现目标芯片寄存器访问、内存读写与断点控制,依赖确定性时序和低延迟通信。传统DAPLink调试器受限于USB线缆束缚,而WiFi-USB-DAPLink项目将完整CMSIS-DAP v2协议栈移植至ESP32-S3平台,同时支持USB CDC直连与WiFi TCP远程通道,兼顾实时性与网络化部署能力。该方案无需主机驱动、兼容主流IDE,并支持多机并发

weixin_31185473的博客 380

微软GraphRAG原理介绍(附带部分源码)

这篇文章主要介绍了微软开源的GraphRAG的数据构建原理和查询检索原理

luxinfeng的博客 6619

AWR1642+DCA1000EVM 不使用mmWave Studio软件采集原始ADC数据 Timeout问题汇总

DCA1000 EVM Timeout问题汇总

Jesy_Hsu的博客 1481

2024最新指南:如何用Python批量下载Sentinel-2数据(附避坑清单)

本文提供2024年最新Python批量下载Sentinel-2遥感数据的完整指南,涵盖环境配置、API准备、核心下载流程实现及实战避坑清单。通过智能查询器、断点续传下载器等实用工具,帮助用户高效获取遥感数据,避免常见网络问题和数据完整性验证失败。

silver的专栏 623

基于Python 批量导入实体与关系到 Neo4j 数据库的完整实践

在知识图谱构建过程中,将结构化或半结构化数据导入到图数据库是关键步骤之一。本文将详细介绍如何使用 Python 解析自定义格式数据,并通过 Neo4j 官方驱动将实体和关系批量导入到 Neo4j 数据库中,帮助你快速搭建自己的知识图谱。我也在最后附上完整代码,可直接运行。

weixin_38252409的博客 1030

高功率半导体叠阵激光快慢轴准直优化技术解析

本文深入解析了高功率半导体叠阵激光快慢轴准直优化技术。针对其光束发散特性,文章系统阐述了从光源建模、光学仿真到透镜选型与参数匹配的完整工程流程,并强调了光束整形对于提升加工精度与效率的核心作用。通过优化快慢轴准直,可将原始散光转变为能量集中、均匀性好的高质量光束,为后续工业应用奠定基础。

php55的博客 714

GraphRAG手调Prompt提取自定义实体

调查论文《A Survey on Retrieval-Augmented Text Generation for Large Language Models》由Yizheng Huang和Jimmy Huang撰写,于2024年4月17日发表。该论文详细探讨了RAG如何结合检索方法与深度学习进展,以解决大型语言模型(LLMs)的静态限制问题,通过动态整合最新的外部信息来增强模型的准确性和可靠性。

weixin_58753619的博客 2254

6、哈代空间、算子函数及相关概念解析

本文深入探讨了数学中哈代空间与算子函数的核心概念,包括强函数的因式分解、半单零点的定义与性质、Blaschke-Potapov乘积的存在性、Nagy-Foias模型算子的结构与谱分析、可数集合的相关性质(如Carlesonian集合、稀有集合等)、简单分式族的可分性与基性质,以及指数型整函数的增长特性。文章还分析了这些数学对象之间的内在联系,并通过图表与表格形式直观呈现了集合性质与函数空间结构的关系。这些理论不仅在数学分析和泛函分析中具有重要意义,也在信号处理、量子力学等应用领域具有广泛价值。

yhn4567890的博客 172

YOLO11涨点优化:卷积魔改 | 可变形条带卷积(DSCN),魔改轻量DCNv3二次创新

如何跟YOLO11结合:1)和C3k2创新性结合

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 993

nano-graphrag NO.2

tuple_delimiter作为一个分割的串。-goal--steps-给两个实例,类似few-shot,以及真实数据的格式。对描述进行总结,减少token数PROMPTS[#######-Data-#######Output:"""生成响应:生成一个符合目标长度和格式的响应,该响应应回答用户的问题,并总结多个分析师的报告,这些分析师专注于数据集的不同部分。报告的重要性排序:注意,提供的分析师报告是按重要性降序排列的。不知道则明确说明。

2301_80378706的博客 979

基于fme和python-docx第三方库批量更新不动产调查表

最近应朋友需要批量更新在不动产成果中提交的各种word报表中的指定数据,根据初步的了解,我做了一个基于fme软件和python-docx第三方库进行一个批量的更新方案。

weixin_43229258的博客 1244

从RAG到GraphRAG:知识图谱、本体论与更智能的AI

本文深入解析了从传统RAG技术向GraphRAG演进的技术路径,详细介绍了知识图谱和本体论如何革新AI问答系统,让AI不仅能检索信息,更能真正理解和推理复杂知识关系,为企业级AI应用提供更精准、更具洞察力的解决方案。

pythonhy的博客 1491

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

快速理解 GraphRAG:构建更可靠、更智能的 Chatbot

这一问题,基于 GraphRAG 的检索器能够追溯从牛顿的理论到爱因斯坦的成就之间的演变,清晰地展示了 17 世纪物理学对 20 世纪初物理学发展的深刻影响。尽管有一些人尝试构建强大稳固的问答系统,但往往模型给出的答案不尽人意,即使它们接入的是内容全面的知识库,也难以成功。RAG 技术是将基于检索的方法和基于生成的方法的优点结合起来的重要一步。以“法国的首都是什么?”这样的简单问题为例,RAG 系统会在其语料库中寻找涉及法国及其首都巴黎的信息,检索到相关内容后,生成答案:“法国的首都是巴黎。

Baihai_IDP的博客 1151

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

【AI大模型实战】GraphRAG+Ollama:打造本地知识图谱AI助手,小白轻松也能上手

GraphRAG通过将信息组织成知识图谱,使AI能精准回答复杂问题;Ollama则是在本地运行AI模型的开源工具。两者结合,可构建隐私优先、成本效益高的本地AI系统。文章详细介绍了GraphRAG与Ollama的协同工作原理、代码实现、设置指南及实际应用场景,帮助开发者从零开始构建本地知识图谱AI助手,提升AI回答的准确性和关联性。

Android23333的博客 671

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 保姆级教程:利用大模型与高德地图API,轻松实现查找附近咖啡店
下一篇: 利用Milvus向量数据库,带你实现GraphRAG
少喝冰美式
博客等级 码龄3年 6895粉丝 517原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址