IP Library › Granted Patent US 11,449,500
Granted Patent B2
US 11,449,500 · App. 16/892,874 · Granted Sep 20, 2022

Method and apparatus for outputting structured query sentence

Inventors: Lijie Wang (Beijing, CN); Bo Yu (Beijing, CN); Ke Sun (Beijing, CN); Tingting Li (Beijing, CN)
Assignee: BEIJING BAIDU NETCOM SCIENCE AND TECHNOLOGY CO., LTD.
G06F16/24522G06F16/243G06F16/288G06K9/6224G06K9/6257
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,449,500
App. No.
16/892,874
Filed
Jun 4, 2020
Granted
Sep 20, 2022
Kind
B2
Art Unit
2164
USPC
707/760
Abstract

Embodiments of the present disclosure provide a method and apparatus for outputting a structured query sentence. The method may include: acquiring a to-be-converted natural language sentence; inputting the to-be-converted natural language sentence into a pre-trained sequence to sequence model to obtain an action sequence corresponding to the to-be-converted natural language sentence; generating a directed acyclic graph according to the action sequence; and outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence.

Claims (50)

1. A method for outputting a structured query sentence, comprising:

acquiring a to-be-converted natural language sentence;

inputting the to-be-converted natural language sentence into a pre-trained sequence to sequence model to obtain an action sequence corresponding to the to-be-converted natural language sentence;

generating a directed acyclic graph according to the action sequence; and

outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence;

wherein the sequence to sequence model includes a model trained and obtained by:

acquiring a sample set, the sample set including a sample natural language sentence and a sample structured query sentence corresponding to the sample natural language sentence;

ascertaining a sample directed acyclic graph corresponding to the sample structured query sentence in the sample set according to the preset corresponding relationship;

acquiring a sample action sequence of the ascertained sample directed acyclic graph; and

using respectively the sample natural language sentence and a sample action sequence corresponding to the sample natural language sentence as an input and an output to train and obtain the sequence to sequence model.

2. The method according to claim 1 , wherein the generating a directed acyclic graph according to the action sequence comprises:

generating, based on a shift-reduce algorithm, the directed acyclic graph according to the action sequence.

3. The method according to claim 1 , wherein the directed acyclic graph includes at least one combination of information items, and the combination of the information items includes parent node information, child node information and relationship information.

4. The method according to claim 1 , wherein the outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence comprises:

ascertaining a node in the directed acyclic graph as a first part of the structured query sentence, the first part including an aggregator, a field name, a table name and an attribute; and

ascertaining a relationship between nodes in the directed acyclic graph as a second part of the structured query sentence.

5. An apparatus for outputting a structured query sentence, comprising:

at least one processor; and

a memory storing instructions, wherein the instructions when executed by the at least one processor, cause the at least one processor to perform operations, the operations comprising:

acquiring a to-be-converted natural language sentence;

inputting the to-be-converted natural language sentence into a pre-trained sequence to sequence model to obtain an action sequence corresponding to the to-be-converted natural language sentence;

generating a directed acyclic graph according to the action sequence; and

outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence;

wherein the sequence to sequence model includes a model trained and obtained by:

acquiring a sample set, the sample set including a sample natural language sentence and a sample structured query sentence corresponding to the sample natural language sentence;

ascertaining a sample directed acyclic graph corresponding to the sample structured query sentence in the sample set according to the preset corresponding relationship;

acquiring a sample action sequence of the ascertained sample directed acyclic graph; and

using respectively the sample natural language sentence and a sample action sequence corresponding to the sample natural language sentence as an input and an output to train and obtain the sequence to sequence model.

6. The apparatus according to claim 5 , wherein the generating a directed acyclic graph according to the action sequence comprises:

generating, based on a shift-reduce algorithm, the directed acyclic graph according to the action sequence.

7. The apparatus according to claim 5 , wherein the directed acyclic graph includes at least one combination of information items, and the combination of the information items includes parent node information, child node information and relationship information.

8. The apparatus according to claim 5 , wherein the outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence comprises:

ascertaining a node in the directed acyclic graph as a first part of the structured query sentence, the first part including an aggregator, a field name, a table name and an attribute; and

ascertaining a relationship between nodes in the directed acyclic graph as a second part of the structured query sentence.

9. A non-transitory computer readable medium, storing a computer program, wherein the program, when executed by a processor, causes the processor to perform operations, the operations comprising:

acquiring a to-be-converted natural language sentence;

inputting the to-be-converted natural language sentence into a pre-trained sequence to sequence model to obtain an action sequence corresponding to the to-be-converted natural language sentence;

generating a directed acyclic graph according to the action sequence; and

outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence;

wherein the sequence to sequence model includes a model trained and obtained by:

acquiring a sample set, the sample set including a sample natural language sentence and a sample structured query sentence corresponding to the sample natural language sentence;

ascertaining a sample directed acyclic graph corresponding to the sample structured query sentence in the sample set according to the preset corresponding relationship;

acquiring a sample action sequence of the ascertained sample directed acyclic graph; and

using respectively the sample natural language sentence and a sample action sequence corresponding to the sample natural language sentence as an input and an output to train and obtain the sequence to sequence model.

10. The non-transitory computer readable medium according to claim 9 , wherein the generating a directed acyclic graph according to the action sequence comprises:

generating, based on a shift-reduce algorithm, the directed acyclic graph according to the action sequence.

11. The non-transitory computer readable medium according to claim 9 , wherein the directed acyclic graph includes at least one combination of information items, and the combination of the information items includes parent node information, child node information and relationship information.

12. The non-transitory computer readable medium according to claim 9 , wherein the outputting a structured query sentence corresponding to the generated directed acyclic graph according to a preset corresponding relationship between a directed acyclic graph and a structured query sentence comprises:

ascertaining a node in the directed acyclic graph as a first part of the structured query sentence, the first part including an aggregator, a field name, a table name and an attribute; and

ascertaining a relationship between nodes in the directed acyclic graph as a second part of the structured query sentence.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 5, 2020
From: WANG, LIJIE; YU, BO; SUN, KE; LI, TINGTING
To: BEIJING BAIDU NETCOM SCIENCE AND TECHNOLOGY CO., LTD.
Reel/Frame 052858/0333 →
Priority Claims (1)
CN 201911413464.4 · Dec 31, 2019 · national
Continuity (1)
Related Publication 20210200763A1 · Jul 1, 2021
Cited By (1)
US 12,511,282