Code interface specification generation method and device
By generating vector database retrieval and processing of large language model, code interface specifications are automatically generated, which solves the problem of low efficiency in manually writing code interface specifications by developers and improves the efficiency of integrated development of payment systems.
Patent Information
- Application Number
- CN202411119539.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-08-15
AI Technical Summary
In the payment industry, developers need to extract key information from API documents provided by complex and huge card organizations and manually write code interface specifications, resulting in low efficiency in integrated development.
Provide a code interface specification generation method, which obtains the generated requirement data input by the user, searches based on a preset vector database, calls a large language model to process the result sample code, result sample text and generated requirement data, and generates the target code interface specification.
The code interface specifications are not required to be written manually by users, which improves the integrated development efficiency of payment processing and management systems with card organizations and simplifies the development process.
Smart Images

Figure CN118981306B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of payment software development, and in particular to a method and device for generating a code interface specification. Background Art
[0002] In the payment industry, the API (Application Programming Interface) documents or SDK (Software Development Kit) provided by card organizations (such as Visa, MasterCard, etc.) usually contain complex and huge amounts of information, and different card organizations provide different API documents.
[0003] Developers need to extract key information from these documents and manually write code interface specifications such as code interfaces, code explanations, or calling examples to achieve integrated development with card organizations' payment processing and management systems.
[0004] The above-mentioned manual coding method by developers results in low efficiency in integrated development with payment processing and management systems of card organizations. Summary of the invention
[0005] Based on this, it is necessary to provide a method and device for generating code interface specifications that can improve the efficiency of system integration development such as payment processing and management with card organizations in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for generating a code interface specification, comprising:
[0007] Obtaining generation requirement data input by a user, the generation requirement data including a target card organization name and a target interface function;
[0008] Based on the generated demand data, a search process is performed in a preset vector database to obtain a search result, wherein the search result includes a result sample text and a result sample code corresponding to the result sample text;
[0009] The large language model is called to process the result sample code, result sample text and generation requirement data to obtain the target code interface specification, which includes at least one of the target code interface or target code interpretation or target call example corresponding to the target card organization name and the target interface function.
[0010] In one embodiment, a large language model is called to process the result sample code, the result sample text and the generated requirement data to obtain the target code interface specification, including:
[0011] Determining a target prompt word template corresponding to the generation demand data from a plurality of preset prompt word templates;
[0012] Based on the result sample code, the result sample text, the generation requirement data and the target prompt word template, the target prompt word text is obtained;
[0013] The target prompt word text is input into the large language model to obtain the target code interface specification.
[0014] In one embodiment, a search process is performed in a preset vector database based on the generated demand data to obtain a search result, including:
[0015] Vectorize the generated demand data to obtain a query vector;
[0016] Based on the query vector, similarity matching is performed in the vector database to obtain the retrieval result.
[0017] In one embodiment, the vector database includes a plurality of sample vectors, the sample vectors are obtained by vectorizing sample texts, and the sample texts correspond to sample codes;
[0018] Based on the query vector, similarity matching is performed in the vector database to obtain retrieval results, including:
[0019] Determine, from the plurality of sample vectors, a first sample vector whose similarity to the query vector satisfies a preset similarity condition;
[0020] Based on the first sample vector, a search result is obtained.
[0021] In one embodiment, determining, from a plurality of sample vectors, a first sample vector whose similarity with a query vector satisfies a preset similarity condition includes:
[0022] Perform similarity calculation on the query vector and each sample vector respectively to obtain the query similarity value corresponding to each sample vector;
[0023] A sample vector whose query similarity value is greater than a similarity threshold is determined as a first sample vector.
[0024] In one of the embodiments, the number of the first sample vectors is greater than 1;
[0025] Based on the first sample vector, the search results are obtained, including:
[0026] Using the large language model, a relevance filtering process is performed on the first sample text corresponding to the generated demand data and the first sample vector to obtain a second sample text that is relevant to the generated demand data;
[0027] Based on the second sample text, a search result is obtained.
[0028] In one embodiment, the number of the second sample texts is greater than 1; based on the second sample texts, the search results are obtained, including:
[0029] Calling the large language model to perform reverse question generation processing on the first sample text corresponding to the first sample vector to obtain a first sample question corresponding to the first sample text;
[0030] Calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the first sample question, to obtain a sample correlation array corresponding to the first sample question, wherein the sample correlation array includes an identifier corresponding to each second sample text;
[0031] Calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the generated demand data, and obtaining a query correlation array corresponding to the generated demand data, wherein the query correlation array includes an identifier corresponding to each second sample text;
[0032] Perform frequency weighting processing on each second sample text according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each second sample text;
[0033] Based on each correlation value, a search result is obtained.
[0034] In one embodiment, frequency weighting is performed on each second sample text according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each second sample text, including:
[0035] Obtain the number of times the second sample text corresponds to each sequential position;
[0036] Based on the number of times the second sample text corresponds to each sequential position and the weight corresponding to each sequential position, the correlation value corresponding to the second sample text is obtained.
[0037] In one embodiment, based on each relevant value, a search result is obtained, including:
[0038] Performing average calculation on each correlation value to obtain a correlation average value;
[0039] Determine the second sample text whose correlation value is greater than the correlation average value as the result sample text;
[0040] The sample code corresponding to the result sample text is determined as the result sample code.
[0041] In a second aspect, the present application also provides a code interface specification generating device, comprising:
[0042] An input module, used to obtain generation requirement data input by a user, the generation requirement data including a target card organization name and a target interface function;
[0043] A retrieval module, used to perform retrieval processing in a preset vector database based on the generated demand data to obtain retrieval results, wherein the retrieval results include result sample text and result sample code corresponding to the result sample text;
[0044] A generation module is used to call a large language model to process the result sample code, result sample text and generation requirement data to obtain a target code interface specification, which includes at least one of a target code interface or a target code interpretation or a target call example corresponding to the target card organization name and the target interface function.
[0045] The above-mentioned code interface specification generation method and device obtains the generation requirement data input by the user, performs retrieval processing in the preset vector database based on the generation requirement data, and obtains the result sample text and the result sample code corresponding to the result sample text; calls the large language model to process the result sample code, the result sample text and the generation requirement data, and obtains the target code interface specification, wherein the target code interface specification includes at least one of the target code interface or the target code interpretation or the target call example corresponding to the target card organization name and the target interface function. In this way, based on the generation requirement data, the vector database is retrieved to obtain the result sample text and the corresponding result sample code matching the generation requirement data, and then the large language model is called to refer to the retrieved result sample text and result sample code, and based on the user's generation requirement data, the code interface specification corresponding to the generation requirement data is generated; there is no need for the user to manually write the code interface specification, which improves the efficiency of integrated development with the payment processing and management systems of the card organization. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 An application environment diagram of a code interface specification generating method in an embodiment;
[0048] Figure 2 A schematic diagram of a flow chart of a method for generating a code interface specification in one embodiment;
[0049] Figure 3 A schematic diagram of the content structure of an exemplary API document in an embodiment;
[0050] Figure 4A schematic diagram of the content structure of another exemplary API document in an embodiment;
[0051] Figure 5 A schematic diagram of the content structure of a target prompt word template in one embodiment;
[0052] Figure 6 A schematic diagram of the content structure of a target prompt word template in another embodiment;
[0053] Figure 7 A schematic diagram of a flow chart of a step of obtaining a search result in one embodiment;
[0054] Figure 8 A schematic flow chart of the step of obtaining search results in another embodiment;
[0055] Fig. 9 A schematic flow chart of the step of obtaining search results in another embodiment;
[0056] Fig.10 A schematic flow chart of the step of obtaining search results in another embodiment;
[0057] Fig.11 A schematic diagram of a flow chart of a method for generating a code interface specification in another embodiment;
[0058] Fig.12 A structural block diagram of a code interface specification generating device in an embodiment;
[0059] Fig.13 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] The code interface specification generation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones and tablets. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0062] Terminal 102 obtains generation requirement data input by a user, the generation requirement data including a target card organization name and a target interface function; performs search processing in a preset vector database based on the generation requirement data to obtain search results, the search results including a result sample text and a result sample code corresponding to the result sample text; calls a large language model to process the result sample code, the result sample text and the generation requirement data to obtain a target code interface specification, the target code interface specification including at least one of a target code interface or a target code interpretation or a target call example corresponding to the target card organization name and the target interface function.
[0063] In an exemplary embodiment, Figure 2 As shown, a method for generating a code interface specification is provided, and the method is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 202 to 206. Among them:
[0064] Step 202: acquiring generation requirement data input by a user, wherein the generation requirement data includes a target card organization name and a target interface function.
[0065] Among them, the full name of the card organization is the Bank Card Switching and Clearing Agency (also known as the credit card organization or bank card organization), which is an international or regional payment card organization composed of members. It authorizes members to issue cards, accept merchant card transactions, and own and operate its own international regional processing network.
[0066] The card organization name is used to identify the card organization, and the target card organization name refers to the card organization name for which the user currently needs to generate the code interface specification. Exemplarily, the target card organization name can be the name of any card organization.
[0067] Exemplary card organization names may include UnionPay, Visa, Mastercard, and American Express.
[0068] The interface function refers to the specific operation or service implemented by the interface. For example, when the interface function is a payment interface, the specific function may include: processing the user's payment request, verifying the payment information, and executing the transaction and feeding back the result. The target interface function refers to the interface function that the user currently needs to implement.
[0069] The generation requirement data refers to the requirements of the generation code interface specification input by the user. For example, the currently acquired generation requirement data is "how to create a LinkPay order and obtain a payment link?".
[0070] In a possible implementation, the generation requirement data includes a target code type. Exemplarily, the code type may include python, C language, JAVA, C++, etc. The target code type refers to the type of code that the user currently needs to generate. The target code type may be any code type.
[0071] For example, the currently acquired generation requirement data is “how to connect to the Python SDK of the LinkPay payment interface”.
[0072] Step 204 , performing a search process in a preset vector database based on the generated demand data to obtain a search result, wherein the search result includes a result sample text and a result sample code corresponding to the result sample text.
[0073] The preset vector database is pre-built and includes vectorized sample texts and sample codes. It is understandable that a vector in the vector database can be used as an index of a sample text and its corresponding sample code.
[0074] In a possible implementation, the sample text and sample code corresponding to the vector database may include two parts. One part of the sample text and sample code comes from the accumulated code in the industry; illustratively, the sample code is the example code commonly used in the industry and the corresponding text description; the other part of the sample text comes from parsing the API document through a document parsing system, and the sample code is obtained by constructing general web request code snippets in various languages based on the above sample text and Restful API specifications.
[0075] For example, please refer to Figure 3 and 4 , which are the API interface documentation sections of "LinkPay creates an order and obtains a payment link" and "Obtains LinkPay payment results" in the LinkPay API documentation. It can be seen that each API interface contains fixed-format texts such as title, description, endpoint, HTTP method, request parameters, and response parameters; these texts contain common specifications required by Restful API documents. It should be noted that Figure 3 and Figure 4 The content in the above is only a sample part of the corresponding API document, which is only used to illustrate the structure of the API document. The content is not the complete API document content, nor is it necessarily the latest API document content. You can obtain sample text, sample code and corresponding sample vector by following the steps below:
[0076] Step A1: parse the API document to obtain necessary information of the Restful API, including but not limited to API endpoints, HTTP methods, request parameters, and response parameters.
[0077] For example, the API document may be parsed using a corresponding document parser according to its format, such as a PDF (Portable Document Format) parser or a MarkDown parser. For example, a regular expression or other parsing method may be used to obtain necessary information of a Restful API.
[0078] Exemplarily, the necessary information of the acquired Restful API is output in a structured expression.
[0079] Step A2: Based on the necessary information of the above Restful API, a general web request code snippet of each language is constructed according to the Restful specification, such as Python Restful API request code or Java Restful API request code.
[0080] Step A3: Based on the necessary information of the RESTful API, the large language model is called to generate n questions for the necessary information of the RESTful API, where n is an integer greater than or equal to 1.
[0081] Step A4, based on at least part of the necessary information of the Restful API and the n questions, obtain metadata information for the API document; illustratively, the metadata information includes the current LinkPay API description, API endpoint, HTTP method and the n questions generated above.
[0082] Step A5: vectorize the metadata information and the above-mentioned general web request code snippet to obtain a vector for the API document.
[0083] Among them, vectorization is performed according to the granularity of the API interface, that is, one piece of data is vectorized each time. This piece of data contains a single API interface metadata information and the corresponding Restful API code snippet, which ensures the integrity of the API interface when the vector data is saved, and enables highly matched code snippets to be obtained in subsequent vector similarity searches.
[0084] The vector database includes a vector, metadata information corresponding to the vector, and a general web request code snippet.
[0085] In a possible implementation, the vectorization process in step A5 may also only perform vectorization processing on the metadata information to obtain a vector for the API document; wherein the vector database includes the vector, the metadata information corresponding to the vector, and a general web request code snippet.
[0086] Exemplarily, the vectorization process in step A5 can use a bag-of-words model to vectorize the metadata information, or a text conversion vector model such as a word2Vec (Word to Vector) model or a BERT (Bidirectional Encoder Representations from Transformers) model.
[0087] In a possible implementation, the card organization provides a directly usable SDK (Software Development Kit), which users can install and use without writing code interfaces. At the same time, the SDK is equipped with corresponding documents that provide methods for calling code interfaces in the SDK. In this implementation, when the SDK is obtained, it is parsed according to the granularity of the API interface to obtain the sample text and sample code corresponding to each API interface, vectorized, and stored in the vector database.
[0088] The result sample text is a sample text that is retrieved from multiple sample texts in the vector database and matches the generated required data.
[0089] In a possible implementation, the search results include multiple groups of result sample texts and their corresponding result sample codes.
[0090] In a possible implementation, the search result includes a set of result sample texts and their corresponding result sample codes.
[0091] In a possible implementation, the sample text and sample code corresponding to the vector database include sample text and sample code from accumulated codes in the industry.
[0092] In a possible implementation, the sample text corresponding to the vector data is obtained by parsing the API document through a document parsing system, and the sample code is obtained based on the sample text and a common web request code snippet and the sample text.
[0093] In a possible implementation, the vector database is divided into a plurality of vector data sub-databases, and the vector data sub-databases correspond to the card organizations; thus, step 204 further includes: determining a target vector data sub-database from the plurality of vector data sub-databases according to the target card organization name, and searching in the target vector data sub-database based on the generated demand data to obtain a search result. Thus, searching in the target vector data sub-database corresponding to the target card organization name increases the data processing amount during the search, improves the search efficiency, and at the same time, filters the data not related to the target card organization name, and improves the relevance and accuracy of the search result.
[0094] In a possible implementation, step 204 further includes: determining a filtering keyword based on the generated demand data, filtering multiple sample texts in the vector database based on the filtering keyword to obtain a matching database, and performing a search in the matching database based on the generated demand data to obtain a search result. In this way, a portion of the data is first filtered out by the keyword and then the search is performed, thereby improving the efficiency of the search.
[0095] Step 206, calling the large language model to process the result sample code and result sample text and generate the required data to obtain the target code interface specification, which includes at least one of the target code interface or target code interpretation or target call example corresponding to the target card organization name and the target interface function.
[0096] In a possible implementation, based on generation requirement data, result sample code and result sample text are filled into a preset prompt word template to obtain target prompt word text, and the target prompt word text is input into a large language model to obtain a target code interface specification output by the large language model.
[0097] Exemplarily, the preset prompt word template includes structured paragraphs. For example, the first paragraph is "Please answer the following questions based on the context", the second paragraph is "Context to be filled in", which is an area used to fill in the result sample code and result sample text, and the third paragraph is "Question: Question to be filled in", where "Question to be filled in" is used to fill in based on the generated demand data.
[0098] In a possible implementation, a large language model is called to process result sample code, result sample text, and generation requirement data to obtain a target code interface specification, including: determining a target prompt word template corresponding to the generation requirement data from a plurality of preset prompt word templates; obtaining a target prompt word text based on the result sample code, result sample text, generation requirement data, and the target prompt word template; and inputting the target prompt word text into the large language model to obtain a target code interface specification.
[0099] Among them, multiple prompt word templates are used to obtain different answers. For example, one prompt word template corresponds to the prompt word content of generating the target code interface; one prompt word template corresponds to the prompt word content of generating the target code interpretation; Figure 5 ;in, Figure 5 The code content in the dashed box in is filled based on the result sample code; one prompt word template corresponds to the prompt word content of generating the target call example; one prompt word template corresponds to the prompt word content of generating the target code interface, target code explanation and target call example, such as Figure 6 As shown; among them, Figure 6 The contents of the "Code Snippet" section and the "API Information" section are only examples. The "Code Snippet" section is filled based on the result sample code in the search results, and the content of the "API Information" section is filled based on the result sample text.
[0100] Exemplarily, determining a target prompt word template corresponding to the generated demand data from a plurality of preset prompt word templates includes: displaying a plurality of prompt word templates to a user based on the generated demand data, and in response to a user's selection input, determining the prompt word template selected and input by the user as the target prompt word template.
[0101] Exemplarily, determining the target prompt word template corresponding to the generated demand data from the preset multiple prompt word templates includes: determining the prompt word template matching the generated demand data from the multiple prompt word templates by keyword matching as the target prompt word template. The keyword matching method may be a keyword matching method. For example, if the generated demand data includes the word "connection", then the target prompt word template is selected. Figure 5 For example, if the generated requirement data includes the words "call" or "example", select Figure 6 The prompt word template shown.
[0102] It should be noted that the generation of demand data, prompt word templates or prompt word texts in multiple embodiments of the present application are all described in Chinese. It can be understood that in other embodiments of the present application, the generation of demand data, prompt word templates or prompt word texts can also be implemented in other languages.
[0103] In a possible implementation, the generation requirement data input by the user includes the target code type, and the generated target code interface specification corresponds to the target code type. In a possible implementation, the generation requirement data input by the user does not include the target code type, and the generated target code interface specification uses the same code type as the retrieved result sample code, or uses a default code type (such as Python).
[0104] For example, the large language model may use CHAT GPT (Generative Pre-trained Transformer) 3.5, or CHAT GPT 4, etc.
[0105] In a possible implementation, the provided code interface specification generation method further includes verifying the target code interface in the target code interface specification.
[0106] During the verification process, the code checker is used to check the executability of the target code interface, including but not limited to the request method, request parameters, response format, etc. If any non-compliance is found, the code checker can provide modification suggestions to help users adjust and optimize the code interface.
[0107] The code interface specification generation method provided in the above embodiment obtains the generation requirement data input by the user, performs a search process in a preset vector database based on the generation requirement data, and obtains a result sample text and a result sample code corresponding to the result sample text; calls a large language model to process the result sample code, the result sample text and the generation requirement data, and obtains a target code interface specification, wherein the target code interface specification includes at least one of a target code interface or a target code interpretation or a target call example corresponding to the target card organization name and the target interface function. In this way, based on the generation requirement data, a search is performed from the vector database to obtain the result sample text and the corresponding result sample code matching the generation requirement data, and then the large language model is called to refer to the retrieved result sample text and result sample code, and based on the user's generation requirement data, a code interface specification corresponding to the generation requirement data is generated; there is no need for the user to manually write the code interface specification, and the efficiency of integrated development with the payment processing and management systems of the card organization is improved.
[0108] In the above embodiment, the result sample text and result sample code are first retrieved from a preset vector database based on the generation requirement data, and used together as the input of the large language model, so that the large language model generates a code interface specification based on the result sample text and result sample code data, thereby improving the accuracy of the generated code interface specification.
[0109] In an exemplary embodiment, based on Figure 2 The embodiment shown in the figure is a process of performing search processing in a preset vector database based on generating demand data to obtain search results. Figure 7 As shown, the process includes:
[0110] Step 702: vectorize the generated demand data to obtain a query vector.
[0111] Exemplarily, the generation demand data may be vectorized by constructing a vector database to generate corresponding vectors for each sample, such as a bag-of-words model, a word2Vec model, or a BERT model or other text conversion vector model.
[0112] Step 704: perform similarity matching processing in the vector database based on the query vector to obtain a search result.
[0113] In the above embodiment, by constructing a vector database after vectorizing the sample text and determining the search result based on vector matching, the efficiency of searching based on the generated demand data can be improved.
[0114] In an exemplary embodiment, based on Figure 7 In the embodiment shown, the vector database includes a plurality of sample vectors, the sample vectors are obtained by vectorizing the sample text, and the sample text corresponds to the sample code. Figure 8 As shown, the process of performing similarity matching processing in the vector database based on the query vector to obtain the search result includes steps 802 to 804, wherein:
[0115] Step 802: Determine, from a plurality of sample vectors, a first sample vector whose similarity to the query vector satisfies a preset similarity condition.
[0116] In a possible implementation, step 802 further includes: performing similarity calculation processing on the query vector and each sample vector respectively to obtain query similarity values corresponding to each sample vector; and determining the sample vector with the largest query similarity value as the first sample vector.
[0117] In a possible implementation, step 802 further includes: performing similarity calculation processing on the query vector and each sample vector respectively to obtain a query similarity value corresponding to each sample vector; and determining a sample vector having a query similarity value greater than a similarity threshold as a first sample vector.
[0118] The similarity calculation process refers to calculating the proportion of similar characters in two text blocks. For example, the cosine similarity of the vectors corresponding to the two text blocks is calculated to obtain the similarity value of the two vectors. For example, the pre-similarity can be calculated according to the following formula:
[0119]
[0120] Among them, A and B are two vectors of dimension n respectively.
[0121] The query similarity value ranges from 0 to 1. The closer the query similarity value is to 1, the more similar the query vector is to the sample vector.
[0122] In this embodiment, query similarity values within a certain range are used as reference content for generating query data to improve the accuracy of generation. Among them, only sample vectors with query similarity values greater than a similarity threshold are determined as first sample vectors.
[0123] The similarity threshold can be determined based on a large number of experiments. Optionally, the similarity threshold is a value greater than 0.6. Exemplarily, the similarity threshold is 0.68. The applicant found through a large number of tests and comparisons that, for API documents, the accuracy of the subsequently generated code interface specification is higher when the similarity value is greater than 0.68, and the number of first sample vectors obtained at this time is between 1 and 20 (including 1 and 20).
[0124] In a possible implementation, if there is no sample vector whose query similarity value is greater than the similarity threshold, the sample vector with the highest query similarity value can be selected as the first sample vector for output; alternatively, the first sample vector may not be output and a prompt message may be output to prompt the user to modify and generate the required data.
[0125] In a possible implementation, step 802 further includes: performing similarity calculation processing on the query vector and each sample vector respectively to obtain a query similarity value corresponding to each sample vector; sorting the query similarity values in descending order, and determining the sample vectors corresponding to the first k query similarity values as the first sample vector.
[0126] Step 804: Obtain a search result based on the first sample vector.
[0127] In a possible implementation, based on the first sample vector, the sample text corresponding to the first sample vector is determined as the result sample text, and the sample code corresponding to the first sample vector is determined as the result sample code to obtain the search result.
[0128] In one possible implementation, please refer to Fig. 9 The process of obtaining the search result based on the first sample vector includes steps 902 to 904, wherein:
[0129] Step 902: Use a large language model to perform relevance filtering on the generation demand data and the first sample text corresponding to the first sample vector to obtain a second sample text.
[0130] The first sample vector is a sample vector having a higher similarity with the query vector among the multiple sample vectors; however, similarity is not completely equivalent to relevance, and this embodiment further filters the first sample vector from the perspective of relevance.
[0131] If the number of the first sample vectors is equal to 1, the correlation filtering step of this embodiment may also be used to filter whether the first sample vectors are correlated with the generated demand data.
[0132] Exemplarily, a relevance filtering prompt word template is filled based on a first sample text corresponding to the first sample vector to obtain a relevance filtering prompt word text, the relevance filtering prompt word text is input into a large language model, and the first sample vector is filtered according to the answer of the large language model to obtain a second sample vector.
[0133] Exemplarily, the first sample vector constitutes a text paragraph set, and the relevance filtering prompt word template is as follows:
[0134] “Given a passage of text and a query, predict whether the passage contains the answer to the query by answering “yes” or “no”.
[0135] Text: {{passage}};
[0136] Query: {{query}};
[0137] Does the text answer the query?"
[0138] Among them, each first sample text is filled into the {{passage}} part in turn, and {{query}} is filled based on the generated demand data, and the answers of the large language model are collected to obtain a set of answer results corresponding to the text paragraph set; the first sample text with the corresponding answer of "yes" is determined as the second sample text.
[0139] In a possible implementation, the result of using a large language model to filter the relevance of the generated demand data and the first sample texts is that all the first sample texts are irrelevant to the generated demand data, that is, the number of second sample texts is 0. In this implementation, a prompt message may be output to inform the user that no sample text and sample code related to the generated demand data are found and that the demand needs to be further described; illustratively, an example of the generated demand data may be given in the prompt message for the user's reference.
[0140] Step 904: obtaining search results based on the second sample text.
[0141] In a possible implementation, the second sample text is determined as the result sample text, and the sample code corresponding to the second sample text is determined as the result sample code to obtain the search result.
[0142] In a possible implementation, the number of the second sample texts is greater than 1. Fig.10 In this embodiment, the process of obtaining the search result based on the second sample text includes:
[0143] Step 1002: Call the large language model to perform reverse question generation processing on the first sample text corresponding to the first sample vector to obtain a first sample question corresponding to the first sample text.
[0144] Exemplarily, a reverse question prompt word template is filled based on the first sample text to obtain a reverse question prompt word text, and the reverse question prompt word text is input into the large language model to obtain a first sample question corresponding to the first sample text.
[0145] For example, the reverse question prompt word template is as follows:
[0146] “Please read the following text passage and ask a specific and relevant question based on the content of the passage, making sure the question reflects the main idea of the passage or an important detail within it.
[0147] Passage: {{passage}}".
[0148] Among them, each first sample text is filled into the {{passage}} part in turn, and the first sample question output by the large language model is obtained in turn.
[0149] Among them, the possible questions to be asked are generated based on the first sample text to obtain the first sample question; the first sample question is the question that is most similar to the query vector. It can be understood that the first sample question is the question that the user wants to ask but has not expressed. In this embodiment, the method of generating the first sample question based on the first sample vector in step 1002 is adopted to make up for the lack of expression when the user asks a question.
[0150] Step 1004, calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the first sample questions, to obtain a sample correlation array corresponding to the first sample question, wherein the sample correlation array includes identifiers corresponding to the second sample texts.
[0151] Exemplarily, a plurality of second sample texts constitute a related text block set P = [p1, p2, ..., p m ], where p1 refers to the second sample text with sequence number 1, p2 refers to the second sample text with sequence number 2, and so on, and the number of second sample texts is m. For each first sample question, a relevant sorting prompt word template is filled based on the first sample question and the relevant text block set to obtain the relevant sorting prompt word text for the first sample question; the relevant sorting prompt word text is input into the large language model to obtain the sample relevance array of the first sample question.
[0152] Exemplarily, the identifier corresponding to the second sample text is the serial number of each second sample text when the relevant text block set is formed; wherein each element in the sample correlation array is the serial number of each second sample text.
[0153] Exemplarily, the relevant sorting prompt word template may indicate a large language model, and arrange the second sample texts in descending order of relevance, wherein the relevant sorting prompt word template is exemplified as follows:
[0154] “It’s an intelligent assistant that ranks passages based on their relevance to a query.
[0155] Below are {{num}} paragraphs, each with a number []. I can sort them by relevance based on the query {{query}}.
[0156] [1]{{passage_1}}
[0157] [2]{{passage_2}}
[0158] …
[0159] The query is: {{query}}
[0160] I will sort the above {{num}} paragraphs by relevance based on the search query. The paragraphs will be sorted in descending order of relevance, the most relevant paragraphs should be listed first, and the output format should be an array, such as {3, 2, 1, 4}, etc.
[0161] The ranking results for these {{num}} paragraphs (number only) are: ".
[0162] As another example, the relevance prompt word template may indicate a large language model, and arrange the second sample texts in ascending order of relevance.
[0163] Step 1006, calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the generated demand data, and obtaining a query correlation array corresponding to the generated demand data, wherein the query correlation array includes an identifier corresponding to each second sample text.
[0164] Exemplarily, based on generating demand data and a set of related text blocks P = [p1, p2, ..., p m ] is filled into the relevant sorting prompt word template to obtain the relevant sorting prompt word text for generating the demand data; the relevant sorting prompt word text is input into the large language model to obtain the query relevance array for generating the demand data.
[0165] Exemplarily, each sample correlation array and the query correlation array constitute a two-dimensional matrix data M qx , as shown below:
[0166]
[0167] Among them, P'1 represents the query relevance array, P'2 to P' q They refer to the first sample correlation array to the kth sample correlation array respectively, where q refers to the number of rows of the matrix, q=k+1, where k is the number of the first sample problems.
[0168] Step 1008: Perform frequency weighting processing on each second sample text according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each second sample text.
[0169] In a possible implementation, step 1008 further includes: obtaining the number of times the second sample text corresponds to each sequential position; and obtaining a correlation value corresponding to the second sample text based on the number of times the second sample text corresponds to each sequential position and the weights corresponding to each sequential position.
[0170] Here, the sequential position refers to the first position, the second position, ..., the last position in each array.
[0171] Among them, the number of times the second sample text No. 1 appears in each sequential position includes: the total number of times the second sample text No. 1 appears in the first position in each sample relevance array and query relevance array, the total number of times it appears in the second position,..., the total number of times it appears in the last position.
[0172] For example, the two-dimensional matrix data M qx For example, the number of times the identifier corresponding to each second sample text appears in each column is counted, which includes steps B1 and B2:
[0173] Step B1, define a matrix C, where C ij Indicates that the identifier i is in the two-dimensional matrix data M qx The number of occurrences of the jth column; let D be the range set containing the identifier, D = {1, 2, ..., r}, where r is the number of second sample texts; C ij = count(d i in column j), where 1≤j≤x, 1≤i≤r.
[0174] Step B2, define a matrix S, where S i It represents the sum of the number of times the number i appears in each column and the product of the score, that is, Exemplarily, it is defined that the identifier corresponding to the second sample text that is ranked higher in the query relevance array and the sample relevance array is greater in relevance.
[0175] Step 1010, obtaining search results based on the relevant values.
[0176] In a possible implementation, the second sample text having a correlation value greater than a correlation threshold is determined as the search result text, and the sample code corresponding to the result sample text is determined as the result sample code to obtain the search result.
[0177] For example, the relevant threshold value can be determined through a large number of experiments.
[0178] In a possible implementation, step 1010 further includes: calculating the average value of each correlation value to obtain the correlation average value; determining the second sample text having a correlation value greater than the correlation average value as the result sample text, and determining the sample code corresponding to the result sample text as the result sample code.
[0179] In this implementation, the average value of each correlation value is used as a criterion for measuring whether the second sample text is relevant to the generated demand data; in this implementation, the second sample text with a correlation value higher than the correlation average value is screened as the result sample text.
[0180] In a possible implementation, step 1010 further includes: performing average calculation processing on each correlation value to obtain a correlation average value; obtaining a correlation threshold value based on the correlation average value and the fine-tuning coefficient, determining the second sample text whose correlation value is greater than the correlation threshold value as the result sample text, and determining the sample code corresponding to the result sample text as the result sample code. In this implementation, the line management average value is fine-tuned by the fine-tuning coefficient to obtain the correlation threshold value, so that the correlation threshold value can adapt to different scenarios and requirements based on the correlation average value.
[0181] It should be noted that a special situation may occur during the execution of step 1008, that is, the distribution of numbers in the matrix presents a hash distribution, that is, the relevance rankings are different, and the size of the relevance values corresponding to each second sample text obtained is very close. This situation indicates that the generation demand data input by the user is very general. At this time, most of the relevant texts will be screened out, that is, more retrieval result samples will be obtained; more retrieval result samples will cause the prompt word context input when the large language model generates the code interface specification to be relatively large, so the result of the large language model answer without obtaining the precise context will also present a probabilistic and general phenomenon, which is in line with expectations. At this time, the user can be prompted to further describe the specific problem until a smaller number of retrieval result samples are obtained. In a possible implementation, when the number of retrieval result samples is greater than a preset number threshold, a prompt message is generated to inform the user to further describe the problem.
[0182] In an exemplary embodiment, Fig.11 As shown, a method for generating a code interface specification is provided, and the method is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 1102 to 1126. Among them:
[0183] Step 1102, obtaining generation requirement data input by the user, where the generation requirement data includes the target card organization name and the target interface function.
[0184] Step 1104, vectorize the generated demand data to obtain a query vector.
[0185] Step 1106, perform similarity calculation on the query vector and each sample vector in the vector database to obtain a query similarity value corresponding to each sample vector; wherein the vector database includes multiple sample vectors, the sample vectors are obtained by vectorizing the sample text, and the sample text corresponds to the sample code.
[0186] Step 1108: Determine the sample vector whose query similarity value is greater than the similarity threshold as the first sample vector.
[0187] Step 1110 , using a large language model to perform relevance filtering processing on the generation demand data and the first sample text corresponding to the first sample vector, to obtain a second sample text that is relevant to the generation demand data.
[0188] Step 1112: Call the large language model to perform reverse question generation processing on the first sample text corresponding to the first sample vector to obtain a first sample question corresponding to the first sample text.
[0189] Step 1114, calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the first sample questions, to obtain a sample correlation array corresponding to the first sample question, wherein the sample correlation array includes identifiers corresponding to the second sample texts.
[0190] Step 1116, calling the large language model to sort the second sample texts according to the correlation between the second sample texts and the generated demand data, and obtaining a query correlation array corresponding to the generated demand data, wherein the query correlation array includes an identifier corresponding to each second sample text.
[0191] Step 1118: Perform frequency weighting processing on each second sample text according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each second sample text.
[0192] Optionally, the process of performing frequency-weighted processing on each second sample text according to the sample relevance array and the query relevance array to obtain the relevance value corresponding to each second sample text includes: obtaining the number of times the second sample text corresponds to each sequential position; and obtaining the relevance value corresponding to the second sample text based on the number of times the second sample text corresponds to each sequential position and the weight corresponding to each sequential position.
[0193] Step 1120, performing average calculation processing on each correlation value to obtain a correlation average value.
[0194] Step 1124: determine the second sample text whose correlation value is greater than the correlation average value as the result sample text, and determine the sample code corresponding to the result sample text as the result sample code.
[0195] Step 1126, call the large language model to process the result sample code, result sample text and generation requirement data to obtain the target code interface specification, which includes at least one of the target code interface or target code interpretation or target call example corresponding to the target card organization name and the target interface function.
[0196] Optionally, step 1126 further includes: determining a target prompt word template corresponding to the generation requirement data from a plurality of preset prompt word templates, obtaining a target prompt word text based on the result sample code, the result sample text, the generation requirement data and the target prompt word template, inputting the target prompt word text into the large language model, and obtaining a target code interface specification.
[0197] The code interface specification generation method provided in the above embodiment retrieves from the vector database based on the generation requirement data, obtains the result sample text and the corresponding result sample code that match the generation requirement data, and then calls the large language model to refer to the retrieved result sample text and the result sample code, and generates the code interface specification corresponding to the generation requirement data based on the user's generation requirement data; there is no need for users to manually write code interface specifications, which improves the efficiency of integrated development with payment processing and management systems such as card organizations; the use of the above code interface specification generation method allows users to complete the docking of related interfaces and the writing of codes by asking questions without reading the API document or even the API document, which greatly reduces the development time and makes the form of converting the API document into a code interface more direct, flexible and user-friendly.
[0198] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0199] It is understood that the term "based on" used in this application is used to describe one or more factors that affect the determination, and does not exclude other factors that may affect the determination. For example, the phrase "determine A based on B" means that the determination of A can be based entirely or at least partially on factor B, that is, B is a factor that affects the determination of A, but does not exclude that the determination of A is also based on C.
[0200] Based on the same inventive concept, the embodiment of the present application also provides a code interface specification generation device for implementing the code interface specification generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more code interface specification generation device embodiments provided below can refer to the limitations of the code interface specification generation method above, and will not be repeated here.
[0201] In an exemplary embodiment, Fig.12 As shown, a device for generating a code interface specification is provided, including: an input module 1202, a retrieval module 1204 and a generation module 1206, wherein:
[0202] Input module 1202, used to obtain generation requirement data input by a user, the generation requirement data including the target card organization name and the target interface function;
[0203] A search module 1204 is used to perform search processing in a preset vector database based on the generated demand data to obtain search results, where the search results include result sample texts and result sample texts corresponding to the result sample texts;
[0204] The generation module 1206 is used to call the large language model to process the result sample code and the result sample text and generate the required data to obtain the target code interface specification. The target representative interface specification includes at least one of the target code interface or the target code interpretation or the target call example corresponding to the target card organization name and the target interface function.
[0205] In an exemplary embodiment, the generation module 1206 is used to determine a target prompt word template corresponding to the generation requirement data from a plurality of preset prompt word templates, obtain the target prompt word text based on the result sample code, the result sample text, the generation requirement data and the target prompt word template, input the target prompt word text into the large language model, and obtain the target code interface specification.
[0206] In an exemplary embodiment, the retrieval module 1206 is used to perform vectorization processing on the generated demand data to obtain a query vector, and perform similarity matching processing in a vector database based on the query vector to obtain a retrieval result.
[0207] In an exemplary embodiment, the vector database includes multiple sample vectors, the sample vectors are obtained based on vectorization processing of sample text, and the sample text corresponds to the sample code; the retrieval module 1206 is used to determine the first sample vector whose similarity with the query vector meets the preset similarity condition from the multiple sample vectors; based on the first sample vector, obtain the retrieval result.
[0208] In an exemplary embodiment, the retrieval module 1206 is used to perform similarity calculation processing on the query vector and each sample vector respectively to obtain a query similarity value corresponding to each sample vector; and determine the sample vector whose query similarity value is greater than the similarity threshold as the first sample vector.
[0209] In an exemplary embodiment, the number of first sample vectors is greater than 1; the retrieval module 1206 is used to use a large language model to perform relevance filtering on the first sample text corresponding to the generated demand data and the first sample vector to obtain a second sample text that is relevant to the generated demand data; based on the second sample text, a retrieval result is obtained.
[0210] In an exemplary embodiment, the number of second sample texts is greater than 1; the retrieval module 1206 is used to call the large language model to perform reverse question generation processing on the first sample text corresponding to the first sample vector, to obtain the first sample question corresponding to the first sample text, to call the large language model to sort each second sample text according to the correlation between each second sample text and the first sample question, to obtain a sample correlation array corresponding to the first sample question, the sample correlation array includes an identifier corresponding to each second sample text, to call the large language model to sort each second sample text according to the correlation between each second sample text and the generated demand data, to obtain a query correlation array corresponding to the generated demand data, the query correlation array includes an identifier corresponding to each second sample text, to perform frequency weighted processing on each second sample text according to the sample correlation array and the query correlation array, to obtain a correlation value corresponding to each second sample text, and to obtain a retrieval result based on each correlation value.
[0211] In an exemplary embodiment, the retrieval module 1206 is used to obtain the number of times the second sample text corresponds to each sequential position; based on the number of times the second sample text corresponds to each sequential position and the weight corresponding to each sequential position, obtain the relevant value corresponding to the second sample text.
[0212] In an exemplary embodiment, the retrieval module 1206 is used to calculate the average value of each correlation value to obtain the correlation average value; determine the second sample text with a correlation value greater than the correlation average value as the result sample text; and determine the sample code corresponding to the result sample text as the result sample code.
[0213] Each module in the above-mentioned code interface specification generating device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0214] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.13 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a code interface specification generation method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0215] Those skilled in the art will understand that Fig.13The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0216] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0217] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0218] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0219] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0220] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0221] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0222] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating a code interface specification, characterized in that: The method comprises: Acquire generation requirement data input by a user, wherein the generation requirement data includes a target card organization name and a target interface function; Vectorizing the generated demand data to obtain a query vector; Performing similarity calculation processing on the query vector and each sample vector respectively, to obtain query similarity values corresponding to each sample vector; wherein the vector database includes a plurality of the sample vectors, the sample vectors are obtained by vectorization processing based on sample text, and the sample text corresponds to the sample code; Determine the sample vector whose query similarity value is greater than a similarity threshold as a first sample vector; Using a large language model, a relevance filtering process is performed on the first sample text corresponding to the generated demand data and the first sample vector to obtain a second sample text having relevance to the generated demand data; Calling the large language model to perform reverse question generation processing on the first sample text corresponding to the first sample vector to obtain a first sample question corresponding to the first sample text; Calling the large language model to sort each of the second sample texts according to the correlation between each of the second sample texts and the first sample question, to obtain a sample correlation array corresponding to the first sample question, wherein the sample correlation array includes an identifier corresponding to each of the second sample texts; Calling the large language model to sort each of the second sample texts according to the correlation between each of the second sample texts and the generation requirement data, to obtain a query correlation array corresponding to the generation requirement data, wherein the query correlation array includes an identifier corresponding to each of the second sample texts; Performing frequency weighted processing on each of the second sample texts according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each of the second sample texts; Based on each of the related values, a search result is obtained; the search result includes a result sample text and a result sample code corresponding to the result sample text; The large language model is called to process the result sample code, the result sample text and the generation requirement data to obtain a target code interface specification, wherein the target code interface specification includes at least one of a target code interface or a target code interpretation or a target call example corresponding to the target card organization name and the target interface function.
2. The method according to claim 1, characterized in that The calling of the large language model to process the result sample code, the result sample text and the generation requirement data to obtain the target code interface specification includes: Determining a target prompt word template corresponding to the generation demand data from a plurality of preset prompt word templates; Based on the result sample code, the result sample text, the generation requirement data and the target prompt word template, obtaining the target prompt word text; The target prompt word text is input into the large language model to obtain the target code interface specification.
3. The method according to claim 1, characterized in that: The performing frequency weighted processing on each of the second sample texts according to the sample relevance array and the query relevance array to obtain a relevance value corresponding to each of the second sample texts includes: Obtain the number of times the second sample text corresponds to each sequential position; Based on the number of times the second sample text corresponds to each of the sequential positions and the weights corresponding to each of the sequential positions, a correlation value corresponding to the second sample text is obtained.
4. The method according to claim 1, characterized in that: The obtaining of the search result based on each of the related values comprises: Performing average calculation processing on each of the correlation values to obtain a correlation average value; Determine the second sample text whose correlation value is greater than the correlation average value as the result sample text; The sample code corresponding to the result sample text is determined as the result sample code.
5. A device for generating code interface specifications, characterized in that: The code interface specification generating device comprises: An input module, used to obtain generation requirement data input by a user, wherein the generation requirement data includes a target card organization name and a target interface function; A retrieval module is used to vectorize the generated demand data to obtain a query vector; perform similarity calculation on the query vector and each sample vector to obtain a query similarity value corresponding to each sample vector; wherein the vector database includes a plurality of sample vectors, the sample vectors are obtained by vectorizing sample texts, and the sample texts correspond to sample codes; the sample vectors whose query similarity values are greater than a similarity threshold are determined as first sample vectors; a large language model is used to perform relevance filtering on the generated demand data and the first sample text corresponding to the first sample vector to obtain a second sample text that is relevant to the generated demand data; the large language model is used to perform reverse question generation on the first sample text corresponding to the first sample vector to obtain a query similarity value corresponding to the first sample text the first sample question; calling the large language model to sort each of the second sample texts according to the correlation between each of the second sample texts and the first sample question, to obtain a sample correlation array corresponding to the first sample question, the sample correlation array including the identifier corresponding to each of the second sample texts; calling the large language model to sort each of the second sample texts according to the correlation between each of the second sample texts and the generated demand data, to obtain a query correlation array corresponding to the generated demand data, the query correlation array including the identifier corresponding to each of the second sample texts; performing frequency weighting processing on each of the second sample texts according to the sample correlation array and the query correlation array, to obtain a correlation value corresponding to each of the second sample texts; obtaining a search result based on each of the correlation values; A generation module is used to call a large language model to process the result sample code, the result sample text and the generation requirement data to obtain a target code interface specification, wherein the target code interface specification includes at least one of a target code interface or a target code interpretation or a target call example corresponding to the target card organization name and the target interface function.
Citation Information
Patent Citations
Code generation method based on API document
CN117032722A
Parameter calling method and device, electronic equipment and computer program product
CN118171646A