Document quality detection method and device, storage medium and electronic equipment

By building a vector database and calculating document similarity, the problem of low efficiency in programming document quality detection is solved, and automated and efficient document quality evaluation is achieved.

CN119740046APending Publication Date: 2025-04-01INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411929289.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

In the prior art, the quality inspection of program design documents relies on manual labor, lack of unified and quantitative indicators, resulting in inefficiency and difficulty in achieving large-scale document quality inspection.

Method used

By obtaining the vector data of the document to be detected, a vector database is constructed, and the similarity between the document to be detected and the target document is calculated using the database, and quality detection is performed based on the similarity to obtain the quality level.

Benefits of technology

It realizes automation and efficiency of document quality inspection, and can quickly and accurately evaluate the quality of a large number of documents, improve detection efficiency, and reduce manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119740046A_ABST
    Figure CN119740046A_ABST
Patent Text Reader

Abstract

The invention discloses a document quality detection method and device, a storage medium and electronic equipment, and relates to the technical field of artificial intelligence. The method can comprise the steps of obtaining first vector data of a to-be-detected document; a vector database is constructed, the similarity between the first vector data and second vector data of the target document is determined through the vector database, the vector database is used for storing the first vector data and the second vector data and retrieving the first vector data, and the quality grade of the target document is higher than a grade threshold value; based on the similarity, quality detection is conducted on the to-be-detected document, a quality detection result is obtained, and the quality detection result is at least used for representing the quality level of the to-be-detected document. The technical problem of low efficiency of document quality detection is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a document quality detection method, device, storage medium and electronic device. Background Art

[0002] At present, in the process of software development, the quality of program design documents is crucial to the successful implementation of the project and team collaboration. Program design documents can improve the quality of project implementation from the source, thereby better guiding coding, testing and production.

[0003] In related technologies, program design documents usually rely on manual quality inspection, and the quality evaluation criteria rely on expert experience. There is a lack of unified and quantitative indicators. At the same time, due to the large amount of content in program design documents and the long evaluation time, there is a technical problem of low efficiency in document quality inspection.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a document quality detection method, device, storage medium and electronic device to at least solve the technical problem of low efficiency in quality detection of documents.

[0006] According to one aspect of an embodiment of the present application, a document quality detection method is provided. The method may include: obtaining first vector data of a document to be detected; constructing a vector database, and using the vector database to determine the similarity between the first vector data and the second vector data of a target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, performing quality detection on the document to be detected, and obtaining a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

[0007] Optionally, obtaining first vector data of the document to be detected includes: converting the document to be detected to obtain the first vector data.

[0008] Optionally, converting the document to be detected to obtain first vector data includes: performing vectorization processing on the document to be detected and converting the document to be detected into the first vector data.

[0009] Optionally, vectorization is performed on the document to be detected to convert the document to be detected into first vector data, including: preprocessing the document to be detected to obtain a preprocessed document to be detected; extracting features from the preprocessed document to be detected, and converting the extracted features into first vector data.

[0010] Optionally, feature extraction is performed on the preprocessed document to be detected, and the extracted features are converted into first vector data, including: calling a word embedding model, extracting features from the preprocessed document to be detected, and converting the extracted features into first vector data.

[0011] Optionally, the method further comprises: obtaining a quality evaluation index of the document to be detected, wherein the quality evaluation index is used to represent the quality level of the document to be detected in spatial distribution.

[0012] Optionally, based on the similarity, quality detection is performed on the document to be detected to obtain a quality detection result, including: based on the similarity and the quality assessment index, quality detection is performed on the document to be detected to obtain a quality detection result.

[0013] Optionally, after performing quality detection on the document to be detected based on the similarity and the quality assessment index to obtain the quality detection result, the method further includes: adjusting the document to be detected based on the quality detection result.

[0014] According to another aspect of the embodiment of the present application, a document quality detection device is also provided. The device may include: an acquisition unit, used to acquire first vector data of a document to be detected; a determination unit, used to construct a vector database, and use the vector database to determine the similarity between the first vector data and the second vector data of the target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; a detection unit, used to perform quality detection on the document to be detected based on the similarity, and obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

[0015] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, including: the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any document quality detection method.

[0016] According to another aspect of an embodiment of the present invention, a processor is further provided. The processor is used to run a program. When the program is run, the document quality detection method in the embodiment of the present invention is executed.

[0017] According to another aspect of an embodiment of the present application, there is also provided an electronic device, comprising: a processor; and a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement any document quality detection method.

[0018] According to another aspect of the embodiment of the present application, a computer program product is further provided. The computer program product may include a computer program, wherein the computer program is configured to execute any of the above-mentioned document quality detection methods when running.

[0019] According to another aspect of the embodiment of the present application, a computer program product is also provided. The computer program product may include a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and the computer program is configured to execute any of the above-mentioned document quality detection methods when running.

[0020] According to another aspect of the embodiment of the present application, a computer program is further provided, which is configured to execute any of the above-mentioned document quality detection methods when running.

[0021] In an embodiment of the present application, first vector data of a document to be detected is obtained; a vector database is constructed, and the similarity between the first vector data and the second vector data of the target document is determined using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, a quality detection is performed on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected, thereby achieving the technical effect of improving the efficiency of quality detection of documents, and further solving the technical problem of low efficiency of quality detection of documents. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0023] Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a document quality detection method according to an embodiment of the present application;

[0024] Figure 2 is a flow chart of a document quality detection method according to an embodiment of the present application;

[0025] Figure 3 is a structural schematic diagram of a document quality detection device according to an embodiment of the present application;

[0026] Figure 4 is a schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with relevant laws, regulations and standards, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions to provide users with corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.

[0030] According to an embodiment of the present application, a method embodiment of a document quality detection method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0031] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a document quality detection method is shown. Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0032] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0033] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the document quality detection method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, to implement the above-mentioned document quality detection method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0034] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0035] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0036] Under the above operating environment, this application provides Figure 2 The quality detection method of the document shown. Figure 2 is a flow chart of a document quality detection method according to an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:

[0037] Step S202, obtaining first vector data of the document to be detected.

[0038] In the technical solution provided in the above step S202, first vector data of the document to be detected can be obtained. The document to be detected can be a program design document to be detected. The first vector data can be a vector obtained by converting the document to be detected.

[0039] Optionally, the document to be detected is first obtained, and then vectorization processing is further performed on the obtained document to be detected, so that the document to be detected can be converted into first vector data, thereby obtaining the first vector data.

[0040] Step S204, constructing a vector database, and using the vector database to determine the similarity between the first vector data and the second vector data of the target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold.

[0041] In the technical solution provided in the above step S204, a vector database can be constructed, which can be used to store and retrieve programming documents. The database has the ability to efficiently store vector data and provides flexible query and retrieval functions.

[0042] Optionally, after obtaining the first vector data of the document to be detected, since the vector database provides a similarity calculation method, the vector database can be used to perform similarity calculation on the first vector data and the second vector data of the target document to determine the similarity between the first vector data and the second vector data. The quality level of the target document is higher than the level threshold, the level threshold can be a quality threshold pre-set according to actual conditions, and the target document can be a high-quality document stored in the vector database.

[0043] Optionally, using the similarity calculation method provided by the vector database, the program design document to be tested can be similar to the target document (i.e., an existing high-quality document) to determine the quality level of the program design document to be tested. The cosine similarity method can be used to calculate vector similarity, and the similarity between vectors is measured by calculating the cosine value of the angle between two vectors:

[0044]

[0045] Among them, A and B can be used to represent two vectors, ||A|| can be used to represent the modulus of vector A, ||B|| can be used to represent the modulus of vector B, cos(θ) can be used to represent the cosine value of the angle between vector A and vector B, and the value range of cosine similarity is [-1, 1], 1 can be used to represent complete similarity, and -1 can be used to represent complete dissimilarity. In addition to cosine similarity, Euclidean distance can also be used to measure the similarity between two documents:

[0046]

[0047] Among them, d(A,B) can be used to represent the Euclidean distance between vector A and vector B, n can be used to represent the dimension of the vector, that is, the number of elements contained in the vector, and a i Can be used to represent the value of vector A in the i-th dimension, b i It can be used to represent the value of vector B in the i-th dimension. In addition, the inner product can also be used to measure the similarity between two documents:

[0048]

[0049] Among them, p(A,B) can be used to represent the inner product between vector A and vector B.

[0050] Step S206: Based on the similarity, quality detection is performed on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

[0051] In the technical solution provided in the above step S206, after determining the similarity between the first vector data and the second vector data of the target document using the vector database, a quality test can be performed on the document to be tested based on the determined similarity to obtain a quality test result. The quality test result can at least be used to indicate the quality level of the document to be tested, and the quality test result can also be called an evaluation result.

[0052] Optionally, after determining the similarity between the first vector data and the second vector data of the target document using the vector database, the quality of the program design document to be detected can be evaluated based on the similarity calculation result, and the evaluation result can be output. The evaluation result can include document quality rating, specific problem prompts, etc.

[0053] In an embodiment of the present application, first vector data of a document to be detected is obtained; a vector database is constructed, and the similarity between the first vector data and the second vector data of the target document is determined using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, a quality detection is performed on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected, thereby achieving the technical effect of improving the efficiency of quality detection of documents, and further solving the technical problem of low efficiency of quality detection of documents.

[0054] The above embodiments of the present application are further described below.

[0055] In some embodiments of the present application, step S202, obtaining first vector data of the document to be detected, includes: converting the document to be detected to obtain the first vector data.

[0056] In this embodiment, the document to be detected may be obtained, and further converted to obtain first vector data. Optionally, after obtaining the document to be detected, features may be extracted from the document to be detected, and the extracted features may be converted to first vector data.

[0057] In some embodiments of the present application, converting the document to be detected to obtain first vector data includes: vectorizing the document to be detected and converting the document to be detected into the first vector data.

[0058] In this embodiment, the acquired document to be detected can be vectorized to convert the document to be detected into first vector data. Optionally, the program design document to be detected can be vectorized to convert the program design document to be detected into a high-dimensional vector representation, thereby obtaining the first vector data.

[0059] In some embodiments of the present application, vectorization is performed on the document to be detected to convert the document to be detected into first vector data, including: preprocessing the document to be detected to obtain a preprocessed document to be detected; extracting features from the preprocessed document to be detected, and converting the extracted features into first vector data.

[0060] In this embodiment, after obtaining the document to be detected, the document to be detected may be preprocessed, including removing stop words, cleaning punctuation marks, word segmentation, stem extraction, etc. The preprocessed document to be detected is further subjected to feature extraction, and the extracted features are converted into first vector data.

[0061] This embodiment can remove stop words, clean up punctuation marks, and perform word segmentation by preprocessing the document to be detected, thereby converting the original text into more standardized and clean text data, reducing noise interference, and improving the efficiency and accuracy of subsequent processing.

[0062] In some embodiments of the present application, feature extraction is performed on the preprocessed document to be detected, and the extracted features are converted into first vector data, including: calling a word embedding model, performing feature extraction on the preprocessed document to be detected, and converting the extracted features into first vector data.

[0063] In this embodiment, a word embedding (Word2Vec) model may be called to extract features from the preprocessed document to be detected, and the extracted features may be converted into first vector data. In order to facilitate subsequent retrieval, an index may be created for the generated vector.

[0064] Optionally, the method of extracting features from the preprocessed document to be detected includes: a paragraph vector model (Doc2vec) and a simple contrastive learning sentence embedding model (Simple Contrastive Learning of SentenceEmbeddings, referred to as SimCSE), wherein Doc2vec is a simple method and SimCSE is an advanced method.

[0065] Optionally, the Word2vec model includes two models: the Continuous Bag of Words (CBOW) model and the Skip-gram model. CBOW predicts the middle word given the context, while Skip-gram predicts the context given the middle word. Taking the CBOW model as an example, the objective function of the CBOW model is:

[0066]

[0067] Among them, T can be used to represent the total number of words in the entire training corpus, that is, the length of the sentence, t can be used to represent the position of the word in the sentence, and k can be used to represent the size of the context window, that is, consider k words before and after the center word as context words. w_t can be used to represent the center word, that is, the word at position t, and w_(tk),…,w_(t+k) can be used to represent the context words, that is, the set of k words before and after the center word w_t, excluding w_t itself. The process of predicting the middle word by the CBOW model can be expressed by the following formula:

[0068]

[0069] Among them, w t Can be used to represent the target word, w t-k ,…,w t+k Can be used to represent context words, Can be used to represent the output score of the target word, It can be used to represent the normalization factor, and p can be used to represent the conditional probability of the target word appearing given the context word. Doc2vec can learn fixed-length features from sentences, paragraphs, or documents, and is an extension of the Word2vec model. Doc2vec has two training methods: Distributed Memory Model of Paragraph Vectors (PV-DM) and Distributed Bag of Words version of Paragraph Vector (PV-DBOW). PV-DM and PV-DBOW correspond to the CBOW and Skip-gram training methods in Word2vec, respectively. The difference between Doc2vec and Word2vec is that Doc2vec adds a sentence vector (Paragraph vector) to the input layer. During the training process, the vector is regarded as the main idea of ​​the sentence.

[0070] Alternatively, if a large pre-trained model is used directly to obtain classification tags (e.g., [CLS]) or if average pooling is directly used to obtain the feature vector of the input sentence, the feature representation of each dimension of the word embedding will be inconsistent, resulting in the inability to directly compare the feature vectors at the sentence level. The Doc2vec-based method is simple and easy to implement, but has limited performance. If better text processing capabilities are required, a pre-trained model based on a self-attention mechanism (e.g., Transformer) is required, such as Bidirectional Encoder Representations from Transformers (BERT). However, directly using a large pre-trained model to obtain [CLS] or directly average pooling to obtain the feature vector of the input sentence will result in inconsistent feature representation of each dimension of the word embedding, resulting in the inability to directly compare the feature vectors at the sentence level, so an augmentation operation is required.

[0071] Optionally, SimCSE uses the dropout mask provided by the pre-trained model as an augmentation method to obtain the word vector of the sentence, achieving advanced technology (State of the Art, referred to as SOTA) in unsupervised and supervised semantics. Based on SimCSE, better document vector features can be obtained than Doc2vec.

[0072] In this embodiment, the Word2Vec model can convert each word in the document into a high-dimensional vector representation of a fixed length. These vectors not only capture the semantic information of the word, but also reflect the usage of the word in the context, so that the content of the document can be represented and understood in the form of a vector.

[0073] In some embodiments of the present application, the method further includes: obtaining a quality assessment index of the document to be detected, wherein the quality assessment index is used to represent the quality level of the document to be detected in spatial distribution.

[0074] In this embodiment, a series of quality assessment indicators can be designed according to the quality assessment requirements of the program design document. The quality assessment indicators can at least include indicators such as code specifications, annotation quality, architecture design, reusability, maintainability, performance capacity assessment, and security assessment.

[0075] Optionally, the quality of the spatial distribution of the document word vector can be judged by the two indicators of alignment and uniformity. The smaller the above two indicators are, the better the quality of the document. Among them, alignment can be used to measure whether the spatial distribution distance of the feature space corresponding to similar samples is close enough. Alignment can be expressed by the following formula:

[0076]

[0077] Among them, l align It can be used to represent alignment loss, which is one of the ways to quantify alignment indicators. It is used to measure whether the similar sample feature vectors output by the model are distributed closely enough in space. It can be used to represent the expected value, that is, the average value of the feature vector distance under a certain distribution. (x,x + ) can be used to represent a positive sample pair, x is a sample, and x + is another sample similar to x, which can be different parts of the same document or two documents with similar topics. pos Can be used to represent the probability distribution of positive sample pairs. ||f(x)-f(x + )|| 2 It can be used to represent f(x) and f(x + )The square of the Euclidean distance between two eigenvectors. The smaller the square of the Euclidean distance, the closer the two vectors are in space. Uniformity can be used to measure the diversity of information retained by the system. The features mapped to the unit hypersphere are distributed as evenly as possible on the sphere. The more evenly distributed, the more sufficient the information retained. Uniformity can be expressed by the following formula:

[0078]

[0079] Among them, l uniform It can be used to represent uniformity loss, which is an indicator to measure the uniformity of the distribution of embedded vectors on the unit hypersphere. The smaller the uniformity loss value, the more uniform the vector distribution is and the more sufficient the information is retained. It can be used to represent the data distribution p data The expected values ​​of random samples x and y from . It can be used to indicate that the square of the Euclidean distance is converted into a similarity score through an exponential function. The square of the Euclidean distance is multiplied by -2, and then a value in the range of (0, 1) is calculated through the exponential function e. The closer the two vectors are, the closer the value will be to 1.

[0080] This embodiment can comprehensively reflect the overall quality of program design documents by covering evaluation indicators in multiple dimensions, ensuring that the documents meet high standards in multiple aspects such as technical description, design logic, coding practice, and security specifications.

[0081] In some embodiments of the present application, step S206, based on the similarity, performing quality detection on the document to be detected to obtain a quality detection result, includes: based on the similarity and the quality assessment index, performing quality detection on the document to be detected to obtain a quality detection result.

[0082] In this embodiment, the quality assessment index can transform the abstract document quality standard into a specific, quantifiable index, so that the assessment of document quality is no longer based on subjective judgment, but on measurable values, which helps to improve the objectivity and consistency of the assessment. The quality assessment index covers multiple dimensions of document quality, such as code specifications, comment quality, architecture design, reusability and maintainability, etc., thereby ensuring that the detection process can comprehensively evaluate the document, not just the quality of one aspect.

[0083] Optionally, vector similarity calculation can quickly evaluate document quality, and the designed quality evaluation index can make this evaluation more efficient. Through the rapid retrieval and similarity calculation of the vector database, the quality of a large number of documents can be tested in a very short time, greatly improving the efficiency of quality detection.

[0084] In this embodiment, when the detection results are output, combined with specific quality evaluation indicators, it is easier to understand in which aspects the document performs well and which aspects need improvement, thereby providing developers with clear feedback to help them improve the document in a targeted manner.

[0085] In some embodiments of the present application, after performing quality detection on the document to be detected based on similarity and quality assessment indicators and obtaining the quality detection result, the method further includes: adjusting the document to be detected based on the quality detection result.

[0086] In this embodiment, after quality detection is performed on the document to be detected based on similarity and quality assessment indicators and quality detection results are obtained, targeted quality improvement suggestions can be provided to developers based on the quality detection results, including but not limited to standardized code writing, optimized annotations, improved architecture design, performance capacity assessment, security assessment, etc. Further, based on the above quality improvement suggestions, the document to be detected can be adjusted to improve the quality of the document to be detected.

[0087] In this embodiment, the evaluation results can clearly point out specific problem areas in the document, such as insufficient code standardization, unclear comments, architectural design defects, etc., thereby providing developers with precise improvement directions and avoiding blind modifications and waste of resources.

[0088] In an embodiment of the present application, first vector data of a document to be detected is obtained; a vector database is constructed, and the similarity between the first vector data and the second vector data of the target document is determined using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, a quality detection is performed on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected, thereby achieving the technical effect of improving the efficiency of quality detection of documents, and further solving the technical problem of low efficiency of quality detection of documents.

[0089] In order to facilitate those skilled in the art to better understand the technical solution of the present application, a specific embodiment is now described.

[0090] At present, in the process of software development, the quality of program design documents is crucial to the successful implementation of the project and team collaboration. Program design documents can improve the quality of project implementation from the source, thereby better guiding coding, testing and production. However, since the writing process of program design documents is relatively complex and time-consuming, the quality is usually low.

[0091] In related technologies, the quality inspection of program design documents mainly relies on manual work, which places high demands on the program design evaluation ability of the inspectors. The quality evaluation criteria mainly rely on expert experience and lack unified and quantitative indicators. At the same time, due to the large amount of content in program design documents and the long evaluation time, it is difficult to ensure the quality and quantity of each document.

[0092] Traditional programming document quality inspection usually relies on manual evaluation and lacks quantitative indicators and standards, which leads to subjectivity and uncertainty in the evaluation results and makes it difficult to objectively measure the quality of the documents. Traditional programming document quality inspection usually requires a lot of manual reading and analysis, which is time-consuming and labor-intensive, limits the scale and frequency of inspection, and makes it difficult to timely discover and correct document quality problems. Traditional programming document quality inspection usually differs due to subjective factors of the evaluator. Different evaluators have certain differences in their judgments on document quality, resulting in inconsistent evaluation results. Traditional programming document quality inspection mainly relies on manual operation and lacks automated support, which limits the efficiency and accuracy of the inspection and makes it difficult to achieve large-scale document quality inspection. Traditional programming document quality inspection mainly focuses on surface structure and content problems, and it is difficult to discover implicit quality problems. For example, issues such as architecture design and code specifications may be ignored, resulting in a decline in document quality.

[0093] It should be noted that there are still the following problems in quality inspection of program design documents through database plug-ins and vector search libraries. Quality inspection of program design documents through database plug-ins. More and more traditional relational databases and search systems contain built-in vector search plug-ins. However, this solution does not adopt a full-stack approach to embed management and vector search. Usually these plug-ins are enhancements on top of existing architectures, so they are easily restricted and difficult to optimize. Quality inspection of program design documents through vector search libraries, which can be used for vector similarity search or vector clustering. But these are just lightweight libraries, not managed solutions, and have limited functionality. If the data set is small and limited, then these libraries are sufficient for unstructured data processing, even for systems running in production environments. However, as the size of the data set increases and more users join, the scale problem becomes increasingly difficult to solve.

[0094] In summary, traditional programming document quality inspection has the problems of lack of quantitative indicators, low efficiency, lack of consistency, lack of automation support and difficulty in discovering hidden problems, resulting in technical problems of low efficiency in document quality inspection.

[0095] In order to solve the above problems, this application proposes a programming document quality detection method based on a vector database to improve document quality and enhance development efficiency. In view of the problem of lack of quantitative indicators when performing quality detection on documents in related technologies, the vector database in this application can realize quantitative analysis of document content by converting programming documents into high-dimensional vector representations, and can objectively and quantitatively evaluate the quality of documents by calculating the similarity between vectors. In view of the problem of low efficiency when performing quality detection on documents in related technologies, the vector database in this application provides the ability to efficiently store and retrieve vector data, which can realize large-scale document quality detection. Through the similarity calculation method of the vector database, the quality level of the document can be quickly and accurately judged, thereby improving the efficiency of detection.

[0096] In view of the lack of consistency in document quality testing in related technologies, the similarity calculation method of the vector database in this application can provide consistent evaluation results. By calculating the similarity between the document to be tested and the existing high-quality documents, the differences caused by the subjective factors of the evaluator can be avoided, and the consistency of the evaluation results can be improved. In view of the lack of automated support for document quality testing in related technologies, the similarity calculation method of the vector database in this application can realize automated document quality testing. By writing corresponding programs and algorithms, large-scale document quality testing can be achieved, improving the efficiency and accuracy of testing. In view of the difficulty in discovering hidden problems when performing document quality testing in related technologies, the similarity calculation method of the vector database in this application can discover hidden quality problems. By calculating the similarity between the document to be tested and the existing high-quality documents, implicit quality problems such as architecture design and code specifications can be discovered, thereby improving document quality.

[0097] In summary, vector databases can solve technical problems such as lack of quantitative indicators, low efficiency, lack of consistency, lack of automation support, and difficulty in discovering hidden problems in the quality detection of programming documents. Through the similarity calculation method of vector databases, objective quantitative evaluation of document quality can be achieved, the efficiency and accuracy of detection can be improved, and hidden quality problems can be discovered, thereby improving the quality of programming documents.

[0098] In this embodiment, a vector database is first established to store and retrieve programming documents. The database should have the ability to efficiently store vector data and provide flexible query and retrieval functions. The programming documents are further vectorized, that is, the documents are converted into high-dimensional vector representations. The documents need to be preprocessed here, including removing stop words, punctuation cleaning, word segmentation, stem extraction, etc. Then feature extraction is performed on the document, and the document content is converted into vectors using the Word2Vec model. In order to facilitate subsequent retrieval, an index needs to be created for the generated vector.

[0099] There are two ways to extract features from documents: Doc2vec and SimCSE. There are two Word2vec models: CBOW and Skip-gram. CBOW predicts the middle word given the context, while Skip-gram predicts the context given the middle word. Taking the CBow model as an example, the objective function of the CBow model is:

[0100]

[0101] The process of predicting the middle word by the CBow model can be expressed by the following formula:

[0102]

[0103] Doc2vec can learn fixed-length features from sentences, paragraphs, or documents. It is an extension of Word2vec. Doc2vec has two training methods: PV-DM and PV-DBOW, which correspond to the CBOW and Skip-gram training methods in Word2vec. Doc2vec is different from Word2vec in that it adds a Paragraph vector to the input layer. During the training process, the vector is regarded as the main idea of ​​the sentence.

[0104] If you directly use a pre-trained large model to obtain [CLS] or directly average pool to obtain the feature vector of the input sentence, it will lead to inconsistent feature representation of each dimension of word embedding, resulting in the inability to directly compare the obtained sentence-level feature vectors.

[0105] The advantage of the Doc2vec-based method is that it is simple and easy to implement, but its performance is limited. If you need to obtain better text processing capabilities, you need to use the pre-trained model BERT built on Transformer. However, directly using a pre-trained large model to obtain [CLS] or directly averaging the pooling to obtain the feature vector of the input sentence will result in inconsistent feature representations of each dimension of word embedding, resulting in the inability to directly compare the obtained sentence-level feature vectors. Therefore, augmentation operations are required. SimCSE uses the Dropout mask that comes with the pre-trained model as an augmentation method to obtain the word vector of the sentence, achieving SOTA in unsupervised and supervised semantics. Based on SimCSE, better document vector features can be obtained than Doc2vec.

[0106] According to the quality assessment requirements of program design documents, a series of evaluation indicators can be designed, including code specifications, annotation quality, architecture design, reusability, maintainability, performance capacity assessment, security assessment, etc. Determine the quality of the document word vector in spatial distribution (the smaller the following two indicators, the better):

[0107] Alignment can be used to measure whether the spatial distribution distance of the feature spaces corresponding to similar samples is close enough:

[0108]

[0109] Uniformity can be used to measure the diversity of information retained by the system, mapped to the characteristics of the unit hypersphere, and distributed as evenly as possible on the sphere. The more uniform the distribution, the more sufficient the information retained:

[0110]

[0111] Use the similarity calculation method provided by the vector database to calculate the similarity between the program design document to be tested and the existing high-quality documents to determine their quality level. The cosine similarity method can be used to calculate the similarity between vectors, and their similarity is measured by calculating the cosine value of the angle between two vectors:

[0112]

[0113] In addition to cosine similarity, Euclidean distance can also be used to measure the similarity between two documents:

[0114]

[0115] In addition, the inner product can also be used to measure the similarity between two documents:

[0116]

[0117] According to the similarity calculation results, the quality of the program design document is evaluated and the evaluation results are output. The evaluation results may include document quality ratings, specific problem prompts, etc. According to the evaluation results, targeted quality improvement suggestions are provided to developers, including but not limited to standardized code writing, optimized comments, improved architecture design, performance capacity evaluation, security evaluation, etc. Through the above technical solution, the quality detection of program design documents based on vector database can be realized.

[0118] The program design document quality inspection method based on the vector database of this embodiment can automatically inspect the quality of the document, reducing the tediousness and time-consuming of manual inspection. The vector database can efficiently store and process large-scale program design documents, making the quality inspection faster and more efficient. The vector database can accurately calculate and compare the similarity or distance between program design documents, so as to more accurately evaluate the quality of the document and reduce the influence of subjective factors.

[0119] In this embodiment, the vector database can support large-scale programming documents and can be expanded according to needs to meet the needs of different projects and application scenarios. The vector database can conveniently manage and maintain the quality inspection results of programming documents, which is convenient for subsequent updates and maintenance. The programming document quality inspection method based on the vector database can be customized according to specific projects and needs to meet specific quality inspection requirements.

[0120] In summary, the programming document quality inspection method based on vector database can evaluate the document quality quickly, accurately and reliably, and has the advantages of scalability and easy maintenance. It can provide guidance for quality improvement for the development team and improve the efficiency and quality of the entire development process.

[0121] In an embodiment of the present application, first vector data of a document to be detected is obtained; a vector database is constructed, and the similarity between the first vector data and the second vector data of the target document is determined using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, a quality detection is performed on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected, thereby achieving the technical effect of improving the efficiency of quality detection of documents, and further solving the technical problem of low efficiency of quality detection of documents.

[0122] The embodiment of the present application also provides a document quality detection device. It should be noted that the document quality detection device of this embodiment can be used to execute the document quality detection method of the embodiment of the present invention.

[0123] Figure 3 is a schematic diagram of the structure of a document quality detection device according to an embodiment of the present application, such as Figure 3 As shown, the document quality detection device 300 may include: an acquisition unit 302 , a determination unit 304 and a detection unit 306 .

[0124] The acquisition unit 302 is used to acquire first vector data of the document to be detected.

[0125] The determination unit 304 is used to construct a vector database and use the vector database to determine the similarity between the first vector data and the second vector data of the target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold.

[0126] The detection unit 306 is used to perform quality detection on the document to be detected based on the similarity to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

[0127] Optionally, the acquisition unit 302 includes: a conversion module, configured to convert the document to be detected to obtain first vector data.

[0128] Optionally, the conversion module includes: a processing submodule, configured to perform vectorization processing on the document to be detected, and convert the document to be detected into first vector data.

[0129] Optionally, the processing submodule is further used to: preprocess the document to be detected to obtain the preprocessed document to be detected; extract features from the preprocessed document to be detected, and convert the extracted features into first vector data.

[0130] Optionally, the processing submodule is further used to: call the word embedding model, perform feature extraction on the preprocessed document to be detected, and convert the extracted features into first vector data.

[0131] Optionally, the device further includes: a first acquisition unit, configured to acquire a quality evaluation index of the document to be detected, wherein the quality evaluation index is used to represent a quality level of the document to be detected in spatial distribution.

[0132] Optionally, the detection unit 306 includes: a detection module, configured to perform quality detection on the document to be detected based on similarity and quality assessment indicators to obtain a quality detection result.

[0133] Optionally, in the detection module, which is used to perform quality detection on the document to be detected based on the similarity and the quality assessment index, after obtaining the quality detection result, the device also includes: an adjustment unit, which is used to adjust the document to be detected based on the quality detection result.

[0134] In the device, the first vector data of the document to be detected is obtained by the acquisition unit 302. The vector database is constructed by the determination unit 304, and the similarity between the first vector data and the second vector data of the target document is determined by using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold. The detection unit 306 performs quality detection on the document to be detected based on the similarity to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected, thereby achieving the technical effect of improving the efficiency of quality detection of documents, and then solving the technical problem of low efficiency of quality detection of documents.

[0135] It should be noted that the acquisition unit 302, the determination unit 304 and the detection unit 306 correspond to steps S202 to S206, and the three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above embodiment 1. It should be noted that the above modules or units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above modules may also be part of the device and may be run in the computer terminal 10 provided in the embodiment.

[0136] An embodiment of the present application may provide an electronic device, Figure 4 is a structural block diagram of an electronic device according to an embodiment of the present application, such as Figure 4 As shown, the electronic device may include: one or more ( Figure 4(only one is shown) processor 402, memory 404, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0137] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0138] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain the first vector data of the document to be detected; construct a vector database, and use the vector database to determine the similarity between the first vector data and the second vector data of the target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than the level threshold; based on the similarity, perform quality detection on the document to be detected to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

[0139] The processor can also call the information and application program stored in the memory through the transmission device to perform the following steps: converting the document to be detected to obtain first vector data.

[0140] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: vectorize the document to be detected and convert the document to be detected into first vector data.

[0141] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: preprocessing the document to be detected to obtain the preprocessed document to be detected; extracting features from the preprocessed document to be detected, and converting the extracted features into first vector data.

[0142] The processor can also call the information and application programs stored in the memory through the transmission device to perform the following steps: call the word embedding model, extract features from the preprocessed document to be detected, and convert the extracted features into first vector data.

[0143] The processor can also call the information and application program stored in the memory through the transmission device to perform the following steps: obtaining a quality evaluation index of the document to be detected, wherein the quality evaluation index is used to represent the quality level of the document to be detected in spatial distribution.

[0144] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: based on the similarity and quality evaluation indicators, perform quality detection on the document to be detected to obtain a quality detection result.

[0145] The processor may also call the information and application program stored in the memory through the transmission device to perform the following steps: adjusting the document to be inspected based on the quality inspection result.

[0146] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 4 The structure of the electronic device is not limited. Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 4 Different configurations are shown.

[0147] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0148] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the document quality detection method provided in the first embodiment.

[0149] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0150] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the document quality detection method.

[0151] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0152] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0153] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0155] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0156] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0157] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A document quality detection method, characterized in that: include: Acquire first vector data of the document to be detected; constructing a vector database, and using the vector database, determining a similarity between the first vector data and second vector data of a target document, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than a level threshold; Based on the similarity, a quality test is performed on the document to be detected to obtain a quality test result, wherein the quality test result is at least used to indicate a quality level of the document to be detected.

2. The method according to claim 1, characterized in that Obtaining the first vector data of the document to be detected, including: The document to be detected is converted to obtain the first vector data.

3. The method according to claim 2, characterized in that Converting the document to be detected to obtain the first vector data includes: Vectorization processing is performed on the document to be detected, and the document to be detected is converted into the first vector data.

4. The method according to claim 3, characterized in that Performing vectorization processing on the document to be detected to convert the document to be detected into the first vector data includes: Preprocessing the document to be detected to obtain a preprocessed document to be detected; Feature extraction is performed on the preprocessed document to be detected, and the extracted features are converted into the first vector data.

5. The method according to claim 4, characterized in that Extracting features from the preprocessed document to be detected, and converting the extracted features into the first vector data, including: The word embedding model is called to perform feature extraction on the preprocessed document to be detected, and the extracted features are converted into the first vector data.

6. The method according to claim 1, characterized in that The method further comprises: A quality evaluation index of the document to be detected is obtained, wherein the quality evaluation index is used to represent the quality level of the document to be detected in spatial distribution.

7. The method according to claim 6, characterized in that Based on the similarity, the document to be detected is subjected to quality detection to obtain a quality detection result, including: Based on the similarity and the quality assessment index, the quality detection is performed on the document to be detected to obtain the quality detection result.

8. The method according to claim 7, characterized in that After performing quality detection on the document to be detected based on the similarity and the quality assessment index to obtain the quality detection result, the method further includes: Based on the quality detection result, the document to be detected is adjusted.

9. A document quality detection device, characterized in that: include: An acquisition unit, used for acquiring first vector data of a document to be detected; a determining unit, configured to construct a vector database, and determine the similarity between the first vector data and the second vector data of the target document using the vector database, wherein the vector database is used to store the first vector data and the second vector data, and the vector database is used to retrieve the first vector data, and the quality level of the target document is higher than a level threshold; The detection unit is used to perform quality detection on the document to be detected based on the similarity to obtain a quality detection result, wherein the quality detection result is at least used to indicate the quality level of the document to be detected.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 8.

11. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 8 when running.

12. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.