WO2023065544A1 - Intention classification method and apparatus, electronic device, and computer-readable storage medium - Google Patents

Intention classification method and apparatus, electronic device, and computer-readable storage medium Download PDF

Info

Publication number
WO2023065544A1
WO2023065544A1 PCT/CN2022/071077 CN2022071077W WO2023065544A1 WO 2023065544 A1 WO2023065544 A1 WO 2023065544A1 CN 2022071077 W CN2022071077 W CN 2022071077W WO 2023065544 A1 WO2023065544 A1 WO 2023065544A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
intent
intention
model
matching
Prior art date
Application number
PCT/CN2022/071077
Other languages
French (fr)
Chinese (zh)
Inventor
舒畅
陈又新
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2023065544A1 publication Critical patent/WO2023065544A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • 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/044Recurrent networks, e.g. Hopfield networks
    • 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/084Backpropagation, e.g. using gradient descent

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Molecular Biology (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

Embodiments of the present application provide an intention classification method and apparatus, an electronic device, and a computer-readable storage medium, and relate to the technical field of deep learning in artificial intelligence. The method comprises: acquiring request text; extracting entity features from the request text, and obtain first text comprising a target query parameter; inputting the first text into a pre-trained comparison model to perform matrix multiplication with a reference word embedding matrix in the comparison model, and obtain multiple target word embedding vectors; performing classification on the target word embedding vectors by using a pre-trained intention classification model, and obtain an intention classification probability value and a target word embedding vector comprising an intention category label; performing matching on the first text by using a pre-trained intention matching model, and obtain an intention matching value; and obtaining intention classification data according to the intention matching value and the intention classification probability value. The embodiments of the present invention can achieve the accurate classification of user intention and improve the accuracy of intention classification.

Description

意图分类方法、装置、电子设备及计算机可读存储介质Intent Classification Method, Device, Electronic Device, and Computer-Readable Storage Medium
本申请要求于2021年10月18日提交中国专利局、申请号为202111212210.3,发明名称为“意图分类方法、装置、电子设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202111212210.3 submitted to the China Patent Office on October 18, 2021, and the title of the invention is "Intention Classification Method, Device, Electronic Equipment, and Computer-Readable Storage Medium", the entire content of which Incorporated in this application by reference.
技术领域technical field
本申请涉及人工智能中的深度学习技术领域,尤其涉及一种意图分类方法、装置、电子设备及计算机可读存储介质。The present application relates to the technical field of deep learning in artificial intelligence, and in particular to an intent classification method, device, electronic equipment, and computer-readable storage medium.
背景技术Background technique
在自然语言理解中,需要对用户意图进行分类。目前,通常基于模板或者模型进行意图分类,但发明人意识到基于模型的意图分类易受到意图的发生频率以及数据量的影响,往往无法很好地解决真实场景下的意图分类,影响意图分类的准确性。因此,如何提高意图分类的准确性,成为了亟待解决的技术问题。In natural language understanding, user intent needs to be classified. At present, intent classification is usually based on templates or models, but the inventors realized that model-based intent classification is easily affected by the occurrence frequency and data volume of intent, and often cannot solve the intent classification in real scenarios well, affecting the accuracy of intent classification. accuracy. Therefore, how to improve the accuracy of intent classification has become an urgent technical problem to be solved.
发明内容Contents of the invention
本申请实施例的主要目的在于提出一种意图分类方法、装置、电子设备及计算机可读存储介质,旨在实现对用户意图的准确分类,提高意图分类的准确性。The main purpose of the embodiments of the present application is to provide an intent classification method, device, electronic device, and computer-readable storage medium, aiming at realizing accurate classification of user intent and improving the accuracy of intent classification.
为实现上述目的,本申请实施例的第一方面提出了一种意图分类方法,所述方法包括:In order to achieve the above purpose, the first aspect of the embodiments of the present application proposes an intention classification method, the method includes:
获取请求文本;get request text;
对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
为实现上述目的,本申请实施例的第二方面提出了一种意图分类装置,所述装置包括:In order to achieve the above purpose, the second aspect of the embodiments of the present application proposes an intention classification device, the device includes:
文本获取模块,用于获取请求文本;A text acquisition module, configured to acquire the request text;
特征提取模块,用于对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;A feature extraction module, configured to extract entity features from the request text to obtain the first text containing target query parameters;
对比模块,用于将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;Comparison module, for inputting the first text to the pre-trained comparison model and performing matrix multiplication with the reference word embedding matrix in the comparison model, to obtain a plurality of target word embedding vectors;
分类模块,用于利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;A classification module, configured to classify the target word embedding vector using a pre-trained intent classification model, to obtain a target word embedding vector and an intent classification probability value including an intent category label;
匹配模块,用于利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;A matching module, configured to use a pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value;
计算模块,用于根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。A calculation module, configured to obtain intention classification data according to the intention matching value and the intention classification probability value.
为实现上述目的,本申请实施例的第三方面提出了一种电子设备,所述电子设备包括存储器、处理器、存储在所述存储器上并可在所述处理器上运行的程序以及用于实现所述处理器和所述存储器之间的连接通信的数据总线,所述程序被所述处理器执行时实现一种意图分类方法,其中,所述意图分类方法包括:To achieve the above object, the third aspect of the embodiments of the present application proposes an electronic device, the electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a program for A data bus for connection and communication between the processor and the memory is implemented, and when the program is executed by the processor, an intent classification method is implemented, wherein the intent classification method includes:
获取请求文本;get request text;
对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
为实现上述目的,本申请实施例的第四方面提出了一种计算机可读存储介质,用于计算机可读存储,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现一种意图分类方法,其中,所述意图分类方法包括以下步骤:To achieve the above purpose, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium for computer-readable storage, the computer-readable storage medium stores one or more programs, and the one or more This program can be executed by one or more processors to implement a method for classifying intent, wherein the method for classifying intent includes the following steps:
获取请求文本;get request text;
对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
本申请提出的意图分类方法、装置、电子设备及计算机可读存储介质,其通过获取请求文本,对请求文本进行实体特征提取,得到包含目标查询参数的第一文本,这一方式能够实现对请求文本的特征抽取,缩小请求文本的数据空间,使得更为方便提取到所需要的包含目标查询参数的第一文本。进而将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量,利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值,通过对比模型能够较好地解决目标词嵌入向量分布不均匀的问题,同时,通过对比模型和意图分类模型能够进行意图分类概率的深度学习,提高意图分类概率值的准确性。另外,本申请还可以利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值,通过意图匹配模型能够基于规则匹配对用户的意图匹配值进行计算,提高意图匹配的准确性。最后根据意图匹配值和意图分类概率值,得到意图分类数据。本申请通过对比模型、意图分类模型以及意图匹配模型能够综合意图分类概率以及意图匹配性两方面来识别用户的对话意图,使得最终得到的意图分类数据能够呈现出更为准确的意图分类结果,实现了对用户意图的准确分类,提高了意图分类的准确性。The intent classification method, device, electronic equipment, and computer-readable storage medium proposed in this application obtain the request text, extract the entity features of the request text, and obtain the first text containing the target query parameters. This method can realize the request The feature extraction of the text reduces the data space of the requested text, making it easier to extract the required first text containing the target query parameters. Then input the first text to the pre-trained comparison model and perform matrix multiplication with the reference word embedding matrix in the comparison model to obtain multiple target word embedding vectors, and use the pre-trained intent classification model to classify the target word embedding vectors, The target word embedding vector and intent classification probability value containing the intent category label are obtained, and the problem of uneven distribution of the target word embedding vector can be better solved by comparing the model. At the same time, the depth of the intent classification probability can be determined by comparing the model and the intent classification model. Learning to improve the accuracy of intent classification probability values. In addition, the present application can also use the pre-trained intention matching model to perform matching processing on the first text to obtain the intention matching value, and the intention matching model can be used to calculate the user's intention matching value based on rule matching to improve the accuracy of intention matching. Finally, according to the intention matching value and the intention classification probability value, the intention classification data is obtained. In this application, through the comparison model, intent classification model, and intent matching model, the user's dialogue intent can be identified by integrating the two aspects of intent classification probability and intent matching, so that the final intent classification data can present more accurate intent classification results. The accurate classification of user intent is achieved, and the accuracy of intent classification is improved.
附图说明Description of drawings
图1是本申请实施例提供的意图分类方法的流程图;FIG. 1 is a flow chart of an intent classification method provided in an embodiment of the present application;
图2是图1中的步骤S102的流程图;Fig. 2 is the flowchart of step S102 in Fig. 1;
图3是图1中的步骤S103的流程图;Fig. 3 is the flowchart of step S103 in Fig. 1;
图4是本申请实施例提供的意图分类方法的另一流程图;Fig. 4 is another flow chart of the intent classification method provided by the embodiment of the present application;
图5是图1中的步骤S104的流程图;Fig. 5 is the flowchart of step S104 in Fig. 1;
图6是图1中的步骤S105的流程图;Fig. 6 is the flowchart of step S105 in Fig. 1;
图7是图1中的步骤S106的流程图;Fig. 7 is the flowchart of step S106 in Fig. 1;
图8是本申请实施例提供的意图分类装置的结构示意图;Fig. 8 is a schematic structural diagram of an intention classification device provided by an embodiment of the present application;
图9是本申请实施例提供的电子设备的硬件结构示意图。FIG. 9 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, not to limit the present application.
需要说明的是,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although the functional modules are divided in the schematic diagram of the device, and the logical sequence is shown in the flowchart, in some cases, it can be executed in a different order than the module division in the device or the flowchart in the flowchart. steps shown or described. The terms "first", "second" and the like in the specification and claims and the above drawings are used to distinguish similar objects, and not necessarily used to describe a specific sequence or sequence.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
首先,对本申请中涉及的若干名词进行解析:First, analyze some nouns involved in this application:
人工智能(artificial intelligence,AI):是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门新的技术科学;人工智能是计算机科学的一个分支,人工智能企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器,该领域的研究包括机器人、语言识别、图像识别、自然语言处理和专家系统等。人工智能可以对人的意识、思维的信息过程的模拟。人工智能还是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。Artificial Intelligence (AI): It is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence; artificial intelligence is a branch of computer science. Intelligence attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a manner similar to human intelligence. Research in this field includes robotics, language recognition, image recognition, natural language processing, and expert systems. Artificial intelligence can simulate the information process of human consciousness and thinking. Artificial intelligence is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
自然语言处理(natural language processing,NLP):NLP用计算机来处理、理解以及运用人类语言(如中文、英文等),NLP属于人工智能的一个分支,是计算机科学与语言学的交叉学科,又常被称为计算语言学。自然语言处理包括语法分析、语义分析、篇章理解等。自然语言处理常用于机器翻译、手写体和印刷体字符识别、语音识别及文语转换、信息检索、信息抽取与过滤、文本分类与聚类、舆情分析和观点挖掘等技术领域,它涉及与语言处理相关的数据挖掘、机器学习、知识获取、知识工程、人工智能研究和与语言计算相关的语言学研究等。Natural language processing (NLP): NLP uses computers to process, understand and use human languages (such as Chinese, English, etc.). NLP belongs to a branch of artificial intelligence and is an interdisciplinary subject between computer science and linguistics. Known as computational linguistics. Natural language processing includes syntax analysis, semantic analysis, text understanding, etc. Natural language processing is often used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information retrieval, information extraction and filtering, text classification and clustering, public opinion analysis and opinion mining. It involves language processing Related data mining, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research and linguistics research related to language computing, etc.
信息抽取(Information Extraction,NER):从自然语言文本中抽取指定类型的实体、关系、事件等事实信息,并形成结构化数据输出的文本处理技术。信息抽取是从文本数据中抽取特定信息的一种技术。文本数据是由一些具体的单位构成的,例如句子、段落、篇章,文本信息正是由一些小的具体的单位构成的,例如字、词、词组、句子、段落或是这些具体的单位的组合。抽取文本数据中的名词短语、人名、地名等都是文本信息抽取,当然,文本信息抽取技术所抽取的信息可以是各种类型的信息。Information Extraction (Information Extraction, NER): A text processing technology that extracts specified types of factual information such as entities, relationships, and events from natural language texts, and forms structured data output. Information extraction is a technique to extract specific information from text data. Text data is composed of some specific units, such as sentences, paragraphs, and chapters. Text information is composed of some small specific units, such as words, words, phrases, sentences, paragraphs, or combinations of these specific units. . Extracting noun phrases, personal names, and place names in text data is all text information extraction. Of course, the information extracted by text information extraction technology can be various types of information.
实体:指具有可区别性且独立存在的某种事物。如某一个人、某一个城市、某一种植物等、某一种商品等等。世界万物有具体事物组成,此指实体。实体是知识图谱中的最基本元素,不同的实体间存在不同的关系。Entity: Refers to something that is distinguishable and exists independently. Such as a certain person, a certain city, a certain plant, a certain commodity, etc. Everything in the world is made up of concrete things, which refer to entities. Entities are the most basic elements in knowledge graphs, and different entities have different relationships.
概念:某一类实体的集合。Concept: A collection of entities of a certain type.
语义类(概念):具有同种特性的实体构成的集合,如国家、民族、书籍、电脑等。概念主要指集合、类别、对象类型、事物的种类,例如人物、地理等。Semantic class (concept): A collection of entities with the same characteristics, such as countries, nations, books, computers, etc. Concepts mainly refer to collections, categories, object types, and types of things, such as people, geography, etc.
自监督学习:自监督学习主要是利用辅助任务(pretext)从大规模的无监督数据中挖掘自身的监督信息,通过这种构造的监督信息对网络进行训练,从而可以学习到对下游任务有价值的表征。也就是说自监督学习的监督信息不是人工标注,而是算法在大规模无监督数据中自动构造监督信息,来进行监督学习或训练。Self-supervised learning: Self-supervised learning mainly uses auxiliary tasks (pretext) to mine its own supervision information from large-scale unsupervised data, and trains the network through this structured supervision information, so that it can learn to be valuable for downstream tasks representation. That is to say, the supervision information of self-supervised learning is not manually labeled, but the algorithm automatically constructs supervision information in large-scale unsupervised data for supervised learning or training.
对比学习(Contrastive Learning)是自监督学习的一种,不需要依赖人工标注的类别标签信息,直接利用数据本身作为监督信息。对比学习是一种为深度学习模型描述相似和不同事物的任务的方法。利用对比学习方法,可以训练机器学习模型来区分相似和不同的图像。在图像领域的自监督学习分为两种类型:生成式自监督学习、判别式自监督学习。对比学习 应用的是典型的判别式自监督学习。对比学习的核心要点是:通过自动构造相似实例和不相似实例,也就是正样本和负样本,学习将正样本和负样本在特征空间进行对比,使得相似的实例在特征空间中距离拉近,而不相似的实例在特征空间中的距离拉远,差异性变大,通过这样的学习过程得到的模型表征就可以去执行下游任务,在较小的标记数据集上进行微调,从而实现无监督的模型学习过程。对比学习的指导原则是:通过自动构造相似实例和不相似实例,通过学习得到一个学习模型,利用这个模型,使得相似的实例在投影空间中比较接近,而可不相似的实例在投影空间中距离比较远。Contrastive learning is a kind of self-supervised learning, which does not need to rely on manually labeled category label information, and directly uses the data itself as supervisory information. Contrastive learning is an approach to the task of describing similar and dissimilar things for deep learning models. Using contrastive learning methods, machine learning models can be trained to distinguish between similar and dissimilar images. Self-supervised learning in the image field is divided into two types: generative self-supervised learning and discriminative self-supervised learning. Contrastive learning applies typical discriminative self-supervised learning. The core point of comparative learning is: by automatically constructing similar instances and dissimilar instances, that is, positive samples and negative samples, learning to compare positive samples and negative samples in the feature space, so that similar instances are closer in the feature space, The distance between dissimilar instances in the feature space is farther, and the difference becomes larger. The model representation obtained through such a learning process can perform downstream tasks and fine-tune on a smaller labeled data set to achieve unsupervised model learning process. The guiding principle of comparative learning is: by automatically constructing similar instances and dissimilar instances, a learning model is obtained through learning, and using this model, similar instances are relatively close in the projection space, while dissimilar instances can be compared in the projection space. Far.
嵌入(embedding):embedding是一种向量表征,是指用一个低维的向量表示一个物体,该物体可以是一个词,或是一个商品,或是一个电影等等;这个embedding向量的性质是能使距离相近的向量对应的物体有相近的含义,embedding实质是一种映射,从语义空间到向量空间的映射,同时尽可能在向量空间保持原样本在语义空间的关系,如语义接近的两个词汇在向量空间中的位置也比较接近。embedding能够用低维向量对物体进行编码还能保留其含义,常应用于机器学习,在机器学习模型构建过程中,通过把物体编码为一个低维稠密向量再传给DNN,以提高效率。Embedding: embedding is a kind of vector representation, which refers to representing an object with a low-dimensional vector, which can be a word, or a commodity, or a movie, etc.; the nature of this embedding vector is that it can Make objects corresponding to vectors with similar distances have similar meanings. Embedding is essentially a mapping from semantic space to vector space, while maintaining the relationship of the original sample in the semantic space in the vector space as much as possible, such as two semantically close The positions of the words in the vector space are also relatively close. Embedding can encode an object with a low-dimensional vector and retain its meaning. It is often used in machine learning. In the process of building a machine learning model, the object is encoded as a low-dimensional dense vector and then passed to DNN to improve efficiency.
批量(Batch):Batch大小(即批量大小)是一个超参数,用于定义在更新内部模型参数之前要处理的样本数,也就是在模型的内部参数更新之前控制训练样本的数量。训练数据集可以分为一个或多个Batch,其中,当所有训练样本用于创建一个Batch时,学习算法称为批量梯度下降;当批量是一个样本的大小时,学习算法称为随机梯度下降;当批量大小超过一个样本且小于训练数据集的大小时,学习算法称为小批量梯度下降。Batch大小是在更新模型之前处理的多个样本。Batch: Batch size (i.e., batch size) is a hyperparameter used to define the number of samples to be processed before updating the internal model parameters, that is, to control the number of training samples before the internal parameters of the model are updated. The training data set can be divided into one or more batches, where when all training samples are used to create a batch, the learning algorithm is called batch gradient descent; when the batch is the size of a sample, the learning algorithm is called stochastic gradient descent; When the batch size is more than one sample and less than the size of the training dataset, the learning algorithm is called mini-batch gradient descent. The batch size is the number of samples processed before updating the model.
数据增强:数据增强主要用来防止过拟合,用于dataset(数据集)较小时对数据集进行优化,通过数据增强,可以增加训练的数据量,提高模型的泛化能力,增加噪声数据,提升模型的鲁棒性。数据增强可以分为两类,离线增强和在线增强;其中,离线增强是直接对数据集进行处理,数据的数目会变成增强因子x原数据集的数目,离线增强常常用于数据集很小时;在线增强,主要用于获得batch数据之后,对这个batch的数据进行增强,如旋转、平移、翻折等相应的变化,由于有些数据集不能接受线性级别的增长,在线增强常用于较大数据集,很多机器学习框架已经支持了在线增强方式,并且可以使用GPU优化计算。Data enhancement: Data enhancement is mainly used to prevent overfitting and optimize the dataset when the dataset is small. Through data enhancement, the amount of training data can be increased, the generalization ability of the model can be improved, and noise data can be increased. Improve the robustness of the model. Data enhancement can be divided into two categories, offline enhancement and online enhancement. Among them, offline enhancement is to directly process the data set, and the number of data will become the enhancement factor x the number of original data sets. Offline enhancement is often used when the data set is small. ;Online enhancement is mainly used to enhance the batch data after obtaining the batch data, such as rotation, translation, flipping and other corresponding changes. Since some data sets cannot accept linear level growth, online enhancement is often used for larger data Set, many machine learning frameworks already support online enhancement methods, and can use GPU to optimize calculations.
dropout(丢弃):dropout是一种防止模型过拟合的技术,是指在深度学习网络的训练过程中,对于神经网络单元,按照一定的概率将其暂时从网络中丢弃,从而可以让模型更鲁棒,因为它不会太依赖某些局部的特征(因为局部特征有可能被丢弃)。Dropout (discard): dropout is a technique to prevent model overfitting. It means that during the training process of the deep learning network, for the neural network unit, it is temporarily discarded from the network according to a certain probability, so that the model can be more accurate. Robust, because it does not depend too much on some local features (because local features may be discarded).
mask(掩码、掩膜):mask是深度学习中的常见操作;简单而言,mask相当于在原始张量上盖上一层掩膜,从而屏蔽或选择一些特定元素,因此常用于构建张量的过滤器。线性激活函数Relu(根据输出的正负区间进行简单粗暴的二分)、dropout机制(根据概率进行二分)都可以理解为泛化的mask操作。Mask (mask, mask): mask is a common operation in deep learning; in simple terms, mask is equivalent to putting a mask on the original tensor to shield or select some specific elements, so it is often used to construct tensors volume filter. The linear activation function Relu (simple and rough dichotomy based on the positive and negative range of the output) and the dropout mechanism (division according to the probability) can be understood as generalized mask operations.
encoder:编码,就是将输入序列转化成一个固定长度的向量;解码(decoder),就是将之前生成的固定向量再转化成输出序列;其中,输入序列可以是文字、语音、图像、视频;输出序列可以是文字、图像。Encoder: encoding is to convert the input sequence into a fixed-length vector; decoding (decoder) is to convert the previously generated fixed vector into an output sequence; where the input sequence can be text, voice, image, video; output sequence Can be text, image.
反向传播:反向传播的大致原理为:将训练集数据输入到神经网络的输入层,经过神经网络的隐藏层,最后达到神经网络的输出层并输出结果;由于神经网络的输出结果与实际结果有误差,则计算估计值与实际值之间的误差,并将该误差从输出层向隐藏层反向传播,直至传播到输入层;在反向传播的过程中,根据误差调整各种参数的值;不断迭代上述过程,直至收敛。Backpropagation: The general principle of backpropagation is: input the training set data into the input layer of the neural network, pass through the hidden layer of the neural network, and finally reach the output layer of the neural network and output the result; because the output result of the neural network is different from the actual If there is an error in the result, the error between the estimated value and the actual value is calculated, and the error is backpropagated from the output layer to the hidden layer until it is propagated to the input layer; in the process of backpropagation, various parameters are adjusted according to the error The value of ; continue to iterate the above process until convergence.
随着人工智能技术的飞速发展,各类基于对话系统的应用产品逐渐增多,语音交互需求也日益扩增。对话系统是一种基于自然语言的人机交互系统。通过对话系统,用户可以使用自然语言和计算机进行多轮交互来完成特定的任务。当前,对话系统广泛应用于不同领域,如搜索领域、智能问答领域、情感分析领域等,其中,自然语言理解是对话系统中的核心模 块。自然语言理解的目标是将自然语言的文本信息转换为可被计算机处理的语义表示,即用一种结构化的数据来表示一句话所表达的含义。也就是说,自然语言理解的目标是根据待解析的文本信息确定用户想表达的意图以及满足用户意图的条件。With the rapid development of artificial intelligence technology, various application products based on dialogue systems are gradually increasing, and the demand for voice interaction is also increasing. A dialogue system is a human-computer interaction system based on natural language. Through the dialogue system, users can use natural language to interact with the computer in multiple rounds to complete specific tasks. At present, dialogue systems are widely used in different fields, such as search, intelligent question answering, sentiment analysis, etc. Among them, natural language understanding is the core module of dialogue systems. The goal of natural language understanding is to convert the text information of natural language into a semantic representation that can be processed by a computer, that is, to use a structured data to represent the meaning expressed in a sentence. That is to say, the goal of natural language understanding is to determine the intention that the user wants to express and the conditions to satisfy the user's intention according to the text information to be parsed.
在自然语言理解中,需要对用户意图进行分类。目前,通常基于模板或者模型进行意图分类,但发明人意识到基于模板的意图分类严重依赖于模板的覆盖程度,易受到数据规模以及数据质量的影响;基于模型的意图分类易受到意图的发生频率以及数据量的影响,往往无法很好地解决真实场景下的意图分类,影响意图分类结果的准确性。因此,如何提供实现对用户意图的准确分类,提高意图分类的准确性,成为了亟待解决的技术问题。In natural language understanding, user intent needs to be classified. At present, intent classification is usually based on templates or models, but the inventor realized that template-based intent classification is heavily dependent on the coverage of templates, and is easily affected by data scale and data quality; model-based intent classification is vulnerable to the occurrence frequency of intent And the impact of the amount of data, it is often unable to solve the intent classification in the real scene well, affecting the accuracy of the intent classification results. Therefore, how to provide and realize accurate classification of user intent and improve the accuracy of intent classification has become a technical problem to be solved urgently.
基于此,本申请实施例提供一种意图分类方法、装置、电子设备及存储介质,可以实现对用户意图的准确分类,提高意图分类结果的准确性。Based on this, the embodiments of the present application provide an intention classification method, device, electronic device, and storage medium, which can realize accurate classification of user intentions and improve the accuracy of intention classification results.
本申请实施例提供的意图分类方法、装置、电子设备及计算机可读存储介质,具体通过如下实施例进行说明,首先描述本申请实施例中的意图分类方法。The intent classification method, device, electronic device, and computer-readable storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the intent classification method in the embodiments of the present application is described.
本申请实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。The embodiments of the present application may acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. .
人工智能基础技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理技术、操作/交互系统、机电一体化等技术。人工智能软件技术主要包括计算机视觉技术、机器人技术、生物识别技术、语音处理技术、自然语言处理技术以及机器学习/深度学习等几大方向。Artificial intelligence basic technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation/interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning/deep learning.
本申请实施例提供的意图分类方法,涉及人工智能中的深度学习技术领域。本申请实施例提供的意图分类方法可应用于终端中,也可应用于服务器端中,还可以是运行于终端或服务器端中的软件。在一些实施例中,终端可以是智能手机、平板电脑、笔记本电脑、台式计算机等;服务器端可以配置成独立的物理服务器,也可以配置成多个物理服务器构成的服务器集群或者分布式系统,还可以配置成提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN以及大数据和人工智能平台等基础云计算服务的云服务器;软件可以是实现意图分类方法的应用等,但并不局限于以上形式。The intent classification method provided in the embodiment of the present application relates to the technical field of deep learning in artificial intelligence. The intent classification method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running on the terminal or the server. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server end can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or It can be configured as a cloud that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server; the software may be an application that implements the intent classification method, but is not limited to the above forms.
本申请可用于众多通用或专用的计算机系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、多处理器系统、基于微处理器的系统、置顶盒、可编程的消费电子设备、网络PC、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The application can be used in numerous general purpose or special purpose computer system environments or configurations. Examples: personal computers, server computers, handheld or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, including A distributed computing environment for any of the above systems or devices, etc. This application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
图1是本申请实施例提供的意图分类方法的一个可选的流程图,图1中的方法可以包括但不限于包括步骤S101至步骤S106。Fig. 1 is an optional flow chart of the intention classification method provided by the embodiment of the present application, the method in Fig. 1 may include but not limited to include steps S101 to S106.
步骤S101,获取请求文本;Step S101, obtaining request text;
步骤S102,对请求文本进行实体特征提取,得到包含目标查询参数的第一文本;Step S102, extracting entity features from the request text to obtain the first text containing the target query parameters;
步骤S103,将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;Step S103, inputting the first text to the pre-trained comparison model and performing matrix multiplication with the reference word embedding matrix in the comparison model to obtain a plurality of target word embedding vectors;
步骤S104,利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Step S104, using the pre-trained intent classification model to classify the target word embedding vector, and obtain the target word embedding vector and the intent classification probability value including the intent category label;
步骤S105,利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值;Step S105, using the pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value;
步骤S106,根据意图匹配值和意图分类概率值,得到意图分类数据。Step S106, according to the intention matching value and the intention classification probability value, the intention classification data is obtained.
在一些实施例的步骤S101中,可以通过编写网络爬虫,设置好数据源之后进行有目标性的爬取数据,得到请求文本。需要说明的是,该请求文本为自然语言文本。In step S101 of some embodiments, the request text can be obtained by writing a web crawler, setting a data source, and then performing targeted crawling of data. It should be noted that the request text is a natural language text.
请参阅图2,在一些实施例中,第一文本包括字符文本和语义文本,步骤S102可以包括但不限于包括步骤S201至步骤S202:Referring to FIG. 2, in some embodiments, the first text includes character text and semantic text, and step S102 may include, but is not limited to, step S201 to step S202:
步骤S201,根据基于前缀树的特征提取模型对请求文本进行实体特征提取,得到字符文本;Step S201, extracting the entity features of the request text according to the feature extraction model based on the prefix tree to obtain the character text;
步骤S202,利用预先训练的词法分析模型对请求文本进行识别处理,得到语义文本。Step S202, using the pre-trained lexical analysis model to perform recognition processing on the request text to obtain semantic text.
在一些实施例的步骤S201中,可以根据各种类型的知识数据库构建基于前缀树的特征提取模型。例如,基于前缀树的特征提取模型中,包含根据音乐知识数据库构建的多个前缀树,这些前缀树由音乐知识库包含的歌曲名称、歌手名、专辑名称等预存数据构建。该特征提取模型中的每一颗树的根节点都代表着每一个预存数据的第一个字符。通过将请求文本中的实体特征的字符数据与每一预存数据的第一个字符进行对比,可以方便地确定出当前请求文本中的实体特征,进而对实体特征进行信息抽取,得到字符文本。In step S201 of some embodiments, a feature extraction model based on a prefix tree may be constructed according to various types of knowledge databases. For example, the prefix tree-based feature extraction model contains multiple prefix trees constructed according to the music knowledge database, and these prefix trees are constructed from pre-stored data such as song names, singer names, and album names contained in the music knowledge database. The root node of each tree in the feature extraction model represents the first character of each pre-stored data. By comparing the character data of the entity feature in the request text with the first character of each pre-stored data, the entity feature in the current request text can be determined conveniently, and then information extraction is performed on the entity feature to obtain the character text.
在一些实施例的步骤S202中,需要预先构建请求数据词库,该请求数据词库可以包括各类查询管理相关的专有名词、术语、非专有名称等等。通过这一请求数据词库,预设的词法分析模型可以将特定查询管理名称进行列举,例如,用户主诉、查询类别等等。将请求文本输入至预设的词法分析模型中,通过预设的词法分析模型中包含的特定查询管理以及预设的词性类别,对请求文本中的实体特征进行识别,该实体特征可以包括上述与查询管理相关的专有名词、术语、非专有名称、修饰词、时间信息等多个维度的实体词汇。In step S202 of some embodiments, the request data thesaurus needs to be constructed in advance, and the request data thesaurus may include various proper nouns, terms, non-proper names and the like related to query management. Through this request data lexicon, the preset lexical analysis model can enumerate specific query management names, for example, user complaints, query categories, and so on. Input the request text into the preset lexical analysis model, and identify the entity features in the request text through the specific query management contained in the preset lexical analysis model and the preset part-of-speech category. The entity features may include the above-mentioned and Query and manage entity vocabulary in multiple dimensions such as proper nouns, terms, non-proper names, modifiers, and time information.
为了更准确地提取语义文本,还可以通过预先训练的序列分类器对请求文本中的实体特征进行标记,使得这些实体特征都能够带上预设的标签,以便提高分类效率。In order to extract semantic text more accurately, the entity features in the request text can also be marked by a pre-trained sequence classifier, so that these entity features can carry preset labels to improve classification efficiency.
需要说明的是,在一些具体实施例中,预先训练的序列分类器可以是最大熵马尔科夫模型(MEMM模型)或者基于条件随机场算法(CRF)的模型或者是基于双向长短时记忆算法(bi-LSTM)的模型。例如,可以基于bi-LSTM算法构建序列分类器,在基于bi-LSTM算法的模型中,输入单词wi和字符嵌入,通过左到右的长短记忆和右向左的长短时记忆,使得在输出被连接的位置生成单一的输出层。序列分类器通过这一输出层可以将输入的实体特征直接传递到softmax分类器上,通过softmax分类器在预设的词性类别标签上创建一个概率分布,从而根据概率分布对实体特征数据进行标记分类。最后对包含类别标签的实体特征数据进行特征提取,得到所需要的语义文本。It should be noted that, in some specific embodiments, the pre-trained sequence classifier can be a maximum entropy Markov model (MEMM model) or a model based on conditional random field algorithm (CRF) or based on a two-way long short-term memory algorithm ( bi-LSTM) model. For example, a sequence classifier can be constructed based on the bi-LSTM algorithm. In the model based on the bi-LSTM algorithm, the input word wi and character embedding are passed through left-to-right long-short-term memory and right-to-left long-short-term memory, so that the output is The connected locations generate a single output layer. The sequence classifier can pass the input entity features directly to the softmax classifier through this output layer, and create a probability distribution on the preset part-of-speech category label through the softmax classifier, so as to mark and classify the entity feature data according to the probability distribution . Finally, feature extraction is performed on the entity feature data containing category labels to obtain the required semantic text.
另外,为了实现数据存储,还可以采用BERT编码器,通过预设的编码函数将语义文本由文本形式转化为编码形式,以实现对语义文本的存储。该方法能够实现对请求文本的语义识别处理和特征抽取,缩小数据总量,使得更为方便提取到所需要的语义文本。In addition, in order to achieve data storage, the BERT encoder can also be used to convert the semantic text from the text form to the encoded form through the preset encoding function to realize the storage of the semantic text. The method can realize the semantic recognition processing and feature extraction of the request text, reduce the total amount of data, and make it more convenient to extract the required semantic text.
请参阅图3,在一些实施例中,步骤S103可以包括但不限于包括步骤S301至步骤S303:Referring to FIG. 3, in some embodiments, step S103 may include but not limited to include steps S301 to S303:
步骤S301,对第一文本进行分词处理和编码处理,得到多个查询词段向量;Step S301, performing word segmentation and encoding processing on the first text to obtain a plurality of query word segment vectors;
步骤S302,将多个查询词段向量输入到预先训练的对比模型中,以使查询词段向量与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个基本词嵌入向量;Step S302, inputting a plurality of query word vectors into the pre-trained comparison model, so that the query word vector and the reference word embedding matrix in the comparison model are matrix multiplied to obtain a plurality of basic word embedding vectors;
步骤S303,对基本词嵌入向量进行映射处理,得到目标词嵌入向量。Step S303, performing mapping processing on the basic word embedding vector to obtain the target word embedding vector.
在一些实施例的步骤S301中,可以包括但不限于包括以下步骤:In some embodiments, step S301 may include, but is not limited to, the following steps:
利用预先训练的文本分词模型对第一文本进行分词处理,得到多个文本词段。A pre-trained text segmentation model is used to perform word segmentation processing on the first text to obtain multiple text word segments.
在一些实施例的步骤S301中,可以利用预先训练的Jieba分词器对原始文本进行分词处理,得到文本词段;具体地,在利用Jieba分词器进行分词时,首先通过对照Jieba分词器内的词典生成该原始文本对应的有向无环图,再根据预设的选择模式和词典寻找有向无环图上的最短路径,根据最短路径对该原始文本进行截取,或者直接对该原始文本进行截取,得到文本词段。进一步地,对于不在词典中的文本词段,可以使用HMM(隐马尔科夫模型)进行新词发现。具体地,将字符在文本词段中的位置B、M、E、S作为隐藏状态,字符是观测状态,其中,B/M/E/S分别代表出现在词头、词中、词尾以及单字成词。使用词典文件分别存 储字符之间的表现概率矩阵、初始概率向量和转移概率矩阵。再利用维特比算法对最大可能的隐藏状态进行求解,从而得到文本字段。In step S301 of some embodiments, the pre-trained Jieba word breaker can be used to perform word segmentation processing on the original text to obtain text segments; specifically, when using the Jieba word breaker for word segmentation, first by comparing the dictionary in the Jieba word breaker Generate the directed acyclic graph corresponding to the original text, and then find the shortest path on the directed acyclic graph according to the preset selection mode and dictionary, and intercept the original text according to the shortest path, or directly intercept the original text , to get the text segment. Further, for text word segments that are not in the dictionary, HMM (Hidden Markov Model) can be used for new word discovery. Specifically, the positions B, M, E, and S of the characters in the text segment are taken as the hidden state, and the characters are the observed state, where B/M/E/S represent the words that appear at the beginning, middle, end, and composition of words, respectively. word. The dictionary file is used to store the performance probability matrix, initial probability vector and transition probability matrix between characters respectively. Then use the Viterbi algorithm to solve the maximum possible hidden state, so as to obtain the text field.
在另一些实施例的步骤S301中,还需要对文本词段进行词性标注处理,即根据预设的词性类别对文本词段进行词性标注,得到包含词性类别标签的文本词段,其中,预设的词性类别包括名称、动词、修饰词、形容词等等。In step S301 of some other embodiments, it is also necessary to perform part-of-speech tagging on the text word segment, that is, perform part-of-speech tagging on the text word segment according to the preset part-of-speech category to obtain a text word segment containing the part-of-speech category tag, wherein the preset The part-of-speech categories include names, verbs, modifiers, adjectives, and more.
通过上述步骤能够实现对第一文本的分词处理,使得更为方便提取到所需要的文本词段。Through the above steps, word segmentation processing of the first text can be realized, making it more convenient to extract required text word segments.
进一步地,在另一些实施例的步骤S301中,可以包括但不限于包括以下步骤:Further, in step S301 of other embodiments, it may include but not limited to include the following steps:
利用目标词库模型中的index函数对每一文本词段进行元素提取,得到每一文本词段的元素值;Use the index function in the target thesaurus model to extract the elements of each text phrase to obtain the element value of each text phrase;
根据元素值对文本词段进行位置识别,得到文本词段的目标位置。The position recognition of the text word segment is carried out according to the element value, and the target position of the text word segment is obtained.
由于index函数可以返回表格或数组中的元素值。因此通过数组形式的index函数对每一文本词段的元素值进行提取,得到文本词段的元素值。其中,文本词段的元素值包括文本词段的行号和列号的索引值。因而,通过index函数对文本词段的行号和列号进行搜索,能够对指定位置的文本词段进行获取。通过index函数对文本词段的行号和列号进行搜索,遍历原始文本中的每一文本字段,生成文本词段的位置序列表,该位置序列表能够反映出文本字段与行号、列号(元素值)的对应关系。即实现了根据元素值确定文本词段的目标位置,从而能够较为准确地对每一文本词段进行位置识别。Because the index function can return the element value in the table or array. Therefore, the element value of each text word segment is extracted through the index function in the form of an array to obtain the element value of the text word segment. Wherein, the element value of the text word segment includes the index value of the line number and the column number of the text word segment. Therefore, by searching the line number and column number of the text word segment through the index function, the text word segment at the specified position can be obtained. Use the index function to search the line number and column number of the text word segment, traverse each text field in the original text, and generate a position sequence table of the text word segment, which can reflect the text field, line number, and column number (element value) correspondence. That is to say, the target position of the text word segment is determined according to the element value, so that the location of each text word segment can be more accurately identified.
进一步地,在另一些实施例的步骤S301中,可以包括但不限于包括以下步骤:Further, in step S301 of other embodiments, it may include but not limited to include the following steps:
根据目标位置,对每一文本词段进行归一化处理,得到标准词段;According to the target position, each text word segment is normalized to obtain a standard word segment;
对标准词段进行独热编码,得到文本词段向量。Perform one-hot encoding on the standard word segment to obtain the text word segment vector.
具体地,目标位置为文本词段的index位置。根据每一文本词段的index位置,从第一文本中分别提取每一文本词段,将每一文本词段进行线性缩放至[-1,1],或者将每一文本词段都放缩至均值为0,方差为1,以实现对每一文本词段的归一化处理,得到标准词段。Specifically, the target position is the index position of the text word segment. According to the index position of each text segment, each text segment is extracted from the first text, and each text segment is linearly scaled to [-1,1], or each text segment is scaled The average value is 0, and the variance is 1, so as to realize the normalization processing for each text segment and obtain the standard term segment.
需要说明的是,独热编码即One-Hot编码,又称一位有效编码。其方法是使用N位状态寄存器来对N个状态进行编码,每个状态都有它独立的寄存器位,并且在任意时候,其中只有一位有效。It should be noted that one-hot encoding is One-Hot encoding, also known as one-bit effective encoding. The method is to use an N-bit state register to encode N states, each state has its own independent register bit, and at any time, only one bit is valid.
通过独热编码可以将标准词段的长度表示为向量形式,得到多个文本词段向量。例如,假设某个原始文本由3个文本词段组成,通过前述步骤可以获得这3个文本词段的index位置。One-hot编码就是对每一文本词段使用长度为V的向量表示,这个V就是目标词库模型中与文本词段对应的字典词的个数。向量把原始文本中出现了文本词段的index位置标记为1,其他都为0,假设某个句子由3个文本词段组成,那么这个向量里就有3个1,这个1的位置可以和文本词段的index位置对应。The length of the standard word segment can be expressed as a vector form by one-hot encoding, and multiple text word segment vectors can be obtained. For example, assuming that a certain original text consists of 3 text segments, the index positions of these 3 text segments can be obtained through the aforementioned steps. One-hot encoding is to use a vector representation of length V for each text segment, and this V is the number of dictionary words corresponding to the text segment in the target thesaurus model. The vector marks the index position of the text segment in the original text as 1, and the others are 0. Suppose a sentence is composed of 3 text segments, then there are 3 1s in this vector, and the position of this 1 can be compared with Corresponds to the index position of the text segment.
通过上述步骤能够较为方便地根据目标位置对每一文本词段进行编码处理,得到查询词段向量,以通过该查询词段向量得到目标词嵌入向量。Through the above steps, each text word segment can be more conveniently encoded according to the target position to obtain a query word segment vector, so as to obtain a target word embedding vector through the query word segment vector.
进而,执行步骤S302,通过训练对比模型可以使得对比模型内的参考词嵌入矩阵的数值将被完全固定下来,对比模型的其他模型参数也被固定。因而,将查询词段向量输入到对比模型中,可以利用固定的参考词嵌入矩阵与每一查询词段向量进行矩阵相乘,得到基本词嵌入向量。Furthermore, step S302 is executed, and the value of the reference word embedding matrix in the comparison model can be completely fixed by training the comparison model, and other model parameters of the comparison model are also fixed. Therefore, when the query word vector is input into the comparison model, the fixed reference word embedding matrix can be used to perform matrix multiplication with each query word vector to obtain the basic word embedding vector.
最后,执行步骤S303,利用对比模型中固定的MLP网络对基本词嵌入向量进行映射处理,得到目标词嵌入向量。其中,MLP网络包括linear层、ReLu激活函数以及linear层。Finally, step S303 is executed, using the fixed MLP network in the comparison model to perform mapping processing on the basic word embedding vector to obtain the target word embedding vector. Among them, the MLP network includes a linear layer, a ReLu activation function, and a linear layer.
请参阅图4,在一些实施例中,在步骤S103之前,该方法还包括训练对比模型,具体可以包括但不限于包括步骤S401至步骤S405:Referring to FIG. 4, in some embodiments, before step S103, the method further includes training a comparison model, which may specifically include but not limited to steps S401 to S405:
步骤S401,获取样本数据;Step S401, acquiring sample data;
步骤S402,对样本数据进行数据增强处理,得到正例对;Step S402, performing data enhancement processing on the sample data to obtain positive example pairs;
步骤S403,将正例对输入到对比学习模型;Step S403, input positive example pairs into the comparative learning model;
步骤S404,通过对比学习模型的损失函数计算出正例对的第一相似度和负例对的第二相 似度;Step S404, calculate the first similarity of the positive example pair and the second similarity of the negative example pair by comparing the loss function of the learning model;
步骤S405,根据第一相似度和第二相似度对对比学习模型的损失函数进行优化,以更新对比学习模型。Step S405, optimizing the loss function of the contrastive learning model according to the first similarity and the second similarity, so as to update the contrastive learning model.
具体地,首先将样本数据映射至嵌入空间、并对样本数据进行向量表示,从而可以得到初始嵌入数据(即初始embedding数据),该初始嵌入数据包括正样本数据和负样本数据。Specifically, firstly, the sample data is mapped to the embedding space, and the sample data is expressed as a vector, so that initial embedded data (that is, initial embedding data) can be obtained, and the initial embedded data includes positive sample data and negative sample data.
在一些实施例的步骤S402中,通过dropout mask机制对初始嵌入数据进行数据增强处理;本申请实施例通过dropout mask机制替换了传统的数据增强方法,即将同一个样本数据两次输入dropout编码器得到的两个向量作为对比学习的正例对,效果就足够好了,因为比如BERT内部每次dropout都随机会生成一个不同的dropout mask,所以只需要将同一个样本数据(即本实施例的初始嵌入数据)输入至simCSE模型两次,得到的两个向量就是应用两次不同dropout mask的结果了。可以理解的是,dropout mask是一种网络模型的随机,是对模型参数W的mask,起到防止过拟合的作用。In step S402 of some embodiments, data enhancement processing is performed on the initial embedded data through the dropout mask mechanism; the embodiment of the present application replaces the traditional data enhancement method through the dropout mask mechanism, that is, the same sample data is input into the dropout encoder twice to obtain The two vectors of the two vectors are used as positive example pairs for comparative learning, and the effect is good enough, because for example, a different dropout mask is randomly generated for each dropout inside BERT, so only the same sample data (that is, the initial Embedding data) is input to the simCSE model twice, and the two vectors obtained are the results of applying two different dropout masks. It is understandable that the dropout mask is a random network model, which is the mask of the model parameter W, which prevents overfitting.
在一个batch中,经过数据增强处理得到的数据(即第一向量和第二向量)是正例对,未经过数据增强的其他数据为负例对。本申请实施例中,可以将一个batch中的其中一部分初始嵌入数据经过数据增强处理得到正例对,另一部分初始嵌入数据作为负例对。In a batch, the data (that is, the first vector and the second vector) obtained through data enhancement processing are positive example pairs, and other data that have not undergone data enhancement are negative example pairs. In the embodiment of the present application, some of the initial embedded data in a batch can be processed through data enhancement to obtain positive example pairs, and the other part of the initial embedded data can be used as negative example pairs.
在一些实施例中,通过随机采样dropout mask来生成正例对。In some embodiments, positive pairs are generated by randomly sampling the dropout mask.
在一些具体应用场景中,在进行对比学习的阶段,采用典型的batch内的对比学习方法,在batch内部进行数据增强处理,即将上述得到的完整的初始embedding数据进行数据增强处理,让正例的两个样本有所差异。本申请实施例直接把dropout当作数据增强,即通过随机采样dropout mask来生成正例对即相同的第一样本数据和第二样本数据分别输入至dropout编码器进行数据增强处理,从而可以得到两个不同的表示向量x(第一向量)和x′(第二向量),将第一向量与第二向量作为一个正例对<x,x′>。In some specific application scenarios, in the stage of comparative learning, the typical comparative learning method in the batch is used to perform data enhancement processing within the batch, that is, to perform data enhancement processing on the complete initial embedding data obtained above, so that the positive examples There are differences between the two samples. In the embodiment of the present application, dropout is directly regarded as data enhancement, that is, the positive example pair is generated by randomly sampling the dropout mask, that is, the same first sample data and second sample data are respectively input to the dropout encoder for data enhancement processing, so that it can be obtained Two different representation vectors x (first vector) and x′ (second vector), the first vector and the second vector are taken as a positive example pair <x, x′>.
在一些实施例的步骤S404中,第一相似度和第二相似度均为余弦相似度,根据第一相似度和第二相似度对对比学习模型的损失函数进行优化,可以包括但不限于包括:In step S404 of some embodiments, the first similarity and the second similarity are both cosine similarity, and the loss function of the comparative learning model is optimized according to the first similarity and the second similarity, which may include but not limited to include :
将第一相似度最大化为第一数值和将第二相似度最小化为第一数值,以对损失函数进行优化;其中,第一相似度为损失函数的分子,第一相似度和第二相似度为损失函数的分母,第一数值取值为1,第二数值取值为0。该损失函数中,分子是对应正例对的第一相似度,分母是第一相似度以及所有负例对的第二相似度,然后将分子和分母构成的分子式值包装在-log()中,这样最大化分子且最小化分母,就能实现最小化损失函数。本申请实施例中,最小化损失函数infoNCE loss,就是最大化分子且最小化分母,也就是最大化正例对的第一相似度且最小化负例对的第二相似度,并对该损失函数进行最小化,实现对损失函数的优化。更具体地,损失函数为公式(1)所示:Maximize the first similarity to the first value and minimize the second similarity to the first value to optimize the loss function; where the first similarity is the numerator of the loss function, the first similarity and the second The similarity is the denominator of the loss function, the first value is 1, and the second value is 0. In this loss function, the numerator is the first similarity of the corresponding positive example pair, the denominator is the first similarity and the second similarity of all negative example pairs, and then the molecular formula value composed of the numerator and denominator is wrapped in -log() , so that the loss function can be minimized by maximizing the numerator and minimizing the denominator. In the embodiment of this application, minimizing the loss function infoNCE loss is to maximize the numerator and minimize the denominator, that is, to maximize the first similarity of the positive pair and minimize the second similarity of the negative pair, and the loss The function is minimized to realize the optimization of the loss function. More specifically, the loss function is shown in formula (1):
Figure PCTCN2022071077-appb-000001
Figure PCTCN2022071077-appb-000001
其中,f(x) T是f(x)的转置,f(x)是原样本,f(x +)是正例样本,f(x j)是单个负例样本,然后把负例样本全部累加起来,分母项包括一个正例样本,和N-1个负例样本; Among them, f(x) T is the transpose of f(x), f(x) is the original sample, f(x + ) is a positive sample, f(x j ) is a single negative sample, and then all negative samples Added up, the denominator includes a positive sample and N-1 negative samples;
该损失函数表示的是样本N的损失(loss);该损失函数中,分子是正例对的相似度,分母是正例对以及所有负例对的相似度,然后将该值包装在-log()中,这样最大化分子且最小化分母,就能实现最小化损失函数。The loss function represents the loss of sample N; in this loss function, the numerator is the similarity of the positive pair, the denominator is the similarity of the positive pair and all negative pairs, and then wrap the value in -log() In this way, the loss function can be minimized by maximizing the numerator and minimizing the denominator.
需要说明的是,正例对的相似度(第一相似度)与负例对的相似度(第二相似度)满足条件:It should be noted that the similarity (first similarity) of the positive example pair and the similarity (second similarity) of the negative example pair meet the conditions:
Score(f(x),f(x +))>>Score(f(x),f(x -))      公式(2) Score(f(x), f(x + ))>>Score(f(x), f(x - )) formula (2)
通过上式可知,该方法需要满足:正例对的相似度大于或等于负例对的相似度,这里x+指的是与x相似的数据,即正样本对数据;这里x-指的是与x不相似的数据,即负样本对数 据,f(x +)是正例样本,f(x -)是负例样本。 It can be seen from the above formula that this method needs to satisfy: the similarity of the positive example pair is greater than or equal to the similarity of the negative example pair, where x+ refers to the data similar to x, that is, the positive sample pair data; here x- refers to the data with x Dissimilar data, that is, negative sample pair data, f(x + ) is a positive sample, and f(x - ) is a negative sample.
进一步地,预设的度量函数为:Further, the preset measurement function is:
Score(f(x),f(x +))=f(x) Tf(x +)       公式(3) Score(f(x), f(x + )) = f(x) T f(x + ) formula (3)
Score(f(x),f(x -))=f(x) Tf(x -)       公式(4) Score(f(x), f(x - )) = f(x) T f(x - ) formula (4)
其中,Score是一个度量函数,用于评价两个特征之间的相似性。预设的度量函数为使用点积作为分数函数的函数。Among them, Score is a measurement function used to evaluate the similarity between two features. The default metric function is one that uses the dot product as the fraction function.
在一些实施例的步骤S405中,根据第一相似度和第二相似度对对比学习模型的损失函数进行优化,可以包括但不限于包括:In step S405 of some embodiments, optimizing the loss function of the comparative learning model according to the first similarity and the second similarity may include but not limited to:
根据损失函数进行反向传播,更新损失函数的损失参数,以对损失函数进行优化。Backpropagation is performed according to the loss function, and the loss parameters of the loss function are updated to optimize the loss function.
本申请实施例,根据损失函数进行反向传播,以通过优化损失函数更新对比学习模型,更新对比学习模型的内部参数(也即损失参数)。可以理解的是,反向传播原理可以应用常规的反向传播原理,本申请实施例不做限定。In the embodiment of the present application, backpropagation is performed according to the loss function, so as to update the contrastive learning model by optimizing the loss function, and update the internal parameters (ie, loss parameters) of the contrastive learning model. It can be understood that conventional backpropagation principles may be applied to the backpropagation principle, which is not limited in this embodiment of the present application.
请参阅图5,在一些实施例中,步骤S104还可以包括但不限于包括步骤S501至步骤S502:Referring to FIG. 5, in some embodiments, step S104 may also include but not limited to include steps S501 to S502:
步骤S501,利用预先训练的意图分类模型和预设的意图类别对词嵌入向量进行分类处理,得到包含意图类别标签的词嵌入向量和每一意图类别对应的意图概率值;Step S501, using the pre-trained intention classification model and the preset intention category to classify the word embedding vector, and obtain the word embedding vector containing the intention category label and the intention probability value corresponding to each intention category;
步骤S502,根据意图概率值,得到意图分类概率值。Step S502, according to the intention probability value, the intention classification probability value is obtained.
具体地,在步骤S501中,该意图分类模型包括softmax多类别分类器,其中,softmax多类别分类器包括输入层、第一特征层和第二特征层。将词嵌入向量输入至意图分类模型中,通过输入层、第一特征层和第二特征层依次对词嵌入向量进行编码处理、池化处理,得到特征向量,该softmax多类别分类器可以在预设的意图类别标签上创建一个概率分布,从而根据概率分布对特征向量进行标记分类,得到包含意图类别标签的词嵌入向量和每一意图类别对应的意图概率值。Specifically, in step S501, the intention classification model includes a softmax multi-class classifier, wherein the softmax multi-class classifier includes an input layer, a first feature layer and a second feature layer. The word embedding vector is input into the intent classification model, and the word embedding vector is encoded and pooled sequentially through the input layer, the first feature layer and the second feature layer to obtain the feature vector. The softmax multi-category classifier can be used in the pre- Create a probability distribution on the set intention category label, so as to mark and classify the feature vector according to the probability distribution, and obtain the word embedding vector containing the intention category label and the corresponding intention probability value of each intention category.
进而,执行步骤S502,根据意图概率值,将多个意图概率值进行降序排列,选取最高的意图概率值作为意图分类概率值,将该意图概率值对应的意图类别作为参考意图类别。Furthermore, step S502 is executed, according to the intention probability value, the multiple intention probability values are arranged in descending order, the highest intention probability value is selected as the intention classification probability value, and the intention category corresponding to the intention probability value is used as the reference intention category.
上述步骤通过对比模型和意图分类模型能够进行意图分类概率的深度学习,从而提高意图分类的准确性。In the above steps, the deep learning of intent classification probability can be performed by comparing the model and the intent classification model, thereby improving the accuracy of intent classification.
请参阅图6,在一些实施例的步骤S105可以包括但不限于包括步骤S601至步骤S602:Referring to FIG. 6, step S105 in some embodiments may include but not limited to steps S601 to S602:
步骤S601,将第一文本输入到预设的意图匹配模型中,以使第一文本与预设的句式模板进行字符匹配,生成匹配数据;Step S601, inputting the first text into the preset intent matching model, so that the first text is matched with the preset sentence template to generate matching data;
步骤S602,根据预设的参考匹配分数对匹配数据进行分数统计,得到意图匹配值。Step S602, performing score statistics on the matching data according to a preset reference matching score to obtain an intended matching value.
具体地,执行步骤S601,预设的意图匹配模型包括多个预设的句式模板,将第一文本输入到预设的意图匹配模型中,使第一文本(具体为包含目标查询参数的字符文本)与句式模板进行字符匹配,若某一句式模板包括了该字符文本,则认为该句式模板是与该字符文本匹配。同时,通过对比字符文本和句式模板的文本内容,也可以得到每一句式模板的匹配数据,匹配数据包括目标查询参数是否匹配,句式字符是否匹配,是否有字符交叉,字符文本与句式模板是否完全一致等等。Specifically, step S601 is executed, the preset intent matching model includes a plurality of preset sentence templates, the first text is input into the preset intent matching model, and the first text (specifically, the character containing the target query parameter text) and the sentence pattern template for character matching, if a certain sentence pattern template includes the character text, then it is considered that the sentence pattern template matches the character text. At the same time, by comparing the text content of the character text and the sentence pattern template, the matching data of each sentence pattern template can also be obtained. The matching data includes whether the target query parameters match, whether the sentence pattern characters match, whether there is a character intersection, the character text and the sentence pattern Whether the template is exactly the same and so on.
进而,执行步骤S602,根据预设的参考匹配分数来对不同的匹配数据进行分数计算,可以得到每一句式模板对应的意图匹配值,例如,预设的参考匹配分数包括:目标查询参数匹配加2分,句式字符匹配得1分,字符交叉-0.5分,字符文本与句式模板是否完全一致得100分等。根据预设的参考匹配分数,遍历每一句式模板的匹配数据,实现对每一句式模板的分数计算,得到每一句式模板的意图匹配值。通过比较每一句式模板的意图匹配值,选取其中意图匹配值最高的作为最终的句式模板和意图匹配值。Furthermore, step S602 is executed to calculate the score of different matching data according to the preset reference matching score, and the intention matching value corresponding to each sentence template can be obtained. For example, the preset reference matching score includes: target query parameter matching plus 2 points, 1 point for sentence character matching, 0.5 points for character intersection, 100 points for whether the character text is completely consistent with the sentence template, etc. According to the preset reference matching score, the matching data of each sentence template is traversed, the score calculation of each sentence template is realized, and the intention matching value of each sentence template is obtained. By comparing the intent matching values of each sentence template, the one with the highest intent matching value is selected as the final sentence template and intent matching value.
请参阅图7,在一些实施例中,步骤S106可以包括但不限于包括步骤S701至步骤S702:Referring to FIG. 7, in some embodiments, step S106 may include but not limited to include steps S701 to S702:
步骤S701,根据预设的权重比例,对意图匹配值和意图分类概率值进行加权计算,得到综合意向值;Step S701, performing weighted calculation on the intention matching value and the intention classification probability value according to the preset weight ratio to obtain the comprehensive intention value;
步骤S702,根据综合意向值,得到意图分类数据。In step S702, according to the integrated intention value, the intention classification data is obtained.
具体地,预设的权重比例可以为意图匹配值:意图分类概率值为3:2,则根据这一比例对意图匹配值和意图分类概率值进行加权计算,得到综合意向值。根据综合意向值的大小,查询综合意向值与意图类别的对照表,从而确定对应的意图类别。根据这一意图类别,获取意图分类数据,该意图分类数据即为该意图类别下的意图数据。Specifically, the preset weight ratio may be the intent matching value: the intent classification probability value is 3:2, then the intent matching value and the intent classification probability value are weighted and calculated according to this ratio to obtain the comprehensive intent value. According to the size of the comprehensive intention value, query the comparison table of the comprehensive intention value and the intention category, so as to determine the corresponding intention category. According to the intent category, the intent classification data is obtained, and the intent classification data is the intent data under the intent category.
本申请实施例通过获取请求文本,对请求文本进行实体特征提取,得到包含目标查询参数的第一文本,这一方式能够实现对请求文本的特征抽取,缩小请求文本的数据空间,使得更为方便提取到所需要的包含目标查询参数的第一文本。进而将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量,利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值,通过对比模型能够较好地解决目标词嵌入向量分布不均匀的问题,同时,通过对比模型和意图分类模型能够进行意图分类概率的深度学习,提高意图分类概率值的准确性。另外,本申请还可以利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值,通过意图匹配模型能够基于规则匹配对用户的意图匹配值进行计算,提高意图匹配的准确性。最后根据意图匹配值和意图分类概率值,得到意图分类数据。本申请通过对比模型、意图分类模型以及意图匹配模型能够综合意图分类概率以及意图匹配性两方面来识别用户的对话意图,使得最终得到的意图分类数据能够呈现出更为准确的意图分类结果,实现了对用户意图的准确分类,提高了意图分类的准确性。The embodiment of the present application obtains the request text, extracts the entity features of the request text, and obtains the first text containing the target query parameters. This method can realize the feature extraction of the request text and reduce the data space of the request text, making it more convenient Extract to the desired first text containing the target query parameters. Then input the first text to the pre-trained comparison model and perform matrix multiplication with the reference word embedding matrix in the comparison model to obtain multiple target word embedding vectors, and use the pre-trained intent classification model to classify the target word embedding vectors, The target word embedding vector and intent classification probability value containing the intent category label are obtained, and the problem of uneven distribution of the target word embedding vector can be better solved by comparing the model. At the same time, the depth of the intent classification probability can be determined by comparing the model and the intent classification model. Learning to improve the accuracy of intent classification probability values. In addition, the present application can also use the pre-trained intention matching model to perform matching processing on the first text to obtain the intention matching value, and the intention matching model can be used to calculate the user's intention matching value based on rule matching to improve the accuracy of intention matching. Finally, according to the intention matching value and the intention classification probability value, the intention classification data is obtained. In this application, through the comparison model, intent classification model, and intent matching model, the user's dialogue intent can be identified by integrating the two aspects of intent classification probability and intent matching, so that the final intent classification data can present more accurate intent classification results. The accurate classification of user intent is achieved, and the accuracy of intent classification is improved.
请参阅图8,本申请实施例还提供一种意图分类装置,可以实现上述意图分类方法,该装置包括:Please refer to FIG. 8, the embodiment of the present application also provides an intention classification device, which can realize the above intention classification method, and the device includes:
文本获取模块801,用于获取请求文本;A text acquisition module 801, configured to acquire the request text;
特征提取模块802,用于对请求文本进行实体特征提取,得到包含目标查询参数的第一文本;A feature extraction module 802, configured to extract entity features from the request text to obtain the first text containing the target query parameters;
对比模块803,用于将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量; Comparison module 803, for inputting the first text to the pre-trained comparison model and the reference word embedding matrix in the comparison model to perform matrix multiplication to obtain a plurality of target word embedding vectors;
分类模块804,用于利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;The classification module 804 is used to classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
匹配模块805,用于利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值;A matching module 805, configured to match the first text with a pre-trained intent matching model to obtain an intent matching value;
计算模块806,用于根据意图匹配值和意图分类概率值,得到意图分类数据。The calculation module 806 is configured to obtain intention classification data according to the intention matching value and the intention classification probability value.
该意图分类装置的具体实施方式与上述意图分类方法的具体实施例基本相同,在此不再赘述。The specific implementation manner of the intention classification device is basically the same as the specific embodiment of the above intention classification method, and will not be repeated here.
本申请实施例还提供了一种电子设备,电子设备包括:存储器、处理器、存储在存储器上并可在处理器上运行的程序以及用于实现处理器和存储器之间的连接通信的数据总线,程序被处理器执行时实现上述意图分类方法。该电子设备可以为包括平板电脑、车载电脑等任意智能终端。The embodiment of the present application also provides an electronic device, the electronic device includes: a memory, a processor, a program stored in the memory and operable on the processor, and a data bus for realizing connection and communication between the processor and the memory , when the program is executed by the processor, the above intention classification method is realized. The electronic device may be any intelligent terminal including a tablet computer, a vehicle-mounted computer, and the like.
请参阅图9,图9示意了另一实施例的电子设备的硬件结构,电子设备包括:Please refer to FIG. 9. FIG. 9 illustrates a hardware structure of an electronic device in another embodiment. The electronic device includes:
处理器901,可以采用通用的CPU(CentralProcessingUnit,中央处理器)、微处理器、应用专用集成电路(ApplicationSpecificIntegratedCircuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本申请实施例所提供的意图分类方法;The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit, central processing unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute related programs, so as to realize The intention classification method provided by the embodiment of this application;
存储器902,可以采用只读存储器(ReadOnlyMemory,ROM)、静态存储设备、动态存储设备或者随机存取存储器(RandomAccessMemory,RAM)等形式实现。存储器902可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器902中,并由处理器901来调用执行本申请实施例的意图分类方法;The memory 902 may be implemented in the form of a read-only memory (ReadOnlyMemory, ROM), a static storage device, a dynamic storage device, or a random access memory (RandomAccessMemory, RAM). The memory 902 can store operating systems and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 902 and called by the processor 901 to execute the implementation of this application. Example intent classification method;
输入/输出接口903,用于实现信息输入及输出;The input/output interface 903 is used to realize information input and output;
通信接口904,用于实现本设备与其他设备的通信交互,可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信;The communication interface 904 is used to realize the communication and interaction between the device and other devices, and the communication can be realized through a wired method (such as USB, network cable, etc.), or can be realized through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.);
总线905,在设备的各个组件(例如处理器901、存储器902、输入/输出接口903和通信接口904)之间传输信息;bus 905, for transferring information between various components of the device (such as processor 901, memory 902, input/output interface 903 and communication interface 904);
其中处理器901、存储器902、输入/输出接口903和通信接口904通过总线905实现彼此之间在设备内部的通信连接。The processor 901 , the memory 902 , the input/output interface 903 and the communication interface 904 are connected to each other within the device through the bus 905 .
其中,本申请实施例所提供的意图分类方法包括:Among them, the intention classification method provided by the embodiment of the present application includes:
获取请求文本;get request text;
对请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;Input the first text to the pre-trained comparison model and perform matrix multiplication with the reference word embedding matrix in the comparison model to obtain a plurality of target word embedding vectors;
利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Use the pre-trained intent classification model to classify the target word embedding vector, and obtain the target word embedding vector and intent classification probability value containing the intent category label;
利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
根据意图匹配值和意图分类概率值,得到意图分类数据。本申请实施例还提供了一种计算机可读存储介质,用于计算机可读存储,计算机可读存储介质可以是非易失性,也可以是易失性。计算机可读存储介质存储有一个或者多个程序,一个或者多个程序可被一个或者多个处理器执行,以实现一种意图分类方法。其中,意图分类方法包括以下步骤:获取请求文本;对请求文本进行实体特征提取,得到包含目标查询参数的第一文本;将第一文本输入至预先训练的对比模型与对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;利用预先训练的意图分类模型对目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;利用预先训练的意图匹配模型对第一文本进行匹配处理,得到意图匹配值;根据意图匹配值和意图分类概率值,得到意图分类数据。According to the intent matching value and the intent classification probability value, the intent classification data is obtained. An embodiment of the present application also provides a computer-readable storage medium for computer-readable storage. The computer-readable storage medium may be non-volatile or volatile. The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement an intention classification method. Wherein, the intention classification method includes the following steps: obtaining the request text; performing entity feature extraction on the request text to obtain the first text containing the target query parameters; inputting the first text to the pre-trained comparison model and the reference word embedding in the comparison model Multiply the matrix to get multiple target word embedding vectors; use the pre-trained intent classification model to classify the target word embedding vectors, and obtain the target word embedding vector and intent classification probability value containing the intent category label; use the pre-trained intent classification model The intent matching model performs matching processing on the first text to obtain an intent matching value; and obtains intent classification data according to the intent matching value and the intent classification probability value.
存储器作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序以及非暂态性计算机可执行程序。此外,存储器可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器可选包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至该处理器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。As a non-transitory computer-readable storage medium, memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
本申请实施例描述的实施例是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域技术人员可知,随着技术的演变和新应用场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The embodiments described in the embodiments of the present application are to illustrate the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation to the technical solutions provided by the embodiments of the present application. Those skilled in the art know that with the evolution of technology and new For the emergence of application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
本领域技术人员可以理解的是,图1-7中示出的技术方案并不构成对本申请实施例的限定,可以包括比图示更多或更少的步骤,或者组合某些步骤,或者不同的步骤。Those skilled in the art can understand that the technical solutions shown in Figures 1-7 do not constitute a limitation to the embodiments of the present application, and may include more or fewer steps than those shown in the illustrations, or combine certain steps, or be different A step of.
以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、设备中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组合。Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, the functional modules/units in the system, and the device can be implemented as software, firmware, hardware, and an appropriate combination thereof.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括多指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例的方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,简称ROM)、随机存取存储器(Random Access Memory,简称RAM)、磁碟或者光盘等各种可以存储程序的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including multiple instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), magnetic disk or optical disc, etc., which can store programs. medium.
以上参照附图说明了本申请实施例的优选实施例,并非因此局限本申请实施例的权利范 围。本领域技术人员不脱离本申请实施例的范围和实质内所作的任何修改、等同替换和改进,均应在本申请实施例的权利范围之内。The preferred embodiments of the embodiments of the present application have been described above with reference to the accompanying drawings, and are not intended to limit the scope of rights of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall fall within the scope of rights of the embodiments of the present application.

Claims (20)

  1. 一种意图分类方法,其中,所述方法包括:A method for classifying intentions, wherein the method includes:
    获取请求文本;get request text;
    对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
    将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
    利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
    利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
    根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
  2. 根据权利要求1所述的意图分类方法,其中,所述第一文本包括字符文本和语义文本,所述对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本的步骤,包括:The intent classification method according to claim 1, wherein the first text includes character text and semantic text, and the step of performing entity feature extraction on the request text to obtain the first text containing target query parameters includes :
    根据基于前缀树的特征提取模型对所述请求文本进行实体特征提取,得到字符文本;performing entity feature extraction on the request text according to a prefix tree-based feature extraction model to obtain character text;
    利用预先训练的词法分析模型对所述请求文本进行识别处理,得到语义文本。A pre-trained lexical analysis model is used to identify and process the request text to obtain semantic text.
  3. 根据权利要求1所述的意图分类方法,其中,所述将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量的步骤,包括:The intent classification method according to claim 1, wherein the input of the first text to the pre-trained comparison model is matrix-multiplied with the reference word embedding matrix in the comparison model to obtain a plurality of target word embeddings Vector steps, including:
    对第一文本进行分词处理和编码处理,得到多个查询词段向量;performing word segmentation and encoding processing on the first text to obtain a plurality of query word segment vectors;
    将多个所述查询词段向量输入到预先训练的对比模型中,以使所述查询词段向量与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个基本词嵌入向量;A plurality of the query word vectors are input into the pre-trained comparison model, so that the query word vector and the reference word embedding matrix in the comparison model are multiplied by matrix to obtain a plurality of basic word embedding vectors;
    对所述基本词嵌入向量进行映射处理,得到目标词嵌入向量。The basic word embedding vector is mapped to obtain the target word embedding vector.
  4. 根据权利要求1所述的意图分类方法,其中,在所述将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量的步骤之前,所述方法还包括训练对比模型,具体包括:The method for classifying intent according to claim 1, wherein the input of the first text to the pre-trained comparison model is multiplied with the reference word embedding matrix in the comparison model to obtain a plurality of target words Before the step of embedding vectors, the method also includes training a comparison model, specifically including:
    获取样本数据;Get sample data;
    对所述样本数据进行数据增强处理,得到正例对;performing data enhancement processing on the sample data to obtain positive example pairs;
    将所述正例对输入到所述对比学习模型;inputting the positive example pair into the contrastive learning model;
    通过所述对比学习模型的损失函数计算出所述正例对的第一相似度和负例对的第二相似度;Calculate the first similarity of the positive example pair and the second similarity of the negative example pair through the loss function of the comparative learning model;
    根据所述第一相似度和所述第二相似度对所述对比学习模型的损失函数进行优化,以更新所述对比学习模型。Optimizing the loss function of the contrastive learning model according to the first similarity and the second similarity, so as to update the contrastive learning model.
  5. 根据权利要求1所述的意图分类方法,其中,所述利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值的步骤,包括:The intention classification method according to claim 1, wherein, the step of using the pre-trained intention classification model to classify the target word embedding vector to obtain the target word embedding vector containing the intention category label and the intention classification probability value ,include:
    利用预先训练的意图分类模型和预设的意图类别对所述词嵌入向量进行分类处理,得到包含意图类别标签的词嵌入向量和每一意图类别对应的意图概率值;Classify the word embedding vector using a pre-trained intent classification model and preset intent categories to obtain a word embedding vector containing an intent category label and an intent probability value corresponding to each intent category;
    根据所述意图概率值,得到意图分类概率值。According to the intention probability value, an intention classification probability value is obtained.
  6. 根据权利要求1所述的意图分类方法,其中,所述利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值的步骤,包括:The intent classification method according to claim 1, wherein the step of using a pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value includes:
    将所述第一文本输入到预设的意图匹配模型中,以使所述第一文本与预设的句式模板进行字符匹配,生成匹配数据;Inputting the first text into a preset intent matching model, so that the first text is character-matched with a preset sentence template to generate matching data;
    根据预设的参考匹配分数对所述匹配数据进行分数统计,得到意图匹配值。Score statistics are performed on the matching data according to a preset reference matching score to obtain an intention matching value.
  7. 根据权利要求1至6任一项所述的意图分类方法,其中,所述根据所述意图匹配值和所述意图分类概率值,得到意图分类数据的步骤,包括:The intention classification method according to any one of claims 1 to 6, wherein the step of obtaining intention classification data according to the intention matching value and the intention classification probability value includes:
    根据预设的权重比例,对所述意图匹配值和所述意图分类概率值进行加权计算,得到综合意向值;performing weighted calculations on the intention matching value and the intention classification probability value according to a preset weight ratio to obtain a comprehensive intention value;
    根据所述综合意向值,得到意图分类数据。According to the comprehensive intention value, the intention classification data is obtained.
  8. 一种意图分类装置,其中,所述装置包括:An intention classification device, wherein the device includes:
    文本获取模块,用于获取请求文本;A text acquisition module, configured to acquire the request text;
    特征提取模块,用于对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;A feature extraction module, configured to extract entity features from the request text to obtain the first text containing target query parameters;
    对比模块,用于将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;Comparison module, for inputting the first text to the pre-trained comparison model and performing matrix multiplication with the reference word embedding matrix in the comparison model, to obtain a plurality of target word embedding vectors;
    分类模块,用于利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;A classification module, configured to classify the target word embedding vector using a pre-trained intent classification model, to obtain a target word embedding vector and an intent classification probability value including an intent category label;
    匹配模块,用于利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;A matching module, configured to use a pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value;
    计算模块,用于根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。A calculation module, configured to obtain intention classification data according to the intention matching value and the intention classification probability value.
  9. 一种电子设备,其中,所述电子设备包括存储器、处理器、存储在所述存储器上并可在所述处理器上运行的程序以及用于实现所述处理器和所述存储器之间的连接通信的数据总线,所述程序被所述处理器执行时实现一种意图分类方法,其中,所述意图分类方法包括:An electronic device, wherein the electronic device includes a memory, a processor, a program stored on the memory and operable on the processor, and a program for realizing the connection between the processor and the memory A data bus for communication, when the program is executed by the processor, an intent classification method is implemented, wherein the intent classification method includes:
    获取请求文本;get request text;
    对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
    将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
    利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
    利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
    根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
  10. 根据权利要求9所述的电子设备,其中,所述第一文本包括字符文本和语义文本,所述对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本的步骤,包括:The electronic device according to claim 9, wherein the first text includes character text and semantic text, and the step of performing entity feature extraction on the request text to obtain the first text containing target query parameters includes:
    根据基于前缀树的特征提取模型对所述请求文本进行实体特征提取,得到字符文本;performing entity feature extraction on the request text according to a prefix tree-based feature extraction model to obtain character text;
    利用预先训练的词法分析模型对所述请求文本进行识别处理,得到语义文本。A pre-trained lexical analysis model is used to identify and process the request text to obtain semantic text.
  11. 根据权利要求9所述的电子设备,其中,所述将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量的步骤,包括:The electronic device according to claim 9, wherein the input of the first text to the pre-trained comparison model is matrix-multiplied with the reference word embedding matrix in the comparison model to obtain a plurality of target word embedding vectors steps, including:
    对第一文本进行分词处理和编码处理,得到多个查询词段向量;performing word segmentation and encoding processing on the first text to obtain a plurality of query word segment vectors;
    将多个所述查询词段向量输入到预先训练的对比模型中,以使所述查询词段向量与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个基本词嵌入向量;A plurality of the query word vectors are input into the pre-trained comparison model, so that the query word vector and the reference word embedding matrix in the comparison model are multiplied by matrix to obtain a plurality of basic word embedding vectors;
    对所述基本词嵌入向量进行映射处理,得到目标词嵌入向量。The basic word embedding vector is mapped to obtain the target word embedding vector.
  12. 根据权利要求9所述的电子设备,其中,所述利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值的步骤,包括:The electronic device according to claim 9, wherein the step of using a pre-trained intention classification model to classify the target word embedding vector to obtain a target word embedding vector containing an intention category label and an intention classification probability value, include:
    利用预先训练的意图分类模型和预设的意图类别对所述词嵌入向量进行分类处理,得到包含意图类别标签的词嵌入向量和每一意图类别对应的意图概率值;Classify the word embedding vector using a pre-trained intent classification model and preset intent categories to obtain a word embedding vector containing an intent category label and an intent probability value corresponding to each intent category;
    根据所述意图概率值,得到意图分类概率值。According to the intention probability value, an intention classification probability value is obtained.
  13. 根据权利要求9所述的电子设备,其中,所述利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值的步骤,包括:The electronic device according to claim 9, wherein the step of using a pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value includes:
    将所述第一文本输入到预设的意图匹配模型中,以使所述第一文本与预设的句式模板进行字符匹配,生成匹配数据;Inputting the first text into a preset intent matching model, so that the first text is character-matched with a preset sentence template to generate matching data;
    根据预设的参考匹配分数对所述匹配数据进行分数统计,得到意图匹配值。Score statistics are performed on the matching data according to a preset reference matching score to obtain an intention matching value.
  14. 根据权利要求9至13任一项所述的电子设备,其中,所述根据所述意图匹配值和所述意图分类概率值,得到意图分类数据的步骤,包括:The electronic device according to any one of claims 9 to 13, wherein the step of obtaining intent classification data according to the intent matching value and the intent classification probability value includes:
    根据预设的权重比例,对所述意图匹配值和所述意图分类概率值进行加权计算,得到综合意向值;performing weighted calculations on the intention matching value and the intention classification probability value according to a preset weight ratio to obtain a comprehensive intention value;
    根据所述综合意向值,得到意图分类数据。According to the comprehensive intention value, the intention classification data is obtained.
  15. 一种计算机可读存储介质,用于计算机可读存储,其中,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现一种意图分类方法,其中,所述意图分类方法包括以下步骤:A computer-readable storage medium for computer-readable storage, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to A method for classifying intent is realized, wherein the method for classifying intent includes the following steps:
    获取请求文本;get request text;
    对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本;performing entity feature extraction on the request text to obtain the first text containing target query parameters;
    将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量;The first text is input to the pre-trained comparison model and the reference word embedding matrix in the comparison model is multiplied by matrix to obtain a plurality of target word embedding vectors;
    利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值;Classify the target word embedding vector by using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label;
    利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值;performing matching processing on the first text by using a pre-trained intent matching model to obtain an intent matching value;
    根据所述意图匹配值和所述意图分类概率值,得到意图分类数据。According to the intention matching value and the intention classification probability value, the intention classification data is obtained.
  16. 根据权利要求15所述的计算机可读存储介质,其中,所述第一文本包括字符文本和语义文本,所述对所述请求文本进行实体特征提取,得到包含目标查询参数的第一文本的步骤,包括:The computer-readable storage medium according to claim 15, wherein the first text includes character text and semantic text, and the step of performing entity feature extraction on the request text to obtain the first text containing target query parameters ,include:
    根据基于前缀树的特征提取模型对所述请求文本进行实体特征提取,得到字符文本;performing entity feature extraction on the request text according to a prefix tree-based feature extraction model to obtain character text;
    利用预先训练的词法分析模型对所述请求文本进行识别处理,得到语义文本。A pre-trained lexical analysis model is used to identify and process the request text to obtain semantic text.
  17. 根据权利要求15所述的计算机可读存储介质,其中,所述将所述第一文本输入至预先训练的对比模型与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个目标词嵌入向量的步骤,包括:The computer-readable storage medium according to claim 15, wherein the input of the first text to the pre-trained comparison model is matrix-multiplied with the reference word embedding matrix in the comparison model to obtain a plurality of target The steps of word embedding vector include:
    对第一文本进行分词处理和编码处理,得到多个查询词段向量;performing word segmentation and encoding processing on the first text to obtain a plurality of query word segment vectors;
    将多个所述查询词段向量输入到预先训练的对比模型中,以使所述查询词段向量与所述对比模型中的参考词嵌入矩阵进行矩阵相乘,得到多个基本词嵌入向量;A plurality of the query word vectors are input into the pre-trained comparison model, so that the query word vector and the reference word embedding matrix in the comparison model are multiplied by matrix to obtain a plurality of basic word embedding vectors;
    对所述基本词嵌入向量进行映射处理,得到目标词嵌入向量。The basic word embedding vector is mapped to obtain the target word embedding vector.
  18. 根据权利要求15所述的计算机可读存储介质,其中,所述利用预先训练的意图分类模型对所述目标词嵌入向量进行分类处理,得到包含意图类别标签的目标词嵌入向量和意图分类概率值的步骤,包括:The computer-readable storage medium according to claim 15, wherein the target word embedding vector is classified using the pre-trained intent classification model to obtain the target word embedding vector and the intent classification probability value including the intent category label steps, including:
    利用预先训练的意图分类模型和预设的意图类别对所述词嵌入向量进行分类处理,得到包含意图类别标签的词嵌入向量和每一意图类别对应的意图概率值;Classify the word embedding vector using a pre-trained intent classification model and preset intent categories to obtain a word embedding vector containing an intent category label and an intent probability value corresponding to each intent category;
    根据所述意图概率值,得到意图分类概率值。According to the intention probability value, an intention classification probability value is obtained.
  19. 根据权利要求15所述的计算机可读存储介质,其中,所述利用预先训练的意图匹配模型对所述第一文本进行匹配处理,得到意图匹配值的步骤,包括:The computer-readable storage medium according to claim 15, wherein the step of using a pre-trained intent matching model to perform matching processing on the first text to obtain an intent matching value includes:
    将所述第一文本输入到预设的意图匹配模型中,以使所述第一文本与预设的句式模板进行字符匹配,生成匹配数据;Inputting the first text into a preset intent matching model, so that the first text is character-matched with a preset sentence template to generate matching data;
    根据预设的参考匹配分数对所述匹配数据进行分数统计,得到意图匹配值。Score statistics are performed on the matching data according to a preset reference matching score to obtain an intention matching value.
  20. 根据权利要求15至19任一项所述的计算机可读存储介质,其中,所述根据所述意图匹配值和所述意图分类概率值,得到意图分类数据的步骤,包括:The computer-readable storage medium according to any one of claims 15 to 19, wherein the step of obtaining intent classification data according to the intent matching value and the intent classification probability value includes:
    根据预设的权重比例,对所述意图匹配值和所述意图分类概率值进行加权计算,得到综合意向值;performing weighted calculations on the intention matching value and the intention classification probability value according to a preset weight ratio to obtain a comprehensive intention value;
    根据所述综合意向值,得到意图分类数据。According to the comprehensive intention value, the intention classification data is obtained.
PCT/CN2022/071077 2021-10-18 2022-01-10 Intention classification method and apparatus, electronic device, and computer-readable storage medium WO2023065544A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111212210.3A CN113792818B (en) 2021-10-18 2021-10-18 Intention classification method and device, electronic equipment and computer readable storage medium
CN202111212210.3 2021-10-18

Publications (1)

Publication Number Publication Date
WO2023065544A1 true WO2023065544A1 (en) 2023-04-27

Family

ID=78878152

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/071077 WO2023065544A1 (en) 2021-10-18 2022-01-10 Intention classification method and apparatus, electronic device, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN113792818B (en)
WO (1) WO2023065544A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116384411A (en) * 2023-06-05 2023-07-04 北京水滴科技集团有限公司 Training method and device for user intention recognition model based on outbound robot
CN116776887A (en) * 2023-08-18 2023-09-19 昆明理工大学 Negative sampling remote supervision entity identification method based on sample similarity calculation
CN116994073A (en) * 2023-09-27 2023-11-03 江西师范大学 Graph contrast learning method and device for self-adaptive positive and negative sample generation
CN117151121A (en) * 2023-10-26 2023-12-01 安徽农业大学 Multi-intention spoken language understanding method based on fluctuation threshold and segmentation
CN117234341A (en) * 2023-11-15 2023-12-15 中影年年(北京)文化传媒有限公司 Virtual reality man-machine interaction method and system based on artificial intelligence

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023014398A1 (en) * 2021-08-06 2023-02-09 Salesforce.Com, Inc. Self-supervised learning with model augmentation
CN113792818B (en) * 2021-10-18 2023-03-10 平安科技(深圳)有限公司 Intention classification method and device, electronic equipment and computer readable storage medium
CN114358007A (en) * 2022-01-11 2022-04-15 平安科技(深圳)有限公司 Multi-label identification method and device, electronic equipment and storage medium
CN114358201A (en) * 2022-01-11 2022-04-15 平安科技(深圳)有限公司 Text-based emotion classification method and device, computer equipment and storage medium
CN114510570A (en) * 2022-01-21 2022-05-17 平安科技(深圳)有限公司 Intention classification method and device based on small sample corpus and computer equipment
CN114444462B (en) * 2022-01-26 2022-11-29 北京百度网讯科技有限公司 Model training method and man-machine interaction method and device
CN114519356B (en) * 2022-02-22 2023-07-18 平安科技(深圳)有限公司 Target word detection method and device, electronic equipment and storage medium
CN114564964B (en) * 2022-02-24 2023-05-26 杭州中软安人网络通信股份有限公司 Unknown intention detection method based on k nearest neighbor contrast learning
CN115063753B (en) * 2022-08-17 2023-05-12 苏州魔视智能科技有限公司 Safety belt wearing detection model training method and safety belt wearing detection method
CN115168593B (en) * 2022-09-05 2022-11-29 深圳爱莫科技有限公司 Intelligent dialogue management method capable of self-learning and processing equipment
CN115759035A (en) * 2022-12-09 2023-03-07 成都明途科技有限公司 Text processing method and device, electronic equipment and computer readable storage medium
CN116028627B (en) * 2023-02-13 2023-06-13 特斯联科技集团有限公司 News classification method and device, electronic equipment and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108417210A (en) * 2018-01-10 2018-08-17 苏州思必驰信息科技有限公司 A kind of word insertion language model training method, words recognition method and system
CN110147445A (en) * 2019-04-09 2019-08-20 平安科技(深圳)有限公司 Intension recognizing method, device, equipment and storage medium based on text classification
CN112084789A (en) * 2020-09-14 2020-12-15 腾讯科技(深圳)有限公司 Text processing method, device, equipment and storage medium
CN113792818A (en) * 2021-10-18 2021-12-14 平安科技(深圳)有限公司 Intention classification method and device, electronic equipment and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239702A (en) * 2021-05-12 2021-08-10 北京三快在线科技有限公司 Intention recognition method and device and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108417210A (en) * 2018-01-10 2018-08-17 苏州思必驰信息科技有限公司 A kind of word insertion language model training method, words recognition method and system
CN110147445A (en) * 2019-04-09 2019-08-20 平安科技(深圳)有限公司 Intension recognizing method, device, equipment and storage medium based on text classification
CN112084789A (en) * 2020-09-14 2020-12-15 腾讯科技(深圳)有限公司 Text processing method, device, equipment and storage medium
CN113792818A (en) * 2021-10-18 2021-12-14 平安科技(深圳)有限公司 Intention classification method and device, electronic equipment and computer readable storage medium

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116384411A (en) * 2023-06-05 2023-07-04 北京水滴科技集团有限公司 Training method and device for user intention recognition model based on outbound robot
CN116384411B (en) * 2023-06-05 2023-07-25 北京水滴科技集团有限公司 Training method and device for user intention recognition model based on outbound robot
CN116776887A (en) * 2023-08-18 2023-09-19 昆明理工大学 Negative sampling remote supervision entity identification method based on sample similarity calculation
CN116776887B (en) * 2023-08-18 2023-10-31 昆明理工大学 Negative sampling remote supervision entity identification method based on sample similarity calculation
CN116994073A (en) * 2023-09-27 2023-11-03 江西师范大学 Graph contrast learning method and device for self-adaptive positive and negative sample generation
CN116994073B (en) * 2023-09-27 2024-01-26 江西师范大学 Graph contrast learning method and device for self-adaptive positive and negative sample generation
CN117151121A (en) * 2023-10-26 2023-12-01 安徽农业大学 Multi-intention spoken language understanding method based on fluctuation threshold and segmentation
CN117151121B (en) * 2023-10-26 2024-01-12 安徽农业大学 Multi-intention spoken language understanding method based on fluctuation threshold and segmentation
CN117234341A (en) * 2023-11-15 2023-12-15 中影年年(北京)文化传媒有限公司 Virtual reality man-machine interaction method and system based on artificial intelligence
CN117234341B (en) * 2023-11-15 2024-03-05 中影年年(北京)科技有限公司 Virtual reality man-machine interaction method and system based on artificial intelligence

Also Published As

Publication number Publication date
CN113792818A (en) 2021-12-14
CN113792818B (en) 2023-03-10

Similar Documents

Publication Publication Date Title
WO2023065544A1 (en) Intention classification method and apparatus, electronic device, and computer-readable storage medium
CN112528672B (en) Aspect-level emotion analysis method and device based on graph convolution neural network
CN107133213B (en) Method and system for automatically extracting text abstract based on algorithm
CN107798140B (en) Dialog system construction method, semantic controlled response method and device
CN112101041B (en) Entity relationship extraction method, device, equipment and medium based on semantic similarity
CN112395385B (en) Text generation method and device based on artificial intelligence, computer equipment and medium
CN111709243A (en) Knowledge extraction method and device based on deep learning
CN113887215A (en) Text similarity calculation method and device, electronic equipment and storage medium
WO2023134083A1 (en) Text-based sentiment classification method and apparatus, and computer device and storage medium
CN113177412A (en) Named entity identification method and system based on bert, electronic equipment and storage medium
KR102379660B1 (en) Method for utilizing deep learning based semantic role analysis
CN113255320A (en) Entity relation extraction method and device based on syntax tree and graph attention machine mechanism
WO2023159767A1 (en) Target word detection method and apparatus, electronic device and storage medium
CN114358007A (en) Multi-label identification method and device, electronic equipment and storage medium
CN111581392B (en) Automatic composition scoring calculation method based on statement communication degree
CN115827819A (en) Intelligent question and answer processing method and device, electronic equipment and storage medium
CN111984782A (en) Method and system for generating text abstract of Tibetan language
CN114358020A (en) Disease part identification method and device, electronic device and storage medium
CN114757184A (en) Method and system for realizing knowledge question answering in aviation field
CN112989839A (en) Keyword feature-based intent recognition method and system embedded in language model
CN114611529B (en) Intention recognition method and device, electronic equipment and storage medium
US11822887B2 (en) Robust name matching with regularized embeddings
CN115329075A (en) Text classification method based on distributed machine learning
CN115270810A (en) Intention recognition device and method based on sentence similarity
CN114722774A (en) Data compression method and device, electronic equipment and storage medium