A quantum attention model parameter determination method and device based on a quantum circuit

CN123014249APending Publication Date: 2026-10-30ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510489546.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]本发明提供了一种基于量子线路的量子注意力模型参数确定方法及装置,用以解决现有技术中量子注意力模型中的参数矩阵随着特征维度提升,矩阵之间的内积计算复杂度大大提升,导致计算资源消耗较大;同时需要对各个参数矩阵进行存储以及对内积计算结果进行存储导致占用计算机存储空间较多问题

Benefits of technology

[0032]其有益效果在于:本申请通过构建参数矩阵中多维向量对应的旋转位置矩阵的方式,并结合将目标位置索引对应的旋转位置矩阵编码至第一量子比特形成第一量子态,以及利用振幅编码将所述目标位置索引对应的多维向量编码到第二量子比特形成第二量子态;在第一量子比特和第二量子比特上作用实现第一量子态和第二量子态纠缠的量子逻辑门并测量得到目标多维向量的方式替换传统的正弦和余弦位置编码在高维空间的方式,避免了传统的正弦和余弦位置编码在高维空间中可能会导致位置信息的衰减问题,同时,旋转位置编码的整体计算复杂度从s*d2级别变更为s*log2d级别,大大降低旋转位置编码的内积计算复杂度,从而减少计算资源消耗;同时降低了占用计算机存储空间。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014249A_ABST
    Figure CN123014249A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of quantum computers, in particular to a quantum attention model parameter determination method and device based on a quantum circuit, which comprises the following steps: encoding a rotation position matrix corresponding to a target position index to a first quantum bit to form a first quantum state, and encoding a multidimensional vector corresponding to the target position index to a second quantum bit by using amplitude coding to form a second quantum state; and replacing the traditional sine and cosine position coding in a high-dimensional space by a mode of applying a quantum logic gate for realizing entanglement of the first quantum state and the second quantum state on the first quantum bit and the second quantum bit and measuring to obtain a target multidimensional vector, so that the problem of position information attenuation in the traditional sine and cosine position coding in a high-dimensional space is avoided, and meanwhile, the overall calculation complexity of the rotation position coding is reduced from s*d 2 to s*log2d levels, so that the calculation resource consumption and the computer storage space occupation are greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantum computer technology, and in particular to a method and apparatus for determining parameters of a quantum attention model based on quantum circuits. Background Technology

[0002] The Transformer model is based on a self-attention mechanism, which allows it to process all positions in a sequence in parallel, unlike recurrent neural networks (RNNs) that rely on sequential processing. However, the self-attention mechanism itself does not contain positional information, thus requiring additional positional encoding to incorporate it. Positional encoding ensures that the model can capture sequential information within the sequence, which is crucial for understanding the syntax and semantics of language. Introducing positional information can significantly improve model performance, especially when dealing with long sequences and complex language structures, while traditional sine and cosine positional encoding may lead to attenuation of positional information in high-dimensional spaces.

[0003] However, in existing technologies, when using rotational position encoding to encode the parameter matrix q and parameter matrix k in a transformer model, it is necessary to calculate the inner product of the parameter matrix q and parameter matrix k with dimensions [sequence length s, feature dimension d] with the corresponding rotational position matrix, which has a computational complexity of s*d. 2 As the feature dimension increases, the complexity of inner product calculation between matrices increases significantly, resulting in a large consumption of computing resources. At the same time, when the parameter matrix q and parameter matrix k are used to calculate the inner product with the corresponding rotation position matrix, it is necessary to store each parameter matrix and occupy storage space for the inner product calculation process, resulting in a large consumption of computer storage space. Summary of the Invention

[0004] This invention provides a method and apparatus for determining parameters of a quantum attention model based on quantum circuits, which solves the problem that in the prior art, as the feature dimension of the parameter matrix in the quantum attention model increases, the computational complexity of the inner product between the matrices increases significantly, resulting in a large consumption of computing resources; at the same time, the need to store each parameter matrix and the inner product calculation results leads to a large amount of computer storage space.

[0005] This specification provides an embodiment of a method for determining parameters of a quantum attention model based on quantum circuits, including:

[0006] Obtain the parameter matrix in the quantum attention model; wherein the parameter matrix has position indices and multi-dimensional vectors corresponding to each position index;

[0007] Construct the rotation position matrix corresponding to the multidimensional vector; encode the rotation position matrix corresponding to the target position index into the first qubit to form the first quantum state; and use amplitude encoding to encode the multidimensional vector corresponding to the target position index into the second qubit to form the second quantum state; wherein, the number of the first qubit and the second qubit is equal to the logarithm of the feature dimension of the multidimensional vector to the base 2;

[0008] A quantum logic gate is applied to the first and second qubits to realize the entanglement of the first and second quantum states, and the target multidimensional vector is measured and used as the parameter matrix for updating the quantum attention model.

[0009] Optionally, the step of applying a quantum logic gate to the first and second qubits to achieve entanglement of the first and second quantum states and measuring the target multidimensional vector as the parameter matrix for updating the quantum attention model includes:

[0010] The quantum logic gate for achieving entanglement of the first and second quantum states is determined based on a quantum algorithm; wherein the quantum algorithm includes at least one of exchange testing, singular value estimation, or linear equation solving algorithms;

[0011] The quantum logic gates are applied to the first and second qubits and the target multidimensional vector is measured.

[0012] Update the multidimensional vector corresponding to the target position index in the parameter matrix to the target multidimensional vector;

[0013] The process continues until the multidimensional vectors corresponding to all position indices in the parameter matrix are completely updated, thus obtaining the updated parameter matrix of the quantum attention model.

[0014] Optionally, the parameter matrix includes a query vector matrix and a key vector matrix;

[0015] The acquisition of the parameter matrix in the quantum attention model includes:

[0016] Obtain the word vector data to be trained;

[0017] The query vector matrix and key vector matrix are obtained by performing a linear transformation on the word vector data to be trained.

[0018] Optionally, constructing the rotation position matrix corresponding to the multidimensional vector includes:

[0019] Based on the sequence length of the parameter matrix, construct a rotation position matrix with position index corresponding to the multidimensional vector under each sequence in the sequence length; wherein, the number of rotation position matrices is equal to the sequence length, and each position index corresponds to each sequence in the sequence length.

[0020] Optionally, encoding the rotation position matrix corresponding to the target position index into the first qubit to form the first quantum state includes:

[0021] A single-qubit rotation gate is applied to the first qubit so that the rotation position matrix corresponding to the target position index undergoes quantum state evolution on the first qubit to form the first quantum state.

[0022] Optionally, the formula for calculating the number of the first and second qubits is as follows:

[0023]

[0024] Where n is the number of qubits in the quantum circuit, and d is the characteristic dimension of the parameter matrix. This indicates rounding up to the nearest integer.

[0025] This specification also provides an embodiment of a quantum attention model parameter determination device based on quantum circuits, comprising:

[0026] A parameter matrix acquisition module is used to acquire the parameter matrix in the quantum attention model; wherein, the parameter matrix has position indices and multi-dimensional vectors corresponding to each position index;

[0027] A quantum state forming module is used to construct the rotation position matrix corresponding to the multidimensional vector; encode the rotation position matrix corresponding to the target position index into a first quantum bit to form a first quantum state; and use amplitude encoding to encode the multidimensional vector corresponding to the target position index into a second quantum bit to form a second quantum state; wherein, the number of the first quantum bit and the second quantum bit is equal to the logarithm of the feature dimension of the multidimensional vector to the base 2;

[0028] The parameter matrix update module is used to apply quantum logic gates to the first and second qubits to realize the entanglement of the first and second quantum states and measure the target multidimensional vector as the parameter matrix for updating the quantum attention model.

[0029] A quantum control system that performs quantum computing tasks using the quantum circuit-based quantum attention model parameter determination method described above, or includes the quantum circuit-based quantum attention model parameter determination device described above.

[0030] A quantum computer, comprising a quantum control system as described above.

[0031] A readable storage medium having a computer program stored thereon, which, when executed by a processor, enables the above-described method for determining parameters of a quantum attention model based on quantum circuits.

[0032] Its beneficial effects are as follows: This application constructs a rotation position matrix corresponding to a multidimensional vector in a parameter matrix, and combines this with encoding the rotation position matrix corresponding to the target position index into a first qubit to form a first quantum state, and using amplitude encoding to encode the multidimensional vector corresponding to the target position index into a second qubit to form a second quantum state; it replaces the traditional sine and cosine position encoding in high-dimensional space by applying quantum logic gates to the first and second qubits to realize the entanglement of the first and second quantum states and measuring the target multidimensional vector. This avoids the problem of position information attenuation that may occur in high-dimensional space with traditional sine and cosine position encoding. At the same time, the overall computational complexity of rotation position encoding is reduced from s*d. 2 The level was changed to s*log2d, which greatly reduced the computational complexity of the inner product of the rotation position encoding, thereby reducing the consumption of computing resources; at the same time, it reduced the computer storage space occupied. Attached Figure Description

[0033] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0034] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0035] Figure 1 A flowchart illustrating a method for determining parameters of a quantum attention model based on quantum circuits, provided in an embodiment of this specification.

[0036] Figure 2 A schematic diagram of a quantum attention model parameter determination device based on quantum circuits provided in the embodiments of this specification;

[0037] Figure 3 This is a schematic diagram of a computer-readable medium provided for embodiments of this specification. Detailed Implementation

[0038] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0039] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps described in these embodiments do not limit the scope of the invention.

[0040] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.

[0041] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0042] In all the examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0043] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0044] Self-attention mechanisms (SAMs) can process all positions in a sequence in parallel, unlike recurrent neural networks (RNNs) which rely on sequential processing. However, SAMs themselves do not contain positional information, thus requiring additional positional encoding to incorporate it. Positional encoding ensures that the model captures sequential information within the sequence, which is crucial for understanding the syntax and semantics of language. By introducing positional information, positional encoding can significantly improve model performance, especially when dealing with long sequences and complex language structures.

[0045] In the original self-attention mechanism model, it is assumed that the sequence length of the query vector matrix q and the key vector matrix k is s, and the feature dimension is d. Then, s rotation position matrices Rm are constructed, and the rotation position matrix R... m The dimension of q is [d, d], and it is a unitary matrix; where m is the position index of the current embedded vector, and the value of m ranges from [0, s-1]. When training the self-attention mechanism model, Q is defined as the d-dimensional vector with index m among the s position indices of the query vector matrix q. m And the d-dimensional vector k with index m in the sequence of s position indices of the key vector matrix k. m Then, this Q m Vector and rotation position matrix R mPerforming an inner product calculation yields s vectors of dimension d, which are then concatenated into a matrix of dimension [d, s]. This matrix replaces the original parameter matrix q and contains positional encoding information. Similarly, performing the same rotation position matrix construction and inner product calculation on the key vector matrix k also results in a key vector matrix k containing positional encoding information. However, the inner product approach is used in the process of integrating positional encoding information into the query vector matrix q and the key vector matrix k. This leads to a situation where the query vector matrix q or the key vector matrix k is related to the rotation position matrix R. m The computational complexity for calculating the inner product is s*d. 2 As the dimensionality of the feature d increases, the complexity grows exponentially, consuming a significant amount of computing resources and runtime space, thus reducing the training efficiency of the self-attention mechanism model. To address this, this application proposes a method and apparatus for determining the parameters of a quantum attention model based on quantum circuits. This method utilizes quantum logic gates applied to qubits to replace the query vector matrix q or the key vector matrix k in relation to the rotation position matrix R. m The process of performing inner product calculation reduces the computational complexity to s*log2d, which significantly reduces the computational complexity and thus reduces the computer's computational resource consumption and runtime space consumption, thereby improving the subsequent training efficiency of the self-attention mechanism model.

[0046] Reference Figure 1 A flowchart of a method for determining parameters of a quantum attention model based on quantum circuits, provided in an embodiment of this specification, includes: S101: obtaining a parameter matrix in the quantum attention model; wherein the parameter matrix has position indices and multidimensional vectors corresponding to each position index; S102: constructing a rotation position matrix corresponding to the multidimensional vector; encoding the rotation position matrix corresponding to the target position index into a first qubit to form a first quantum state, and encoding the multidimensional vector corresponding to the target position index into a second qubit using amplitude encoding to form a second quantum state; wherein the number of the first qubit and the second qubit is equal to the logarithm of the characteristic dimension of the multidimensional vector to base 2; S103: applying a quantum logic gate to the first qubit and the second qubit to realize the entanglement of the first quantum state and the second quantum state, and measuring the target multidimensional vector as the parameter matrix for updating the quantum attention model.

[0047] In an optional embodiment, when a quantum computer trains a quantum attention model, it is necessary to first obtain word vector data to be trained, then perform linear transformation on the word vector data to be trained to obtain a query vector matrix and a key vector matrix, that is, the parameter matrix includes the query vector matrix, the key vector matrix, etc. At this time, the query vector matrix and the key vector matrix are both parameter matrices without position information. If such parameter matrices are used, the order information in the sequence cannot be captured, resulting in poor performance of the quantum attention model. For this reason, it is necessary to construct a rotational position matrix, and realize the assignment of position information by integrating the rotational position matrix into the parameter matrix.

[0048] Specifically, the rotational position matrix corresponding to the multidimensional vector is first constructed, and a single-qubit rotation gate is applied to the first qubit to make the rotational position matrix corresponding to the target position index perform quantum state evolution on the first qubit to form a first quantum state. Since the rotational position matrix R corresponding to the target position index m m can be expressed in the following form:

[0049]

[0050] And the matrix form of the RY quantum logic gate can be expressed in the following form:

[0051]

[0052] If we make the variational parameter φ of the RY quantum logic gate satisfy φ=2mθ i Its form exactly corresponds to θ in the rotational position matrix R m i , where i is the dimension index, indicating that the i-th dimension of the vector is currently calculated, i is counted from 0, and the value range of i is 0≤i<d / 2-1, because the rotational position encoding processes the vector in groups of two dimensions.

[0053] To encode the above rotational position matrix R m , only qubits are needed, and a total of s quantum circuits containing such RY quantum logic gates are required to encode all rotational position matrices; where n is the number of qubits in the quantum circuit, d is the feature dimension of the parameter matrix, represents rounding up. Through the above method of applying the RY quantum logic gate in the single-qubit rotation gate to the first qubit to perform quantum state evolution to obtain the first quantum state, and using amplitude encoding to encode the multidimensional vector corresponding to the target position index m into the second qubit to form the second quantum state, the conversion from matrix to quantum state is realized, which provides data support for the subsequent realization of matrix multiplication operation between the rotational position matrix and the query vector matrix or the key vector matrix. ​

[0054] In one alternative embodiment, encoding the multidimensional vector corresponding to the target location index m only requires... A number of qubits, wherein the second quantum state comprises the first sub-quantum state and the second sub-quantum state, that is, using amplitude encoding to generate the multidimensional vector q corresponding to the target position index m in the query vector matrix. m Encoding is performed into the second qubit to form the first sub-quantum state, and amplitude encoding is used to generate the multidimensional vector k corresponding to the target position index m in the key vector matrix. m The second quantum state is formed by encoding the information into the second qubit. Since the quantum algorithm is implemented through quantum circuits, which consist of a series of quantum logic gates, the quantum logic gates for achieving entanglement between the first and second quantum states can be determined based on the quantum algorithm. Then, the quantum logic gates are applied to the first and second qubits, and the target multidimensional vector is measured. Afterward, the multidimensional vector corresponding to the target position index in the parameter matrix is ​​updated to the target multidimensional vector. Finally, the step of encoding the rotation position matrix corresponding to the target position index into the first qubit to form the first quantum state is repeated until all multidimensional vectors corresponding to position indices in the parameter matrix are completely updated, resulting in the updated parameter matrix of the quantum attention model. The quantum algorithm includes at least one of exchange testing, singular value estimation, or linear equation solving algorithms. By implementing matrix multiplication between the rotation position matrix and the query vector matrix or key vector matrix in the above manner, the position information of the rotation position matrix is ​​integrated into the query vector matrix or key vector matrix, reducing the overall computational complexity from s*d. 2 The level is changed to s*log2d, which greatly reduces the computational complexity of the inner product of the rotation position encoding, reduces the consumption of computing resources, and reduces the computer storage space occupied. At the same time, the above method replaces the traditional sine and cosine position encoding in high-dimensional space, avoiding the problem of position information attenuation that may occur in high-dimensional space due to the traditional sine and cosine position encoding.

[0055] Optionally, constructing the rotation position matrix corresponding to the multidimensional vector includes: constructing a rotation position matrix with position index corresponding to the multidimensional vector under each sequence in the sequence length s, based on the sequence length s of the parameter matrix; wherein the number of rotation position matrices is equal to the sequence length, and each position index corresponds to each sequence in the sequence length. For example, if the sequence length s of the parameter matrix is ​​3, then the number of rotation position matrices is 3. The position index corresponding to the first sequence can be denoted as 1, the position index corresponding to the second sequence as 2, and the position index corresponding to the third sequence as 3. The rotation position matrix with position index 1 can be denoted as R1, R2, and R3. The position index is used to associate the multidimensional vector under each sequence with the rotation position matrix, providing index support for subsequent matrix multiplication operations between the rotation position matrix and the query vector matrix or key vector matrix.

[0056] In one optional embodiment, the dimensions of the multidimensional vector corresponding to the target location index and the multidimensional vector with location information are the same as the feature dimensions of the parameter matrix, ensuring the uniformity of dimensions and facilitating subsequent matrix multiplication operations between the rotation position matrix and the query vector matrix or key vector matrix using quantum circuits.

[0057] This application replaces the traditional sine and cosine position encoding in high-dimensional space by constructing rotation position matrices corresponding to multidimensional vectors in a parameter matrix, encoding the rotation position matrix corresponding to the target position index into a first qubit to form a first quantum state, and using amplitude encoding to encode the multidimensional vector corresponding to the target position index into a second qubit to form a second quantum state. A quantum logic gate is applied to the first and second qubits to achieve entanglement between the first and second quantum states, and the target multidimensional vector is measured. This avoids the attenuation of position information that may occur with traditional sine and cosine position encoding in high-dimensional space. Furthermore, the overall computational complexity of rotation position encoding is reduced from s*d. 2 The level was changed to s*log2d, which greatly reduced the computational complexity of the inner product of the rotation position encoding, thereby reducing the consumption of computing resources; at the same time, it reduced the computer storage space occupied.

[0058] Reference Figure 2 This specification also provides an embodiment of a quantum attention model parameter determination device based on quantum circuits, comprising:

[0059] The parameter matrix acquisition module 201 is used to acquire the parameter matrix in the quantum attention model; wherein, the parameter matrix has position indices and multi-dimensional vectors corresponding to each position index;

[0060] The quantum state forming module 202 is used to construct the rotation position matrix corresponding to the multidimensional vector; encode the rotation position matrix corresponding to the target position index into the first quantum bit to form the first quantum state; and use amplitude encoding to encode the multidimensional vector corresponding to the target position index into the second quantum bit to form the second quantum state; wherein, the number of the first quantum bit and the second quantum bit is equal to the logarithm of the feature dimension of the multidimensional vector to the base 2;

[0061] The parameter matrix update module 203 is used to apply quantum logic gates to the first and second qubits to realize the entanglement of the first and second quantum states and measure the target multidimensional vector as the parameter matrix for updating the quantum attention model.

[0062] Optionally, the parameter matrix update module 203 includes:

[0063] A quantum logic gate determination unit is used to determine, based on a quantum algorithm, the quantum logic gate that realizes the entanglement of the first quantum state and the second quantum state; wherein, the quantum algorithm includes at least one of exchange testing, singular value estimation, or linear equation solving algorithms;

[0064] A quantum logic gate action unit is used to act the quantum logic gate on the first and second qubits and measure the target multidimensional vector.

[0065] The parameter matrix update unit is used to update the multidimensional vector corresponding to the target position index in the parameter matrix to the target multidimensional vector.

[0066] The parameter matrix cyclic update unit is used to return the steps of encoding the rotation position matrix corresponding to the target position index into the first quantum bit to form the first quantum state until the multidimensional vectors corresponding to all position indices in the parameter matrix are completely updated, thus obtaining the parameter matrix updated by the quantum attention model.

[0067] Optionally, the parameter matrix includes a query vector matrix and a key vector matrix;

[0068] The parameter matrix acquisition module 201 includes:

[0069] The data acquisition unit is used to acquire word vector data to be trained.

[0070] The linear transformation unit is used to perform a linear transformation on the word vector data to be trained to obtain the query vector matrix and the key vector matrix.

[0071] Optionally, the quantum state forming module 202 includes:

[0072] A rotation position matrix construction unit is used to construct a rotation position matrix with position index corresponding to the multidimensional vector under each sequence in the sequence length according to the sequence length of the parameter matrix; wherein, the number of rotation position matrices is equal to the sequence length, and each position index corresponds to each sequence in the sequence length.

[0073] Optionally, the quantum state forming module 202 further includes:

[0074] A quantum state forming unit is used to apply a single-qubit rotation gate on the first qubit so that the rotation position matrix corresponding to the target position index undergoes quantum state evolution on the first qubit to form the first quantum state.

[0075] Optionally, the formula for calculating the number of the first and second qubits is as follows:

[0076]

[0077] Where n is the number of qubits in the quantum circuit, and d is the characteristic dimension of the parameter matrix. This indicates rounding up to the nearest integer.

[0078] Regarding the apparatus in the above embodiments, the process of performing each step has already been described in the relevant method.

[0079] A quantum control system that performs quantum computing tasks using the quantum circuit-based quantum attention model parameter determination method described above, or includes the quantum circuit-based quantum attention model parameter determination device described above.

[0080] A quantum computer, comprising a quantum control system as described above.

[0081] Reference Figure 3 This is a schematic diagram of a computer-readable medium provided for embodiments of this specification.

[0082] accomplish Figure 1 The computer instructions of the method shown can be stored on one or more computer-readable media. A computer-readable medium can be a readable signal medium or a readable storage medium. A readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0083] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution device, apparatus, or apparatus. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0084] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0085] In summary, this invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that in practice, general-purpose data processing devices such as microprocessors or digital signal processors (DSPs) can be used to implement some or all of the functions of some or all of the components according to the embodiments of the invention. The invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the invention can be stored on a computer-readable medium or can take the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0086] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the present invention is not inherently related to any specific computer, virtual device, or electronic device, and various general-purpose devices can also implement the present invention. The above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0087] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0088] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for determining parameters of a quantum attention model based on quantum circuits, characterized in that, include: Obtain the parameter matrix in the quantum attention model; wherein the parameter matrix has position indices and multi-dimensional vectors corresponding to each position index; Construct the rotation position matrix corresponding to the multidimensional vector; encode the rotation position matrix corresponding to the target position index into the first qubit to form the first quantum state; and use amplitude encoding to encode the multidimensional vector corresponding to the target position index into the second qubit to form the second quantum state; wherein, the number of the first qubit and the second qubit is equal to the logarithm of the feature dimension of the multidimensional vector to the base 2; A quantum logic gate is applied to the first and second qubits to realize the entanglement of the first and second quantum states, and the target multidimensional vector is measured and used as the parameter matrix for updating the quantum attention model.

2. The method as described in claim 1, characterized in that, The process of applying quantum logic gates to the first and second qubits to achieve entanglement of the first and second quantum states, and measuring the target multidimensional vector as the parameter matrix for updating the quantum attention model, includes: The quantum logic gate for achieving entanglement of the first and second quantum states is determined based on a quantum algorithm; wherein the quantum algorithm includes at least one of exchange testing, singular value estimation, or linear equation solving algorithms; The quantum logic gates are applied to the first and second qubits and the target multidimensional vector is measured. Update the multidimensional vector corresponding to the target position index in the parameter matrix to the target multidimensional vector; The process continues until the multidimensional vectors corresponding to all position indices in the parameter matrix are completely updated, thus obtaining the updated parameter matrix of the quantum attention model.

3. The method as described in claim 1, characterized in that, The parameter matrix includes a query vector matrix and a key vector matrix; The acquisition of the parameter matrix in the quantum attention model includes: Obtain the word vector data to be trained; The query vector matrix and key vector matrix are obtained by performing a linear transformation on the word vector data to be trained.

4. The method as described in claim 1, characterized in that, The construction of the rotation position matrix corresponding to the multidimensional vector includes: Based on the sequence length of the parameter matrix, construct a rotation position matrix with position index corresponding to the multidimensional vector under each sequence in the sequence length; wherein, the number of rotation position matrices is equal to the sequence length, and each position index corresponds to each sequence in the sequence length.

5. The method as described in claim 1, characterized in that, Encoding the rotation position matrix corresponding to the target position index into the first qubit to form the first quantum state includes: A single-qubit rotation gate is applied to the first qubit so that the rotation position matrix corresponding to the target position index undergoes quantum state evolution on the first qubit to form the first quantum state.

6. The method as described in claim 1, characterized in that, The formulas for calculating the number of the first and second qubits are as follows: Where n is the number of qubits in the quantum circuit, and d is the characteristic dimension of the parameter matrix. This indicates rounding up to the nearest integer.

7. A device for determining parameters of a quantum attention model based on quantum circuits, characterized in that, include: A parameter matrix acquisition module is used to acquire the parameter matrix in the quantum attention model; wherein, the parameter matrix has position indices and multi-dimensional vectors corresponding to each position index; A quantum state forming module is used to construct the rotation position matrix corresponding to the multidimensional vector; encode the rotation position matrix corresponding to the target position index into a first quantum bit to form a first quantum state; and use amplitude encoding to encode the multidimensional vector corresponding to the target position index into a second quantum bit to form a second quantum state; wherein, the number of the first quantum bit and the second quantum bit is equal to the logarithm of the feature dimension of the multidimensional vector to the base 2; The parameter matrix update module is used to apply quantum logic gates to the first and second qubits to realize the entanglement of the first and second quantum states and measure the target multidimensional vector as the parameter matrix for updating the quantum attention model.

8. A quantum control system, characterized in that, The execution of quantum computing tasks is carried out using the quantum circuit-based quantum attention model parameter determination method as described in any one of claims 1-6, or includes the quantum circuit-based quantum attention model parameter determination device as described in claim 7.

9. A quantum computer, characterized in that, Including the quantum control system as described in claim 8.

10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it can implement the method for determining the parameters of a quantum attention model based on quantum circuits as described in any one of claims 1 to 6.