# US 12,585,885 B2 · Dialogue model training method

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,585,885 B2
- Document ID: US12585885B2
- Status: Granted
- Kind: B2
- Application number: 18/747,641
- Filed: 2024-06-19
- Published: 2024-12-12
- Granted: 2026-03-24
- Earliest claimed: 2023-06-30
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Yanbin Zhao; Siyu Ding; Shuohuan Wang; Yu Sun; Hao Tian; Hua Wu; Haifeng Wang
- Web page: https://patentgrep.com/patent/US12585885B2

## CPC

- G06F 40/35: Discourse or dialogue representation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method is provided. The method includes: obtaining a first sample dataset; inputting at least one first question text corresponding to at least one piece of first sample data into a dialog model separately to obtain at least one first answer prediction result; inputting each second question text into the dialog model to obtain a second answer prediction result output by the dialog model; inputting the second answer prediction result into a reward model to obtain a score of the second answer prediction result output by the reward model; determining a comprehensive loss based on the at least one first answer prediction result, a first answer text of each of the at least one piece of first sample data, and a score corresponding to each of at least one piece of second sample data; and adjusting at least one parameter of the dialog model based on the comprehensive loss.

## Claims

### Claim 1

A training method for a dialog model, comprising:
obtaining a first sample dataset, wherein the first sample dataset includes at least one piece of first sample data and at least one piece of second sample data, wherein each of the at least one piece of first sample data includes a first question text and a first answer text, and wherein each of the at least one piece of second sample data includes a second question text;
performing following first training process by using the first sample dataset to train the dialog model:
inputting at least one first question text corresponding to the at least one piece of first sample data into the dialog model separately to obtain at least one first answer prediction result corresponding to the at least one first question text output by the dialog model;
performing following operations for the second question text of each of the at least one piece of second sample data:
inputting the second question text into the dialog model to obtain a second answer prediction result output by the dialog model; and
inputting the second answer prediction result into a reward model to obtain a score of the second answer prediction result output by the reward model, wherein the reward model is obtained through training based on at least one sample question, a plurality of answer texts corresponding to each of the at least one sample question, and a label of each of the plurality of answer texts indicating a user satisfaction degree of corresponding answer text;
determining a comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and a score corresponding to each of the at least one piece of second sample data; and
adjusting at least one parameter of the dialog model based on the comprehensive loss.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the determining the comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and the score corresponding to each of the at least one piece of second sample data comprises:
determining a first loss based on the first answer text and a corresponding first answer prediction result of each of the at least one piece of first sample data;
determining a second loss based on at least one score corresponding to the at least one piece of second sample data; and
determining the comprehensive loss based on the first loss and the second loss.

### Claim 3 (depends on 2)

The method according to claim 2, wherein the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining a mean value and a variance of the at least one score;
normalizing each of the at least one score based on the mean value and the variance to obtain an updated score; and
determining the second loss based on at least one updated score.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the determining the comprehensive loss based on the first loss and the second loss comprises:
weighting the first loss and the second loss based on a first preset weight corresponding to the first loss and a second preset weight corresponding to the second loss to obtain the comprehensive loss.

### Claim 5 (depends on 4)

The method according to claim 4, further comprising:
obtaining a pre-trained language model and a second sample dataset, wherein the second sample dataset includes at least one piece of third sample data, wherein each of the at least one piece of third sample data includes a third question text and a third answer text, and wherein the pre-trained language model is obtained through training based on a preset quantity of unsupervised sample corpora; and
repeating, before training the dialog model by using the first sample dataset, following training operations for the pre-trained language model based on each piece of third sample data in the second sample dataset until the pre-trained language model converges, to obtain an initial dialog model:
inputting the third question text corresponding to a piece of third sample data into the pre-trained language model to obtain a third answer prediction result output by the pre-trained language model; and
adjusting at least one parameter of the pre-trained language model based on the third answer prediction result and a third answer text corresponding to the piece of third sample data to update the pre-trained language model.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the dialog model is obtained by performing, at least once, the first training process to the initial dialog model, and wherein the method further comprises:
inputting, for the second question text of each of the at least one piece of second sample data, the second question text into the initial dialog model to obtain a fourth answer prediction result output by the initial dialog model; and wherein
the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining the second loss based on the at least one score, and the second question text, the second answer prediction result, and the fourth answer prediction result corresponding to each of the at least one piece of second sample data.

### Claim 7 (depends on 6)

The method according to claim 6, wherein a first quantity of the at least one piece of first sample data and a second quantity of the at least one piece of second sample data are both plural, and wherein the first quantity and the second quantity meet a preset ratio.

### Claim 8

An electronic device, comprising:
one or more processors; and
a memory storing one or more programs configured to be executed by the one or more processors, wherein the one or more programs comprising instructions for:
obtaining a first sample dataset, wherein the first sample dataset includes at least one piece of first sample data and at least one piece of second sample data, wherein each of the at least one piece of first sample data includes a first question text and a first answer text, and wherein each of the at least one piece of second sample data includes a second question text;
performing following first training process by using the first sample dataset to train a dialog model:
inputting at least one first question text corresponding to the at least one piece of first sample data into the dialog model separately to obtain at least one first answer prediction result corresponding to the at least one first question text output by the dialog model;
performing following operations for the second question text of each of the at least one piece of second sample data:
inputting the second question text into the dialog model to obtain a second answer prediction result output by the dialog model; and
inputting the second answer prediction result into a reward model to obtain a score of the second answer prediction result output by the reward model, wherein the reward model is obtained through training based on at least one sample question, a plurality of answer texts corresponding to each of the at least one sample question, and a label of each of the plurality of answer texts indicating a user satisfaction degree of corresponding answer text;
determining a comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and a score corresponding to each of the at least one piece of second sample data; and
adjusting at least one parameter of the dialog model based on the comprehensive loss.

### Claim 9 (depends on 8)

The electronic device according to claim 8, wherein the determining the comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and the score corresponding to each of the at least one piece of second sample data comprises:
determining a first loss based on the first answer text and a corresponding first answer prediction result of each of the at least one piece of first sample data;
determining a second loss based on at least one score corresponding to the at least one piece of second sample data; and
determining the comprehensive loss based on the first loss and the second loss.

### Claim 10 (depends on 9)

The electronic device according to claim 9, wherein the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining a mean value and a variance of the at least one score;
normalizing each of the at least one score based on the mean value and the variance to obtain an updated score; and
determining the second loss based on at least one updated score.

### Claim 11 (depends on 10)

The electronic device according to claim 10, wherein the determining the comprehensive loss based on the first loss and the second loss comprises:
weighting the first loss and the second loss based on a first preset weight corresponding to the first loss and a second preset weight corresponding to the second loss to obtain the comprehensive loss.

### Claim 12 (depends on 11)

The electronic device according to claim 11, wherein the one or more programs further comprising instructions for:
obtaining a pre-trained language model and a second sample dataset, wherein the second sample dataset includes at least one piece of third sample data, wherein each of the at least one piece of third sample data includes a third question text and a third answer text, and wherein the pre-trained language model is obtained through training based on a preset quantity of unsupervised sample corpora; and
repeating, before training the dialog model by using the first sample dataset, following training operations for the pre-trained language model based on each piece of third sample data in the second sample dataset until the pre-trained language model converges, to obtain an initial dialog model:
inputting the third question text corresponding to a piece of third sample data into the pre-trained language model to obtain a third answer prediction result output by the pre-trained language model; and
adjusting at least one parameter of the pre-trained language model based on the third answer prediction result and a third answer text corresponding to the piece of third sample data to update the pre-trained language model.

### Claim 13 (depends on 12)

The electronic device according to claim 12, wherein the dialog model is obtained by performing, at least once, the first training process to the initial dialog model, and wherein the one or more programs further comprising instructions for:
inputting, for the second question text of each of the at least one piece of second sample data, the second question text into the initial dialog model to obtain a fourth answer prediction result output by the initial dialog model; and wherein
the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining the second loss based on the at least one score, and the second question text, the second answer prediction result, and the fourth answer prediction result corresponding to each of the at least one piece of second sample data.

### Claim 14 (depends on 13)

The electronic device according to claim 13, wherein a first quantity of the at least one piece of first sample data and a second quantity of the at least one piece of second sample data are both plural, and wherein the first quantity and the second quantity meet a preset ratio.

### Claim 15

A non-transitory computer-readable storage medium, storing one or more programs comprising instructions that, when executed by one or more processors of a computing device, cause the computing device to perform operations comprising:
obtaining a first sample dataset, wherein the first sample dataset includes at least one piece of first sample data and at least one piece of second sample data, wherein each of the at least one piece of first sample data includes a first question text and a first answer text, and wherein each of the at least one piece of second sample data includes a second question text;
performing following first training process by using the first sample dataset to train a dialog model:
inputting at least one first question text corresponding to the at least one piece of first sample data into the dialog model separately to obtain at least one first answer prediction result corresponding to the at least one first question text output by the dialog model;
performing following operations for the second question text of each of the at least one piece of second sample data:
inputting the second question text into the dialog model to obtain a second answer prediction result output by the dialog model; and
inputting the second answer prediction result into a reward model to obtain a score of the second answer prediction result output by the reward model, wherein the reward model is obtained through training based on at least one sample question, a plurality of answer texts corresponding to each of the at least one sample question, and a label of each of the plurality of answer texts indicating a user satisfaction degree of corresponding answer text;
determining a comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and a score corresponding to each of the at least one piece of second sample data; and
adjusting at least one parameter of the dialog model based on the comprehensive loss.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the determining the comprehensive loss based on the at least one first answer prediction result, the first answer text of each of the at least one piece of first sample data, and the score corresponding to each of the at least one piece of second sample data comprises:
determining a first loss based on the first answer text and a corresponding first answer prediction result of each of the at least one piece of first sample data;
determining a second loss based on at least one score corresponding to the at least one piece of second sample data; and
determining the comprehensive loss based on the first loss and the second loss.

### Claim 17 (depends on 16)

The non-transitory computer-readable storage medium according to claim 16, wherein the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining a mean value and a variance of the at least one score;
normalizing each of the at least one score based on the mean value and the variance to obtain an updated score; and
determining the second loss based on at least one updated score.

### Claim 18 (depends on 17)

The non-transitory computer-readable storage medium according to claim 17, wherein the determining the comprehensive loss based on the first loss and the second loss comprises:
weighting the first loss and the second loss based on a first preset weight corresponding to the first loss and a second preset weight corresponding to the second loss to obtain the comprehensive loss.

### Claim 19 (depends on 18)

The non-transitory computer-readable storage medium according to claim 18, wherein the operations further comprising:
obtaining a pre-trained language model and a second sample dataset, wherein the second sample dataset includes at least one piece of third sample data, wherein each of the at least one piece of third sample data includes a third question text and a third answer text, and wherein the pre-trained language model is obtained through training based on a preset quantity of unsupervised sample corpora; and
repeating, before training the dialog model by using the first sample dataset, following training operations for the pre-trained language model based on each piece of third sample data in the second sample dataset until the pre-trained language model converges, to obtain an initial dialog model:
inputting the third question text corresponding to a piece of third sample data into the pre-trained language model to obtain a third answer prediction result output by the pre-trained language model; and
adjusting at least one parameter of the pre-trained language model based on the third answer prediction result and a third answer text corresponding to the piece of third sample data to update the pre-trained language model.

### Claim 20 (depends on 19)

The non-transitory computer-readable storage medium according to claim 19, wherein the dialog model is obtained by performing, at least once, the first training process to the initial dialog model, and wherein the operations further comprises:
inputting, for the second question text of each of the at least one piece of second sample data, the second question text into the initial dialog model to obtain a fourth answer prediction result output by the initial dialog model; and wherein
the determining the second loss based on the at least one score corresponding to the at least one piece of second sample data comprises:
determining the second loss based on the at least one score, and the second question text, the second answer prediction result, and the fourth answer prediction result corresponding to each of the at least one piece of second sample data.
