# US 2026/0087048 A1 · Method for training text retrieval model, method for retrieving text, and related apparatuses

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

- Number: US 2026/0087048 A1
- Document ID: US20260087048A1
- Status: Published application
- Kind: A1
- Application number: 19/408,059
- Filed: 2025-12-03
- Published: 2026-03-26
- Earliest claimed: 2025-08-15
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Jiawen SONG; Junwei XING; Yunpeng PENG; Hui LI; Bingfei ZHANG; Sai GAO; Xiangfei MIN; Wenqing XU; Guanyu CHEN
- Web page: https://patentgrep.com/patent/US20260087048A1

## CPC

- G06F 16/3334: {Selection or weighting of terms from queries, including natural language queries}
- G06F 40/284: Lexical analysis, e.g. tokenisation or collocates
- G06F 40/40: Processing or translation of natural language (natural language analysis G06F40/20; semantic analysis G06F40/30)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for training a text retrieval model, a method for retrieving a text and corresponding apparatuses are provided. An implementation of method comprises: compressing each pair of a query term sample and a candidate text sample into one character string sample; processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample; calculating feature weights of the hidden-layer features of the tokens using a weight determination sub-model in the text retrieval model; calculating, based on the feature weights and the hidden-layer features of the corresponding tokens, to obtain a correlation score between the query term sample and the candidate text sample using a similarity calculation sub-model in the text retrieval model; and training, based on the correlation score, the text retrieval model by means of contrastive learning.

## Claims

### Claim 1

A method for training a text retrieval model, the method comprising:
compressing each pair of a query term sample and a candidate text sample into one character string sample;
processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample;
calculating feature weights of the hidden-layer features of the tokens using a weight determination sub-model in the text retrieval model;
calculating, based on the feature weights and the hidden-layer features of the corresponding tokens and using a similarity calculation sub-model in the text retrieval model, to obtain a correlation score between the query term sample and the candidate text sample; and
training, based on the correlation score, the text retrieval model by means of contrastive learning.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample comprises:
processing the character string sample using the feature extraction sub-model in the text retrieval model to generate an aggregate token;
splitting the character string sample into a plurality of split tokens using the feature extraction sub-model; and
performing feature extraction on a plurality of tokens containing the aggregate token and the plurality of split tokens using the feature extraction sub-module, and outputting the hidden-layer features of the tokens.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample comprises:
outputting hidden-layer sub-features corresponding to the tokens using network layers in the feature extraction sub-model;
determining network weights of the hidden-layer sub-features outputted from the network layers in the feature extraction sub-model; and
determining the hidden-layer features corresponding to the tokens based on the network weights and the corresponding hidden-layer sub-features.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the calculating feature weights of the hidden-layer features of the tokens using a weight determination sub-model in the text retrieval model comprises:
determining a linguistic feature of a token using the weight determination sub-model in the text retrieval model; and
calculating the feature weight of the hidden-layer feature of the token based on the linguistic feature of the token.

### Claim 5 (depends on 1)

The method according to claim 1, wherein the weight determination sub-model is an attention pooling layer.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the calculating, based on the feature weights and the hidden-layer features of the corresponding tokens and using a similarity calculation sub-model in the text retrieval model, to obtain a correlation score between the query term sample and the candidate text sample comprises:
multiplying the feature weights by the hidden-layer features of the corresponding tokens to obtain a plurality of multiplication results; and summing the plurality of multiplication results to obtain a global hidden-layer feature; and
inputting the global hidden-layer feature into the similarity calculation sub-model for calculation, and outputting the correlation score between the query term sample and the candidate text sample.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the inputting the global hidden-layer feature into the similarity calculation sub-model for calculation, and outputting the correlation score between the query term sample and the candidate text sample comprises:
performing correlation score calculation using the similarity calculation sub-model in the text retrieval model, comprising:
performing up-sampling mapping on the global hidden-layer feature to obtain an up-sampled feature, and performing feature filtering on the up-sampled feature to obtain a filtered feature;
performing down-sampling mapping on the filtered feature and the up-sampled feature to obtain a down-sampled feature; and
calculating, based on the down-sampled feature, the correlation score between the query term sample and the candidate text sample.

### Claim 8 (depends on 7)

The method according to claim 7, wherein the similarity calculation sub-model comprises a first mapping layer, a second mapping layer, a first activation layer, a third mapping layer and a second activation layer, and
the inputting the global hidden-layer feature into the similarity calculation sub-model for calculation, and outputting the correlation score between the query term sample and the candidate text sample comprises:
inputting the global hidden-layer feature into the first mapping layer for first up-sampling mapping to output a first up-sampled feature, and performing the feature filtering on the first up-sampled feature using the first activation layer to output a filtered feature;
inputting the global hidden-layer feature into the second mapping layer for second up-sampling mapping to output a second up-sampled feature;
inputting the filtered feature and the second up-sampled feature into the third mapping layer for down-sampling mapping to output the down-sampled feature; and
performing calculation on the down-sampled feature using the second activation layer, and outputting the correlation score between the query term sample and the candidate text sample.

### Claim 9 (depends on 8)

The method according to claim 8, wherein the similarity calculation sub-model comprises a fourth mapping layer, and
the calculating, based on the down-sampled feature, the correlation score between the query term sample and the candidate text sample comprises:
performing dimension mapping on the down-sampled feature using the fourth mapping layer to obtain an output feature of an output dimension; and
inputting the output feature of the output dimension into the second activation layer for calculation, and outputting the correlation score between the query term sample and the candidate text sample.

### Claim 10 (depends on 9)

The method according to claim 9, wherein the similarity calculation sub-model further comprises a random deactivation layer and a normalization layer, and
the performing dimension mapping on the down-sampled feature using the fourth mapping layer to obtain an output feature of an output dimension comprises:
inputting the down-sampled feature into the random deactivation layer for over-fitting processing to output a processed feature;
inputting the processed feature into the normalization layer for normalization processing to output a normalized feature; and
inputting the normalized feature into the fourth mapping layer for the dimension mapping to obtain the output feature of the output dimension.

### Claim 11 (depends on 1)

The method according to claim 1, wherein the feature extraction sub-model is a large language model.

### Claim 12 (depends on 1)

The method according to claim 1, wherein candidate text samples are divided into positive text samples and negative text samples, and correspondingly, correlation scores comprises a positive correlation score between the query term sample and the positive text sample and a negative correlation score between the query term sample and the negative text sample, and
the training, based on the correlation score, the text retrieval model by means of contrastive learning comprises:
inputting the positive correlation score and the negative correlation score into a preset loss function to calculate and obtain a loss value; and
training the text retrieval model based on the loss value.

### Claim 13 (depends on 1)

A method for retrieving a text, by using the text retrieval model obtained according to claim 1, the method comprising:
compressing a query term and a candidate text into one character string;
inputting the character string into the text retrieval model to calculate a correlation score between the query term and the candidate text; and
determining a text retrieval result corresponding to the query term from the candidate text based on the correlation score.

### Claim 14

An apparatus for training a text retrieval model, the apparatus comprising:
at least one processor; and
a memory, in communication with the at least one processor,
wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, to enable the at least one processor to perform operations comprising:
compressing each pair of a query term sample and a candidate text sample into one character string sample;
processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample;
calculating feature weights of the hidden-layer features of the tokens using a weight determination sub-model in the text retrieval model;
calculating, based on the feature weights and the hidden-layer features of the corresponding tokens and using a similarity calculation sub-model in the text retrieval model, to obtain a correlation score between the query term sample and the candidate text sample; and
training, based on the correlation score, the text retrieval model by means of contrastive learning.

### Claim 15 (depends on 14)

The apparatus according to claim 14, wherein the similarity calculation sub-model comprises a first mapping layer, a second mapping layer, a first activation layer, a third mapping layer and a second activation layer, and
the calculating, based on the feature weights and the hidden-layer features of the corresponding tokens and using a similarity calculation sub-model in the text retrieval model, to obtain a correlation score between the query term sample and the candidate text sample, comprises: performing, based on the feature weights and the corresponding hidden-layer features, first up-sampling mapping using the first mapping layer to output a first up-sampled feature, and performing feature filtering on the first up-sampled feature using the first activation layer to output a filtered feature;
performing, based on the feature weights and the corresponding hidden-layer features, second up-sampling mapping using the second mapping layer to output a second up-sampled feature;
inputting the filtered feature and the second up-sampled feature into the third mapping layer for down-sampling mapping, to output a down-sampled feature; and
performing calculation on the down-sampled feature using the second activation layer and output the correlation score between the query term sample and the candidate text sample.

### Claim 16 (depends on 1)

An apparatus for retrieving a text, by using the text retrieval model obtained according to claim 1, the apparatus comprising:
a compressing unit, configured to compress a query term and a candidate text into one character string;
a correlation score calculating unit, configured to input the character string into the text retrieval model to calculate a correlation score between the query term and the candidate text; and
a retrieving unit, configured to determine a text retrieval result corresponding to the query term from the candidate text based on the correlation score.

### Claim 17

A non-transitory computer readable storage medium, storing a computer instruction, wherein the computer instruction is used to cause a computer to perform operations comprising:
compressing each pair of a query term sample and a candidate text sample into one character string sample;
processing the character string sample using a feature extraction sub-model in a text retrieval model to obtain hidden-layer features of tokens in the character string sample;
calculating feature weights of the hidden-layer features of the tokens using a weight determination sub-model in the text retrieval model;
calculating, based on the feature weights and the hidden-layer features of the corresponding tokens and using a similarity calculation sub-model in the text retrieval model, to obtain a correlation score between the query term sample and the candidate text sample; and
training, based on the correlation score, the text retrieval model by means of contrastive learning.
