# US 2025/0094802 A1 · Model training method, model reasoning method, electronic device, and storage medium

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

- Number: US 2025/0094802 A1
- Document ID: US20250094802A1
- Status: Published application
- Kind: A1
- Application number: 18/965,684
- Filed: 2024-12-02
- Published: 2025-03-20
- Earliest claimed: 2024-09-23
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Junyuan SHANG; Guoxia WANG; Yinqi YANG; Shuohuan WANG; Yu SUN
- Web page: https://patentgrep.com/patent/US20250094802A1

## CPC

- G06N 3/08: Learning methods
- G06F 40/284: Lexical analysis, e.g. tokenisation or collocates
- G06N 3/045: Combinations of networks
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Provided is a model training method, a model reasoning method, an electronic device, and a storage medium, relating to the field of data processing, and especially to the technical fields of artificial intelligence, big data, deep learning and large models. The model training method includes: folding an initial token sequence for training a model based on a folding feature value for folding a token sequence to obtain at least a first token sequence subjected to the folding, wherein the initial token sequence represents a token sequence composed of T1 tokens, and the first token sequence has a sequence length less than that of the initial token sequence; and inputting at least the first token sequence into a preset model to train the preset model so as to obtain a target model.

## Claims

### Claim 1

A model training method, comprising:
folding an initial token sequence for training the model based on a folding feature value for folding a token sequence to obtain at least a first token sequence subjected to the folding, wherein the initial token sequence represents a token sequence composed of T1 tokens, and the first token sequence has a sequence length less than that of the initial token sequence; and
inputting at least the first token sequence into a preset model to train the preset model so as to obtain a target model.

### Claim 2 (depends on 1)

The method of claim 1, wherein folding the initial token sequence for training the model to obtain at least the first token sequence subjected to the folding comprises:
folding the initial token sequence to obtain the first token sequence and a second token sequence, wherein the first token sequence comprises t11 tokens displayed after being subjected to the folding, and the second token sequence comprises t12 tokens hidden by the tokens displayed after being subjected to the folding;
wherein inputting at least the first token sequence into the preset model to train the preset model so as to obtain the target model comprises:
adjusting at least some network parameters in the N network layers by using each token in the first token sequence as an input of a first layer of the N network layers comprised in the preset model and at least using each token in the second token sequence as partial inputs of other layers of the N network layers except for the first layer, to obtain the target model;
wherein the N network layers are connected in series, and an output of a jth layer of the N network layers serves as an input of a (j+1)th layer of the N network layers.

### Claim 3 (depends on 2)

The method of claim 2, further comprising:
determining an input of the jth layer based on the folding feature value and a position where the jth layer of the N network layers is located in the N network layers, wherein j has a value depending on the N.

### Claim 4 (depends on 3)

The method of claim 3, wherein determining the input of the jth layer based on the folding feature value and the position where the jth layer of the N network layers is located in the N network layers comprises:
determining the input of the jth layer based on a numerical relationship between a number where the jth layer is located in the N network layers and the folding feature value.

### Claim 5 (depends on 4)

The method of claim 4, wherein determining the input of the jth layer based on the numerical relationship between the number where the jth layer is located in the N network layers and the folding feature value comprises:
in a case of determining that the number where the jth layer is located in the N network layers is less than the folding feature value, obtaining an input of the jth layer based on an implicit output result of a (j−1)th layer and at least one token in the second token sequence;
or,
in a case of determining that the number where the jth layer is located in the N network layers is greater than or equal to the folding feature value, obtaining an input of an ith position of the jth layer based on an implicit output result of a (j−1)th layer.

### Claim 6 (depends on 5)

The method of claim 5, wherein obtaining the input of the jth layer based on the implicit output result of the (j−1)th layer and the at least one token in the second token sequence comprises:
obtaining an input of an ith position of the jth layer based on an implicit output result hij−1 of an ith position of the (j−1)th layer and a token xj+i×s, wherein i has a value depending on a value of the T1 and the folding feature value, and s represents the folding feature value;
wherein obtaining the input of the ith position of the jth layer based on the implicit output result hij−1 of the ith position of the (j−1)th layer and the token xj+i×s comprises:
fusing the implicit output result hij−1 of the ith position of the (j−1)th layer and the token xj+i×s by using a deep folding function so as to use a fused result as the input of the ith position of the jth layer.

### Claim 7 (depends on 5)

The method of claim 5, wherein obtaining the input of the ith position of the jth layer based on the implicit output result of the (j−1)th layer comprises:
using an implicit output result hij−1 of an ith position of a (j−1)th layer as the input of the ith position of the jth layer.

### Claim 8 (depends on 2)

The method of claim 2, wherein adjusting the at least some network parameters in the N network layers by using each token in the first token sequence as the input of the first layer of the N network layers comprised in the preset model and at least using each token in the second token sequence as partial inputs of other layers of the N network layers except for the first layer to obtain the target model comprises:
using each token in the first token sequence as the input of the first layer of the N network layers comprised in the preset model and at least using each token in the second token sequence as partial inputs of other layers of the N network layers except for the first layer;
obtaining an output predicted token sequence for predicting a next token of each token in the initial token sequence; and
adjusting the at least some network parameters in the N network layers based on a discrepancy between the predicted token sequence and a target sequence to obtain the target model;
wherein the predicted token sequence comprises a predicted token output by the last layer of the N network layers comprised in the preset model and predicted tokens output by other partial layers of the N network layers except for the last layer;
wherein the number of the network layers for the output predicted tokens except for the last layer is related to the folding feature value;
wherein the number of the network layers for the output predicted tokens is greater than the folding feature value;
wherein in a case where j is greater than or equal to a difference between the total number of the layers and the folding feature value s, the predicted token output from the ith position of the jth layer is used for predicting:
x
(
(
s
-
1
)
-
(
N
-
1
-
j
)
)
+
(
i
+
1
)
×
s
;
wherein i has a value depending on a value of the T1 and the folding feature value.

### Claim 9

A model reasoning method, comprising:
obtaining an initial to-be-reasoned token sequence;
folding the initial to-be-reasoned token sequence based on a folding feature value for folding a token sequence to obtain at least a first target to-be-reasoned token sequence, wherein the initial to-be-reasoned token sequence represents a token sequence composed of T2 tokens, and the first target to-be-reasoned token sequence has a sequence length less than that of the initial to-be-reasoned token sequence; and
inputting at least the first target to-be-reasoned token sequence into a target model to obtain a target reasoning result, wherein the target reasoning result is a next token sequence of the target to-be-reasoned token sequence obtained from prediction.

### Claim 10 (depends on 9)

The method of claim 9, wherein folding the initial to-be-reasoned token sequence to obtain at least the first target to-be-reasoned token sequence comprises:
folding the initial to-be-reasoned token sequence to obtain the first target to-be-reasoned token sequence and a second target to-be-reasoned token sequence, wherein the first target to-be-reasoned token sequence comprises t21 tokens displayed after being subjected to the folding, and the second target to-be-reasoned token sequence comprises t22 tokens hidden by the tokens displayed after being subjected to the folding;
wherein inputting at least the first target to-be-reasoned token sequence into the target model to obtain the target reasoning result comprises:
using each token in the first target to-be-reasoned token sequence as an input of a first layer of N target network layers comprised in the target model and at least using each token in the second target to-be-reasoned token sequence as partial inputs of other layers of the N target network layers except for the first layer to obtain a target reasoning result;
wherein the N target network layers are connected in series, and an output of a jth layer of the N target network layers serves as an input of a (j+1)th layer of the N target network layers.

### Claim 11 (depends on 10)

The method of claim 10, further comprising:
determining an input of the jth layer of the N target network layers based on the folding feature value and a position where the jth layer of the N target network layers is located in the N target network layers, wherein j has a value depending on the N.

### Claim 12 (depends on 11)

The method of claim 11, wherein determining the input of the jth layer of the N target network layers based on the folding feature value and the position where the jth layer of the N target network layers is located in the N target network layers comprises:
determining the input of the jth layer of the N target network layers based on a numerical relationship between a number where the jth layer of the N target network layers is located in the N target network layers and the folding feature value.

### Claim 13 (depends on 12)

The method of claim 12, wherein determining the input of the jth layer of the N target network layers based on the numerical relationship between the number where the jth layer of the N target network layers is located in the N target network layers and the folding feature value comprises:
in a case of determining that the number where the jth layer of the N target network layers is located in the N target network layers is less than the folding feature value, obtaining the input of the jth layer of the N target network layers based on an implicit output result of a (j−1)th layer of the N target network layers and at least one token in the second target to-be-reasoned token sequence;
or,
in a case of determining that the number where the jth layer of the N target network layers is located in the N target network layers is greater than or equal to the folding feature value, obtaining an input of an ith position of the jth layer of the N target network layers based on an implicit output result of a (j−1)th layer of the N target network layers.

### Claim 14 (depends on 13)

The method of claim 13, wherein obtaining the input of the jth layer of the N target network layers based on an implicit output result of the (j−1)th layer of the N target network layers and the at least one token in the second target to-be-reasoned token sequence comprises:
obtaining an input of an ith position of the jth layer of the N target network layers based on an implicit output result hij−1 of an ith position of a (j−1)th layer of the N target network layers and a token xj+i×s, wherein i has a value depending on a value of the T2 and the folding feature value, and s represents the folding feature value;
wherein obtaining the input of the ith position of the jth layer of the N target network layers based on the implicit output result hij−1 of the ith position of the (j−1)th layer of the N target network layers and the token xj+i×s comprises:
fusing the implicit output result hij−1 of the ith position of the (j−1)th layer of the N target network layers and the token xj+i×s by using a deep folding function so as to use a fused result as the input of the ith position of the jth layer of the N target network layers.

### Claim 15 (depends on 13)

The method of claim 13, wherein obtaining the input of the ith position of the jth layer of the N target network layers based on the implicit output result of the (j−1)th layer of the N target network layers comprises:
using an implicit output result hij−1 of an ith position of the (j−1)th layer of the N target network layers as the input of the ith position of the jth layer of the N target network layers.

### Claim 16 (depends on 10)

The method of claim 10, wherein obtaining the target reasoning result comprises:
obtaining a target reasoning result output from the last position of last n target network layers of the N target network layers, wherein the target reasoning result is at least a next token of the last token in the initial to-be-reasoned token sequence obtained from prediction.

### Claim 17 (depends on 1)

An electronic device, comprising:
at least one processor; and
a memory, connected in communication with at least one processor,
wherein the memory stores an instruction executable by the at least one processor, and the instruction, when executed by the at least one processor, enables the at least one processor to perform the method of claim 1.

### Claim 18 (depends on 9)

An electronic device, comprising:
at least one processor; and
a memory, connected in communication with at least one processor,
wherein the memory stores an instruction executable by the at least one processor, and the instruction, when executed by the at least one processor, enables the at least one processor to perform the method of claim 9.

### Claim 19 (depends on 1)

A non-transitory computer-readable storage medium storing a computer instruction thereon, wherein the computer instruction is used to cause a computer to perform the method of claim 1.

### Claim 20 (depends on 9)

A non-transitory computer-readable storage medium storing a computer instruction thereon, wherein the computer instruction is used to cause a computer to perform the method of claim 9.
