[go: up one dir, main page]

CN118152428A - A method and device for predicting and enhancing query instructions of power customer service system - Google Patents

A method and device for predicting and enhancing query instructions of power customer service system Download PDF

Info

Publication number
CN118152428A
CN118152428A CN202410564229.1A CN202410564229A CN118152428A CN 118152428 A CN118152428 A CN 118152428A CN 202410564229 A CN202410564229 A CN 202410564229A CN 118152428 A CN118152428 A CN 118152428A
Authority
CN
China
Prior art keywords
text
query
data
customer service
service system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410564229.1A
Other languages
Chinese (zh)
Inventor
王春竹
陈本权
张会钦
于霞
陈鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
YANTAI HAIYI SOFTWARE CO Ltd
Original Assignee
YANTAI HAIYI SOFTWARE CO Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by YANTAI HAIYI SOFTWARE CO Ltd filed Critical YANTAI HAIYI SOFTWARE CO Ltd
Priority to CN202410564229.1A priority Critical patent/CN118152428A/en
Publication of CN118152428A publication Critical patent/CN118152428A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/09Supervised learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/01Customer relationship services
    • G06Q30/015Providing customer assistance, e.g. assisting a customer within a business location or via helpdesk
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/06Energy or water supply

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Economics (AREA)
  • Computing Systems (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Molecular Biology (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Primary Health Care (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Accounting & Taxation (AREA)
  • Tourism & Hospitality (AREA)
  • Human Resources & Organizations (AREA)
  • Water Supply & Treatment (AREA)
  • Public Health (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A prediction and enhancement method and a device for query instructions of an electric power customer service system relate to the field of data query of the electric power customer service system. The method embeds the trained data of the power industry into a large language model for loading, and converts the input data text into a semantic vector; matching the query instruction of the user with the structured data, and returning the structured data matched with the query instruction; if the query instructions are not matched, adopting an error correction algorithm to correct the error query instructions; carrying out knowledge enhancement and text classification on the error correction string by using the structured data; acquiring a query instruction input by a user, performing vector similarity search on the query instruction and the structured data, obtaining a text queue with the most relevant semantics, and outputting and displaying; constructing a retrieval enhancement generation model, and calling a large language model to generate a response result matched with a query instruction of a user. The method is mainly used for predicting and enhancing the intention of the query instruction of the electric power customer service system.

Description

一种电力客服系统查询指令的预测和增强方法及其装置A prediction and enhancement method and device for query instructions of power customer service system

技术领域Technical Field

本发明涉及电力客服系统的数据查询领域,尤其涉及一种电力客服系统查询指令的预测和增强方法及其装置。The present invention relates to the field of data query of an electric power customer service system, and in particular to a method and a device for predicting and enhancing a query instruction of an electric power customer service system.

背景技术Background technique

目前电力客服系统中对于用户问题的应答技术主要是基于FAQ(FrequentlyAsked Questions,常见问题解答)知识库进行的,主要由业务人员进行相关规则的设定,当问题命中规则后给出相关问题应答。这种知识搜索模式存在很多问题:At present, the answering technology for user questions in the power customer service system is mainly based on the FAQ (Frequently Asked Questions) knowledge base, and the business personnel mainly set the relevant rules. When the question hits the rule, the relevant answer is given. This knowledge search mode has many problems:

(1)对问题的理解有限:FAQ知识库只能根据已有的问题和答案库进行匹配,无法对语言进行更深入的理解和解析,难以根据用户的需求进行智能化的预测和推荐;(1) Limited understanding of questions: FAQ knowledge bases can only match existing questions and answer bases, and cannot provide a deeper understanding and analysis of language, making it difficult to make intelligent predictions and recommendations based on user needs.

(2)无法处理复杂问题:FAQ知识库只能处理简单的问题,无法处理复杂的频繁问题和多轮对话,缺乏对于用户需求深度理解和预测的能力,无法准确把握用户的需求,导致用户体验不佳,很多问答规则需要人工进行标注也增加了客服人员的工作负担;(2) Unable to handle complex questions: FAQ knowledge bases can only handle simple questions, but cannot handle complex, frequent questions and multi-round conversations. They lack the ability to deeply understand and predict user needs and cannot accurately grasp user needs, resulting in poor user experience. Many question-and-answer rules require manual labeling, which increases the workload of customer service staff.

(3)对答案的质量要求高:FAQ知识库返回的答案必须是准确的,否则会影响用户体验和信任度。(3) High quality requirements for answers: The answers returned by the FAQ knowledge base must be accurate, otherwise it will affect user experience and trust.

在电力客服系统中,对用户query(即查询指令)的准确理解是为客户提供优质服务的关键。电力行业由于其本身的专业性与特殊性,对于电力知识的搜索要求也很高。一般来说,电力企业客户服务内部会存在多个不同的业务系统,比如专业面向客户的客服助手、面向员工内部的业务系统以及面向供应商的采购系统等,多样化的业务产生的数据以及文档是海量的,而且电力客户系统的搜索的术语一般是专业术语、短文段或者长文档,客户咨询问题的时候时常出现表达不清晰、使用语音输入转换不准确、省略表达等情况,导致搜索结果不尽如人意,不能有效服务客户的情况。In the power customer service system, accurate understanding of user queries (i.e. query instructions) is the key to providing customers with quality services. Due to its own professionalism and particularity, the power industry also has high requirements for the search of power knowledge. Generally speaking, there are multiple different business systems within the customer service of power companies, such as professional customer service assistants for customers, business systems for employees, and procurement systems for suppliers. The data and documents generated by the diverse businesses are massive, and the search terms of the power customer system are generally professional terms, short paragraphs or long documents. When customers ask questions, they often express unclearly, use voice input conversion inaccurately, omit expressions, etc., resulting in unsatisfactory search results and ineffective customer service.

虽然现有技术中的电力客服系统也对一些简单的搜索模型进行了研发,对于用户query的应答与意图识别主要依赖于关键词匹配或者是主要基于自然语言处理技术,但这在某些情况下可能导致意图识别的不准确。例如,用户可能使用不同的词汇或短语来表达相同的意图,或者由于语音输入的误差导致关键词匹配失败。Although the existing power customer service system has also developed some simple search models, the response to user queries and intent recognition mainly rely on keyword matching or are mainly based on natural language processing technology, but this may lead to inaccurate intent recognition in some cases. For example, users may use different words or phrases to express the same intent, or keyword matching fails due to errors in voice input.

因此,就需要一种能够精准深入地理解用户的意图、对用户查询指令进行预测和意图增强的电力客服系统查询指令的预测和增强方法及其装置。Therefore, there is a need for a method and device for predicting and enhancing query instructions of an electric power customer service system that can accurately and deeply understand the user's intentions, predict the user's query instructions, and enhance the intentions of the user.

发明内容Summary of the invention

本发明为了解决现有的电力客服系统对用户的查询指令的意图识别不准确、不能深入理解用户的意图的缺陷,提供了一种能够精准深入地理解用户的意图、对用户查询指令进行预测和意图增强的电力客服系统查询指令的预测和增强方法及其装置。In order to solve the defects of the existing electric power customer service system inaccurately recognizing the intention of user query instructions and failing to deeply understand the user's intention, the present invention provides a method and device for predicting and enhancing the query instructions of the electric power customer service system, which can accurately and deeply understand the user's intention, predict the user's query instructions and enhance the intention.

本发明所述的一种电力客服系统查询指令的预测和增强方法,包括如下步骤:The method for predicting and enhancing a query instruction of a power customer service system according to the present invention comprises the following steps:

S1:收集并处理电力行业的数据,并对其进行训练;S1: Collect and process data from the power industry and train it;

S2:将训练好的数据嵌入到大语言模型进行加载,采用大语言模型将输入的数据文本转换成语义向量;S2: embed the trained data into the large language model for loading, and use the large language model to convert the input data text into a semantic vector;

S3:对用户的查询指令进行与结构化数据进行匹配,若匹配成功,则直接返回与所述查询指令匹配的结构化数据;若不匹配,则对出错的查询指令执行S4;S3: Match the user's query instruction with the structured data. If the match is successful, directly return the structured data matching the query instruction; if the match is not successful, execute S4 for the query instruction with error;

S4:采用纠错算法对所述出错的查询指令进行纠错,从而获得正确概率最高的纠错串;S4: using an error correction algorithm to correct the erroneous query instruction, thereby obtaining an error correction string with the highest probability of being correct;

S5:利用所述结构化数据对所述纠错串进行知识增强和文本分类;S5: performing knowledge enhancement and text classification on the error correction string using the structured data;

S6:获取用户输入的查询指令,将其与所述结构化数据执行向量相似度搜索,得到语义最相关的文本队列并输出展示;S6: Obtain the query instruction input by the user, perform vector similarity search on the query instruction and the structured data, obtain the text queue with the most semantic relevance, and output it for display;

S7:构造检索增强生成模型,调用所述大语言模型生成与用户的查询指令匹配的应答结果。S7: Construct a retrieval enhancement generation model, and call the large language model to generate a response result that matches the user's query instruction.

进一步地:在S2中,还包括:构建向量数据库并将所述语义向量存入向量数据库中。Furthermore: in S2, it also includes: constructing a vector database and storing the semantic vector in the vector database.

进一步地:在S7中,还包括:构造提示库,用于指导所述大语言模型根据上下文回答问题;Further: in S7, it also includes: constructing a prompt library for guiding the large language model to answer questions according to the context;

进一步地:在S1中,所述收集的数据包括用户查询指令和电力领域知识;所述处理包括预处理和清洗,用于去除无关信息和噪声数据;所述训练是首先采用文档加载器将不同种类的文档加载成纯文本,然后采用文本分割器对所述纯文本进行分割。Further: in S1, the collected data includes user query instructions and power field knowledge; the processing includes preprocessing and cleaning for removing irrelevant information and noise data; the training is first using a document loader to load different types of documents into plain text, and then using a text segmenter to segment the plain text.

进一步地:在S4中,所述纠错算法通过贝叶斯公式进行建模和计算,即:Further: In S4, the error correction algorithm is modeled and calculated by the Bayesian formula, that is:

argmax p(r|q) = argmax p(q|r)p(r)/p(q) = argmax p(q|r)p(r);argmax p(r|q) = argmax p(q|r)p(r)/p(q) = argmax p(q|r)p(r);

其中,argmax 表示求所有纠错串发生的概率的最大值,q表示原串,r表示纠错串,p(r|q)表示在原串q发生的情况下,纠错串发生的概率,p(q|r)表示原串到纠错串的转移概率,p(r)表示纠错串作为正常查询指令的概率,p(q)是一个与r无关的常数。Among them, argmax means finding the maximum value of the probability of all error-correcting strings occurring, q represents the original string, r represents the error-correcting string, p(r|q) represents the probability of the error-correcting string occurring when the original string q occurs, p(q|r) represents the transition probability from the original string to the error-correcting string, p(r) represents the probability of the error-correcting string being a normal query instruction, and p(q) is a constant that is independent of r.

进一步地:在S5中,所述结构化数据存储在知识图谱或知识库中,所述知识增强是指对用户的查询指令与所述结构化数据进行实体链接和语义推理,训练所述大语言模型对知识图谱或知识库中的结构化数据进行理解和表示,从而提高所述大语言模型对所述查询指令意图的识别能力。Further: In S5, the structured data is stored in a knowledge graph or a knowledge base, and the knowledge enhancement refers to entity linking and semantic reasoning between the user's query instructions and the structured data, and training the large language model to understand and represent the structured data in the knowledge graph or knowledge base, thereby improving the large language model's ability to recognize the intent of the query instructions.

进一步地:在S5中,所述文本分类是采用卷积神经网络实现的,具体过程如下:Further: In S5, the text classification is implemented by using a convolutional neural network, and the specific process is as follows:

S51:构建卷积神经网络模型;所述卷积神经网络模型包括输入层、卷积层、池化层、全连接层和输出层;所述输入层用于接收待分类的文本,所述卷积层用于提取文本中的局部特征,所述池化层用于降低数据的维度,所述全连接层用于将提取到的特征映射到输出空间,所述输出层用于对文本进行分类;S51: Construct a convolutional neural network model; the convolutional neural network model includes an input layer, a convolutional layer, a pooling layer, a fully connected layer and an output layer; the input layer is used to receive text to be classified, the convolutional layer is used to extract local features in the text, the pooling layer is used to reduce the dimension of the data, the fully connected layer is used to map the extracted features to the output space, and the output layer is used to classify the text;

S52:使用带标签的结构化数据作为训练集,对所述卷积神经网络模型进行训练,使其从结构化数据中学习并识别不同的文本类别;所述卷积神经网络模型的训练是使用交叉熵损失函数和梯度下降优化器来实现;S52: Using the labeled structured data as a training set, training the convolutional neural network model so that it learns and recognizes different text categories from the structured data; the training of the convolutional neural network model is implemented using a cross entropy loss function and a gradient descent optimizer;

S53:使用测试集对训练好的卷积神经网络模型进行测试和评估,计算分类准确率和/或召回率指标,以评估所述卷积神经网络模型的性能。S53: Use the test set to test and evaluate the trained convolutional neural network model, and calculate the classification accuracy and/or recall rate indicators to evaluate the performance of the convolutional neural network model.

进一步地:在S7中,所述应答结果根据用户的需要选择展示方式,所述展示方式包括文本形式、数据图表形式、音频形式和/或视频形式。Further: in S7, the response result is displayed in a manner selected according to the needs of the user, and the display manner includes text form, data chart form, audio form and/or video form.

本发明所述的一种电力客服系统查询指令的预测和增强装置,包括大语言模型、数据训练模块、文本转换模块、意图识别增强模块、纠错模块和应答结果生成展示模块;The device for predicting and enhancing query instructions of a power customer service system described in the present invention comprises a large language model, a data training module, a text conversion module, an intention recognition enhancement module, an error correction module and a response result generation and display module;

所述数据训练模块用于训练电力行业的数据;The data training module is used to train data of the power industry;

所述文本转换模块用于调用大语言模型对训练好的数据文本转换成语义向量;The text conversion module is used to call the large language model to convert the trained data text into a semantic vector;

所述纠错模块用于对出错的查询指令进行纠错,从而获得正确概率最高的纠错串;The error correction module is used to correct the error query instruction, so as to obtain the error correction string with the highest correct probability;

所述意图识别增强模块用于对所述纠错串进行知识增强和文本分类;The intention recognition enhancement module is used to perform knowledge enhancement and text classification on the error correction string;

所述应答结果生成展示模块用于调用所述大语言模型生成与用户的查询指令匹配的应答结果。The response result generation and display module is used to call the large language model to generate a response result that matches the user's query instruction.

进一步地:还包括向量数据库和提示库;Further: also including a vector database and a prompt library;

所述向量数据库用于存储所述语义向量;The vector database is used to store the semantic vector;

所述提示库用于指导所述大语言模型根据上下文生成应答结果。The prompt library is used to guide the large language model to generate a response result according to the context.

本发明的有益效果是:The beneficial effects of the present invention are:

本发明是基于大模型生成式技术的电力客服系统中的数据查询意图的精准预测及增强方法及其装置,能提高电力客服系统中用户意图识别的准确率,提高电力用户统一搜索查询的效率,还能够提高服务效率,能更便捷、更统一、更快速、更准确理解以及预测用户意图,提高客户服务效率以及客户服务满意度。The present invention is a method and device for accurately predicting and enhancing data query intentions in an electric power customer service system based on large model generative technology. It can improve the accuracy of user intention recognition in the electric power customer service system, improve the efficiency of unified search queries by electric power users, and improve service efficiency. It can understand and predict user intentions more conveniently, uniformly, quickly, and accurately, and improve customer service efficiency and customer service satisfaction.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是查询指令的预测和增强方法的流程示意图;FIG1 is a flow chart of a method for predicting and enhancing a query instruction;

图2是知识增强的结构示意图。FIG2 is a schematic diagram of the structure of knowledge enhancement.

具体实施方式Detailed ways

以下仅为本发明较佳的具体实施例,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。以下所述实施例仅用于解释本发明,而不能解释为对本发明的限制,本发明的保护范围应该以权利要求的保护范围为准。下面详细描述本发明的实施例,为了便于描述本发明和简化描述,本发明的说明书中使用的技术术语应当做广义解读,包括但不限于本申请未提及的常规替换方案,同时包括直接实现方式和间接实现方式。The following are only preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. The embodiments described below are only used to explain the present invention and cannot be interpreted as limitations on the present invention. The protection scope of the present invention should be based on the protection scope of the claims. The embodiments of the present invention are described in detail below. In order to facilitate the description of the present invention and simplify the description, the technical terms used in the specification of the present invention should be interpreted in a broad sense, including but not limited to conventional replacement schemes not mentioned in this application, and also including direct implementation methods and indirect implementation methods.

实施例1Example 1

结合图1和图2说明本实施例,本实施例公开的一种电力客服系统查询指令的预测和增强方法,具体包括如下步骤:The present embodiment is described in conjunction with FIG. 1 and FIG. 2 . The present embodiment discloses a method for predicting and enhancing a query instruction of a power customer service system, which specifically includes the following steps:

S1:收集并处理电力行业的数据,并对其进行训练;S1: Collect and process data from the power industry and train it;

首先对电力行业的数据进行收集和处理,从而实现对电力客服领域的查询指令query数据进行增强,要让大语言模型可以学习和理解到电力客服领域的知识,需要从电力领域客服知识库等系统,收集电力行业领域的相关问答数据,包括用户query(查询指令)和电力领域知识等。需要对收集到的数据进行相关预处理和清洗,去除无关信息和噪声数据。所述收集的数据包括用户查询指令和电力领域知识;所述处理包括预处理和清洗,用于去除无关信息和噪声数据;所述训练是首先采用文档加载器将不同种类的文档加载成纯文本,然后采用文本分割器对所述纯文本进行分割。First, the data of the power industry is collected and processed to enhance the query data of the query instructions in the power customer service field. In order for the large language model to learn and understand the knowledge in the power customer service field, it is necessary to collect relevant question and answer data in the power industry field from systems such as the power customer service knowledge base, including user queries (query instructions) and power field knowledge. The collected data needs to be preprocessed and cleaned to remove irrelevant information and noise data. The collected data includes user query instructions and power field knowledge; the processing includes preprocessing and cleaning to remove irrelevant information and noise data; the training is to first use a document loader to load different types of documents into plain text, and then use a text segmenter to segment the plain text.

大语言模型(Large Language Models,LLMs)是大模型在自然语言处理领域的一种应用。大模型生成式技术是指利用大模型进行生成式任务的技术和方法。Large Language Models (LLMs) are an application of large models in the field of natural language processing. Large model generative technology refers to the technology and methods of using large models for generative tasks.

对于长篇的文档信息可以进行文档拆分。大语言模型上下文窗口是有限制的,所述上下文窗口是指大语言模型在处理文本输入时能够考虑和记忆的文本范围或长度。这个窗口的大小对于模型的性能至关重要,因为它决定了模型在生成响应或执行任务时能够参考和理解的文本量。而一个文档往往会比较大,因此需要对文件进行拆分,并根据用户语义查找相关的内容片段。使用langchain(LLM编程框架)的文档加载器将不同种类文档加载成纯文本,然后对文档分段拆分。Document splitting can be performed for long document information. The context window of a large language model is limited. The context window refers to the range or length of text that a large language model can consider and remember when processing text input. The size of this window is critical to the performance of the model because it determines the amount of text that the model can refer to and understand when generating responses or performing tasks. A document is often large, so the file needs to be split and relevant content fragments need to be found based on user semantics. Use the document loader of langchain (LLM programming framework) to load different types of documents into plain text, and then split the document into segments.

Recursive Character Text Splitter(递归字符文本拆分器)是一种文本分割器,用于将文本按照指定的规则进行分割,它使用一组字符作为分隔符,例如"\n\n"、"\n"、"空格"和"-"等,并根据这些分隔符将文本拆分成较小的块。通过控制分割器的参数,如文本块的最大尺寸和重叠量,可以调整分割的粒度和连续性。Recursive Character Text Splitter is a text splitter that splits text into smaller chunks using a set of characters as separators, such as "\n\n", "\n", "space", and "-". The granularity and continuity of the segmentation can be adjusted by controlling the parameters of the splitter, such as the maximum size of the text chunks and the amount of overlap.

S2:将训练好的电力领域的数据嵌入到大语言模型进行加载,从而为文本转换成语义向量做准备,采用大语言模型将输入的数据文本转换成语义向量;用于后续使用向量进行语义搜索。S2: Embed the trained power field data into the large language model for loading, so as to prepare for the conversion of text into semantic vectors. Use the large language model to convert the input data text into semantic vectors; for subsequent semantic search using vectors.

构建向量数据库,大语言模型会将输入的文本等电力客户信息转换成语义向量,并存入向量数据库。通过使用大模型生成式技术,将输入的文本等电力客户信息转换为语义向量,这些语义向量能够捕捉到文本中的深层语义信息,从而使得我们能够更准确地理解电力客户输入的查询指令的真实需求和准确意图。并将生成的语义向量存入向量数据库中,可以方便后续的查询和使用,在需要时,可以从向量数据库中检索相关向量,进行相似度计算、分类等任务,从而实现对电力客户查询指令的快速、准确处理。Construct a vector database. The big language model will convert the input text and other power customer information into semantic vectors and store them in the vector database. By using the big model generative technology, the input text and other power customer information are converted into semantic vectors. These semantic vectors can capture the deep semantic information in the text, so that we can more accurately understand the real needs and accurate intentions of the query instructions entered by the power customers. And storing the generated semantic vectors in the vector database can facilitate subsequent queries and use. When necessary, relevant vectors can be retrieved from the vector database to perform similarity calculations, classification and other tasks, thereby realizing fast and accurate processing of power customer query instructions.

如图1所示,提前加载好Prompt-RAG检索增强生成-提示词,指导模型根据上下文回答问题。Prompt-RAG是一种类似RAG(Retrieval-Augmented Generation,检索增强生成)但无需矢量数据库和嵌入的方法,用于针对特定领域的实现优化大语言模型(LLM)。所述大语言模型可以选用文心一言3(英文名:ERNIE Bot),其具备知识增强、检索增强和对话增强的技术优势。模型参数N(不包括嵌入)的数量,数据集D的大小,用于训练的计算量C,训练过程包括预训练和微调。As shown in Figure 1, Prompt-RAG is loaded in advance to guide the model to answer questions based on the context. Prompt-RAG is a method similar to RAG (Retrieval-Augmented Generation) but without vector database and embedding. It is used to optimize large language models (LLM) for specific domains. The large language model can be ERNIE Bot, which has the technical advantages of knowledge enhancement, retrieval enhancement and dialogue enhancement. The number of model parameters N (excluding embedding), the size of the data set D, the amount of computation used for training C, and the training process includes pre-training and fine-tuning.

S3:对用户的查询指令进行与所述结构化数据进行匹配,若匹配成功,则直接返回与所述查询指令匹配的结构化数据;若不匹配,则对出错的查询指令执行S4;当用户输入一个电力相关的查询指令query,由于用户输入的查询指令query可能由于方言或者专业名称等特殊性,一般会对用户输入的查询指令query进行判断,如果能够直接命中向量数据库内对应的结构化数据,直接返回对该查询指令query对应的结构化数据;若不命中,则会对query进行纠错。S3: Match the user's query instruction with the structured data. If the match is successful, directly return the structured data matching the query instruction; if not, execute S4 for the erroneous query instruction; when the user enters an electricity-related query instruction query, since the query instruction query entered by the user may be special due to dialects or professional names, the query instruction query entered by the user will generally be judged. If it can directly hit the corresponding structured data in the vector database, directly return the structured data corresponding to the query instruction query; if it does not hit, the query will be corrected.

S4:采用纠错算法对所述出错的查询指令query进行改写纠错,从而获得正确概率最高的纠错串;query纠错是对电力企业用户输入的查询指令query出现的错误进行检测和纠正的过程,一般包括对于词的纠错。由于电力行业的特殊性,用户在进行问题咨询,输入搜索的过程中,会出现对专业名词不了解、输入时候出现手误、语音输入识别出现错误、方言输入等情况 ,导致电力用户输入的搜索query会存在一定的错误。因此需要对这部分错误的query进行纠错以免影响大语言模型匹配的准确,最终影响到用户的搜索体验S4: Use an error correction algorithm to rewrite and correct the erroneous query instruction query, so as to obtain the error correction string with the highest probability of being correct; query error correction is the process of detecting and correcting errors in the query instruction query input by the power enterprise user, generally including word correction. Due to the particularity of the power industry, when users are consulting questions and inputting searches, they may not understand professional terms, make mistakes when inputting, make errors in voice input recognition, and input in dialects, etc., which will lead to certain errors in the search queries input by power users. Therefore, it is necessary to correct these erroneous queries so as not to affect the accuracy of the large language model matching, and ultimately affect the user's search experience.

query产生的错误类型一般是包括两种:Non-word拼写错误与Real-word拼写错误,其中Non-word拼写错误,这种错误表示此词汇本身在字典中不存在;Real-word拼写错误是指单词本身没有错误,但是不符合上下文语境,常常涉及语法语义层面的错误,比如把“我要查电费”错写成“我要查电分”,这种错误的纠错比Non-word拼写错误更加困难。There are generally two types of errors generated by queries: Non-word spelling errors and Real-word spelling errors. Non-word spelling errors indicate that the word itself does not exist in the dictionary. Real-word spelling errors refer to errors in the word itself, but do not conform to the context. They often involve errors at the grammatical and semantic levels, such as writing "I want to check the electricity bill" as "I want to check the electricity share". This type of error is more difficult to correct than a Non-word spelling error.

以下是对电力客服相关query的纠错的举例:The following is an example of error correction for power customer service related queries:

Non-word拼写错误:Non-word spelling errors:

拼音错误:chadianfen→查电费;Pinyin error: chadianfen → check electricity bill;

拼音简写:Cdf→查电费;Pinyin abbreviation: Cdf → check electricity bill;

拼音数字混合:woyao 2查电费→我要查电费;Mixed pinyin and numbers: woyao 2 check electricity bill → I want to check the electricity bill;

Real-word拼写错误:Real-word spelling errors:

漏字:我要查费→我要查电费;Missing words: I want to check the bill → I want to check the electricity bill;

多字:我要查电费费→我要查电费;Multi-word: I want to check the electricity bill → I want to check the electricity bill;

颠倒:电费我查→我要查电费;Reversal: I check the electricity bill → I want to check the electricity bill;

同谐音:我要查电废→我要查电费;Homophone: I want to check the electricity waste → I want to check the electricity bill;

混淆音:擦电费→查电费;Confusing sound: rub electricity bill → check electricity bill;

形近字:查由费→查电费;Similar characters: 查由费→查电费;

词组搭配错误:业扩报装→业扩爆装。Wrong phrase collocation: Business expansion registration → Business expansion explosion.

对用户查询指令query的纠错包含错误检测和错误纠正两个部分,其中错误检测用于识别错误词语的位置,简单地可以通过对输入query进行切分后检查各个词语是否在维护的自定义词表或挖掘积累的常见纠错对(pair)中,若不在,则根据字形、字音或输入码相近字进行替换构造候选并结合N-Gram语言模型概率来判断其是否存在错误,N-Gram是大词汇连续语音识别中常用的一种语言模型,对中文而言,称之为汉语语言模型(CLM,Chinese Language Model)。汉语语言模型利用上下文中相邻词间的搭配信息,可以实现汉字的自动转换,这个方法并未充分考虑到上下文信息,仅可以适用于常见中文词组搭配、英文单词错误等的检测。进一步的做法是通过训练序列标注模型的方法来识别错误的开始和结束位置。The error correction of user query commands includes error detection and error correction. Error detection is used to identify the location of incorrect words. It can be simply done by segmenting the input query and checking whether each word is in the maintained custom word list or the accumulated common error correction pairs. If not, the candidate is replaced based on the shape, pronunciation or similar characters of the input code and combined with the probability of the N-Gram language model to determine whether it is wrong. N-Gram is a language model commonly used in large vocabulary continuous speech recognition. For Chinese, it is called the Chinese Language Model (CLM). The Chinese language model uses the collocation information between adjacent words in the context to realize the automatic conversion of Chinese characters. This method does not fully consider the context information and can only be applied to the detection of common Chinese phrase collocation, English word errors, etc. A further approach is to identify the start and end positions of the error by training a sequence annotation model.

用户query的错误纠正主要是基于对原始query和纠正后query之间的关系进行建模。这个过程可以分解为两个主要的概率计算:p(q|r)和p(r),p(q|r)表示原串到纠错串的转移概率,可以通过计算原串和纠错串之间的编辑距离、共点击概率、抽取相应特征等方式来计算。The error correction of user queries is mainly based on modeling the relationship between the original query and the corrected query. This process can be decomposed into two main probability calculations: p(q|r) and p(r). p(q|r) represents the transition probability from the original string to the corrected string, which can be calculated by calculating the edit distance between the original string and the corrected string, the co-click probability, and extracting corresponding features.

一般使用的编辑距离算法包括Levenshtein距离(允许插入、删除和替换一个字符的编辑距离)和Damerau-Levenshtein距离(允许交换相邻两字符的位置,且允许插入、删除和替换一个字符的编辑距离),是一种用于度量两个字符串之间差异程度的编辑距离算法,它是Levenshtein距离算法的扩展,可以衡量两个字符串之间的相似度。共点击概率是指两个字符串在相同的上下文中被同时点击的概率,可以通过分析用户行为数据来计算;抽取特征的方法则是从query中提取有用的信息,例如关键词、语法结构等,以便于进行后续的模型预测。Commonly used edit distance algorithms include Levenshtein distance (edit distance that allows insertion, deletion, and replacement of a character) and Damerau-Levenshtein distance (edit distance that allows the positions of two adjacent characters to be swapped and allows insertion, deletion, and replacement of a character). It is an edit distance algorithm used to measure the degree of difference between two strings. It is an extension of the Levenshtein distance algorithm and can measure the similarity between two strings. The co-click probability refers to the probability that two strings are clicked at the same time in the same context, which can be calculated by analyzing user behavior data; the feature extraction method is to extract useful information from the query, such as keywords, grammatical structures, etc., to facilitate subsequent model prediction.

如图2所示,p(r)表示纠错串作为正常query的概率,可以通过语言模型、高频query、实体知识库等方式来衡量。语言模型是一种基于统计的语言理解技术,可以通过计算纠错串的语言概率来评估其质量。高频query是指被大量用户频繁使用的query,这些用户query往往具有较高的质量和可信度。实体知识库则是一种包含实体信息的数据库,其中实体信息例如Entitiy1,可以通过查询实体知识库来评估纠错串的相关性和准确性。As shown in Figure 2, p(r) represents the probability that the error correction string is a normal query, which can be measured by language models, high-frequency queries, entity knowledge bases, etc. Language model is a statistical language understanding technology, and its quality can be evaluated by calculating the language probability of the error correction string. High-frequency queries refer to queries that are frequently used by a large number of users. These user queries tend to have high quality and credibility. Entity knowledge base is a database containing entity information, such as Entitiy1. The relevance and accuracy of the error correction string can be evaluated by querying the entity knowledge base.

纠错算法的目标是找到一个纠错串r,使得原串q到纠错串r的转移概率最大,同时纠错串r作为正常query的概率也较高。这个目标可以通过贝叶斯公式进行建模和计算,即argmaxp(r|q)=argmaxp(q|r)p(r)/p(q)=argmaxp(q|r)p(r)。在计算过程中,可以采用各种优化算法和机器学习方法来提高纠错算法的准确率和效率。其中,q表示原串,r表示纠错串,p(r|q)表示在原串q发生的情况下,纠错串发生的概率,p(q|r)表示原串到纠错串的转移概率,p(r)表示纠错串作为正常query的概率,p(q)是一个与r无关的常数。The goal of the error correction algorithm is to find an error correction string r that maximizes the probability of transition from the original string q to the error correction string r, and at the same time, the probability of the error correction string r being a normal query is also high. This goal can be modeled and calculated using the Bayesian formula, i.e., argmaxp(r|q)=argmaxp(q|r)p(r)/p(q)=argmaxp(q|r)p(r). During the calculation process, various optimization algorithms and machine learning methods can be used to improve the accuracy and efficiency of the error correction algorithm. Among them, q represents the original string, r represents the error correction string, p(r|q) represents the probability of the error correction string occurring when the original string q occurs, p(q|r) represents the probability of transition from the original string to the error correction string, p(r) represents the probability of the error correction string being a normal query, and p(q) is a constant that is independent of r.

第一个等式argmaxp(r|q)=argmaxp(q|r)p(r)/p(q)是基于贝叶斯定理得出的。由于argmax操作是在寻找使概率最大的r值,而p(q)是一个与r无关的常数(对于给定的q),因此它不会影响argmax的结果。所以可以忽略分母中的p(q),从而得到第二个等式。第二个等式argmaxp(q|r)p(r)/p(q)=argmaxp(q|r)p(r)正是基于上述理由,即p(q)是一个常数,不会影响argmax的结果。上述公式表明,在寻找使条件概率p(r|q)最大的r值时,可以忽略分母中的p(q),只需考虑分子部分p(q|r)p(r)。从而简化了计算过程,快速获得正确的概率最高的纠错串r。The first equation argmaxp(r|q)=argmaxp(q|r)p(r)/p(q) is based on Bayes' theorem. Since the argmax operation is looking for the value of r that maximizes the probability, and p(q) is a constant that is independent of r (for a given q), it will not affect the result of argmax. Therefore, p(q) in the denominator can be ignored, resulting in the second equation. The second equation argmaxp(q|r)p(r)/p(q)=argmaxp(q|r)p(r) is based on the above reason, that is, p(q) is a constant and will not affect the result of argmax. The above formula shows that when looking for the value of r that maximizes the conditional probability p(r|q), p(q) in the denominator can be ignored, and only the numerator p(q|r)p(r) needs to be considered. This simplifies the calculation process and quickly obtains the correct error correction string r with the highest probability.

S5:利用所述结构化数据对所述纠错串进行知识增强和文本分类;S5: performing knowledge enhancement and text classification on the error correction string using the structured data;

所述结构化数据存储在知识图谱或知识库中,所述知识增强是指对用户的查询指令与所述结构化数据进行实体链接和语义推理,训练所述模型对知识图谱或知识库中的结构化数据进行理解和表示,从而提高所述模型对所述查询指令意图的识别能力。意图识别模块通常是一个分类任务,目的是识别用户要查询的类目,再输出给召回和排序模块,保证最后结果的类目相关性。意图识别增强主要分为两个步骤进行,主要包括客服知识增强和文本分类,增加文本分类可以使得用户query搜索更加准确。The structured data is stored in a knowledge graph or knowledge base, and the knowledge enhancement refers to entity linking and semantic reasoning between the user's query instructions and the structured data, and training the model to understand and represent the structured data in the knowledge graph or knowledge base, thereby improving the model's ability to recognize the intent of the query instructions. The intent recognition module is usually a classification task, and its purpose is to identify the category that the user wants to query, and then output it to the recall and sorting module to ensure the category relevance of the final result. Intent recognition enhancement is mainly divided into two steps, mainly including customer service knowledge enhancement and text classification. Adding text classification can make user query searches more accurate.

知识增强:Knowledge Enhancement:

知识增强是利用知识图谱或知识库中的结构化数据,对用户query进行实体链接和语义推理,通过训练模型对知识图谱或知识库中的知识进行理解和表示,提高模型对于复杂查询意图的识别能力;将用户query与知识图谱或知识库中的知识进行匹配和关联,从而为用户提供更加精准和相关的结果。Knowledge enhancement is the use of structured data in knowledge graphs or knowledge bases to perform entity linking and semantic reasoning on user queries, and to improve the model's ability to recognize complex query intentions by training models to understand and represent the knowledge in the knowledge graph or knowledge base; matching and associating user queries with the knowledge in the knowledge graph or knowledge base to provide users with more accurate and relevant results.

文本分类:Text Categorization:

在进行文本分类时,可以使用神经网络模型,如卷积神经网络(CNN)。CNN在计算机视觉领域广泛应用,但也可以用于文本分类。CNN通过卷积操作捕捉文本中的局部特征,并通过池化操作减少特征的维度。最后,全连接层将特征映射到输出空间。When doing text classification, you can use a neural network model, such as a convolutional neural network (CNN). CNN is widely used in the field of computer vision, but it can also be used for text classification. CNN captures local features in the text through convolution operations and reduces the dimensionality of the features through pooling operations. Finally, a fully connected layer maps the features to the output space.

S51:构建一个卷积神经网络模型,包括输入层、卷积层、池化层、全连接层和输出层。卷积层用于提取文本中的局部特征,池化层用于降低数据的维度,全连接层用于将提取到的特征映射到输出空间,输出层用于对文本进行分类。S51: Build a convolutional neural network model, including input layer, convolution layer, pooling layer, fully connected layer and output layer. The convolution layer is used to extract local features in the text, the pooling layer is used to reduce the dimension of the data, the fully connected layer is used to map the extracted features to the output space, and the output layer is used to classify the text.

S52:训练模型:使用大量的带标签的文本数据作为训练集,对卷积神经网络模型进行训练,使其从数据中学习并识别不同的文本类别。S52: Training model: Use a large amount of labeled text data as a training set to train the convolutional neural network model so that it can learn from the data and recognize different text categories.

S53:测试和评估:使用测试集对训练好的模型进行测试和评估,计算分类准确率、召回率等指标,以评估模型的性能。S53: Testing and evaluation: Use the test set to test and evaluate the trained model, and calculate indicators such as classification accuracy and recall rate to evaluate the performance of the model.

具体的过程如下:The specific process is as follows:

①输入层:① Input layer:

(X = [x_1; x_2; ...; x_n]);(X = [x_1; x_2; ...; x_n]);

其中,(x_i)表示第(i)个单词的嵌入向量,X表示输入矩阵。Where (x_i) represents the embedding vector of the (i)th word and X represents the input matrix.

②卷积层:②Convolutional layer:

(H = [h_1; h_2; ...; h_m]);(H = [h_1; h_2; ...; h_m]);

其中,H表示卷积层输出矩阵的高,(h_j)表示第(j)个特征图的输出,计算公式如下:Where H represents the height of the convolutional layer output matrix, (h_j) represents the output of the (j)th feature map, and the calculation formula is as follows:

(h_j = f(W_j * X + b_j));(h_j = f(W_j * X + b_j));

其中,(h_j)是第(j)个卷积核的高,(W_j)是第(j)个卷积核的权重矩阵,(b_j)是偏置项,(f)是激活函数(如ReLU)。Among them, (h_j) is the height of the (j)th convolution kernel, (W_j) is the weight matrix of the (j)th convolution kernel, (b_j) is the bias term, and (f) is the activation function (such as ReLU).

③池化层:③Pooling layer:

假设使用最大池化操作,计算公式如下:Assuming the maximum pooling operation is used, the calculation formula is as follows:

((pooling_output) = max(h_1, h_2, ..., h_m));((pooling_output) = max(h_1, h_2, ..., h_m));

其中,(pooling_output)表示池化层的输出向量。Among them, (pooling_output) represents the output vector of the pooling layer.

④全连接层:④Fully connected layer:

假设使用ReLU激活函数,计算公式如下:Assuming the ReLU activation function is used, the calculation formula is as follows:

(FC = [relu(w_1h + b_1); relu(w_2h + b_2); ...; relu(w_k*h + b_k)]);(FC = [relu(w_1h + b_1); relu(w_2h + b_2); ...; relu(w_k*h + b_k)]);

其中,(w_i)和(b_i)分别是第i个神经元的权重和偏置项,relu表示每个神经元的激活函数,relu函数的数学表达式为f(x)=max(0,x);FC表示全连接层的输出向量。Among them, (wi) and (bi) are the weight and bias of the i-th neuron respectively, relu represents the activation function of each neuron, and the mathematical expression of the relu function is f(x)=max(0,x); FC represents the output vector of the fully connected layer.

⑤输出层:⑤Output layer:

使用softmax函数将全连接层的输出转换为概率分布,计算公式如下:Use the softmax function to convert the output of the fully connected layer into a probability distribution. The calculation formula is as follows:

(P= [softmax(w'_1FC + b'_1);softmax(w'_2FC + b'_2);...;softmax(w'_n*FC + b'_n)]),(P = [softmax(w'_1FC + b'_1); softmax(w'_2FC + b'_2); ...; softmax(w'_n*FC + b'_n)]),

其中,(w'_i)是第(i)个神经元的权重,(b'_i)是第(i)个神经元的偏置项,P表示全连接层的输出概率;Where (w'_i) is the weight of the (i)th neuron, (b'_i) is the bias term of the (i)th neuron, and P represents the output probability of the fully connected layer;

其中,softmax函数的数学表达式为:Among them, the mathematical expression of the softmax function is: ;

损失函数与优化器:Loss function and optimizer:

使用交叉熵损失函数进行模型训练。损失函数的计算公式如下:The cross entropy loss function is used for model training. The loss function is calculated as follows:

;

其中,Loss是损失函数,N是样本数量,是真实标签(即0或1),/>是预测概率,其中,log函数不限定底数,以遍历的形式计算所有可能的取值。Among them, Loss is the loss function, N is the number of samples, is the true label (i.e. 0 or 1), /> is the predicted probability, where the log function does not limit the base and calculates all possible values in a traversal form.

S6:获取用户输入的查询指令query,将其与所述结构化数据执行向量相似度搜索,如图2所示,即实体队列及其介绍,得到语义最相关的文本队列,即得到语义最相关的top k段文本,即相似问题所形成的文本队列,并输出展示。S6: Get the query command query input by the user, perform a vector similarity search on it and the structured data, as shown in Figure 2, that is, the entity queue and its introduction, obtain the most semantically relevant text queue, that is, obtain the top k most semantically relevant texts, that is, the text queue formed by similar questions, and output it for display.

S7:构造检索增强生成模型,调用所述大语言模型生成与用户的查询指令匹配的应答结果。构造rag_chain,即构造rag_chain(Retriever-Augmented Generation,检索增强生成模型)是一种结合了信息检索和生成式模型的方法,旨在提高生成式模型在回答用户查询时的准确性和相关性。调用大语言模型回答用户问题,输出的结果根据用户需要的不同可以输出基础的文本结果,也可以进行相关问题的数据图表生成,实现用户问题多模态应答。S7: Construct a retrieval-augmented generation model, and call the large language model to generate a response result that matches the user's query instruction. Constructing rag_chain, that is, constructing rag_chain (Retriever-Augmented Generation, retrieval-augmented generation model) is a method that combines information retrieval and generative models, aiming to improve the accuracy and relevance of generative models when answering user queries. Calling a large language model to answer user questions, the output results can output basic text results according to different user needs, or generate data charts for related questions to achieve multimodal responses to user questions.

实施例2Example 2

结合和实施例1说明本实施例,本实施例公开的一种电力客服系统查询指令的预测和增强装置,包括大语言模型、数据训练模块、文本转换模块、意图识别增强模块、纠错模块和应答结果生成展示模块;This embodiment is described in combination with Example 1. This embodiment discloses a prediction and enhancement device for query instructions of an electric customer service system, including a large language model, a data training module, a text conversion module, an intention recognition enhancement module, an error correction module, and a response result generation and display module;

所述数据训练模块用于训练电力行业的数据;The data training module is used to train data of the power industry;

所述文本转换模块用于调用大语言模型对训练好的数据文本转换成语义向量;The text conversion module is used to call the large language model to convert the trained data text into a semantic vector;

所述纠错模块用于对出错的查询指令进行纠错,从而获得正确概率最高的纠错串;The error correction module is used to correct the error query instruction, so as to obtain the error correction string with the highest correct probability;

所述意图识别增强模块用于对所述纠错串进行知识增强和文本分类;The intention recognition enhancement module is used to perform knowledge enhancement and text classification on the error correction string;

所述应答结果生成展示模块用于调用所述大语言模型生成与用户的查询指令匹配的应答结果。The response result generation and display module is used to call the large language model to generate a response result that matches the user's query instruction.

还包括向量数据库和提示库;Also includes vector database and hint library;

所述向量数据库用于存储所述语义向量;The vector database is used to store the semantic vector;

所述提示库用于指导所述大语言模型根据上下文生成应答结果。The prompt library is used to guide the large language model to generate a response result according to the context.

Claims (10)

1.一种电力客服系统查询指令的预测和增强方法,其特征在于,包括如下步骤:1. A method for predicting and enhancing query instructions of an electric power customer service system, characterized in that it comprises the following steps: S1:收集并处理电力行业的数据,并对其进行训练;S1: Collect and process data from the power industry and train it; S2:将训练好的数据嵌入到大语言模型进行加载,采用大语言模型将输入的数据文本转换成语义向量;S2: embed the trained data into the large language model for loading, and use the large language model to convert the input data text into a semantic vector; S3:对用户的查询指令进行与结构化数据进行匹配,若匹配成功,则直接返回与所述查询指令匹配的结构化数据;若不匹配,则对出错的查询指令执行S4;S3: Match the user's query instruction with the structured data. If the match is successful, directly return the structured data matching the query instruction; if the match is not successful, execute S4 for the query instruction with error; S4:采用纠错算法对所述出错的查询指令进行纠错,从而获得正确概率最高的纠错串;S4: using an error correction algorithm to correct the erroneous query instruction, thereby obtaining an error correction string with the highest probability of being correct; S5:利用所述结构化数据对所述纠错串进行知识增强和文本分类;S5: performing knowledge enhancement and text classification on the error correction string using the structured data; S6:获取用户输入的查询指令,将其与所述结构化数据执行向量相似度搜索,得到语义最相关的文本队列并输出展示;S6: Obtain the query instruction input by the user, perform vector similarity search on the query instruction and the structured data, obtain the text queue with the most semantic relevance, and output it for display; S7:构造检索增强生成模型,调用所述大语言模型生成与用户的查询指令匹配的应答结果。S7: Construct a retrieval enhancement generation model, and call the large language model to generate a response result that matches the user's query instruction. 2.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S2中,还包括:构建向量数据库并将所述语义向量存入向量数据库中。2. A method for predicting and enhancing query instructions of an electric power customer service system according to claim 1, characterized in that, in S2, it also includes: constructing a vector database and storing the semantic vector in the vector database. 3.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S7中,还包括:构造提示库,用于指导所述大语言模型根据上下文回答问题。3. The method for predicting and enhancing query instructions of an electric power customer service system according to claim 1, characterized in that in S7, it also includes: constructing a prompt library to guide the large language model to answer questions according to the context. 4.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S1中,收集的数据包括用户查询指令和电力领域知识;所述处理包括预处理和清洗,用于去除无关信息和噪声数据;所述训练是首先采用文档加载器将不同种类的文档加载成纯文本,然后采用文本分割器对所述纯文本进行分割。4. According to claim 1, a method for predicting and enhancing query instructions of an electric power customer service system is characterized in that, in S1, the collected data includes user query instructions and electric power field knowledge; the processing includes preprocessing and cleaning to remove irrelevant information and noise data; the training is first using a document loader to load different types of documents into plain text, and then using a text segmenter to segment the plain text. 5.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S4中,所述纠错算法通过贝叶斯公式进行建模和计算,即:5. The method for predicting and enhancing query instructions of a power customer service system according to claim 1, characterized in that, in S4, the error correction algorithm is modeled and calculated by the Bayesian formula, that is: argmax p(r|q) = argmax p(q|r)p(r)/p(q) = argmax p(q|r)p(r);argmax p(r|q) = argmax p(q|r)p(r)/p(q) = argmax p(q|r)p(r); 其中,argmax 表示求所有纠错串发生的概率的最大值,q表示原串,r表示纠错串,p(r|q)表示在原串q发生的情况下,纠错串发生的概率,p(q|r)表示原串到纠错串的转移概率,p(r)表示纠错串作为正常查询指令的概率,p(q)是一个与r无关的常数。Among them, argmax means finding the maximum value of the probability of all error-correcting strings occurring, q represents the original string, r represents the error-correcting string, p(r|q) represents the probability of the error-correcting string occurring when the original string q occurs, p(q|r) represents the transition probability from the original string to the error-correcting string, p(r) represents the probability of the error-correcting string being a normal query instruction, and p(q) is a constant that is independent of r. 6.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S5中,所述结构化数据存储在知识图谱或知识库中,所述知识增强是指对用户的查询指令与所述结构化数据进行实体链接和语义推理,训练所述大语言模型对知识图谱或知识库中的结构化数据进行理解和表示。6. According to claim 1, a method for predicting and enhancing query instructions of an electric power customer service system is characterized in that, in S5, the structured data is stored in a knowledge graph or a knowledge base, and the knowledge enhancement refers to entity linking and semantic reasoning between the user's query instructions and the structured data, and training the large language model to understand and represent the structured data in the knowledge graph or knowledge base. 7.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S5中,所述文本分类是采用卷积神经网络实现的,具体过程如下:7. The method for predicting and enhancing query instructions of a power customer service system according to claim 1, characterized in that, in S5, the text classification is implemented by using a convolutional neural network, and the specific process is as follows: S51:构建卷积神经网络模型;所述卷积神经网络模型包括输入层、卷积层、池化层、全连接层和输出层;所述输入层用于接收待分类的文本,所述卷积层用于提取文本中的局部特征,所述池化层用于降低数据的维度,所述全连接层用于将提取到的特征映射到输出空间,所述输出层用于对文本进行分类;S51: Construct a convolutional neural network model; the convolutional neural network model includes an input layer, a convolutional layer, a pooling layer, a fully connected layer and an output layer; the input layer is used to receive text to be classified, the convolutional layer is used to extract local features in the text, the pooling layer is used to reduce the dimension of the data, the fully connected layer is used to map the extracted features to the output space, and the output layer is used to classify the text; S52:使用带标签的结构化数据作为训练集,对所述卷积神经网络模型进行训练,使其从结构化数据中学习并识别不同的文本类别;所述卷积神经网络模型的训练是使用交叉熵损失函数和梯度下降优化器来实现;S52: Using the labeled structured data as a training set, training the convolutional neural network model so that it learns and recognizes different text categories from the structured data; the training of the convolutional neural network model is implemented using a cross entropy loss function and a gradient descent optimizer; S53:使用测试集对训练好的卷积神经网络模型进行测试和评估,计算分类准确率和/或召回率指标,以评估所述卷积神经网络模型的性能。S53: Use the test set to test and evaluate the trained convolutional neural network model, and calculate the classification accuracy and/or recall rate indicators to evaluate the performance of the convolutional neural network model. 8.根据权利要求1所述的一种电力客服系统查询指令的预测和增强方法,其特征在于,在S7中,所述应答结果根据用户的需要选择展示方式,所述展示方式包括文本形式、数据图表形式、音频形式和/或视频形式。8. A method for predicting and enhancing query instructions of an electric power customer service system according to claim 1, characterized in that, in S7, the response result is displayed in a manner selected according to user needs, and the display manner includes text form, data chart form, audio form and/or video form. 9.一种电力客服系统查询指令的预测和增强装置,其特征在于,包括大语言模型、数据训练模块、文本转换模块、意图识别增强模块、纠错模块和应答结果生成展示模块;9. A prediction and enhancement device for query instructions of an electric power customer service system, characterized by comprising a large language model, a data training module, a text conversion module, an intention recognition enhancement module, an error correction module and a response result generation and display module; 所述数据训练模块用于训练电力行业的数据;The data training module is used to train data of the power industry; 所述文本转换模块用于调用大语言模型对训练好的数据文本转换成语义向量;The text conversion module is used to call the large language model to convert the trained data text into a semantic vector; 所述纠错模块用于对出错的查询指令进行纠错,从而获得正确概率最高的纠错串;The error correction module is used to correct the error query instruction, so as to obtain the error correction string with the highest correct probability; 所述意图识别增强模块用于对所述纠错串进行知识增强和文本分类;The intention recognition enhancement module is used to perform knowledge enhancement and text classification on the error correction string; 所述应答结果生成展示模块用于调用所述大语言模型生成与用户的查询指令匹配的应答结果。The response result generation and display module is used to call the large language model to generate a response result that matches the user's query instruction. 10.根据权利要求9所述的一种电力客服系统查询指令的预测和增强装置,其特征在于,还包括向量数据库和提示库;10. A prediction and enhancement device for query instructions of a power customer service system according to claim 9, characterized in that it also includes a vector database and a prompt library; 所述向量数据库用于存储所述语义向量;The vector database is used to store the semantic vector; 所述提示库用于指导所述大语言模型根据上下文生成应答结果。The prompt library is used to guide the large language model to generate a response result according to the context.
CN202410564229.1A 2024-05-09 2024-05-09 A method and device for predicting and enhancing query instructions of power customer service system Pending CN118152428A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410564229.1A CN118152428A (en) 2024-05-09 2024-05-09 A method and device for predicting and enhancing query instructions of power customer service system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410564229.1A CN118152428A (en) 2024-05-09 2024-05-09 A method and device for predicting and enhancing query instructions of power customer service system

Publications (1)

Publication Number Publication Date
CN118152428A true CN118152428A (en) 2024-06-07

Family

ID=91291945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410564229.1A Pending CN118152428A (en) 2024-05-09 2024-05-09 A method and device for predicting and enhancing query instructions of power customer service system

Country Status (1)

Country Link
CN (1) CN118152428A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119166662A (en) * 2024-11-21 2024-12-20 烟台海颐软件股份有限公司 A method for constructing SQL agent in power field based on KMDI chain
CN119848074A (en) * 2025-03-19 2025-04-18 东衢智慧交通基础设施科技(江苏)有限公司 File inquiry system and method based on large model

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885938A (en) * 2014-04-14 2014-06-25 东南大学 Industry spelling mistake checking method based on user feedback
US20200311738A1 (en) * 2019-03-25 2020-10-01 Fmr Llc Computer Systems and Methods to Discover Questions and Answers from Conversations
CN112035730A (en) * 2020-11-05 2020-12-04 北京智源人工智能研究院 A semantic retrieval method, device and electronic device
CN112115232A (en) * 2020-09-24 2020-12-22 腾讯科技(深圳)有限公司 A data error correction method, device and server
CN115858758A (en) * 2022-12-28 2023-03-28 国家电网有限公司信息通信分公司 Intelligent customer service knowledge graph system with multiple unstructured data identification
WO2024031891A1 (en) * 2022-08-10 2024-02-15 浙江大学 Fine tuning method and apparatus for knowledge representation-disentangled classification model, and application
CN117573843A (en) * 2024-01-15 2024-02-20 图灵人工智能研究院(南京)有限公司 Knowledge calibration and retrieval enhancement-based medical auxiliary question-answering method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885938A (en) * 2014-04-14 2014-06-25 东南大学 Industry spelling mistake checking method based on user feedback
US20200311738A1 (en) * 2019-03-25 2020-10-01 Fmr Llc Computer Systems and Methods to Discover Questions and Answers from Conversations
CN112115232A (en) * 2020-09-24 2020-12-22 腾讯科技(深圳)有限公司 A data error correction method, device and server
CN112035730A (en) * 2020-11-05 2020-12-04 北京智源人工智能研究院 A semantic retrieval method, device and electronic device
WO2024031891A1 (en) * 2022-08-10 2024-02-15 浙江大学 Fine tuning method and apparatus for knowledge representation-disentangled classification model, and application
CN115858758A (en) * 2022-12-28 2023-03-28 国家电网有限公司信息通信分公司 Intelligent customer service knowledge graph system with multiple unstructured data identification
CN117573843A (en) * 2024-01-15 2024-02-20 图灵人工智能研究院(南京)有限公司 Knowledge calibration and retrieval enhancement-based medical auxiliary question-answering method and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
康砚澜等: "基于知识增强的医学语言模型:现状 、 技术与 应 用", 医学信息学杂志, 25 September 2023 (2023-09-25) *
颛悦;熊锦华;马宏远;程舒杨;程学旗;: "一种支持混合语言的并行查询纠错方法", 中文信息学报, no. 02, 15 March 2016 (2016-03-15) *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119166662A (en) * 2024-11-21 2024-12-20 烟台海颐软件股份有限公司 A method for constructing SQL agent in power field based on KMDI chain
CN119166662B (en) * 2024-11-21 2025-05-16 烟台海颐软件股份有限公司 A method for constructing SQL agent in power field based on KMDI chain
CN119848074A (en) * 2025-03-19 2025-04-18 东衢智慧交通基础设施科技(江苏)有限公司 File inquiry system and method based on large model

Similar Documents

Publication Publication Date Title
CN110096570B (en) Intention identification method and device applied to intelligent customer service robot
CN113591483B (en) A document-level event argument extraction method based on sequence labeling
AU2019263758B2 (en) Systems and methods for generating a contextually and conversationally correct response to a query
CN116719520B (en) Code generation method and device
CN109033305B (en) Question answering method, device and computer readable storage medium
CN108304372B (en) Entity extraction method and device, computer equipment and storage medium
WO2019153737A1 (en) Comment assessing method, device, equipment and storage medium
CN118260391A (en) Class case retrieval system and method based on retrieval enhancement generation technology
CN112069298A (en) Human-computer interaction method, device and medium based on semantic web and intention recognition
US11031009B2 (en) Method for creating a knowledge base of components and their problems from short text utterances
CN110347787B (en) Interview method and device based on AI auxiliary interview scene and terminal equipment
CN111401077A (en) Language model processing method and device and computer equipment
CN112100354A (en) Man-machine conversation method, device, equipment and storage medium
CN118152428A (en) A method and device for predicting and enhancing query instructions of power customer service system
US20060277028A1 (en) Training a statistical parser on noisy data by filtering
CN113742733A (en) Reading comprehension vulnerability event trigger word extraction and vulnerability type identification method and device
CN119577459B (en) Intelligent customer service training method and device for multi-mode large model and storage medium
CN118378623A (en) A global vision-guided image description generation method based on a cross-modal large model
CN118333057A (en) Multilingual event causal relationship recognition method and system based on knowledge meta-learning
CN118070784A (en) Method, device, equipment and storage medium for constructing entity dictionary in vertical industry field
CN116127015A (en) NLP large model analysis system based on artificial intelligence self-adaption
CN114239555A (en) Training method of keyword extraction model and related device
CN119988568B (en) Place name recognition method, device and equipment based on text segment characterization learning
CN118551024B (en) Question answering method, device, storage medium and gateway system
CN117453913A (en) Emotion recognition method, device, equipment and medium based on boundary distance

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20240607