WO2021212683A1 - 基于法律知识图谱的查询方法、装置、电子设备及介质 - Google Patents

基于法律知识图谱的查询方法、装置、电子设备及介质 Download PDF

Info

Publication number
WO2021212683A1
WO2021212683A1 PCT/CN2020/104968 CN2020104968W WO2021212683A1 WO 2021212683 A1 WO2021212683 A1 WO 2021212683A1 CN 2020104968 W CN2020104968 W CN 2020104968W WO 2021212683 A1 WO2021212683 A1 WO 2021212683A1
Authority
WO
WIPO (PCT)
Prior art keywords
query
matrix
encoder
channel
output
Prior art date
Application number
PCT/CN2020/104968
Other languages
English (en)
French (fr)
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 WO2021212683A1 publication Critical patent/WO2021212683A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/248Presentation of query results
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3346Query execution using probabilistic model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/338Presentation of query results

Definitions

  • This application relates to the field of data processing technology, and in particular to a query method, device, electronic device, and medium based on a legal knowledge graph.
  • Natural language generation is a very important research field in the artificial intelligence industry. For humans, this is a natural ability, but for artificial intelligence, it represents the highest level of progress. Research on natural language generation can help users find the answers they need from the database in a faster, more accurate, and lower-cost way.
  • the inventor realized that the current query method has weak generalization ability and cannot cope with complex and changeable new problems. When faced with new problems, it is necessary to retrain the model, and the cost is also high.
  • a query method based on a legal knowledge graph includes:
  • the machine query language is executed in the database, and the query result is output.
  • a query device based on a legal knowledge graph includes:
  • the query unit is used to query the matrix of the query statement from the first preset dictionary when the query statement is received;
  • the link unit is used to link the weight vector of the query sentence from the element list of the legal knowledge graph based on the attention mechanism
  • a calculation unit configured to calculate the product of the matrix of the query sentence and the weight vector to obtain the first matrix corresponding to the query sentence;
  • the query unit is further configured to query a second matrix of SQL statements from a second preset dictionary, and query a third matrix of the element list from a third preset dictionary;
  • a splicing unit for splicing the first matrix, the second matrix, and the third matrix to obtain a feature matrix
  • An input unit configured to input the feature matrix into an encoder to obtain output data of the encoder, where the encoder includes two BiGRU networks;
  • a processing unit configured to use a decoder to process the output data of the encoder to obtain a machine query language, wherein the decoder includes four BiGRU networks;
  • the execution unit is used to execute the machine query language in the database and output the query result.
  • the memory stores at least one computer readable instruction
  • the processor executes at least one computer-readable instruction stored in the memory to implement the following steps:
  • the machine query language is executed in the database, and the query result is output.
  • a computer-readable storage medium in which at least one computer-readable instruction is stored, and the at least one computer-readable instruction is executed by a processor in an electronic device to implement the following steps:
  • the machine query language is executed in the database, and the query result is output.
  • Fig. 1 is a flowchart of a preferred embodiment of the query method based on the legal knowledge graph of this application.
  • Fig. 2 is a functional module diagram of a preferred embodiment of the query device based on the legal knowledge graph of this application.
  • FIG. 3 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present application for implementing a query method based on a legal knowledge graph.
  • FIG. 1 it is a flowchart of a preferred embodiment of the query method based on the legal knowledge graph of this application. According to different needs, the order of the steps in the flowchart can be changed, and some steps can be omitted.
  • the query method based on the legal knowledge graph is applied to one or more electronic devices.
  • the electronic device is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware Including but not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
  • ASIC application specific integrated circuits
  • FPGA Field-Programmable Gate Array
  • DSP Digital Signal Processor
  • the electronic device may be any electronic product that can perform human-computer interaction with the user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television ( Internet Protocol Television, IPTV), smart wearable devices, etc.
  • a personal computer a tablet computer
  • a smart phone a personal digital assistant (PDA)
  • PDA personal digital assistant
  • IPTV interactive network television
  • smart wearable devices etc.
  • the electronic device may also include a network device and/or user equipment.
  • the network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.
  • the network where the electronic device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), etc.
  • the query sentence may be a query sentence related to the law, for example: "check the name of the agent of the plaintiff” and so on.
  • the first preset dictionary can be configured for customization, and the first preset dictionary includes all words related to the query sentence.
  • the electronic device can directly perform a query in the first preset dictionary and determine the matrix of the query sentence.
  • the vector matrix of the question query is V1 (dm dimension), and the question query is a sentence of 10 words, and the dm is 256, a 10*256 matrix is obtained;
  • the vector matrix of the element list name is V2( dm dimension), and there are 100 keywords in the element list, dm is 256, and a 100*256 matrix is obtained;
  • the above two matrices are multiplied, namely: V1*V2T.
  • the above process of calculating the product is to multiply the 10*256 matrix by the 256*100 matrix, and finally get the 10*100 matrix, and then normalize the calculated matrix, that is, the 100 values in each dimension are compared with each other.
  • the electronic device links the weight vector of the query sentence from the element list of the legal knowledge graph based on the attention mechanism to distinguish the contribution of each word in the query sentence to the query process, so as to facilitate more accurate use
  • the query statement performs a query.
  • the legal knowledge graph may include a variety of characteristics related to laws, such as legal entities, characteristics specific to legal relationships, and so on.
  • text statistics features such as text length features, word frequency statistics features, and so on.
  • the legal knowledge map mainly includes, but is not limited to, the following two categories:
  • the features constructed based on legal theory are obtained by combing and summarizing based on legal theory.
  • the legal knowledge graph is constructed in the form of a list, and each element in the legal knowledge graph is displayed in the form of an element list.
  • the electronic device before using the query statement to perform a query, the electronic device first needs to initialize the query statement.
  • the electronic device calculates the product of the matrix of the query sentence and the weight vector to obtain the first matrix corresponding to the query sentence.
  • the electronic device can customize the second preset dictionary and the third preset dictionary.
  • the second preset dictionary includes SQL sentences
  • the third preset dictionary includes each element in the element list.
  • the electronic device splicing the first matrix, the second matrix, and the third matrix to obtain a feature matrix includes:
  • the electronic device uses horizontal splicing or vertical splicing to splice the first matrix, the second matrix, and the third matrix to obtain a feature matrix.
  • the obtained feature matrix has multiple levels of feature attributes, which is more conducive to accurate query.
  • the electronic device is improved based on the Seq2Seq (Sequence to Sequence) architecture, and trained to obtain a language conversion model.
  • the language conversion model includes, but is not limited to: an encoder, a decoder .
  • the method further includes:
  • the electronic device trains the encoder.
  • each BiGRU network in the encoder includes multiple subunits, and training the encoder by the electronic device includes:
  • the initialization value can be customized and configured, which is not limited in this application.
  • the electronic device may obtain training data, and combine the training data to construct the initial feature matrix and the current feature matrix in a manner of constructing the feature matrix.
  • the method further includes:
  • the electronic device uses the serialized output of the multiple subunits as the output state of each BiGRU network, and performs vector splicing on the output state of each BiGRU network as the output data of the encoder;
  • the corresponding summary information is obtained based on the output data of the encoder.
  • the summary information is obtained by hashing the output data of the encoder, for example, obtained by processing the sha256s algorithm.
  • Uploading summary information to the blockchain can ensure its security and fairness and transparency to users.
  • the user equipment can download the summary information from the blockchain to verify whether the output data of the encoder has been tampered with.
  • the blockchain referred to in this embodiment is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the electronic device uses horizontal splicing or vertical splicing to perform vector splicing on the output state of each BiGRU network as the output data of the encoder.
  • the output state of one BiGRU network is a 100*128 matrix
  • the output state of another BiGRU network is 100*128
  • the output data is spliced in 0 dimension (ie vertical splicing)
  • the output data obtained It is a 200*128 matrix.
  • the output data of the encoder obtained is a 100*256 matrix.
  • the output data of the encoder is used as the input data of the decoder.
  • the query can be The sentence is transformed into the machine query language.
  • the four BiGRU networks are respectively a category prediction channel, an SQL channel, an element list channel, and a value channel.
  • the electronic device uses a decoder to process the output data of the encoder to obtain a machine query language including :
  • the electronic device uses the category prediction channel to predict the channel to which each SQL word in the output data of the encoder belongs, and based on the attention mechanism, determines the word with the highest probability in the channel to which each SQL word belongs as each SQL For word segmentation corresponding to a word, the electronic device merges the word segmentation corresponding to each SQL word to obtain the machine query language.
  • the electronic device using the category prediction channel to predict the channel to which each SQL word in the output data of the encoder belongs includes:
  • the electronic device obtains the probability value of the word output in the SQL channel, the probability value output in the element list channel, and the value output in the numerical channel. The probability value, and the channel with the largest probability value is determined as the channel of the next SQL word.
  • the method further includes:
  • the electronic device controls the category prediction channel to stop prediction.
  • the accurate conversion of the query sentence can be realized based on the four channels in the decoder and the type of each channel.
  • the internal structure of the decoder is different.
  • the accuracy is higher.
  • the principle of training the decoder by the electronic device is the same as the working principle of the above-mentioned decoder, except that a large amount of training data is used as a training basis, which is not repeated here.
  • the encoder and the decoder are formed into a language conversion model according to an attention mechanism and a cross-entropy function, and the method further includes:
  • the electronic device calculates the first loss of the category prediction channel, calculates the second loss based on the weight vector of the query sentence linked to the attention mechanism, and further calculates the first loss and the second loss And as the loss function of the language conversion model, the electronic device uses a configuration optimization algorithm to optimize the loss function.
  • the configuration optimization algorithm may be any loss function optimization algorithm, which is not limited in this application.
  • the transformation model further improves the generalization ability and interpretability of the language transformation model, so that the transformation result of the language transformation model is more accurate.
  • the electronic device can query the database based on the machine query language. Since the machine query language converted by the language conversion model is more accurate, the final result is The query results are also more accurate and reliable.
  • this application can query the matrix of the query sentence from the first preset dictionary, and link to the element list of the legal knowledge graph based on the attention mechanism.
  • the weight vector of the query sentence The introduction of the attention mechanism distinguishes the contribution rate of each word.
  • the product of the matrix of the query sentence and the weight vector is further calculated to obtain the first matrix corresponding to the query sentence.
  • This application can be applied in scenarios such as smart courts to promote the construction of smart cities.
  • the legal knowledge graph-based query device 11 includes a query unit 110, a link unit 111, a calculation unit 112, a splicing unit 113, an input unit 114, a processing unit 115, an execution unit 116, a determination unit 117, a control unit 118, and an optimization unit 119.
  • the module/unit referred to in this application refers to a series of computer program segments that can be executed by the processor 13 and can complete fixed functions, and are stored in the memory 12. In this embodiment, the functions of each module/unit will be described in detail in subsequent embodiments.
  • the query unit 110 queries the matrix of the query sentence from the first preset dictionary.
  • the query sentence may be a query sentence related to the law, for example: "check the name of the agent of the plaintiff” and so on.
  • the first preset dictionary can be configured for customization, and the first preset dictionary includes all words related to the query sentence.
  • the query unit 110 can directly perform a query in the first preset dictionary and determine the matrix of the query sentence.
  • the linking unit 111 links the weight vector of the query sentence from the element list of the legal knowledge graph based on the attention mechanism (Attention).
  • the vector matrix of the question query is V1 (dm dimension), and the question query is a sentence of 10 words, and the dm is 256, a 10*256 matrix is obtained;
  • the vector matrix of the element list name is V2( dm dimension), and there are 100 keywords in the element list, dm is 256, and a 100*256 matrix is obtained;
  • the above two matrices are multiplied, namely: V1*V2T.
  • the above process of calculating the product is to multiply the 10*256 matrix by the 256*100 matrix, and finally get the 10*100 matrix, and then normalize the calculated matrix, that is, the 100 values in each dimension are compared with each other.
  • each word in the query sentence has a different importance in the query. For example, for the query sentence "check the name of the plaintiff’s agent", when analyzing the word "check”, several other words Words should not be assigned the same attention.
  • the sentence of the query sentence is relatively short, no obvious problem will arise.
  • the sentence of the query sentence is relatively long, if each word in the query sentence is represented by an intermediate semantic vector, each The information of the word itself will be weakened or even disappear, and a lot of detailed information will be lost. Therefore, the link unit 111 introduces the attention mechanism.
  • the linking unit 111 links the weight vector of the query sentence from the element list of the legal knowledge graph based on the attention mechanism to distinguish the contribution of each word in the query sentence to the query process, so as to facilitate more accurate Use the query statement to query.
  • the legal knowledge graph may include a variety of characteristics related to laws, such as legal entities, characteristics specific to legal relationships, and so on.
  • text statistics features such as text length features, word frequency statistics features, and so on.
  • the legal knowledge map mainly includes, but is not limited to, the following two categories:
  • the loan contract it can be extracted whether the attributes of the plaintiff and the court are natural persons, abstract legal persons or other organizations, the borrower's intention to borrow, the interest calculation method selected in the loan contract, and the form of loan delivery.
  • the features constructed based on legal theory are obtained by combing and summarizing based on legal theory.
  • the legal knowledge graph is constructed in the form of a list, and each element in the legal knowledge graph is displayed in the form of an element list.
  • the calculation unit 112 calculates the product of the matrix of the query sentence and the weight vector to obtain the first matrix corresponding to the query sentence.
  • the calculation unit 112 before using the query statement to perform a query, the calculation unit 112 first needs to initialize the query statement.
  • the calculation unit 112 calculates the product of the matrix of the query sentence and the weight vector to obtain the first matrix corresponding to the query sentence.
  • the query unit 110 queries a second matrix of SQL (Structured Query Language) sentences from a second preset dictionary, and queries a third matrix of the element list from a third preset dictionary.
  • SQL Structured Query Language
  • the query unit 110 can customize the second preset dictionary and the third preset dictionary.
  • the second preset dictionary includes SQL sentences
  • the third preset dictionary includes each element in the element list.
  • the splicing unit 113 splices the first matrix, the second matrix, and the third matrix to obtain a feature matrix.
  • the splicing unit 113 splicing the first matrix, the second matrix, and the third matrix to obtain a feature matrix includes:
  • the splicing unit 113 splices the first matrix, the second matrix, and the third matrix in a horizontal splicing or vertical splicing manner to obtain a feature matrix.
  • the query device 11 based on the legal knowledge graph also includes an uploading unit, which uploads the output data of the encoder to the blockchain.
  • the obtained feature matrix has multiple levels of feature attributes, which is more conducive to accurate query.
  • the input unit 114 inputs the feature matrix into the encoder to obtain output data of the encoder, where the encoder includes two BiGRU networks.
  • the input unit 114 is improved based on the Seq2Seq (Sequence to Sequence) architecture, and trained to obtain a language conversion model.
  • the language conversion model includes, but is not limited to: encoder, decoder Device.
  • the encoder is trained.
  • each BiGRU network in the encoder includes multiple subunits.
  • the input unit 114 obtains a pre-configured initialization value, and obtains an initial feature matrix, and converts the initialization value And the initial feature matrix is input into the subunit, and the initial state is output; or
  • the input unit 114 acquires the output state at the previous moment and acquires the current feature matrix, and inputs the output state at the previous moment and the current feature matrix to the subunit In, the current status is output.
  • the initialization value can be customized and configured, which is not limited in this application.
  • the input unit 114 may obtain training data, and combine the training data to construct the initial feature matrix and the current feature matrix in a manner of constructing the feature matrix.
  • the determining unit 117 uses the serialized output of the multiple subunits as the output state of each BiGRU network, and the splicing unit 113 performs vector splicing on the output state of each BiGRU network as the output of the encoder data.
  • the splicing unit 113 performs vector splicing on the output state of each BiGRU network, and the output data of the encoder includes:
  • the splicing unit 113 uses horizontal splicing or vertical splicing to perform vector splicing on the output state of each BiGRU network as the output data of the encoder.
  • the output state of one BiGRU network is a 100*128 matrix
  • the output state of another BiGRU network is 100*128
  • the output data is spliced in 0 dimension (ie vertical splicing)
  • the output data obtained It is a 200*128 matrix.
  • the output data of the encoder obtained is a 100*256 matrix.
  • the processing unit 115 uses a decoder to process the output data of the encoder to obtain a machine query language, where the decoder includes four BiGRU networks.
  • the output data of the encoder is used as the input data of the decoder.
  • the query can be The sentence is transformed into the machine query language.
  • the four BiGRU networks are respectively a category prediction channel, an SQL channel, an element list channel, and a value channel.
  • the processing unit 115 uses a decoder to process the output data of the encoder to obtain a machine query language include:
  • the processing unit 115 uses the category prediction channel to predict the channel to which each SQL word belongs in the output data of the encoder, and determines the word with the highest probability in the channel to which each SQL word belongs based on the attention mechanism as each For the word segmentation corresponding to the SQL word, the processing unit 115 merges the word segmentation corresponding to each SQL word to obtain the machine query language.
  • the processing unit 115 using the category prediction channel to predict the channel to which each SQL word in the output data of the encoder belongs includes:
  • the processing unit 115 obtains the probability value of the word output in the SQL channel, the probability value output in the element list channel, and the output value in the numerical channel. The channel with the largest probability value is determined as the channel of the next SQL word.
  • control unit 118 controls the category prediction channel to stop prediction.
  • the accurate conversion of the query sentence can be realized based on the four channels in the decoder and the type of each channel.
  • the internal structure of the decoder is different.
  • the accuracy is higher.
  • the principle of training the decoder is the same as the working principle of the above-mentioned decoder, except that a large amount of training data is used as a basis for training, which will not be repeated here.
  • the encoder and the decoder form a language conversion model according to an attention mechanism and a cross-entropy function
  • the calculation unit 112 calculates the first loss of the category prediction channel, and Calculate the second loss based on the weight vector of the query sentence linked to by the attention mechanism, and further calculate the sum of the first loss and the second loss as the loss function of the language conversion model
  • the optimization unit 119 adopts the configuration The optimization algorithm optimizes the loss function.
  • the configuration optimization algorithm may be any loss function optimization algorithm, which is not limited in this application.
  • the transformation model further improves the generalization ability and interpretability of the language transformation model, so that the transformation result of the language transformation model is more accurate.
  • the execution unit 116 executes the machine query language in the database, and outputs the query result.
  • the execution unit 116 can query the database based on the machine query language. Since the machine query language converted by the language conversion model is more accurate, the final result is The results of the query are also more accurate and reliable.
  • this application can query the matrix of the query sentence from the first preset dictionary, and link to the element list of the legal knowledge graph based on the attention mechanism.
  • the weight vector of the query sentence The introduction of the attention mechanism distinguishes the contribution rate of each word.
  • the product of the matrix of the query sentence and the weight vector is further calculated to obtain the first matrix corresponding to the query sentence.
  • FIG. 3 it is a schematic structural diagram of an electronic device in a preferred embodiment of the present application for implementing the query method based on the legal knowledge graph.
  • the electronic device 1 may include a memory 12, a processor 13, and a bus, and may also include a computer program stored in the memory 12 and running on the processor 13, such as a query program based on a legal knowledge graph.
  • the electronic device 1 may have a bus structure or a star structure.
  • the device 1 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.
  • the electronic device 1 may also include an input/output device, a network access device, and the like.
  • the electronic device 1 is only an example. If other existing or future electronic products can be adapted to this application, they should also be included in the scope of protection of this application and included here by reference. .
  • the memory 12 includes at least one type of readable storage medium, the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. .
  • the memory 12 may be an internal storage unit of the electronic device 1 in some embodiments, for example, a mobile hard disk of the electronic device 1.
  • the memory 12 may also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart media card (SMC), and a secure digital (Secure Digital, SD) equipped on the electronic device 1. ) Card, Flash Card, etc.
  • the memory 12 may also include both an internal storage unit of the electronic device 1 and an external storage device.
  • the memory 12 can be used not only to store application software and various data installed in the electronic device 1, such as code of a query program based on the legal knowledge graph, etc., but also to temporarily store data that has been output or will be output.
  • the processor 13 may be composed of integrated circuits in some embodiments, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units. Combinations of central processing unit (CPU), microprocessor, digital processing chip, graphics processor, and various control chips.
  • the processor 13 is the control unit of the electronic device 1, which uses various interfaces and lines to connect the various components of the entire electronic device 1, and runs or executes programs or modules stored in the memory 12 (such as executing A query program based on the legal knowledge graph, etc.), and call data stored in the memory 12 to execute various functions of the electronic device 1 and process data.
  • the processor 13 executes the operating system of the electronic device 1 and various installed applications.
  • the processor 13 executes the application program to implement the steps in each embodiment of the query method based on the legal knowledge graph, such as steps S10, S11, S12, S13, S14, S15, S16, and S17 shown in FIG. 1.
  • the computer program may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 12 and executed by the processor 13 to complete the present invention.
  • the one or more modules/units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device 1.
  • the computer program can be divided into a query unit 110, a link unit 111, a calculation unit 112, a splicing unit 113, an input unit 114, a processing unit 115, an execution unit 116, a determination unit 117, a control unit 118, and an optimization unit 119.
  • the above-mentioned integrated unit implemented in the form of a software function module may be stored in a computer readable storage medium.
  • the above-mentioned software function module is stored in a storage medium and includes several instructions to make a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute the methods described in the various embodiments of the present application part.
  • the integrated module/unit of the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • this application implements all or part of the processes in the above-mentioned embodiment methods, and can also be completed by instructing related hardware devices through a computer program.
  • the computer program can be stored in a computer-readable storage medium.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer program includes computer program code
  • the computer program code may be in the form of source code, object code, executable file, or some intermediate form.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) .
  • the bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only one arrow is used to indicate in FIG. 3, but it does not mean that there is only one bus or one type of bus.
  • the bus is configured to implement connection and communication between the memory 12 and at least one processor 13 and the like.
  • the electronic device 1 may also include a power source (such as a battery) for supplying power to various components.
  • the power source may be logically connected to the at least one processor 13 through a power management device, so as to be realized by the power management device. Functions such as charge management, discharge management, and power consumption management.
  • the power supply may also include any components such as one or more DC or AC power supplies, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators.
  • the electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
  • the electronic device 1 may also include a network interface.
  • the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in the electronic device 1 Establish a communication connection with other electronic devices.
  • the electronic device 1 may also include a user interface.
  • the user interface may be a display (Display) and an input unit (such as a keyboard (Keyboard)).
  • the user interface may also be a standard wired interface or a wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc.
  • the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the electronic device 1 and to display a visualized user interface.
  • FIG. 3 only shows the electronic device 1 with components 12-13. Those skilled in the art can understand that the structure shown in FIG. 3 does not constitute a limitation on the electronic device 1, and may include less Or more parts, or a combination of some parts, or a different arrangement of parts.
  • the memory 12 in the electronic device 1 stores multiple instructions to implement a query method based on a legal knowledge graph, and the processor 13 can execute the multiple instructions to achieve:
  • the machine query language is executed in the database, and the query result is output.
  • modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional modules in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit may be implemented in the form of hardware, or may be implemented in the form of hardware plus software functional modules.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种涉及人工智能的基于法律知识图谱的查询方法、装置、电子设备及介质,能够基于注意力机制从法律知识图谱的元素列表中链接到查询语句的权重向量,区分了每个词的贡献率,基于权重计算得到特征矩阵并输入到编码器中,得到编码器的输出数据,编码器包括两个BiGRU网络,并利用解码器处理编码器的输出数据,得到机器查询语言,解码器包括四个BiGRU网络,由于对编码器及解码器的结构都分别进行了优化,使查询语句的转化更加精确、稳定,进一步在数据库中执行机器查询语言,输出查询结果,由于通过数据处理得到的机器查询语言更加准确,因此输出的查询结果也更加准确可靠,进而实现了对查询语句的自动转化及查询,提升了查询效率。

Description

基于法律知识图谱的查询方法、装置、电子设备及介质
本申请要求于2020年04月24日提交中国专利局、申请号为202010334998.4,发明名称为“基于法律知识图谱的查询方法、装置、电子设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,尤其涉及一种基于法律知识图谱的查询方法、装置、电子设备及介质。
背景技术
自然语言生成是人工智能行业中非常重要的研究领域,对于人类来说这是一种天生的能力,而对于人工智能来说,却代表了最高水平的进展。研究自然语言生成能够帮助用户以更快速、更准确、更低成本的方式从数据库中查到需要的答案。
而在法律领域,由于一些专业名词本身具有很高的相似性,不易区分,且要想得到查询结果,往往需要经过多个步骤,每个步骤都有可能因为意图传递不明确或者理解偏差等原因导致查询结果有误,准确性较低。
同时,发明人意识到,目前的查询方法泛化能力较弱,无法应对复杂多变的新问题,当面对新问题事,还要重新训练模型,成本也较高。
发明内容
鉴于以上内容,有必要提供一种基于法律知识图谱的查询方法、装置、电子设备及介质,能够基于注意力机制区分每个词的贡献率,并对编码器及解码器的结构分别进行了优化,使查询语句的转化更加精确、稳定,由于通过数据处理得到的机器查询语言更加准确,因此输出的查询结果也更加准确可靠,进而实现了对查询语句的自动转化及查询,提升了查询效率。
一种基于法律知识图谱的查询方法,所述方法包括:
当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
在数据库中执行所述机器查询语言,输出查询结果。
一种基于法律知识图谱的查询装置,所述装置包括:
查询单元,用于当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
链接单元,用于基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
计算单元,用于计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语 句对应的第一矩阵;
所述查询单元,还用于从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
拼接单元,用于拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
输入单元,用于将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
处理单元,用于利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
执行单元,用于在数据库中执行所述机器查询语言,输出查询结果。
一种电子设备,所述电子设备包括:
存储器,存储至少一个计算机可读指令;及
处理器,执行所述存储器中存储的至少一个计算机可读指令以实现以下步骤:
当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
在数据库中执行所述机器查询语言,输出查询结果。
一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一个计算机可读指令,所述至少一个计算机可读指令被电子设备中的处理器执行以实现以下步骤:
当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
在数据库中执行所述机器查询语言,输出查询结果。
由以上技术方案可以看出,本申请实现了对查询语句的自动转化及查询,提升了查询效率。
附图说明
图1是本申请基于法律知识图谱的查询方法的较佳实施例的流程图。
图2是本申请基于法律知识图谱的查询装置的较佳实施例的功能模块图。
图3是本申请实现基于法律知识图谱的查询方法的较佳实施例的电子设备的结构示意图。
具体实施方式
为了使本申请的目的、技术方案和优点更加清楚,下面结合附图和具体实施例对本申请进行详细描述。
如图1所示,是本申请基于法律知识图谱的查询方法的较佳实施例的流程图。根据不同的需求,该流程图中步骤的顺序可以改变,某些步骤可以省略。
所述基于法律知识图谱的查询方法应用于一个或者多个电子设备中,所述电子设备是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。
所述电子设备可以是任何一种可与用户进行人机交互的电子产品,例如,个人计算机、平板电脑、智能手机、个人数字助理(Personal Digital Assistant,PDA)、游戏机、交互式网络电视(Internet Protocol Television,IPTV)、智能式穿戴式设备等。
所述电子设备还可以包括网络设备和/或用户设备。其中,所述网络设备包括,但不限于单个网络服务器、多个网络服务器组成的服务器组或基于云计算(Cloud Computing)的由大量主机或网络服务器构成的云。
所述电子设备所处的网络包括但不限于互联网、广域网、城域网、局域网、虚拟专用网络(Virtual Private Network,VPN)等。
S10,当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵。
其中,所述查询语句可以是与法律相关的查询语句,例如:“查原告方的代理人姓名”等。
其中,所述第一预设字典可以进行自定义配置,所述第一预设字典中包括所有查询语句相关的词。
因此,所述电子设备可以直接在所述第一预设字典中进行查询,并确定所述查询语句的矩阵。
S11,基于注意力机制(Attention)从法律知识图谱的元素列表中链接到所述查询语句的权重向量。
例如:如果问题query的向量矩阵是V1(dm维度),且所述问题query是一句10个字的句子,dm为256,得到10*256的矩阵;所述元素列表名称的向量矩阵是V2(dm维度),且所述元素列表中有100个关键字,dm为256,得到100*256的矩阵;将上述两个矩阵相乘,即:V1*V2T。上述计算乘积的过程即为10*256的矩阵乘以256*100的矩阵,最终得到10*100的矩阵,然后对计算出的矩阵进行归一化操作,即将每个维度上的100个值相加,得到10*1的向量,然后计算10个数值的均方根SQRT(SUM(V1*V2T,axis=0)),再将十个值都除以该均方根,即:SUM(V1*V2T,axis=0)/SQRT(SUM(V1*V2T,axis=0)),得到一条新的向量,结构为10*1,该向量即为所述问题query的权重向量W。
可以理解的是,所述查询语句中的每个词在查询时具备不同的重要性,例如,对于查询语句“查原告方的代理人姓名”,在分析“查”这个词时,其他几个词则不应该被分配相同的注意力。在所述查询语句的句子比较短时不会产生明显问题,但是,在所述查询语句的句子比较长时,如果所述查询语句中的每个词都通过一个中间语义向量来表示,每个单词自身的信息将被弱化,甚至消失,那么将会丢失很多细节信息,因此,所述电子设备引入所述注意力机制。
具体地,所述电子设备基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量,以区分所述查询语句中每个词对于查询过程的贡献,便于更加准确地利用所述查询语句进行查询。
在本申请的至少一个实施例中,所述法律知识图谱中可以包括多种与法律相关的特征,例如:法律实体、法律关系特有的特征等。
需要说明的是,传统的特征通常为文本统计类特征,如:文本长度特征、词频统计类特征等。
相比较而言,在所述法律知识图谱中,主要包括,但不限于以下两类:
(1)根据法律、法规、司法解释等提取的法律抽象类特征。
例如:在借贷合同中能够提取到原被告属性是自然人、抽象的法人还是其他组织,借款人的借款意图,借款合同选择的计息方式,借款交付形式等。
具体地,所述法律抽象类特征是根据每个法律的子类别进行归纳的。
(2)根据法学理论构建的特征。
例如:合同订立的过程是否有要约邀请、要约、承诺,合同订立的形式是书面形式还是口头形式,该合同是诺成性合同还是实践性合同,该合同建立的法律关系是单方民事法律关系还是多方民事法律关系,该合同是否确立了先履行义务等。
具体地,所述根据法学理论构建的特征是根据法学理论进行梳理归纳而得到的。
在本申请的至少一个实施例中,所述法律知识图谱以列表的形式构建,所述法律知识图谱中的各个元素以元素列表的形式展示。
S12,计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵。
在本申请的至少一个实施例中,在利用所述查询语句进行查询前,所述电子设备首先需要对所述查询语句进行初始化处理。
具体地,所述电子设备计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵。
S13,从第二预设字典中查询SQL(Structured Query Language,结构化查询语言)语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵。
在本申请的至少一个实施例中,所述电子设备可以对所述第二预设字典及所述第三预设字典进行自定义配置。
其中,所述第二预设字典中包括SQL语句,所述第三预设字典中包括所述元素列表中的每个元素。
需要说明的是,由于字典的构建技术已经相对成熟,本申请在此不赘述。
S14,拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵。
在本申请的至少一个实施例中,所述电子设备拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵包括:
所述电子设备采用横向拼接或者纵向拼接的方式拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵。
通过上述实施方式,使得到的所述特征矩阵具有多个层面的特征属性,更利于准确的查询。
S15,将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络。
在本申请的至少一个实施例中,所述电子设备基于Seq2Seq(Sequence to Sequence)架构进行了改进,并训练得到了语言转化模型,所述语言转化模型包括,但不限于:编码器、解码器。
进一步地,在将所述特征矩阵输入到所述编码器中,得到所述编码器的输出数据前,所述方法还包括:
所述电子设备训练所述编码器。
具体地,所述编码器中的每个BiGRU网络包括多个子单元,所述电子设备训练所述编码器包括:
对于每个子单元,在初始时刻,获取预先配置的初始化值,及获取初始特征矩阵,将所述初始化值及所述初始特征矩阵输入到该子单元中,输出初始状态;或者
在除所述初始时刻外的其他时刻,获取上一时刻的输出状态,及获取当前特征矩阵,将所述上一时刻的输出状态及所述当前特征矩阵输入到该子单元中,输出当前状态。
其中,所述初始化值可以进行自定义配置,本申请不限制。
进一步地,所述电子设备可以获取训练数据,并结合所述训练数据以构建所述特征矩阵的方式构建所述初始特征矩阵及所述当前特征矩阵。
进一步地,所述方法还包括:
所述电子设备以所述多个子单元串行后的输出作为每个BiGRU网络的输出状态,并对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据;
将所述编码器的输出数据上传至区块链中。
基于编码器的输出数据得到对应的摘要信息,具体来说,摘要信息由编码器的输出数据进行散列处理得到,比如利用sha256s算法处理得到。将摘要信息上传至区块链可保证其安全性和对用户的公正透明性。用户设备可以从区块链中下载得该摘要信息,以便查证编码器的输出数据是否被篡改。
本实施例所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。
其中,所述电子设备对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据包括:
所述电子设备采用横向拼接或者纵向拼接的方式对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据。
例如:当一个BiGRU网络的输出状态是100*128的矩阵,另一个BiGRU网络的输出状态是100*128时,如果在0维上拼接(即采用纵向拼接的方式),得到的所述输出数据为200*128的矩阵,如果在1维上拼接(即采用横向拼接的方式),得到的所述编码器的输出数据为100*256的矩阵。
通过上述实施方式,能够实现对所述编码器的训练,与现有的Seq2Seq架构不同,由于所述编码器中具备两个BiGRU网络,因此在模型预测的准确率上有显著提升。
S16,利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络。
在本申请的至少一个实施例中,所述编码器的输出数据被作为所述解码器的输入数据,当所述编码器的输出数据经过所述解码器的处理后,即可将所述查询语句转化为所述机器查询语言。
具体地,所述四个BiGRU网络分别为一个类别预测通道、一个SQL通道、一个元素列表通道以及一个数值通道,所述电子设备利用解码器处理所述编码器的输出数据,得到机器查询语言包括:
所述电子设备利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道,并基于注意力机制将每个SQL词所属的通道内概率最大的词确定为每个SQL词对应的分词,所述电子设备合并每个SQL词对应的分词,得到所述机器查询语言。
其中,所述电子设备利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道包括:
对于所述编码器的输出数据中的每个SQL词,所述电子设备获取该词在所述SQL通道输出的概率值、在所述元素列表通道输出的概率值以及在所述数值通道输出的概率值,并将概率值最大的通道确定为下一个SQL词的通道。
进一步地,所述方法还包括:
当所述编码器的输出数据中的SQL词为停止符时,所述电子设备控制所述类别预测 通道停止预测。
通过上述实施方式,能够基于所述解码器中的四个通道及每个通道的类型实现对所述查询语句的准确转化,相较于现有的Seq2Seq架构,由于所述解码器的内部结构不同,具备4个BiGRU网络,因此准确性更高。
需要说明的是,所述电子设备训练所述解码器的原理与上述解码器的工作原理相同,只是采用了大量的训练数据作为训练依据,在此不赘述。
在本申请的至少一个实施例中,根据注意力机制及交叉熵函数将所述编码器及所述解码器构成语言转化模型,所述方法还包括:
所述电子设备计算所述类别预测通道的第一损失,及计算基于注意力机制链接到的所述查询语句的权重向量的第二损失,进一步计算所述第一损失及所述第二损失的和作为所述语言转化模型的损失函数,所述电子设备采用配置优化算法优化所述损失函数。
所述配置优化算法可以是任意损失函数优化算法,本申请不限制。
通过上述实施方式,不仅能够对所述语言转化模型转化结果的准确性进行评估,还能对中间过程进行评估,同时考虑了选择通道的概率及生成词汇的概率,能够更加精确地优化所述语言转化模型,并进一步提高了所述语言转化模型的泛化能力及可解释能力,使所述语言转化模型的转化结果更加准确。
S17,在数据库中执行所述机器查询语言,输出查询结果。
在得到所述机器查询语言后,所述电子设备即可基于所述机器查询语言在所述数据库中进行查询,由于通过上述语言转化模型转化得到的所述机器查询语言更加精确,因此最终得到的查询结果也更加准确可靠。
由以上技术方案可以看出,本申请能够当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵,并基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量,注意力机制的引入区分了每个词的贡献率,进一步计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵,并从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵,拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵,进一步将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络,并利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络,由于对所述编码器及所述解码器的结构都分别进行了优化,使查询语句的转化更加精确、稳定,进一步在数据库中执行所述机器查询语言,输出查询结果,由于得到的机器查询语言更加准确,因此输出的查询结果也更加准确可靠,进而实现了对查询语句的自动转化及查询,提升了查询效率。本申请可以应用在智慧法院等场景中,从而推动智慧城市的建设。
如图2所示,是本申请基于法律知识图谱的查询装置的较佳实施例的功能模块图。所述基于法律知识图谱的查询装置11包括查询单元110、链接单元111、计算单元112、拼接单元113、输入单元114、处理单元115、执行单元116、确定单元117、控制单元118、优化单元119。本申请所称的模块/单元是指一种能够被处理器13所执行,并且能够完成固定功能的一系列计算机程序段,其存储在存储器12中。在本实施例中,关于各模块/单元的功能将在后续的实施例中详述。
当接收到查询语句时,查询单元110从第一预设字典中查询所述查询语句的矩阵。
其中,所述查询语句可以是与法律相关的查询语句,例如:“查原告方的代理人姓名”等。
其中,所述第一预设字典可以进行自定义配置,所述第一预设字典中包括所有查询语句相关的词。
因此,所述查询单元110可以直接在所述第一预设字典中进行查询,并确定所述查询语句的矩阵。
链接单元111基于注意力机制(Attention)从法律知识图谱的元素列表中链接到所述查询语句的权重向量。
例如:如果问题query的向量矩阵是V1(dm维度),且所述问题query是一句10个字的句子,dm为256,得到10*256的矩阵;所述元素列表名称的向量矩阵是V2(dm维度),且所述元素列表中有100个关键字,dm为256,得到100*256的矩阵;将上述两个矩阵相乘,即:V1*V2T。上述计算乘积的过程即为10*256的矩阵乘以256*100的矩阵,最终得到10*100的矩阵,然后对计算出的矩阵进行归一化操作,即将每个维度上的100个值相加,得到10*1的向量,然后计算10个数值的均方根SQRT(SUM(V1*V2T,axis=0)),再将十个值都除以该均方根,即:SUM(V1*V2T,axis=0)/SQRT(SUM(V1*V2T,axis=0)),得到一条新的向量,结构为10*1,该向量即为所述问题query的权重向量W。
可以理解的是,所述查询语句中的每个词在查询时具备不同的重要性,例如,对于查询语句“查原告方的代理人姓名”,在分析“查”这个词时,其他几个词则不应该被分配相同的注意力。在所述查询语句的句子比较短时不会产生明显问题,但是,在所述查询语句的句子比较长时,如果所述查询语句中的每个词都通过一个中间语义向量来表示,每个单词自身的信息将被弱化,甚至消失,那么将会丢失很多细节信息,因此,所述链接单元111引入所述注意力机制。
具体地,所述链接单元111基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量,以区分所述查询语句中每个词对于查询过程的贡献,便于更加准确地利用所述查询语句进行查询。
在本申请的至少一个实施例中,所述法律知识图谱中可以包括多种与法律相关的特征,例如:法律实体、法律关系特有的特征等。
需要说明的是,传统的特征通常为文本统计类特征,如:文本长度特征、词频统计类特征等。
相比较而言,在所述法律知识图谱中,主要包括,但不限于以下两类:
(1)根据法律、法规、司法解释等提取的法律抽象类特征。
例如:在借贷合同中能够提取到原被告属性是自然人、抽象的法人还是其他组织,借款人的借款意图,借款合同选择的计息方式,借款交付形式等。
具体地,所述法律抽象类特征是根据每个法律的子类别进行归纳的。
(2)根据法学理论构建的特征。
例如:合同订立的过程是否有要约邀请、要约、承诺,合同订立的形式是书面形式还是口头形式,该合同是诺成性合同还是实践性合同,该合同建立的法律关系是单方民事法律关系还是多方民事法律关系,该合同是否确立了先履行义务等。
具体地,所述根据法学理论构建的特征是根据法学理论进行梳理归纳而得到的。
在本申请的至少一个实施例中,所述法律知识图谱以列表的形式构建,所述法律知识图谱中的各个元素以元素列表的形式展示。
计算单元112计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵。
在本申请的至少一个实施例中,在利用所述查询语句进行查询前,所述计算单元112首先需要对所述查询语句进行初始化处理。
具体地,所述计算单元112计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵。
所述查询单元110从第二预设字典中查询SQL(Structured Query Language,结构化查询语言)语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵。
在本申请的至少一个实施例中,所述查询单元110可以对所述第二预设字典及所述第三预设字典进行自定义配置。
其中,所述第二预设字典中包括SQL语句,所述第三预设字典中包括所述元素列表 中的每个元素。
需要说明的是,由于字典的构建技术已经相对成熟,本申请在此不赘述。
拼接单元113拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵。
在本申请的至少一个实施例中,所述拼接单元113拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵包括:
所述拼接单元113采用横向拼接或者纵向拼接的方式拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵。
所述基于法律知识图谱的查询装置11还包括上传单元,将编码器的输出数据上传至区块链中。
通过上述实施方式,使得到的所述特征矩阵具有多个层面的特征属性,更利于准确的查询。
输入单元114将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络。
在本申请的至少一个实施例中,所述输入单元114基于Seq2Seq(Sequence to Sequence)架构进行了改进,并训练得到了语言转化模型,所述语言转化模型包括,但不限于:编码器、解码器。
进一步地,在将所述特征矩阵输入到所述编码器中,得到所述编码器的输出数据前,训练所述编码器。
具体地,所述编码器中的每个BiGRU网络包括多个子单元,对于每个子单元,在初始时刻,所述输入单元114获取预先配置的初始化值,及获取初始特征矩阵,将所述初始化值及所述初始特征矩阵输入到该子单元中,输出初始状态;或者
在除所述初始时刻外的其他时刻,所述输入单元114获取上一时刻的输出状态,及获取当前特征矩阵,将所述上一时刻的输出状态及所述当前特征矩阵输入到该子单元中,输出当前状态。
其中,所述初始化值可以进行自定义配置,本申请不限制。
进一步地,所述输入单元114可以获取训练数据,并结合所述训练数据以构建所述特征矩阵的方式构建所述初始特征矩阵及所述当前特征矩阵。
进一步地,确定单元117以所述多个子单元串行后的输出作为每个BiGRU网络的输出状态,所述拼接单元113对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据。
其中,所述拼接单元113对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据包括:
所述拼接单元113采用横向拼接或者纵向拼接的方式对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据。
例如:当一个BiGRU网络的输出状态是100*128的矩阵,另一个BiGRU网络的输出状态是100*128时,如果在0维上拼接(即采用纵向拼接的方式),得到的所述输出数据为200*128的矩阵,如果在1维上拼接(即采用横向拼接的方式),得到的所述编码器的输出数据为100*256的矩阵。
通过上述实施方式,能够实现对所述编码器的训练,与现有的Seq2Seq架构不同,由于所述编码器中具备两个BiGRU网络,因此在模型预测的准确率上有显著提升。
处理单元115利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络。
在本申请的至少一个实施例中,所述编码器的输出数据被作为所述解码器的输入数据,当所述编码器的输出数据经过所述解码器的处理后,即可将所述查询语句转化为所述机器查询语言。
具体地,所述四个BiGRU网络分别为一个类别预测通道、一个SQL通道、一个元 素列表通道以及一个数值通道,所述处理单元115利用解码器处理所述编码器的输出数据,得到机器查询语言包括:
所述处理单元115利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道,并基于注意力机制将每个SQL词所属的通道内概率最大的词确定为每个SQL词对应的分词,所述处理单元115合并每个SQL词对应的分词,得到所述机器查询语言。
其中,所述处理单元115利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道包括:
对于所述编码器的输出数据中的每个SQL词,所述处理单元115获取该词在所述SQL通道输出的概率值、在所述元素列表通道输出的概率值以及在所述数值通道输出的概率值,并将概率值最大的通道确定为下一个SQL词的通道。
进一步地,当所述编码器的输出数据中的SQL词为停止符时,控制单元118控制所述类别预测通道停止预测。
通过上述实施方式,能够基于所述解码器中的四个通道及每个通道的类型实现对所述查询语句的准确转化,相较于现有的Seq2Seq架构,由于所述解码器的内部结构不同,具备4个BiGRU网络,因此准确性更高。
需要说明的是,训练所述解码器的原理与上述解码器的工作原理相同,只是采用了大量的训练数据作为训练依据,在此不赘述。
在本申请的至少一个实施例中,根据注意力机制及交叉熵函数将所述编码器及所述解码器构成语言转化模型,所述计算单元112计算所述类别预测通道的第一损失,及计算基于注意力机制链接到的所述查询语句的权重向量的第二损失,进一步计算所述第一损失及所述第二损失的和作为所述语言转化模型的损失函数,优化单元119采用配置优化算法优化所述损失函数。
所述配置优化算法可以是任意损失函数优化算法,本申请不限制。
通过上述实施方式,不仅能够对所述语言转化模型转化结果的准确性进行评估,还能对中间过程进行评估,同时考虑了选择通道的概率及生成词汇的概率,能够更加精确地优化所述语言转化模型,并进一步提高了所述语言转化模型的泛化能力及可解释能力,使所述语言转化模型的转化结果更加准确。
执行单元116在数据库中执行所述机器查询语言,输出查询结果。
在得到所述机器查询语言后,所述执行单元116即可基于所述机器查询语言在所述数据库中进行查询,由于通过上述语言转化模型转化得到的所述机器查询语言更加精确,因此最终得到的查询结果也更加准确可靠。
由以上技术方案可以看出,本申请能够当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵,并基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量,注意力机制的引入区分了每个词的贡献率,进一步计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵,并从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵,拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵,进一步将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络,并利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络,由于对所述编码器及所述解码器的结构都分别进行了优化,使查询语句的转化更加精确、稳定,进一步在数据库中执行所述机器查询语言,输出查询结果,由于得到的机器查询语言更加准确,因此输出的查询结果也更加准确可靠,进而实现了对查询语句的自动转化及查询,提升了查询效率。
如图3所示,是本申请实现基于法律知识图谱的查询方法的较佳实施例的电子设备 的结构示意图。
所述电子设备1可以包括存储器12、处理器13和总线,还可以包括存储在所述存储器12中并可在所述处理器13上运行的计算机程序,例如基于法律知识图谱的查询程序。
本领域技术人员可以理解,所述示意图仅仅是电子设备1的示例,并不构成对电子设备1的限定,所述电子设备1既可以是总线型结构,也可以是星形结构,所述电子设备1还可以包括比图示更多或更少的其他硬件或者软件,或者不同的部件布置,例如所述电子设备1还可以包括输入输出设备、网络接入设备等。
需要说明的是,所述电子设备1仅为举例,其他现有的或今后可能出现的电子产品如可适应于本申请,也应包含在本申请的保护范围以内,并以引用方式包含于此。
其中,存储器12至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器12在一些实施例中可以是电子设备1的内部存储单元,例如该电子设备1的移动硬盘。存储器12在另一些实施例中也可以是电子设备1的外部存储设备,例如电子设备1上配备的插接式移动硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(Flash Card)等。进一步地,存储器12还可以既包括电子设备1的内部存储单元也包括外部存储设备。存储器12不仅可以用于存储安装于电子设备1的应用软件及各类数据,例如基于法律知识图谱的查询程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
处理器13在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。处理器13是所述电子设备1的控制核心(Control Unit),利用各种接口和线路连接整个电子设备1的各个部件,通过运行或执行存储在所述存储器12内的程序或者模块(例如执行基于法律知识图谱的查询程序等),以及调用存储在所述存储器12内的数据,以执行电子设备1的各种功能和处理数据。
所述处理器13执行所述电子设备1的操作系统以及安装的各类应用程序。所述处理器13执行所述应用程序以实现上述各个基于法律知识图谱的查询方法实施例中的步骤,例如图1所示的步骤S10、S11、S12、S13、S14、S15、S16、S17。
示例性的,所述计算机程序可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器12中,并由所述处理器13执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序在所述电子设备1中的执行过程。例如,所述计算机程序可以被分割成查询单元110、链接单元111、计算单元112、拼接单元113、输入单元114、处理单元115、执行单元116、确定单元117、控制单元118、优化单元119。
上述以软件功能模块的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、计算机设备,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的部分。
所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指示相关的硬件设备来完成,所述的计算机程序可存储于一计算机可读存储介质中,所述计算机可读存储介质可以是非易失性,也可以是易失性。该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。
其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形 式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。
总线可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,在图3中仅用一根箭头表示,但并不表示仅有一根总线或一种类型的总线。所述总线被设置为实现所述存储器12以及至少一个处理器13等之间的连接通信。
尽管未示出,所述电子设备1还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器13逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备1还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。
进一步地,所述电子设备1还可以包括网络接口,可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备1与其他电子设备之间建立通信连接。
可选地,该电子设备1还可以包括用户接口,用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备1中处理的信息以及用于显示可视化的用户界面。
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。
图3仅示出了具有组件12-13的电子设备1,本领域技术人员可以理解的是,图3示出的结构并不构成对所述电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。
结合图1,所述电子设备1中的所述存储器12存储多个指令以实现一种基于法律知识图谱的查询方法,所述处理器13可执行所述多个指令从而实现:
当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
在数据库中执行所述机器查询语言,输出查询结果。
具体地,所述处理器13对上述指令的具体实现方法可参考图1对应实施例中相关步骤的描述,在此不赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模 块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。

Claims (20)

  1. 一种基于法律知识图谱的查询方法,其中,所述方法包括:
    当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
    基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
    计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
    从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
    拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
    将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
    利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
    在数据库中执行所述机器查询语言,输出查询结果。
  2. 如权利要求1所述的基于法律知识图谱的查询方法,其中,所述编码器中的每个BiGRU网络包括多个子单元,所述方法还包括:
    对于每个子单元,在初始时刻,获取预先配置的初始化值,及获取初始特征矩阵,将所述初始化值及所述初始特征矩阵输入到该子单元中,输出初始状态;或者
    在除所述初始时刻外的其他时刻,获取上一时刻的输出状态,及获取当前特征矩阵,将所述上一时刻的输出状态及所述当前特征矩阵输入到该子单元中,输出当前状态。
  3. 如权利要求2所述的基于法律知识图谱的查询方法,其中,所述方法还包括:
    以所述多个子单元串行后的输出作为每个BiGRU网络的输出状态;
    对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据;
    将所述编码器的输出数据上传至区块链中。
  4. 如权利要求1所述的基于法律知识图谱的查询方法,其中,所述四个BiGRU网络分别为一个类别预测通道、一个SQL通道、一个元素列表通道以及一个数值通道,所述利用解码器处理所述编码器的输出数据,得到机器查询语言包括:
    利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道;
    基于注意力机制将每个SQL词所属的通道内概率最大的词确定为每个SQL词对应的分词;
    合并每个SQL词对应的分词,得到所述机器查询语言。
  5. 如权利要求4所述的基于法律知识图谱的查询方法,其中,所述利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道包括:
    对于所述编码器的输出数据中的每个SQL词,获取该词在所述SQL通道输出的概率值、在所述元素列表通道输出的概率值以及在所述数值通道输出的概率值;
    将概率值最大的通道确定为下一个SQL词的通道。
  6. 如权利要求4所述的基于法律知识图谱的查询方法,其中,所述方法还包括:
    当所述编码器的输出数据中的SQL词为停止符时,控制所述类别预测通道停止预测。
  7. 如权利要求4所述的基于法律知识图谱的查询方法,其中,根据注意力机制及交叉熵函数将所述编码器及所述解码器构成语言转化模型,所述方法还包括:
    计算所述类别预测通道的第一损失,及计算基于注意力机制链接到的所述查询语句的权重向量的第二损失;
    计算所述第一损失及所述第二损失的和作为所述语言转化模型的损失函数;
    采用配置优化算法优化所述损失函数。
  8. 一种基于法律知识图谱的查询装置,其中,所述装置包括:
    查询单元,用于当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
    链接单元,用于基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
    计算单元,用于计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
    所述查询单元,还用于从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
    拼接单元,用于拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
    输入单元,用于将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
    处理单元,用于利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
    执行单元,用于在数据库中执行所述机器查询语言,输出查询结果。
  9. 一种电子设备,其中,所述电子设备包括:
    存储器,存储至少一个计算机可读指令;及
    处理器,执行所述存储器中存储的至少一个计算机可读指令以实现以下步骤:
    当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
    基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
    计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
    从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
    拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
    将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
    利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
    在数据库中执行所述机器查询语言,输出查询结果。
  10. 如权利要求9所述的电子设备,其中,所述编码器中的每个BiGRU网络包括多个子单元,所述处理器执行至少一个计算机可读指令还用以实现以下步骤:
    对于每个子单元,在初始时刻,获取预先配置的初始化值,及获取初始特征矩阵,将所述初始化值及所述初始特征矩阵输入到该子单元中,输出初始状态;或者
    在除所述初始时刻外的其他时刻,获取上一时刻的输出状态,及获取当前特征矩阵,将所述上一时刻的输出状态及所述当前特征矩阵输入到该子单元中,输出当前状态。
  11. 如权利要求10所述的电子设备,其中,所述处理器执行至少一个计算机可读指令还用以实现以下步骤:
    以所述多个子单元串行后的输出作为每个BiGRU网络的输出状态;
    对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据;
    将所述编码器的输出数据上传至区块链中。
  12. 如权利要求9所述的电子设备,其中,所述四个BiGRU网络分别为一个类别预测通道、一个SQL通道、一个元素列表通道以及一个数值通道,所述处理器执行至少一个计算机可读指令以实现所述利用解码器处理所述编码器的输出数据,得到机器查询语言时,包括以下步骤:
    利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道;
    基于注意力机制将每个SQL词所属的通道内概率最大的词确定为每个SQL词对应的分词;
    合并每个SQL词对应的分词,得到所述机器查询语言。
  13. 如权利要求12所述的电子设备,其中,所述处理器执行至少一个计算机可读指令以实现所述利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道时,包括以下步骤:
    对于所述编码器的输出数据中的每个SQL词,获取该词在所述SQL通道输出的概率值、在所述元素列表通道输出的概率值以及在所述数值通道输出的概率值;
    将概率值最大的通道确定为下一个SQL词的通道。
  14. 如权利要求12所述的电子设备,其中,所述处理器执行至少一个计算机可读指令还用以实现以下步骤:
    当所述编码器的输出数据中的SQL词为停止符时,控制所述类别预测通道停止预测。
  15. 如权利要求12所述的电子设备,其中,根据注意力机制及交叉熵函数将所述编码器及所述解码器构成语言转化模型,所述处理器执行至少一个计算机可读指令还用以实现以下步骤:
    计算所述类别预测通道的第一损失,及计算基于注意力机制链接到的所述查询语句的权重向量的第二损失;
    计算所述第一损失及所述第二损失的和作为所述语言转化模型的损失函数;
    采用配置优化算法优化所述损失函数。
  16. 一种计算机可读存储介质,其中:所述计算机可读存储介质中存储有至少一个计算机可读指令,所述至少一个计算机可读指令被电子设备中的处理器执行以实现以下步骤:
    当接收到查询语句时,从第一预设字典中查询所述查询语句的矩阵;
    基于注意力机制从法律知识图谱的元素列表中链接到所述查询语句的权重向量;
    计算所述查询语句的矩阵与所述权重向量的乘积,得到所述查询语句对应的第一矩阵;
    从第二预设字典中查询SQL语句的第二矩阵,以及从第三预设字典中查询所述元素列表的第三矩阵;
    拼接所述第一矩阵、所述第二矩阵及所述第三矩阵,得到特征矩阵;
    将所述特征矩阵输入到编码器中,得到所述编码器的输出数据,其中,所述编码器包括两个BiGRU网络;
    利用解码器处理所述编码器的输出数据,得到机器查询语言,其中,所述解码器包括四个BiGRU网络;
    在数据库中执行所述机器查询语言,输出查询结果。
  17. 如权利要求16所述的存储介质,其中,所述编码器中的每个BiGRU网络包括多个子单元,所述至少一个计算机可读指令被处理器执行还用以实现以下步骤:
    对于每个子单元,在初始时刻,获取预先配置的初始化值,及获取初始特征矩阵,将所述初始化值及所述初始特征矩阵输入到该子单元中,输出初始状态;或者
    在除所述初始时刻外的其他时刻,获取上一时刻的输出状态,及获取当前特征矩阵,将所述上一时刻的输出状态及所述当前特征矩阵输入到该子单元中,输出当前状态。
  18. 如权利要求17所述的存储介质,其中,所述至少一个计算机可读指令被处理器执行还用以实现以下步骤:
    以所述多个子单元串行后的输出作为每个BiGRU网络的输出状态;
    对每个BiGRU网络的输出状态进行向量拼接,作为所述编码器的输出数据;
    将所述编码器的输出数据上传至区块链中。
  19. 如权利要求16所述的存储介质,其中,所述四个BiGRU网络分别为一个类别预测通道、一个SQL通道、一个元素列表通道以及一个数值通道,所述至少一个计算机可读指令被处理器执行以实现所述利用解码器处理所述编码器的输出数据,得到机器查 询语言时,包括以下步骤:
    利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道;
    基于注意力机制将每个SQL词所属的通道内概率最大的词确定为每个SQL词对应的分词;
    合并每个SQL词对应的分词,得到所述机器查询语言。
  20. 如权利要求19所述的存储介质,其中,所述至少一个计算机可读指令被处理器执行以实现所述利用所述类别预测通道预测所述编码器的输出数据中每个SQL词所属的通道时,包括以下步骤:
    对于所述编码器的输出数据中的每个SQL词,获取该词在所述SQL通道输出的概率值、在所述元素列表通道输出的概率值以及在所述数值通道输出的概率值;
    将概率值最大的通道确定为下一个SQL词的通道。
PCT/CN2020/104968 2020-04-24 2020-07-27 基于法律知识图谱的查询方法、装置、电子设备及介质 WO2021212683A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010334998.4A CN111639153A (zh) 2020-04-24 2020-04-24 基于法律知识图谱的查询方法、装置、电子设备及介质
CN202010334998.4 2020-04-24

Publications (1)

Publication Number Publication Date
WO2021212683A1 true WO2021212683A1 (zh) 2021-10-28

Family

ID=72333231

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/104968 WO2021212683A1 (zh) 2020-04-24 2020-07-27 基于法律知识图谱的查询方法、装置、电子设备及介质

Country Status (2)

Country Link
CN (1) CN111639153A (zh)
WO (1) WO2021212683A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115658926A (zh) * 2022-11-21 2023-01-31 中国科学院自动化研究所 知识图谱的要素推测方法、装置、电子设备和存储介质
CN115983379A (zh) * 2023-03-20 2023-04-18 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) Mdata知识图谱的可达路径查询方法及其系统
CN116225973A (zh) * 2023-05-10 2023-06-06 贵州轻工职业技术学院 基于嵌入式实现电子设备的芯片代码测试方法及装置
CN116258521A (zh) * 2022-12-02 2023-06-13 东莞盟大集团有限公司 基于区块链技术的二级节点标识应用积分管理方法
WO2024007619A1 (zh) * 2022-07-06 2024-01-11 京东科技信息技术有限公司 解码器的训练方法、目标检测方法、装置以及存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112328960B (zh) * 2020-11-02 2023-09-19 中国平安财产保险股份有限公司 数据运算的优化方法、装置、电子设备及存储介质
CN113221975B (zh) * 2021-04-26 2023-07-11 中国科学技术大学先进技术研究院 基于改进马尔可夫分析法的工况构建方法及存储介质
CN115455149B (zh) * 2022-09-20 2023-05-30 城云科技(中国)有限公司 基于编码查询方式的数据库构建方法及其应用

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943874A (zh) * 2017-11-13 2018-04-20 平安科技(深圳)有限公司 知识图谱处理方法、装置、计算机设备及存储介质
US20180365579A1 (en) * 2017-06-15 2018-12-20 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and apparatus for evaluating a matching degree of multi-domain information based on artificial intelligence, device and medium
CN109656952A (zh) * 2018-10-31 2019-04-19 北京百度网讯科技有限公司 查询处理方法、装置及电子设备
CN110990536A (zh) * 2019-12-06 2020-04-10 重庆邮电大学 一种基于bert和知识图谱感知的cql生成方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180365579A1 (en) * 2017-06-15 2018-12-20 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and apparatus for evaluating a matching degree of multi-domain information based on artificial intelligence, device and medium
CN107943874A (zh) * 2017-11-13 2018-04-20 平安科技(深圳)有限公司 知识图谱处理方法、装置、计算机设备及存储介质
CN109656952A (zh) * 2018-10-31 2019-04-19 北京百度网讯科技有限公司 查询处理方法、装置及电子设备
CN110990536A (zh) * 2019-12-06 2020-04-10 重庆邮电大学 一种基于bert和知识图谱感知的cql生成方法

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024007619A1 (zh) * 2022-07-06 2024-01-11 京东科技信息技术有限公司 解码器的训练方法、目标检测方法、装置以及存储介质
CN115658926A (zh) * 2022-11-21 2023-01-31 中国科学院自动化研究所 知识图谱的要素推测方法、装置、电子设备和存储介质
CN116258521A (zh) * 2022-12-02 2023-06-13 东莞盟大集团有限公司 基于区块链技术的二级节点标识应用积分管理方法
CN115983379A (zh) * 2023-03-20 2023-04-18 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) Mdata知识图谱的可达路径查询方法及其系统
CN115983379B (zh) * 2023-03-20 2023-10-10 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) Mdata知识图谱的可达路径查询方法及其系统
CN116225973A (zh) * 2023-05-10 2023-06-06 贵州轻工职业技术学院 基于嵌入式实现电子设备的芯片代码测试方法及装置
CN116225973B (zh) * 2023-05-10 2023-06-30 贵州轻工职业技术学院 基于嵌入式实现电子设备的芯片代码测试方法及装置

Also Published As

Publication number Publication date
CN111639153A (zh) 2020-09-08

Similar Documents

Publication Publication Date Title
WO2021212683A1 (zh) 基于法律知识图谱的查询方法、装置、电子设备及介质
WO2022160449A1 (zh) 文本分类方法、装置、电子设备及存储介质
WO2023159755A1 (zh) 虚假新闻检测方法、装置、设备及存储介质
WO2021238563A1 (zh) 基于配置算法的企业运行数据分析方法、装置、电子设备及介质
WO2023029511A1 (zh) 在线医疗处方用药智能检查方法、装置、设备及存储介质
US20170116250A1 (en) System and Method for Identifying Answer Key Problems in a Natural Language Question and Answering System
CN113806434B (zh) 大数据处理方法、装置、设备及介质
WO2022121158A1 (zh) 语音合成方法、装置、电子设备及存储介质
WO2022194062A1 (zh) 疾病标签检测方法、装置、电子设备及存储介质
CN112507663A (zh) 基于文本的判断题生成方法、装置、电子设备及存储介质
WO2023178978A1 (zh) 基于人工智能的处方审核方法、装置、设备及介质
CN113887941A (zh) 业务流程生成方法、装置、电子设备及介质
WO2023040145A1 (zh) 基于人工智能的文本分类方法、装置、电子设备及介质
WO2022227171A1 (zh) 关键信息提取方法、装置、电子设备及介质
CN114840684A (zh) 基于医疗实体的图谱构建方法、装置、设备及存储介质
CN112214602B (zh) 基于幽默度的文本分类方法、装置、电子设备及存储介质
WO2023178979A1 (zh) 问题标注方法、装置、电子设备及存储介质
CN116821373A (zh) 基于图谱的prompt推荐方法、装置、设备及介质
CN111429085A (zh) 合同数据生成方法、装置、电子设备及存储介质
US10084853B2 (en) Distributed processing systems
WO2022141867A1 (zh) 语音识别方法、装置、电子设备及可读存储介质
CN112529743B (zh) 合同要素抽取方法、装置、电子设备及介质
WO2022142019A1 (zh) 基于智能机器人的问题分发方法、装置、电子设备及存储介质
CN114548114A (zh) 文本情绪识别方法、装置、设备及存储介质
CN113591881A (zh) 基于模型融合的意图识别方法、装置、电子设备及介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20931954

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 06.02.2023)

122 Ep: pct application non-entry in european phase

Ref document number: 20931954

Country of ref document: EP

Kind code of ref document: A1