# US 2022/0292265 A1 · Method for determining text similarity, storage medium and electronic device

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

- Number: US 2022/0292265 A1
- Document ID: US20220292265A1
- Status: Published application
- Kind: A1
- Application number: 17/443,608
- Filed: 2021-07-27
- Published: 2022-09-15
- Earliest claimed: 2021-03-09
- Assignees: Beijing Xiaomi Mobile Software Co., Ltd.; Beijing Xiaomi Pinecone Electronics Co., Ltd.
- Applicants: Beijing Xiaomi Mobile Software Co., Ltd.; Beijing Xiaomi Pinecone Electronics Co., Ltd.
- Inventors: Yuankai Guo; Bin Wang; Erli Meng; Liang Shi
- Web page: https://patentgrep.com/patent/US20220292265A1

## CPC

- G06F 40/194: Calculation of difference between files
- G06F 40/40: Processing or translation of natural language (natural language analysis G06F40/20; semantic analysis G06F40/30)
- G06F 40/20: Natural language analysis (semantic analysis of natural language G06F40/30)
- G06F 40/30: Semantic analysis
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for determining text similarity, a storage medium and an electronic device. The method includes: obtaining a first coding sequence corresponding to the first text and a second coding sequence corresponding to the second text; obtaining a first fusion feature corresponding to the first coding sequence and a second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence; converting the first fusion feature and the second fusion feature into a corresponding first semantic feature and a second semantic feature for representing semantics, and determining a text similarity between the first text and the second text based on the first semantic feature and the second semantic feature.

## Claims

### Claim 1

A method for determining text similarity, comprising:
obtaining a first text and a second text required for text similarity calculation;
determining a character string feature between the first text and the second text;
converting the first text and the second text into vector codes respectively, to obtain a first coding sequence corresponding to the first text and a second coding sequence corresponding to the second text;
obtaining a first fusion feature corresponding to the first coding sequence and a second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence;
obtaining a first semantic feature of the first text based on the character string feature, the first coding sequence and the first fusion feature;
obtaining a second semantic feature of the second text based on the character string feature, the second coding sequence and the second fusion feature; and
determining a text similarity between the first text and the second text based on the first semantic feature and the second semantic feature.

### Claim 2 (depends on 1)

The method of claim 1, wherein converting the first text and the second text into vector codes respectively, to obtain the first coding sequence corresponding to the first text and the second coding sequence corresponding to the second text comprises:
obtaining a first character feature vector corresponding to the first text and a second character feature vector corresponding to the second text by respectively converting characters in the first text and the second text into feature vectors correspondingly; and
obtaining the first coding sequence and the second coding sequence by respectively coding the first character feature vector and the second character feature vector.

### Claim 3 (depends on 1)

The method of claim 1, wherein obtaining the first fusion feature corresponding to the first coding sequence and the second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence, comprises:
obtaining an alignment matrix by multiplying elements in the first coding sequence and the second coding sequence;
obtaining the first fusion feature in combination with a first preset calculation formula based on the alignment matrix, the first preset calculation formula being:
a
~
i
=
∑
j
=
1
l
b
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
b
exp
⁡
(
e
i
⁢
k
)
⁢
b
_
j
,
where ãi is the ith element in the first fusion feature, lb is a length of the second coding sequence, eij is an element in the ith row and jth column in the alignment matrix, eik is an element in the ith row and the kth column in the alignment matrix, and bj is the jth element in the second coding sequence; and
obtaining the second fusion feature in combination with a second preset calculation formula based on the alignment matrix, the second preset calculation formula being:
b
˜
i
=
∑
j
=
1
l
a
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
a
exp
⁡
(
e
k
⁢
j
)
⁢
a
_
i
,
where {tilde over (b)}i is the ith element in the second fusion feature, la is a length of the first coding sequence, eij is an element in the ith row and jth column in the alignment matrix, ekj is an element in the kth row and the jth column in the alignment matrix, and āi is the ith element in the first coding sequence.

### Claim 4 (depends on 1)

The method of claim 1, wherein obtaining the first semantic feature of the first text based on the character string feature, the first coding sequence and the first fusion feature, comprises:
obtaining a global feature of the first text by splicing the first coding sequence, the first fusion feature, a difference between the first coding sequence and the first fusion feature, a dot product of the first coding sequence and the first fusion feature, and the character string feature; and
obtaining the first semantic feature by encoding the global feature of the first text.

### Claim 5 (depends on 1)

The method of claim 1, wherein obtaining the second semantic feature of the second text based on the character string feature, the second coding sequence and the second fusion feature, comprises:
obtaining a global feature of the second text by splicing the second coding sequence, the second fusion feature, a difference between the second coding sequence and the second fusion feature, a dot product of the second coding sequence and the second fusion feature, and the character string feature; and
obtaining the second semantic feature by encoding the global feature of the second text.

### Claim 6 (depends on 1)

The method of claim 1, wherein determining the text similarity between the first text and the second text based on the first semantic feature and the second semantic feature, comprises:
performing a pooling process on the first semantic feature and the second semantic feature respectively, to obtain a pooling result corresponding to the first semantic feature and a pooling result corresponding to the second semantic feature;
splicing the pooling result corresponding to the first semantic feature and the pooling result corresponding to the second semantic feature to obtain a splicing feature; and
calculating the text similarity between the first text and the second text based on the splicing feature.

### Claim 7 (depends on 1)

The method of claim 1, wherein the character string feature comprises at least one of word frequency-inverse text frequency, edit distance, Manhattan distance and Jaccard similarity coefficient.

### Claim 8

An electronic device, comprising:
a processor and a memory for storing instructions executable by the processor;
wherein the processor is configured to:
obtain a first text and a second text required for text similarity calculation;
determine a character string feature between the first text and the second text;
convert the first text and the second text into vector codes respectively, to obtain a first coding sequence corresponding to the first text and a second coding sequence corresponding to the second text;
obtain a first fusion feature corresponding to the first coding sequence and a second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence;
obtain a first semantic feature of the first text based on the character string feature, the first coding sequence and the first fusion feature, and to obtain a second semantic feature of the second text based on the character string feature, the second coding sequence and the second fusion feature; and
determine a text similarity between the first text and the second text based on the first semantic feature and the second semantic feature.

### Claim 9 (depends on 8)

The electronic device of claim 8, wherein the processor is configured to:
obtain a first character feature vector corresponding to the first text and a second character feature vector corresponding to the second text by respectively converting characters in the first text and the second text into feature vectors correspondingly; and
obtain the first coding sequence and the second coding sequence by respectively coding the first character feature vector and the second character feature vector.

### Claim 10 (depends on 8)

The electronic device of claim 8, wherein the processor is configured to:
obtain an alignment matrix by multiplying elements in the first coding sequence and the second coding sequence;
obtain the first fusion feature in combination with a first preset calculation formula based on the alignment matrix, the first preset calculation formula being:
a
~
i
=
∑
j
=
1
l
b
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
b
exp
⁡
(
e
i
⁢
k
)
⁢
b
_
j
,
where ãi is the ith element in the first fusion feature, lb is a length of the second coding sequence, eij is an element in the ith row and jth column in the alignment matrix, eik is an element in the ith row and the kth column in the alignment matrix, and bj is the jth element in the second coding sequence; and
obtain the second fusion feature in combination with a second preset calculation formula based on the alignment matrix, the second preset calculation formula being:
b
˜
i
=
∑
j
=
1
l
a
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
a
exp
⁡
(
e
k
⁢
j
)
⁢
a
_
i
,
where {tilde over (b)}i is the ith element in the second fusion feature, la is a length of the first coding sequence, eij is an element in the ith row and jth column in the alignment matrix, ekj is an element in the kth row and the jth column in the alignment matrix, and āi is the ith element in the first coding sequence.

### Claim 11 (depends on 8)

The electronic device of claim 8, wherein the processor is configured to:
obtain a global feature of the first text by splicing the first coding sequence, the first fusion feature, a difference between the first coding sequence and the first fusion feature, a dot product of the first coding sequence and the first fusion feature, and the character string feature; and
obtain the first semantic feature by encoding the global feature of the first text.

### Claim 12 (depends on 8)

The electronic device of claim 8, wherein the processor is configured to:
obtain a global feature of the second text by splicing the second coding sequence, the second fusion feature, a difference between the second coding sequence and the second fusion feature, a dot product of the second coding sequence and the second fusion feature, and the character string feature; and
obtain the second semantic feature by encoding the global feature of the second text.

### Claim 13 (depends on 8)

The electronic device of claim 8, wherein the processor is configured to:
perform a pooling process on the first semantic feature and the second semantic feature respectively, to obtain a pooling result corresponding to the first semantic feature and a pooling result corresponding to the second semantic feature;
splice the pooling result corresponding to the first semantic feature and the pooling result corresponding to the second semantic feature to obtain a splicing feature; and
calculate the text similarity between the first text and the second text based on the splicing feature.

### Claim 14 (depends on 8)

The electronic device of claim 8, wherein the character string feature comprises at least one of word frequency-inverse text frequency, edit distance, Manhattan distance and Jaccard similarity coefficient.

### Claim 15

A non-transitory computer-readable storage medium having computer program instructions stored thereon, wherein when the program instructions are executed by a processor, the processor is caused to implement a method for determining text similarity, and the method comprises:
obtaining a first text and a second text required for text similarity calculation;
determining a character string feature between the first text and the second text;
converting the first text and the second text into vector codes respectively, to obtain a first coding sequence corresponding to the first text and a second coding sequence corresponding to the second text;
obtaining a first fusion feature corresponding to the first coding sequence and a second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence;
obtaining a first semantic feature of the first text based on the character string feature, the first coding sequence and the first fusion feature;
obtaining a second semantic feature of the second text based on the character string feature, the second coding sequence and the second fusion feature; and
determining a text similarity between the first text and the second text based on the first semantic feature and the second semantic feature.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein converting the first text and the second text into vector codes respectively, to obtain the first coding sequence corresponding to the first text and the second coding sequence corresponding to the second text comprises:
obtaining a first character feature vector corresponding to the first text and a second character feature vector corresponding to the second text by respectively converting characters in the first text and the second text into feature vectors correspondingly; and
obtaining the first coding sequence and the second coding sequence by respectively coding the first character feature vector and the second character feature vector.

### Claim 17 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein obtaining the first fusion feature corresponding to the first coding sequence and the second fusion feature corresponding to the second coding sequence based on the first coding sequence and the second coding sequence, comprises:
obtaining an alignment matrix by multiplying elements in the first coding sequence and the second coding sequence;
obtaining the first fusion feature in combination with a first preset calculation formula based on the alignment matrix, the first preset calculation formula being:
a
~
i
=
∑
j
=
1
l
b
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
b
exp
⁡
(
e
i
⁢
k
)
⁢
b
_
j
,
where ãi is the ith element in the first fusion feature, lb is a length of the second coding sequence, eij is an element in the ith row and jth column in the alignment matrix, eik is an element in the ith row and the kth column in the alignment matrix, and bj is the jth element in the second coding sequence; and
obtaining the second fusion feature in combination with a second preset calculation formula based on the alignment matrix, the second preset calculation formula being:
b
˜
i
=
∑
j
=
1
l
a
exp
⁢
(
e
i
⁢
j
)
∑
k
=
1
l
a
exp
⁡
(
e
k
⁢
j
)
⁢
a
_
i
,
where {tilde over (b)}i is the ith element in the second fusion feature, la is a length of the first coding sequence, eij is an element in the ith row and jth column in the alignment matrix, ekj is an element in the kth row and the jth column in the alignment matrix, and āi is the ith element in the first coding sequence.

### Claim 18 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein obtaining the first semantic feature of the first text based on the character string feature, the first coding sequence and the first fusion feature, comprises:
obtaining a global feature of the first text by splicing the first coding sequence, the first fusion feature, a difference between the first coding sequence and the first fusion feature, a dot product of the first coding sequence and the first fusion feature, and the character string feature; and
obtaining the first semantic feature by encoding the global feature of the first text.

### Claim 19 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein obtaining the second semantic feature of the second text based on the character string feature, the second coding sequence and the second fusion feature, comprises:
obtaining a global feature of the second text by splicing the second coding sequence, the second fusion feature, a difference between the second coding sequence and the second fusion feature, a dot product of the second coding sequence and the second fusion feature, and the character string feature; and
obtaining the second semantic feature by encoding the global feature of the second text.

### Claim 20 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein determining the text similarity between the first text and the second text based on the first semantic feature and the second semantic feature, comprises:
performing a pooling process on the first semantic feature and the second semantic feature respectively, to obtain a pooling result corresponding to the first semantic feature and a pooling result corresponding to the second semantic feature;
splicing the pooling result corresponding to the first semantic feature and the pooling result corresponding to the second semantic feature to obtain a splicing feature; and
calculating the text similarity between the first text and the second text based on the splicing feature.
