Writing auxiliary method and device fusing semantic retrieval and large model and electronic equipment
By combining semantic retrieval and large-model technology, structured field information is automatically extracted and filled, and the problems of inefficiency and generalization in corporate report writing are solved, achieving efficient and accurate document generation.
Patent Information
- Application Number
- CN202510977714.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-07-16
AI Technical Summary
When writing professional reports in corporate offices, the existing technology has problems such as low writing efficiency, manual operations are prone to errors, and poor intimacy with internal information of the company, especially when extracting key fields and generating related content.
By calling the writing template based on the type of document to be written, extracting and filling structured field information, combining semantic search and big model to generate text, using OCR, deep learning NER model and semantic search technology, text that is closely related to internal enterprise data is automatically filled and generated.
It improves writing efficiency, reduces manual errors, and the generated text is more accurate and closely integrated with internal enterprise information, reducing the generalization of content and meeting compliance requirements.
Smart Images

Figure CN120492477A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of document processing technology, and in particular to a writing assistance method, device and electronic equipment integrating semantic retrieval and large models. Background Art
[0002] In corporate offices, writing professional reports such as due diligence reports, financial reports, and regulatory documents requires consulting a large amount of information and repeatedly entering or pasting information, resulting in low writing efficiency. Key fields involved in the document (such as customer name, project number, and amount of foreign exchange received) usually need to be extracted from multiple external files (PDFs, scans, historical reports), and manual operations are prone to errors.
[0003] Although some currently use intelligent means to automatically generate relevant content, the generated content is less closely related to the company's internal information, resulting in serious generalization of the generated content. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a writing assistance method, device and electronic device that integrates semantic retrieval and large models to improve writing efficiency and writing quality, and reduce the generalization of generated content.
[0005] In a first aspect, a writing assistance method integrating semantic retrieval and a large model is provided, the method comprising: Based on the type of document to be written, a writing template corresponding to the document type is called; 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; Fill the blank spaces of the structured fields with the extracted information; For the text writing unit on the writing template, based on the search keyword, a context segment associated with the search keyword is searched in the material file; 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 based on the context fragments; Generate target documents based on populated field information and text generated by the large model.
[0006] Optionally, 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; Preprocess the recognized text, including removing noise, deleting extra blank lines, and formatting characters; The preprocessed text is split to obtain split text segments; at the same time, the split text segments are converted into vectors and stored in the 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 fragments; the first type of fields are fields with a fixed format, including at least ID number, account number, and email address; For the second type of fields in the writing template, a pre-trained deep learning NER model is used to extract field information associated with the second type of fields in the text fragment; the second type of fields are complex semantic fields, including at least customer name and business type.
[0007] Optionally, filling the blank position of the structured field with the extracted information includes: Add the extracted information to the pre-built field mapping table; Read the field mapping table and copy the extracted information to the blank position of the structured field corresponding to the writing template.
[0008] Optionally, the method further comprises: Obtaining original text location information of the extracted information, the original text location information at least including: file name, page number, paragraph and OCR line number; Generate reference links based on original text location information; Add citation links to structured fields; In response to a user clicking operation on a reference link, a control style of a referenced target paragraph is switched to a highlight style.
[0009] Optionally, searching the material file for a context segment associated with the search keyword based on the search keyword includes: Vectorize the search keywords to obtain the search keyword vector; Search the vector library for the text associated with the search keyword based on the search engine Elasticsearch; Determine the semantic score of the retrieved text vector and the search keyword vector; and use the BM25 algorithm to determine the literal matching score of the searched text vector and the search keyword vector; The semantic score and the literal matching score are weighted and fused to obtain the final score of the vector of each retrieved text; The score of each retrieved text vector is compared with a preset score threshold, and text segments with scores greater than the preset score threshold are returned in descending order.
[0010] Optionally, the method further comprises: Desensitize pre-uploaded material files and label them with sensitivity levels; sensitivity level labels include public, internal, confidential, and strictly confidential; Determine the user's search permissions based on the sensitivity level corresponding to the sensitivity level label; Retrieving context fragments associated with the search keyword in the material file based on the search keyword; Based on the search keywords and search permissions, context fragments associated with the search keywords are retrieved from the material files that are anonymized and labeled with sensitivity level labels.
[0011] Optionally, based on the retrieved context fragments and pre-built prompt words, the fine-tuned large model generates text including: Desensitize the retrieved context fragments; 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.
[0012] Optionally, after the large model generates the text and before displaying it to the user, the method further includes: Perform verification checks on the generated text, which at least include PII checks, compliance checks, consistency checks, and hallucination detection.
[0013] In a second aspect, a writing assistance device integrating semantic retrieval and a large model is provided, the device comprising: A calling unit, configured to call a writing template corresponding to a document type based on the document type to be written; An extraction unit, for extracting information associated with each structured field to be filled in on the writing template from the pre-uploaded material file; A filling unit, used to fill the blank position of the structured field with the extracted information; A retrieval unit, configured to retrieve, based on a retrieval keyword, a context segment associated with a text writing unit on a writing template in a material file; The first generation unit is configured to generate text using the fine-tuned large model based on the retrieved context fragments and pre-built prompt words; the prompt words are used to instruct the large model to generate text based on the context fragments; 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.
[0014] According to a third aspect, an electronic device is provided, comprising 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 any of the method steps described in the first aspect when executing the program stored in the memory.
[0015] The present invention provides a writing assistance method, device and electronic device that integrates semantic retrieval and a large model. The method calls a writing template corresponding to the document type to be written based on the document type to be written, extracts information associated with the structured field in the pre-uploaded material file for each structured field to be filled in on the writing template; fills the extracted information into the blank position of the structured field; for the text writing unit on the writing template, retrieves the context fragment associated with the search keyword in the material file based on the search keyword; generates text based on the retrieved context fragment and the pre-built prompt word through the fine-tuned large model; the prompt word is used to instruct the large model to generate text in combination with the context fragment; and generates a target document based on the filled field information and the text generated by the large model. The present invention extracts field content by combining it and automatically fills it into the structured field of the writing template, eliminating the need to consult a large amount of information, reducing manual errors, and improving writing efficiency and accuracy. In addition, the method combines semantic retrieval and the large model to generate text content containing complex semantics and syntax, and combines the context fragment to generate relevant text, thereby achieving close integration with internal corporate information, reducing the generalization of the generated content, and making the generated text more accurate.
[0016] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without making any creative efforts.
[0018] Figure 1 A flowchart of a writing assistance method integrating semantic retrieval and a large model provided by an embodiment of the present invention is shown; Figure 2 A flowchart of another writing assistance method integrating semantic retrieval and a large model provided by an embodiment of the present invention is shown; Figure 3 A schematic diagram showing the structure of a writing assistance device integrating semantic retrieval and a large model provided by an embodiment of the present invention is shown; Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally 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 invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0020] An embodiment of the present invention provides a writing assistance method that integrates semantic retrieval and a large model. The method is applied to an intelligent writing platform, and the system architecture of the intelligent writing platform includes a data layer, a front-end layer, and a service layer.
[0021] The data layer consists of an object store, a relational database, a search engine, and a vector database. Specifically, the object store is used to store user-uploaded PDF, Word, image, and other source files; the relational database is used to store structured information related to business fields within the file, such as field names, field values, and modification history. The search engine is used for keyword searches; and the vector database is used to store file segment-vector mappings.
[0022] The front-end layer features a rich text editor, a library display unit, and a template operation unit. The rich text editor supports inserting and replacing text, displaying AI-generated paragraphs, field highlighting, and real-time proofreading. The library display unit provides a unified entry point and multiple views (table, card, and tree); the template management unit is used to switch or customize writing templates.
[0023] The service layer includes an Optical Character Recognition (OCR) service, a Natural Language Processing (NLP) information extraction service, a large language model service, a template management service, and a document management service. The OCR service performs text recognition in images, PDFs, and Word documents (either third-party or in-house), generating searchable text. The NLP information extraction service uses deep learning models (NER, regular expressions, and rules) to parse text into required business fields, addressing "smart fill" requirements. The large language model service is used for text generation (AI-assisted writing). It is used for intelligent question-and-answer (Q&A) and content polishing. Combined with Retrieval-Augmented Generation (RAG), it provides more accurate contextual completion for user writing. The template management service manages and configures various document templates (field definitions, formatting requirements, etc.). The document management service is responsible for interacting with the front-end and coordinating logic for uploads, downloads, editor integration, and source verification.
[0024] The present invention proposes an intelligent writing platform that integrates document management, OCR analysis, natural language information extraction and large model generation, providing users with a full-process solution from data retrieval to report generation.
[0025] On this basis, the embodiment of the present invention provides a writing assistance method that integrates semantic retrieval and large models, such as Figure 1 As shown, the method includes the following steps: Step S101: Based on the type of document to be written, a writing template corresponding to the document type is called.
[0026] In this step, the document types include due diligence reports, financial reports, legal documents, etc. The writing templates of the objects are also the corresponding due diligence report templates, financial report templates, and legal document templates.
[0027] In the step, in the template operation unit at the front end of the intelligent writing platform, the user can also edit the writing template by himself, such as adding a new writing template, modifying a writing template, deleting a writing template, and saving.
[0028] Step S102: 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.
[0029] In this step, structured fields refer to fields with clear data types, formats, and meanings. These fields can be easily identified, parsed, and processed by the system for easy storage, retrieval, analysis, and display. Examples include customer name, project number, and remittance amount.
[0030] Step S103: Fill the blank positions of the structured fields with the extracted information.
[0031] In the writing template, there is a blank space after each field name for filling in specific field values. Therefore, the blank space is the field value position. The background system will automatically fill it in according to the extracted information. The specific process will be explained in the following embodiments and will not be repeated here.
[0032] In addition, during the filling process, when the system detects multiple candidate values for the same field, a "conflict prompt" or "field candidate list" may pop up on the right.
[0033] In the field candidate list, field values are sorted by confidence, and only the values with the highest confidence are displayed. Users can manually decide which value to use after expanding the list.
[0034] Step S104: for the text writing unit on the writing template, based on the search keyword, searching the material file for a context segment associated with the search keyword.
[0035] A text writing unit is a section that allows users to freely enter large amounts of text, such as abstracts, body paragraphs, and conclusions. In this unit, users can elaborate on their ideas, describe events, or explain research findings. The content of text writing units is not as easily parsed and processed automatically as structured fields because it may contain complex syntactic and semantic information.
[0036] In this step, the search keyword can be the content of the already filled field. A one-click generation function button is configured on the front end of the intelligent writing platform. When the background detects that the user clicks the button or, the already filled field will be searched as a keyword in the material library to obtain the context fragment and generate relevant text in combination with the context fragment.
[0037] In another embodiment, the search keyword may also be a keyword input by oneself.
[0038] Therefore, the embodiment of the present invention uses 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.
[0039] Step S105: Generate text using the fine-tuned large model based on the retrieved context fragments and pre-built prompt words; the prompt words are used to instruct the large model to generate text in combination with the context fragments.
[0040] In this step, the large model, such as the GPT series large language model or the BERT model, is used to fine-tune the large model using corpus from a specific field (specialized in generating professional reports), so that the generated text is more in line with the field requirements and more accurate.
[0041] By retrieving context fragments and using them to assist in generating relevant text, a close integration with internal corporate data is achieved, reducing the generalization of the generated content and making the generated text more accurate and compliant.
[0042] Step S106: Generate a target document based on the filled field information and the text generated by the large model.
[0043] The present invention extracts field content and automatically fills it into the structured fields of the writing template, eliminating the need to consult a large amount of information, reducing manual errors, and improving writing efficiency and accuracy. In addition, it combines semantic retrieval and large models to generate text content containing complex semantics and syntax, and combines context fragments to generate relevant text, achieving close integration with internal corporate data, reducing the generalization of the generated content, and making the generated text more accurate and compliant.
[0044] Based on the above embodiment, for each structured field to be filled in the writing template, extracting information associated with the structured field from the pre-uploaded source file includes: Step S102A: calling a third-party OCR service interface to recognize the text of the pre-uploaded material file.
[0045] In one example, a third-party OCR service, such as Tencent or Alibaba's OCR service interface, can directly call Alibaba's OCR service after obtaining service permissions from Alibaba. Alibaba's OCR service supports text recognition in multiple languages and file formats. It can recognize not only plain text content but also PDFs, images, and other file formats, making it easier to extract information from various sources.
[0046] Step S102B: pre-process the recognized text, including removing noise, deleting redundant blank lines, and formatting characters.
[0047] Through preprocessing, the recognized text is made clearer and more accurate, which helps to improve the quality of subsequent text processing.
[0048] Step S102C: Split the pre-processed text to obtain split text segments; convert the split text segments into vectors and store them in a vector library.
[0049] In this step, large texts (such as long PDFs) can be split into fixed word counts (e.g., 256 bytes) or semantic segments. The split text is then stored in the search engine ElasticSearch or a vector database for subsequent retrieval and mapping.
[0050] Step S102D: 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.
[0051] The first type of fields are fixed-format fields, including at least ID number, account number, and email address.
[0052] Step S102E: For the second type of fields in the writing template, use a pre-trained deep learning NER (Named Entity Recognition) model to extract field information associated with the second type of fields from the text segment.
[0053] The second type of field is a complex semantic field, which includes at least the customer name and business type.
[0054] In the prior art, regular expressions are generally used when extracting information, which is not flexible enough.
[0055] This application combines deep learning NER model with regularization technology. For some fields with fixed formats, regular expressions are used to quickly locate them. For those field entities with non-fixed formats, strong context relevance, complex semantics, and requiring understanding of the overall semantics of the text, deep learning NER model is used to extract them. These fields are usually not able to be accurately extracted by simple regular expressions or rule matching. Deep learning models can understand the semantic structure of text by learning a large amount of annotated data, thereby achieving high-precision entity extraction.
[0056] This "deep learning + regularization" hybrid extraction scheme can improve the accuracy and robustness of field extraction.
[0057] Based on the above embodiment, filling the blank position of the structured field with the extracted information includes: Step S103A: Add the extracted information to the pre-built field mapping table.
[0058] The source field and target field are set in the field mapping table. The source field is used to store the name of the field, etc., and the target field stores the specific field value. The extracted information is added to the corresponding target field.
[0059] Step S103B: Read the field mapping table and copy the extracted information to the blank position of the structured field corresponding to the writing template.
[0060] 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 manual operation errors, and improving writing efficiency and writing quality.
[0061] Based on the above embodiment, the method further includes: Step S107: Obtain the original text position information of the extracted information.
[0062] The original text location information includes at least: file name, page number, paragraph and OCR line number; Step S108: Generate a reference link based on the original text location information.
[0063] Step S109: Add a reference link to the structured field.
[0064] Step S110: In response to the user clicking the reference link, the control style of the referenced target paragraph is switched to a highlight style.
[0065] This embodiment can quickly locate the source of the filled field by visually tracing the filled field content, thereby ensuring the authenticity and accuracy of the filled field content.
[0066] The embodiments of the present invention achieve field-level traceability, ensuring visualization, traceability, and high controllability. Together, they constitute the core technical framework and main competitive barrier of the present invention.
[0067] Based on the above embodiment, searching for context segments associated with the search keyword in the source file based on the search keyword includes: Step S104A: vectorize the search keyword to obtain a search keyword vector.
[0068] In this step, the search keywords are encoded using pre-trained language models (such as BERT, SimCSE, etc.). These models can map text into vectors in a high-dimensional space while preserving the semantic information of the text.
[0069] For example, for the keyword "artificial intelligence", the model will output a vector of fixed dimension, such as keyword=[0.1,0.2,-0.3,…].
[0070] Step S104B: searching the vector library for the text vector associated with the search keyword based on the search engine Elasticsearch.
[0071] Elasticsearch supports vector-based similarity searches, which can quickly return text vectors that are most similar to the search keyword vector. This allows for rapid location of text segments semantically related to the search keyword, improving search efficiency.
[0072] Step S104C: Determine the semantic score between the retrieved text vector and the search keyword vector; and use the BM25 algorithm to determine the literal matching score between the searched text vector and the search keyword vector.
[0073] In this step, the semantic score can be calculated by calculating the cosine similarity of two vectors. Cosine similarity is a prior art and will not be described in detail here. The higher the semantic score, the more similar the semantics of the text and the keyword are.
[0074] The BM25 algorithm calculates the literal match score between the text and the keywords, taking into account factors such as keyword frequency in the text and document length. The BM25 algorithm effectively handles literal keyword matches and is particularly effective in scenarios where keywords are clear and the text is short.
[0075] Step S104D: weighted fusion of the semantic score and the literal matching score to obtain the final score of the vector of each retrieved text.
[0076] Through weighted fusion, semantic and literal matching can be comprehensively considered to improve the quality of retrieval results.
[0077] Step S104E: Compare the score of each retrieved text vector with a preset score threshold, and return text segments with scores greater than the preset score threshold in descending order.
[0078] In this step, threshold filtering and sorting are used to ensure that the returned text fragments are highly relevant to the search keywords, improving the accuracy and practicality of the search results. Users can select from the multiple returned text fragments again, ultimately selecting a text that meets their requirements.
[0079] Based on the above embodiment, Figure 2 As shown, the method further includes: Step S111: desensitizing the pre-uploaded material files and marking them with sensitivity level labels.
[0080] In this step, the sensitivity level labels include Public, Internal, Confidential, and Strictly Confidential.
[0081] In one feasible implementation, when annotation is performed, the marking should be performed at the document level, or further at the chapter, paragraph, or text block level (for example, a report that is mostly internal level may contain a confidential level appendix).
[0082] By refining the granularity of documents with marked sensitivity levels, the security of files is improved.
[0083] Step S112: Determine the user's search authority based on the sensitivity level corresponding to the sensitivity level label.
[0084] Step S113: searching the source file for a context segment associated with the search keyword based on the search keyword.
[0085] Step S114: Based on the search keyword and the search permission, the context segment associated with the search keyword is searched in the desensitized and sensitivity-labeled material files.
[0086] In an embodiment of the present invention, the document level that a user can view is determined based on the user's authority during retrieval, and text fragments with a marking level higher than the user's authority are not returned, thereby improving the privacy and security of the text.
[0087] Based on the above embodiment, the text is generated by the fine-tuned large model based on the retrieved context fragments and pre-built prompt words, including: Step S105A: Desensitizing the retrieved context fragments.
[0088] Before inputting into the large model, the retrieved context fragments are desensitized. In a feasible implementation, sensitive data can be detected through NER or regular expressions and replaced.
[0089] In one example, for PII (Personally Identifiable Information) data, a name may be replaced with "redacted-person" and an address may be replaced with "redacted-address".
[0090] Step S105B: adding text desensitization requirements to the pre-built prompt words to obtain modified prompt words.
[0091] An example of instructions for the prompt word in this step: "You are generating content for a strictly confidential M&A due diligence report section. Use only the contextual snippets provided. Maintain an objective and factual tone. Do not infer or speculate beyond the text provided. Ensure all financial data matches the context exactly. Do not include any information identified as [REDACTED] in the output."
[0092] Step S105C: Generate text using the fine-tuned large model based on the desensitized context fragments and the modified prompt words.
[0093] Fine-tuned using domain-specific, compliant, and potentially anonymized sensitive data, such a model will better understand the tone, style, and constraints required for decision-making than a general-purpose model.
[0094] After the text is generated, AI-generated content can be visually distinguished through highlighting, especially content originating from sensitive sources.
[0095] Text generated from confidential or higher-level sources, or where guardrails detect potential issues, can also be flagged, requiring mandatory human review and explicit approval.
[0096] Based on the above embodiment, after the large model generates the text and before displaying it to the user, the method further includes: Perform verification checks on the generated text, which at least include PII checks, compliance checks, consistency checks, and hallucination detection.
[0097] PII checking specifically involves rechecking whether PII, confidential project code, or blacklisted terms have been inadvertently exposed. Rule compliance checking verifies that embedded rules (such as the inclusion of disclaimers and specific wording) are adhered to, which can be compared with the constraints of the writing template. Factual consistency checking verifies that generated statements are factually consistent with the context provided to the LLM, and if not, flags any inconsistencies. Hallucination detection identifies inaccurate or fabricated information in model-generated content. These fabricated information is called hallucinations because they may appear plausible but have no factual basis or are inconsistent with reality.
[0098] Based on the same inventive concept, a writing assistance device integrating semantic retrieval and large models is provided, such as Figure 3 As shown, the device includes: The calling unit 301 is configured to call a writing template corresponding to a document type based on the document type to be written; The extraction unit 302 is configured to extract information associated with each structured field to be filled in on the writing template from the pre-uploaded source file; A filling unit 303 is used to fill the blank position of the structured field with the extracted information; A retrieval unit 304 is configured to retrieve, based on a retrieval keyword, a context segment associated with the retrieval keyword in the source file for the text writing unit on the writing template; The first generation unit 305 is configured to generate text using the fine-tuned large model based on the retrieved context fragments and pre-built prompt words; the prompt words are used to instruct the large model to generate text based on the context fragments; The second generating unit 306 is configured to generate a target document based on the filled field information and the text generated by the large model.
[0099] In one possible implementation, the extraction unit is specifically configured to: Call a third-party OCR service interface to recognize the text of the pre-uploaded material file; Preprocess the recognized text, including removing noise, deleting extra blank lines, and formatting characters; The preprocessed text is split to obtain split text segments; at the same time, the split text segments are converted into vectors and stored in the 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 fragments; the first type of fields are fields with a fixed format, including at least ID number, account number, and email address; For the second type of fields in the writing template, a pre-trained deep learning NER model is used to extract field information associated with the second type of fields in the text fragment; the second type of fields are complex semantic fields, including at least customer name and business type.
[0100] In a possible implementation, the filling unit is specifically used to: Add the extracted information to the pre-built field mapping table; Read the field mapping table and copy the extracted information to the blank position of the structured field corresponding to the writing template.
[0101] Optionally, the device further includes a traceability unit, specifically configured to: Obtaining original text location information of the extracted information, the original text location information at least including: file name, page number, paragraph and OCR line number; Generate reference links based on the original text location information; Add citation links to structured fields; In response to a user clicking operation on a reference link, a control style of a referenced target paragraph is switched to a highlight style.
[0102] In a possible implementation, the retrieval unit is specifically configured to: Vectorize the search keywords to obtain the search keyword vector; Search the vector library for the text associated with the search keyword based on the search engine Elasticsearch; Determine the semantic score of the retrieved text vector and the search keyword vector; and use the BM25 algorithm to determine the literal matching score of the searched text vector and the search keyword vector; The semantic score and the literal matching score are weighted and fused to obtain the final score of the vector of each retrieved text; The score of each retrieved text vector is compared with a preset score threshold, and text segments with scores greater than the preset score threshold are returned in descending order.
[0103] Optionally, the device further includes a desensitization unit, specifically configured to: Desensitize pre-uploaded material files and label them with sensitivity levels; sensitivity level labels include public, internal, confidential, and strictly confidential; Determine the user's search permissions based on the sensitivity level corresponding to the sensitivity level label; Retrieving context fragments associated with the search keyword in the material file based on the search keyword; Based on the search keywords and search permissions, context fragments associated with the search keywords are retrieved from the material files that are anonymized and labeled with sensitivity level labels.
[0104] In a possible implementation, the first generating unit is specifically configured to: Desensitize the retrieved context fragments; 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.
[0105] Optionally, after the large model generates the text and before displaying it to the user, the device further includes: The verification and checking unit is used to perform verification and checking on the generated text, and the verification and checking at least includes PII checking, compliance checking, consistency checking and hallucination detection.
[0106] Based on the same technical concept, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes 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 communicate with each other via the communication bus 404 .
[0107] Memory 403, used for storing computer programs; The processor 401 is configured to implement the steps of the writing assistance method integrating semantic retrieval and a large model when executing the program stored in the memory 403 .
[0108] The communication bus mentioned in the electronic devices mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into address buses, data buses, control buses, etc. For ease of illustration, only a single thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0109] The communication interface is used for communication between the above electronic device and other devices.
[0110] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0111] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0112] The writing assistance device that integrates semantic retrieval and large models provided in the embodiment of the present invention can be specific hardware on the device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in the embodiment of the present invention are the same as those in the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference can be made to the corresponding content in the aforementioned method embodiment. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.
[0113] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interface, the indirect coupling or communication connection of the device or unit may be electrical, mechanical or other forms.
[0114] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0115] In addition, each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0116] If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0117] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.
[0118] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or replace some of the technical features therein with equivalents. However, such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. They should all be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A writing assistance method integrating semantic retrieval and large models, characterized in that: The method comprises: 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, searching the material file for a context segment associated with the search keyword based on the search keyword; 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 2, characterized in that Retrieving a context segment associated with the search keyword in the material file based on the search keyword includes: Vectorize the search keywords to obtain the search keyword vector; Searching the vector library for a vector of text 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; The score of each retrieved text vector is compared with a preset score threshold, and text segments with scores greater than the preset score threshold are returned in descending order.
6. The method according to claim 1, characterized in that 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.
7. The method according to claim 6, 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.
8. The method according to claim 7, 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.
9. A writing assistance device integrating semantic retrieval and large models, 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 a 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.
10. 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 8 when executing the program stored in the memory.
Citation Information
Patent Citations
Recording-level data management method and system based on data dynamic desensitization
CN118260796A
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
Cited By
Text information processing method and electronic equipment
CN121166941A