Fusion semantic retrieval and large model writing assistance method, device and electronic equipment
By integrating semantic retrieval with large-scale model-based writing assistance methods, the problems of low efficiency and serious content generalization in writing professional reports in corporate offices have been solved, efficient and accurate document generation has been achieved, and close integration and compliance with internal corporate information have been ensured.
Patent Information
- Application Number
- CN202510977714.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-07-16
AI Technical Summary
When writing professional reports in corporate offices, existing technologies have problems such as low writing efficiency, serious content generalization, and easy errors, especially when extracting key fields from multiple external documents.
A writing assistance method that integrates semantic retrieval and large models is adopted. By calling the writing template corresponding to the document type, structured field information is extracted and filled, and context fragments are retrieved in the material file based on the search keywords. The large model is used to generate text, and semantic retrieval and large models are combined to generate text content containing complex semantics and syntax.
It improves writing efficiency and accuracy, reduces human errors, achieves close integration with internal corporate data, reduces the generalization of generated content, and makes the generated text more accurate and compliant.
Smart Images

Figure CN120492477B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of document processing, in particular to a writing assistance method and device fusing semantic retrieval and a large model and an electronic device. BACKGROUND
[0002] In enterprise office, writing professional reports such as due diligence report, financial report, regulatory document, etc. requires consulting a large amount of information, repeatedly inputting or pasting information, resulting in low writing efficiency; the key fields involved in the document (such as customer name, project number, collection amount) usually need to be extracted from multiple external files (PDF, scanned copy, historical report), and manual operation is prone to errors.
[0003] And although some related content is generated automatically with the help of intelligent means, the closeness of the generated content to the enterprise internal information is low, resulting in serious generalization of the generated content. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a writing assistance method and device fusing semantic retrieval and a large model and an electronic device to improve writing efficiency and quality and reduce the generalization of the generated content.
[0005] In a first aspect, a writing assistance method fusing semantic retrieval and a large model is provided, which comprises:
[0006] calling a writing template corresponding to the document type based on the document type to be written;
[0007] extracting information associated with the structured field from the pre-uploaded material file for each structured field to be filled on the writing template;
[0008] filling the extracted information into the blank position of the structured field;
[0009] retrieving a context fragment associated with the retrieval keyword in the material file based on the text writing unit on the writing template and the retrieval keyword;
[0010] generating text through a large model after fine-tuning based on the retrieved context fragment and the pre-constructed prompt word; the prompt word is used to instruct the large model to generate text in combination with the context fragment;
[0011] generating a target document based on the filled field information and the text generated by the large model.
[0012] Optionally, extracting information associated with the structured field from the pre-uploaded material file for each structured field to be filled on the writing template comprises:
[0013] Call the OCR service interface of the third party to recognize the text of the pre-uploaded material file;
[0014] Preprocess the recognized text, the preprocessing including removing noise, deleting redundant blank lines, and format characters;
[0015] Split the preprocessed text to obtain split text segments; meanwhile, convert the split text segments into vectors and store them in a vector library;
[0016] For the first type field in the writing template, use the regularization technique to extract field information associated with the first type field from the split text segments; the first type field is a fixed format field, at least including an ID number, an account number, and an email address;
[0017] For the second type field in the writing template, use a pre-trained deep learning NER model to extract field information associated with the second type field from the text segments; the second type field is a complex semantic field, at least including a customer name and a business type.
[0018] Optionally, filling the extracted information into the blank positions of the structured fields includes:
[0019] Adding the extracted information to a pre-constructed field mapping table;
[0020] Reading the field mapping table and copying the extracted information at the blank positions of the structured fields corresponding to the writing template.
[0021] Optionally, the method further includes:
[0022] Obtaining original text position information of the extracted information, the original text position information at least including a file name, a page number, a paragraph, and an OCR line number;
[0023] Generating a reference link based on the original text position information;
[0024] Adding the reference link to the structured field;
[0025] In response to a click operation of the user on the reference link, switching the control style of the referenced target paragraph to a highlight style.
[0026] Optionally, the searching for the context segments associated with the search keyword in the material file based on the search keyword includes:
[0027] Vectorizing the search keyword to obtain a search keyword vector;
[0028] Searching for vectors of text associated with the search keyword in the vector library based on a search engine Elasticsearch;
[0029] determine a semantic score of the retrieved text vector and the search keyword vector; and determine a literal matching score of the retrieved text vector and the search keyword vector by using a BM25 algorithm;
[0030] weight and fuse the semantic score and the literal matching score to obtain a final score of each retrieved text vector;
[0031] compare the score of each retrieved text vector with a preset score threshold, and return text segments greater than the preset score threshold in descending order of the score.
[0032] Optionally, the method further comprises:
[0033] perform desensitization processing and label a sensitivity level tag on the pre-uploaded material file; the sensitivity level tag includes public, internal, confidential, and strictly confidential;
[0034] determine the search permission of the user based on the sensitivity level corresponding to the sensitivity level tag;
[0035] search the context segment associated with the search keyword in the material file based on the search keyword;
[0036] search the context segment associated with the search keyword in the material file based on the search keyword and the search permission after desensitization and labeling of the sensitivity level tag.
[0037] Optionally, generating the text based on the retrieved context segment and the pre-constructed prompt word by using the fine-tuned large model includes:
[0038] perform desensitization processing on the retrieved context segment;
[0039] add a text desensitization requirement in the pre-constructed prompt word to obtain a modified prompt word;
[0040] generate the text based on the desensitized context segment and the modified prompt word by using the fine-tuned large model.
[0041] Optionally, after the large model generates the text, and before displaying the text to the user, the method further comprises:
[0042] perform verification checking on the generated text, the verification checking at least including PII checking, compliance checking, consistency checking, and hallucination detection.
[0043] In a second aspect, a writing assistance device fusing semantic search and a large model is provided, and the device comprises:
[0044] a calling unit configured to call a writing template corresponding to a document type based on the document type to be written;
[0045] extracting information associated with the structured field from a pre-uploaded material file for each structured field to be filled on the writing template;
[0046] filling the extracted information into a blank position of the structured field;
[0047] retrieving, for a text writing unit on the writing template, a context segment associated with the retrieval keyword in the material file based on the retrieval keyword;
[0048] generating, by a large model after fine-tuning, the text based on the retrieved context segment and a pre-constructed prompt word; the prompt word is used to instruct the large model to generate the text in combination with the context segment;
[0049] generating, by a second generation unit, the target document based on the filled field information and the text generated by the large model.
[0050] In a third aspect, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
[0051] the memory is used to store a computer program;
[0052] the processor is used to execute the program stored on the memory, and implement the method steps of any one of the first aspect.
[0053] The writing assistance method, device and electronic device provided by the application combine semantic retrieval and a large model, call a writing template corresponding to a document type based on the document type to be written, extract information associated with a structured field from a pre-uploaded material file for each structured field to be filled on the writing template, fill the extracted information into a blank position of the structured field, retrieve, for a text writing unit on the writing template, a context segment associated with a retrieval keyword in the material file based on the retrieval keyword, generate, by a large model after fine-tuning, the text based on the retrieved context segment and a pre-constructed prompt word, and generate, by a second generation unit, the target document based on the filled field information and the text generated by the large model. The application combines extracted field content and automatically fills the content into a structured field of a writing template, does not need to refer to a large amount of materials, reduces manual errors, improves writing efficiency and accuracy, combines semantic retrieval and a large model to generate text content containing complex semantics and syntax, and combines a context segment to generate relevant text, realizes close combination with enterprise internal materials, reduces generalization of generated content, and makes the generated text more accurate.
[0054] In order to make the above objectives, characteristics and advantages of the present application more apparent, more comprehensible, the following preferred embodiments are specifically described in detail below, together with the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments, and it should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0056] Figure 1 A flowchart of a writing assistance method combining semantic retrieval and a large model provided by an embodiment of the present application is shown;
[0057] Figure 2 A flowchart of another writing assistance method combining semantic retrieval and a large model provided by an embodiment of the present application is shown;
[0058] Figure 3 A structural schematic diagram of a writing assistance device combining semantic retrieval and a large model provided by an embodiment of the present application is shown;
[0059] Figure 4 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION
[0060] In order to make the objectives, technical solutions and advantages of the embodiments of the present application more apparent, the following will combine the drawings in the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0061] The embodiments of the present application provide a writing assistance method combining semantic retrieval and a large model, which is applied to an intelligent writing platform. The system architecture of the intelligent writing platform includes a data layer, a front-end layer and a service layer.
[0062] Among them, the data layer is provided with an object memory, a relational database, a search engine and a vector database. Specifically, the object memory is used to save user-uploaded material files such as PDF, word and pictures; the relational database is used to store structured information related to business fields in the file, such as field name, field value and modification record, etc. The search engine is used for keyword search; the vector database is used to store the mapping of file fragments-vectors.
[0063] The front-end layer is configured with a rich text editor, a material library display unit and a template operation unit. The rich text editor supports inserting / replacing text, displaying AI-generated paragraphs, field highlighting and real-time proofreading. The material library display unit provides a unified entry and multiple views (table / card / tree). The template management unit is used to switch or customize writing templates.
[0064] The service layer is configured with an OCR (Optical Character Recognition) service, an NLP (Natural Language Processing) information extraction service, a large language model service, a template management service and a document management service. The OCR service is used to complete the text recognition of pictures, PDF and word (third-party or self-developed), and generate searchable text. The NLP information extraction service uses a deep learning model (NER, regular, rule, etc.) to parse the text into the required business fields, solving the "intelligent filling" demand. The large language model service is used for text generation (AI-assisted writing). It is used for intelligent question answering and content polishing. Combined with RAG (Retrieval-Augmented Generation), it provides more accurate context completion for user writing. The template management service is used to manage and configure various document templates (field definition, format requirement, etc.). The document management service is responsible for interaction with the front end, and coordinates the logic of uploading, downloading, editor docking, traceability viewing, etc.
[0065] The present application proposes an intelligent writing platform that integrates document management, OCR analysis, natural language information extraction and large model generation, providing a full-process solution from material retrieval to report generation for users.
[0066] On this basis, the embodiment of the present application provides a writing assistance method combining semantic retrieval and a large model, as shown in Figure 1 The method comprises the following steps:
[0067] Step S101: calling a writing template corresponding to the document type based on the document type to be written.
[0068] In this step, the document type is, for example, due diligence report, financial report, legal document, etc. The writing template of the object is also the corresponding due diligence report template, financial report template, and legal document template, etc.
[0069] In this step, in the template operation unit of the front end of the intelligent writing platform, the user can also edit the writing template by himself, such as adding a writing template, modifying a writing template, deleting a writing template, saving, etc.
[0070] Step S102: For each structured field to be filled in on the writing template, extract the information associated with the structured field in the pre-uploaded material file.
[0071] In this step, the structured field refers to a field with a clear data type, format, and meaning. These fields can be easily recognized, parsed, and processed by the system for storage, retrieval, analysis, and display. For example, customer name, project number, collection amount, etc.
[0072] Step S103: Fill the extracted information into the blank position of the structured field.
[0073] In the writing template, a blank position is set after each field name for filling in specific field values, so the blank position is the field value position, and the background system will automatically fill in the extracted information. The specific process will be described in the following embodiments and will not be repeated here.
[0074] In addition, during the filling process, when the system detects multiple candidate values for the same field, a "conflict prompt" or "field candidate list" can be popped up on the right side.
[0075] Among them, the field values in the field candidate list are sorted by confidence, only the highest value is displayed, and the user can manually decide which value to use after expanding the list.
[0076] Step S104: For the text writing unit on the writing template, based on the retrieval keyword, retrieve the context fragment associated with the retrieval keyword in the material file.
[0077] The text writing unit refers to the part that allows the user to freely input a large amount of text, such as the abstract, the main text paragraph, the conclusion, etc. In this unit, the user can elaborate their ideas, describe events, or explain research results. The content of the text writing unit is not as easy to be automatically parsed and processed as the structured field, because it may contain complex syntax and semantic information.
[0078] In this step, the retrieval keyword can be the field content that has been filled in, and a one-key generation function button is configured on the front end of the intelligent writing platform. In the background, when the user clicks the button, the filled-in field is retrieved in the material library as a keyword to obtain a context segment, and relevant text is generated in combination with the context segment.
[0079] In another embodiment, the retrieval keyword can also be a manually input keyword.
[0080] Therefore, the embodiments of the present application use semantic retrieval combined with a large model to generate relevant text. If the text is manually written, it can also be input into the large model for polishing.
[0081] Step S105: Based on the retrieved context segment and the pre-constructed prompt word, the text is generated by the large model after fine-tuning; the prompt word is used to instruct the large model to generate the text in combination with the context segment.
[0082] In this step, the large model is, for example, a large language model of the GPT series or a BERT model. By fine-tuning the large model using a corpus of a specific field (to generate professional reports), the generated text is more accurate and meets the requirements of the field.
[0083] By retrieving the context segment and using the context segment to assist in generating relevant text, the close combination with the internal materials of the enterprise is realized, the generalization of the generated content is reduced, and the generated text is more accurate and meets the compliance.
[0084] Step S106: Based on the filled-in field information and the text generated by the large model, the target document is generated.
[0085] The present application extracts field content and automatically fills it into the structured fields of the writing template, without the need to consult a large amount of materials, reduces human error, improves writing efficiency and accuracy; in addition, semantic retrieval and a large model are combined to generate text content containing complex semantics and syntax, and relevant text is generated in combination with the context segment, realizing the close combination with the internal materials of the enterprise, reducing the generalization of the generated content, making the generated text more accurate and meeting the compliance.
[0086] On the basis of the above embodiments, for each structured field to be filled in on the writing template, information associated with the structured field is extracted from the pre-uploaded material file, including:
[0087] Step S102A: A third-party OCR service interface is called to recognize the text of the pre-uploaded material file.
[0088] In one example, the OCR service of the third party, such as the OCR service interface of Tencent or Ali, can directly call the OCR service of Ali after obtaining the service permission of Ali. The OCR service of Ali supports text recognition in multiple languages and file recognition in multiple formats, and can not only recognize pure text content, but also recognize files in PDF, image and other formats. This makes it easier to extract information from various sources.
[0089] Step S102B: Preprocessing the recognized text, which includes removing noise, deleting redundant blank lines, and format characters.
[0090] Through preprocessing, the recognized text is clearer and more accurate, which helps to improve the quality of subsequent text processing.
[0091] Step S102C: Splitting the preprocessed text to obtain split text segments; and converting the split text segments into vectors and storing them in a vector library.
[0092] In this step, for large texts (long PDFs, etc.), the text can be split according to fixed number of words (such as 256 bytes) or semantic segments. The split text is stored in the search engine ElasticSearch or the vector database for subsequent retrieval and mapping.
[0093] Step S102D: For the first type field in the writing template, regularization techniques are used to extract field information associated with the first type field from the split text segments.
[0094] The first type field is a fixed format field, including at least an ID number, an account number, and an email address.
[0095] Step S102E: For the second type field in the writing template, a pre-trained deep learning NER (Named Entity Recognition) model is used to extract field information associated with the second type field from the text segments.
[0096] The second type field is a complex semantic field, including at least a customer name and a business type.
[0097] In the prior art, regular expressions are generally used for information extraction, which is not flexible enough.
[0098] The present application uses a deep learning NER model + regularization technology combination to quickly locate some fixed format fields using regular expressions, and uses a deep learning NER model to extract those field entities that have a strong context association, complex semantics, and require understanding of the overall semantics of the text. These fields cannot be accurately extracted by simple regular expressions or rule matching, and the deep learning model can understand the semantic structure of the text by learning a large amount of labeled data, thereby achieving high-precision entity extraction.
[0099] This "deep learning + regular" hybrid extraction scheme can improve the accuracy and robustness of field extraction.
[0100] On the basis of the above embodiment, filling the extracted information into the blank position of the structured field comprises:
[0101] Step S103A: adding the extracted information to the pre-built field mapping table.
[0102] The field mapping table is provided with a source field and a target field, the source field is used to store the name of the field, and the target field is used to store the specific field value. The extracted information is added to the corresponding target field.
[0103] Step S103B: reading the field mapping table and copying the extracted information at the blank position of the structured field corresponding to the writing template.
[0104] According to the mapping relationship in the field mapping table, the extracted information is automatically filled in the corresponding position of the writing template, realizing automatic filling, reducing the error of manual operation, and improving the writing efficiency and writing quality.
[0105] On the basis of the above embodiment, the method further comprises:
[0106] Step S107: obtaining original text position information of the extracted information.
[0107] The original text position information at least includes: file name, page number, paragraph, and OCR line number;
[0108] Step S108: generating a reference link based on the original text position information.
[0109] Step S109: adding the reference link to the structured field.
[0110] Step S110: in response to a user's click operation on the reference link, switching the control style of the referenced target paragraph to a highlight style.
[0111] The embodiment can quickly locate the source of the filled field by visualizing the filled field content, and ensure the authenticity and accuracy of the filled field content.
[0112] The embodiment of the application realizes field-level tracing, ensures visualization, traceability and high controllability. They jointly constitute the core technical framework and main competitive barriers of the application.
[0113] On the basis of the above embodiment, the context segment associated with the search keyword is searched in the material file based on the search keyword, including:
[0114] Step S104A: vectorizing the search keyword to obtain a search keyword vector.
[0115] In this step, a pre-trained language model (such as BERT, SimCSE, etc.) is used to encode the search keyword. These models can map text to vectors in a high-dimensional space while preserving the semantic information of the text.
[0116] For example, for the keyword "artificial intelligence", the model will output a fixed-dimensional vector, such as keyword = [0.1, 0.2, -0.3, …].
[0117] Step S104B: searching for the vector of the text associated with the search keyword in the vector library based on the search engine Elasticsearch.
[0118] Elasticsearch supports vector-based similarity search and can quickly return the most similar text vector to the search keyword vector. It can quickly locate the text segment related to the semantic of the search keyword, and improve the search efficiency.
[0119] Step S104C: determining the semantic score of the retrieved text vector and the search keyword vector; and using the BM25 algorithm to determine the literal matching score of the searched text vector and the search keyword vector.
[0120] In this step, the semantic score can be calculated by calculating the cosine similarity of the two vectors. The cosine similarity is a prior art and will not be described here. The higher the semantic score, the more similar the semantics of the text and the keyword.
[0121] Using the BM25 algorithm, the frequency of the keyword in the text, the length of the document, and other factors are considered to calculate the literal matching score of the text and the keyword. The BM25 algorithm can effectively handle the literal matching of keywords and works well in scenarios where keywords are clear and text content is short.
[0122] Step S104D: The semantic score and the literal matching score are weighted and fused to obtain a final score of each text vector of the retrieved result.
[0123] Through weighted fusion, semantic and literal matching can be comprehensively considered to improve the quality of the retrieval result.
[0124] Step S104E: The score of each text vector of the retrieved result is compared with a preset score threshold, and text segments greater than the preset score threshold are returned in descending order of the score.
[0125] In this step, the threshold screening and sorting ensure that the returned text segments are highly relevant to the search keywords, improving the accuracy and practicability of the retrieval result. In the returned multiple text segments, the user can make a selection again. Finally, a text meeting the requirements is determined.
[0126] Based on the above embodiment, as shown in the method further comprises: Figure 2
[0127] Step S111: The pre-uploaded material file is desensitized and labeled with a sensitivity level label.
[0128] In this step, the sensitivity level label includes public, internal, confidential, and strictly confidential.
[0129] In a feasible implementation, when labeling, the marking should be performed at the document level, or further at the chapter, paragraph, or text block level (for example, a report with a large part of internal level may contain an appendix with a confidential level).
[0130] By refining the document granularity of the labeled sensitivity level, the security of the file is higher.
[0131] Step S112: The search permission of the user is determined based on the sensitivity level corresponding to the sensitivity level label.
[0132] Step S113: The context segment associated with the search keyword is searched in the material file based on the search keyword.
[0133] Step S114: The context segment associated with the search keyword is searched in the desensitized and labeled sensitivity level label material file based on the search keyword and the search permission.
[0134] In the embodiment of the application, when searching, the user's permission is determined to determine the document level that the user can view, and text segments with a label higher than the user's permission are not returned, improving the privacy and security of the text.
[0135] On the basis of the above embodiments, based on the retrieved context snippet and the pre-built prompt, the text is generated by the fine-tuned large model, which includes:
[0136] Step S105A: desensitizing the retrieved context snippet.
[0137] Before inputting into the large model, the retrieved context snippet is desensitized. In a feasible implementation, sensitive data can be detected by NER or regular expression, and the sensitive data is replaced.
[0138] In an example, for PII (Personally Identifiable Information) data, the name can be replaced with “Edited-Person”, and the address can be replaced with “Edited-Address”.
[0139] Step S105B: adding text desensitization requirements in the pre-built prompt to obtain a modified prompt.
[0140] In this step, the instruction example of the prompt is: “You are generating content for a chapter of a strictly confidential M&A due diligence report. Only use the provided context snippet. Maintain an objective and factual tone. Do not infer or speculate beyond the provided text. Ensure all financial data matches the context completely. Do not include any information identified as [Edited] in the output”.
[0141] Step S105C: generating text based on the desensitized context snippet and the modified prompt by the fine-tuned large model.
[0142] The sensitive data in a specific field, compliance, and possibly anonymized is fine-tuned. Such a model will better understand the tone, style, and constraints required for decision-making than a general-purpose model.
[0143] After generating the text, the AI-generated content, especially the content from sensitive sources, can be visually distinguished by highlighting.
[0144] Text generated from confidential or higher-level sources can also be marked; or the defense mechanism detects parts of potential problems, requiring mandatory manual review and explicit approval.
[0145] On the basis of the above embodiments, after the large model generates the text, and before displaying it to the user, the method further includes:
[0146] The generated text is verified for checking, and the verification checking at least includes PII checking, compliance checking, consistency checking, and hallucination detection.
[0147] Among them, the PII check specifically refers to rechecking whether PII, confidential project code or blacklisted terms are inadvertently exposed; the rule compliance check verifies whether the embedded rules (such as containing disclaimers, specific wording) are complied with, which can be compared with the constraints of the writing template; the fact consistency check verifies whether the generated statement is consistent with the context provided to the LLM in terms of facts, and if not, marks the inconsistencies. The hallucination detection is used to identify inaccurate or fabricated information in the model-generated content. These fabricated information is called hallucination because they may seem reasonable but have no factual basis or are inconsistent with reality.
[0148] Based on the same inventive concept, a writing assistance device that fuses semantic retrieval and large models is provided, as shown in Figure 3 The device comprises:
[0149] The calling unit 301 is configured to call a writing template corresponding to a document type based on the document type to be written;
[0150] The extraction unit 302 is configured to extract information associated with a structured field to be filled in the writing template from a pre-uploaded material file for each structured field to be filled in the writing template;
[0151] The filling unit 303 is configured to fill the extracted information into the blank position of the structured field;
[0152] The retrieval unit 304 is configured to retrieve a context segment associated with a retrieval keyword in the material file based on the retrieval keyword for a text writing unit on the writing template;
[0153] The first generation unit 305 is configured to generate text by fine-tuning a large model based on the retrieved context segment and a pre-constructed prompt word; the prompt word is used to instruct the large model to generate text in combination with the context segment;
[0154] The second generation unit 306 is configured to generate a target document based on the filled field information and the text generated by the large model.
[0155] In a possible implementation, the extraction unit is specifically configured to:
[0156] Call a third-party OCR service interface to recognize the text of the pre-uploaded material file;
[0157] Preprocess the recognized text, which includes removing noise, deleting redundant blank lines, and format characters;
[0158] Split the preprocessed text to obtain split text segments; at the same time, convert the split text segments into vectors and store them in a vector library;
[0159] For the first type field in the writing template, the regularization technique is used to extract the field information associated with the first type field in the split text segment; the first type field is a fixed format field, at least including an ID number, an account number, and an email address;
[0160] For the second type field in the writing template, a pre-trained deep learning NER model is used to extract the field information associated with the second type field in the text segment; the second type field is a complex semantic field, at least including a customer name and a business type.
[0161] In a possible implementation, the filling unit is specifically configured to:
[0162] add the extracted information to a pre-built field mapping table;
[0163] read the field mapping table, and copy the extracted information at a blank position of a structured field corresponding to the writing template.
[0164] Optionally, the apparatus further includes a tracing unit, which is specifically configured to:
[0165] obtain original text position information of the extracted information, the original text position information at least including a file name, a page number, a paragraph, and an OCR line number;
[0166] generate a reference link based on the original text position information;
[0167] add the reference link to the structured field;
[0168] in response to a click operation of a user on the reference link, switch a control style of a target paragraph of the reference to a highlight style.
[0169] In a possible implementation, the searching unit is specifically configured to:
[0170] vectorize the search keyword to obtain a search keyword vector;
[0171] search, based on a search engine Elasticsearch, a vector of a text associated with the search keyword in a vector library;
[0172] determine a semantic score of the searched vector of the text and the search keyword vector; and determine, by using a BM25 algorithm, a literal matching score of the searched vector of the text and the search keyword vector;
[0173] weight and fuse the semantic score and the literal matching score to obtain a final score of each searched vector of the text;
[0174] compare the score of each searched vector of the text with a preset score threshold, and return a text segment greater than the preset score threshold in a descending order of the score.
[0175] Optionally, the apparatus further comprises a desensitization unit, specifically for:
[0176] desensitizing the pre-uploaded material files and labeling sensitivity level tags; the sensitivity level tags include public, internal, confidential, and strictly confidential;
[0177] determining the retrieval authority of the user based on the sensitivity level corresponding to the sensitivity level tag;
[0178] retrieving the context fragments associated with the retrieval keyword based on the retrieval keyword in the material files;
[0179] retrieving the context fragments associated with the retrieval keyword based on the retrieval keyword and the retrieval authority in the material files that have been desensitized and labeled with the sensitivity level tags.
[0180] In a possible implementation, the first generation unit is specifically for:
[0181] desensitizing the retrieved context fragments;
[0182] adding text desensitization requirements in the pre-constructed prompt words to obtain modified prompt words;
[0183] generating the text based on the desensitized context fragments and the modified prompt words through the fine-tuned large model.
[0184] Optionally, after the large model generates the text, and before displaying the text to the user, the apparatus further comprises:
[0185] a verification checking unit for verifying and checking the generated text, and the verification checking at least includes PII checking, compliance checking, consistency checking, and illusion detection.
[0186] Based on the same technical concept, the present application also provides an electronic device, as shown in Figure 4 which comprises a processor 401, a communication interface 402, a memory 403, and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404.
[0187] The memory 403 is used to store computer programs;
[0188] The processor 401 is used to execute the programs stored in the memory 403, and realize the steps of the writing assistance method combining semantic retrieval and large models.
[0189] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0190] The communication interface is used for communication between the above electronic device and other devices.
[0191] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.
[0192] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0193] The device provided by the embodiment of the application can be specific hardware on the device or software or firmware installed on the device, etc. The device provided by the embodiment of the application has the same implementation principle and technical effects as the foregoing method embodiments, and for the sake of brevity, the part of the device embodiment not mentioned in the foregoing method embodiments can refer to the corresponding content in the foregoing method embodiments. Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the system, device and unit described above can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein again.
[0194] In the embodiments of the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. The embodiments described above are merely exemplary, for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation; for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, and electrical, mechanical or other forms.
[0195] The units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments of the present application.
[0196] In addition, each functional unit in the embodiments of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.
[0197] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application, essentially or the part that contributes to the prior art, or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0198] It should be noted that: similar reference numerals and letters in the following drawings represent similar items, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. In addition, the terms "first", "second", "third" and the like are used only to distinguish descriptions, and cannot be understood as indicating or implying relative importance.
[0199] Finally, it should be noted that the above-described embodiments are merely specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the present application, and the protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features therein, within the technical scope disclosed by the present application, and these modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application. All should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A writing assistance method integrating semantic retrieval and large models, characterized in that: Applied to the scenario of writing professional enterprise reports, the method includes: Based on the type of document to be written, calling a writing template corresponding to the document type; For each structured field to be filled in on the writing template, extract information associated with the structured field from the pre-uploaded material file; Filling the extracted information into the blank position of the structured field; For the text writing unit on the writing template, the context fragments associated with the search keyword are searched in the material file based on the filled fields as the search keyword; the search process includes: Vectorize the search keywords to obtain the search keyword vector; Searching a vector library for a text vector associated with the search keyword based on the search engine Elasticsearch; Determining a semantic score between the retrieved text vector and the search keyword vector; and determining a literal match score between the searched text vector and the search keyword vector using the BM25 algorithm; Performing a weighted fusion of the semantic score and the literal matching score to obtain a final score for each retrieved text vector; Compare the score of each retrieved text vector with a preset score threshold, and return the text segments with scores greater than the preset score threshold in descending order; Based on the retrieved context fragments and pre-built prompt words, the fine-tuned large model generates text; the prompt words are used to instruct the large model to generate text in combination with the context fragments; Generate target documents based on populated field information and text generated by the large model.
2. The method according to claim 1, characterized in that For each structured field to be filled in the writing template, extracting information associated with the structured field from the pre-uploaded material file includes: Call a third-party OCR service interface to recognize the text of the pre-uploaded material file; Preprocessing the recognized text, including removing noise, deleting extra blank lines, and formatting characters; The preprocessed text is split to obtain split text segments; the split text segments are converted into vectors and stored in a vector library; For the first type of fields in the writing template, regularization technology is used to extract field information associated with the first type of fields from the split text segments; the first type of fields are fields in a fixed format, including at least an ID number, an account number, and an email address; For the second type of field in the writing template, a pre-trained deep learning NER model is used to extract field information associated with the second type of field in the text fragment; the second type of field is a complex semantic field, including at least customer name and business type.
3. The method according to claim 1, characterized in that Filling the blank position of the structured field with the extracted information includes: Add the extracted information to the pre-built field mapping table; The field mapping table is read, and the extracted information is copied to the blank position of the structured field corresponding to the writing template.
4. The method according to claim 1, wherein The method further comprises: Obtaining original text location information of the extracted information, wherein the original text location information includes at least: file name, page number, paragraph, and OCR line number; generating a reference link based on the original text location information; Adding the reference link to the structured field; In response to a user clicking operation on the reference link, the control style of the referenced target paragraph is switched to a highlight style.
5. The method according to claim 1, wherein The method further comprises: Desensitize the pre-uploaded material files and label them with sensitivity levels; the sensitivity level labels include public, internal, confidential, and strictly confidential; Determining the user's search authority based on the sensitivity level corresponding to the sensitivity level label; Retrieving a context segment associated with the search keyword in the material file based on the search keyword; Based on the search keywords and the search permissions, context segments associated with the search keywords are retrieved from the desensitized and sensitivity-level labeled material files.
6. The method according to claim 5, characterized in that Generating text based on the retrieved context fragments and pre-built prompt words using the fine-tuned large model includes: performing desensitization processing on the retrieved context fragment; Add text desensitization requirements to the pre-built prompt words to obtain the modified prompt words; Based on the desensitized context fragments and modified prompt words, text is generated through the fine-tuned large model.
7. The method according to claim 6, characterized in that After the large model generates the text and before displaying it to the user, the method further includes: Performing a verification check on the generated text, wherein the verification check at least includes a PII check, a compliance check, a consistency check, and a hallucination detection.
8. A writing assistance device integrating semantic retrieval and large models based on a writing assistance method integrating semantic retrieval and large models according to any one of claims 1 to 7, characterized in that: The device comprises: A calling unit, configured to call a writing template corresponding to a document type to be written based on the document type to be written; an extraction unit, configured to extract information associated with each structured field to be filled in on the writing template from a pre-uploaded material file; A filling unit, configured to fill the blank position of the structured field with the extracted information; A retrieval unit, configured to retrieve, for the text writing unit on the writing template, context segments associated with the search keyword in the material file based on the search keyword; A first generation unit is configured to generate text using a fine-tuned large model based on the retrieved context fragment and pre-built prompt words; the prompt words are used to instruct the large model to generate text in combination with the context fragment; The second generating unit is used to generate a target document based on the filled field information and the text generated by the large model.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method steps described in any one of claims 1 to 7 when executing the program stored in the memory.
Citation Information
Patent Citations
Intelligent writing method and device, electronic equipment, medium and system
CN118569216A
Contract text desensitization method, system and equipment based on large language model, medium and product
CN118940314A
Material extraction and generation method based on large model and multi-storage technology
CN119003639A
RAG data query method and device based on privacy protection, equipment and medium
CN119202339A