Overseas multi-country address resolution method and electronic equipment
By designing a general prompt template and multi-copy strategy, combining a large language model and data cleaning process, automated analysis of overseas addresses in many countries is achieved, and analysis problems and data labeling problems in the existing technology are solved, and the accuracy and stability of analysis are improved.
Patent Information
- Application Number
- CN202411814257.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art has limitations in address resolution in multiple overseas countries, making it difficult to achieve efficient analysis and data cleaning of automated systems, especially without providing and labeling data in advance.
A general prompt template is designed to be used for the inference strategy of large language models. By configuring and deploying large language models, enabling multi-copy policies, customizing Prompt templates and data cleaning processes, we can realize automatic analysis of overseas addresses in many countries.
Without providing and labeling data in advance, accurate analysis of overseas addresses in many countries can be completed, improving the accuracy and stability of the analysis, and solving the problem of effective labeling of overseas address data by large language models.
Smart Images

Figure CN119886107A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of logistics, and in particular relates to an overseas multi-country address resolution method and electronic equipment. Background Art
[0002] In the field of artificial intelligence technology, especially in the application of natural language processing (NLP) and large language models (LLM), there are already a variety of technical frameworks and models for processing text data. These technologies have made significant progress in text generation, understanding, and reasoning, but for specific tasks such as automated systems for overseas multi-country address resolution, existing technologies still have some limitations.
[0003] Currently, the text generation inference framework and the huggingface native framework are two common acceleration frameworks. These frameworks have shown certain capabilities in processing text generation tasks, but they are usually not as good as the vllm framework in terms of ease of deployment and acceleration effect. The vllm framework has shown better performance in this field due to its optimized deployment process and significant acceleration effect.
[0004] In terms of the selection of large models, there are many open source large language models on the market, which can be deployed locally to adapt to different application scenarios. For example, Baichuan2, Qwen1.5, Atom, Openbuddy-llama2, Meta-Llama-2 and Meta-Llama-3 are all in this list.
[0005] In terms of generation strategies, there is currently no universal solution that can be applied to all scenarios. Generation strategies need to be customized according to specific application scenarios and requirements. This means that when developing an automated overseas multi-country address resolution system, it is necessary to design appropriate prompt reasoning strategies based on the characteristics and resolution requirements of overseas addresses to achieve efficient address resolution and data cleaning processes. Summary of the invention
[0006] Purpose of the invention: In order to overcome the deficiencies in the prior art, the present invention provides an overseas multi-country address resolution method and electronic device, designs a universal prompt template for use in reasoning strategies, and can complete the reasoning of multi-country overseas addresses without providing and annotating data in advance.
[0007] Technical solution: To achieve the above purpose, the technical solution of the present invention is as follows:
[0008] An overseas multi-country address resolution method, comprising:
[0009] Configure and deploy a large language model, and enable one or more replication strategies;
[0010] Customized Prompt template, suitable for forming a general template;
[0011] Using a large language model and a copy strategy, the universal template infers a specific country address based on a prompt in any language;
[0012] The inference results are cleaned and the overseas address parsing model is trained with the cleaned data.
[0013] Furthermore, methods for customizing the Prompt template include:
[0014] Set the initial prompt with a common format;
[0015] Translate the initial prompt into English text, which contains the country address of a specific country;
[0016] According to the format of the national address, the variable content of the national address is filled in and used as the real prompt of the large language model.
[0017] Furthermore, the format of the Prompt template includes:
[0018] Role setting, assigning a role to the agent in the large language model;
[0019] Field settings, the input prompt contains [specific country fields];
[0020] The setting is required, and the large language model returns two fields: [Specific Country] and [Specific Country Address].
[0021] Furthermore, the step of inferring the corresponding country address includes: utilizing a multi-copy reasoning strategy, randomly sending a request to a request queue of any one of the copies, and then continuously collecting reasoning results.
[0022] Furthermore, the inference results are cleaned by using regular expression extraction and field validation strategies to filter out inference results that meet the format.
[0023] Further, the following steps are included:
[0024] The output of the large language model is regulated to extract the JSON-style content, and then the JSON-formatted content is checked. If it passes, it is continued, otherwise it is discarded;
[0025] Capitalize the large language model and the original address, and then check whether the fields in the json have appeared in the original address. If all of them appear, they will be used as training data for the next step, otherwise they will be discarded.
[0026] Furthermore, the cleaned data is selected as a training set, and a sequence labeling model is used to perform the address resolution task to obtain an overseas address resolution model.
[0027] Furthermore, the sequence labeling model includes a BERT model.
[0028] Furthermore, the overseas address resolution model is exported from Engine and deployed using Triton.
[0029] An electronic device comprising a memory for storing a computer program;
[0030] The processor is used to execute the computer program to implement the overseas multi-country address resolution method.
[0031] Beneficial effects: The present invention designs a universal prompt template for inference strategy, which can complete the inference of overseas addresses in multiple countries without providing and annotating data in advance. Through the integration of universal prompt templates and country-specific information, this strategy creatively combines elements such as roles, fields, requirements, etc. according to the specific needs of address resolution, and makes personalized adjustments based on the characteristics of addresses in different countries, effectively guiding the large language model to accurately understand complex and diverse address structures, improving the accuracy and stability of resolution, and specifically solving the problem of how to effectively annotate overseas address data through a large language model, without the need to provide and annotate data in the pre-trained model in advance. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Attached Figure 1 It is a schematic diagram of the overall process of the present invention;
[0033] Attached Figure 2 It is a schematic diagram of multiple replica deployment of the present invention;
[0034] Attached Figure 3 A schematic diagram of a general prompt template of a specific embodiment of the present invention;
[0035] Attached Figure 4 The figure is a schematic diagram of data formatting and cleaning according to a specific embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] The terms used in the present disclosure are for the purpose of describing specific embodiments only and are not intended to limit the present disclosure. The singular forms "a", "said" and "the" used in the present disclosure and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise.
[0038] The specific implementation of the present invention is further described in detail below in conjunction with the drawings and examples.
[0039] As attached Figure 1 As shown, a method for overseas multi-country address resolution includes:
[0040] Configure and deploy a large language model, enable one or more copy strategies; customize the prompt template to form a universal template; use the large language model and the copy strategy, and the universal template infers a specific country address based on the prompt in any language; perform data cleaning on the inference results, and use the cleaned data to train an overseas address resolution model.
[0041] The present invention designs a universal prompt template for inference strategy, which can complete the inference of overseas addresses in multiple countries without providing and annotating data in advance. Through the integration of universal prompt templates and country-specific information, this strategy creatively combines elements such as roles, fields, requirements, etc. according to the specific needs of address resolution, and makes personalized adjustments based on the characteristics of addresses in different countries, effectively guiding the large language model to accurately understand complex and diverse address structures, improving the accuracy and stability of resolution, and specifically solving the problem of how to effectively annotate overseas address data through a large language model, without the need to provide and annotate data in the pre-trained model in advance.
[0042] More specifically, methods for customizing the Prompt template include:
[0043] An initial prompt with a universal format is set; the initial prompt is translated into English text, wherein the English text contains a country address of a specific country; and according to the format of the country address, variable content of the country address is filled in as a real prompt of the large language model.
[0044] Design a general prompt template for Chinese address resolution. This template should be as short as possible. The longer the prompt is, the longer the request time for large models will be. This template contains three general parts: role setting, field setting, and requirement setting. Design a prompt that contains country-specific prompt information. The field setting prompt contains [country-specific field], and the requirement setting contains two fields: [country-specific] and [country-specific address].
[0045] For example, see Attachment Figure 2As shown, the prompt for the Philippines address is first translated into English, and then the variable content of the prompt is filled in as the real prompt for the large model.
[0046] More specifically, the format of the Prompt template includes:
[0047] Role setting, assigning the role of the agent in the large language model; field setting, the input prompt contains [specific country field]; requirement setting, the large language model returns two fields: [specific country] and [specific country address].
[0048] In view of the address characteristics of different countries, Prompt templates containing common parts such as roles, fields, requirements, etc. are designed, and country-specific information is added. Through this customized design, the large language model can better understand and process the complex and changeable overseas address structure, improving the accuracy and stability of address resolution.
[0049] In this solution, configuring and deploying a large language model and enabling one or more replica strategies means that multiple copies can be processed according to the performance of the terminal processor, thereby improving the processing speed.
[0050] Use the vllm framework to configure and deploy the Openbuddy-llama2-70b-v10.1-bf16 model. The original vllm multi-card loading method is that one copy occupies multiple GPUs, but after experiments, it is found that under the same total GPU occupancy, multiple copies are opened, and each copy occupies a small number of GPUs. The overall number of requests can be greater, so for an 8-card A100 machine, one copy deployed through vllm is placed on every two graphics cards, and one machine can place four copies, such as Figure 2 shown.
[0051] Among them, vllm has some configuration details in addition to multi-copy deployment
[0052] 1. Set skip_special_tokens to False. This parameter will automatically replace the special start and end tokens output by the model with empty characters. Although you can no longer see them, the requester does not know when to stop when making a request. After setting this parameter to False, the requester only needs to specify the start and end symbols of the corresponding model to stop the model generation when it is time to stop.
[0053] 2. Setting the vllm requester
[0054] temperature=0.7, that is, the randomness of the generated text is controlled to be less than the threshold value X1, where the value range of X1 is 0~1.
[0055] top_p=0.85, that is, controls the range of vocabulary considered in the generation process. When sampling, only the vocabulary with the highest top_p percentage of cumulative probability is considered, where the value range of top_p is 0~1.
[0056] max_tokens = 200, which limits the maximum number of words that the model can generate before stopping generation to X2, where the value range of X2 is 50 to 1000.
[0057] stop=["[ / INST]",""]; that is, it is used to specify the termination condition for generating text.
[0058] temperature: This is a parameter that controls the randomness of the generated text. A lower value (close to 0) will make the generated text more inclined to choose the option with the highest probability, that is, more deterministic; a higher value (greater than 0) will increase the randomness and make the model explore more possible words. When set to 0, the model will adopt greedy sampling, that is, always choose the word with the highest probability.
[0059] top_p: This parameter is used to control the range of vocabulary considered during generation. It means that only the top_p percentage of vocabulary with the highest cumulative probability will be considered during sampling. For example, top_p = 0.85 means that only the 85% of vocabulary with the highest cumulative probability will be considered for generation. This value must be between 0 and 1 (excluding 0 and including 1). When set to 1, it means that the range of vocabulary considered is not restricted.
[0060] stop: This is a list of strings that specify the termination condition for generating text. When the generated text contains any of the strings in the list, the generation process stops. These strings are often used as a clear end signal to avoid generating too long text.
[0061] max_tokens: This parameter limits the maximum number of words that the model can generate before stopping. For example, max_tokens = 200 means that the model will stop outputting after generating 200 words, regardless of whether the text is complete. This parameter helps control the length of the generated text and avoid generating too long or unnecessary content.
[0062] The steps of inferring the corresponding country address include: using a multi-copy reasoning strategy, randomly sending the request to the request queue of any of the copies, and then continuously collecting the reasoning results.
[0063] For example, more than 20 million overseas address data are input into the deployed large model, and a multi-copy inference strategy is used, that is, each request is randomly sent to the request queue of a certain copy, and then the inference results are continuously collected until all data inference is completed. The duration is related to the deployed machine model. In this embodiment, the Philippines solution uses two 8-card A100s with a total of 8 copies, which takes nearly 7 days.
[0064] In some specific implementations, data cleaning of the inference results uses regular expression extraction and field verification strategies to filter out inference results that meet the format. The following steps are included:
[0065] The output of the large language model is regulated to extract the json-style content, and then the json check is performed. If it passes, it is continued, otherwise it is discarded; the large language model and the original address are capitalized, and then the json fields are checked to see if they have appeared in the original address. If all of them appear, they are used as the training data for the next step, otherwise they are discarded. Since the results generated by the large language model are not necessarily accurate, they need to be cleaned. This method of cleaning is highly efficient and accurate. For reference, Figure 4 .
[0066] Through large-scale data reasoning and strict two-stage data processing (formatting and cleaning), the quality of training data input to the lightweight model is ensured. In particular, in the data cleaning stage, inaccurate reasoning results are removed through strategies such as regular expression extraction and field verification, ensuring the efficiency and accuracy of subsequent model training.
[0067] In some specific implementations, the cleaned data is selected as a training set, and a sequence labeling model is used to perform the address resolution task to obtain an overseas address resolution model. Optionally, the sequence labeling model includes a BERT model.
[0068] Select the cleaned data as the training set and design a sequence labeling model to focus on the address parsing task. The model here can be any model that can solve the NER task. The Bert model is used here.
[0069] The lightweight sequence annotation model trained based on the cleaned high-quality data set not only maintains high parsing accuracy, but also significantly enhances the response speed and resource utilization in the online environment through model optimization (such as Engine export and Triton deployment). This lightweight design makes the system more suitable for integration and deployment of practical applications while ensuring parsing performance, improving the practicality and scalability of the system.
[0070] In some specific implementations, the overseas address resolution model is exported from Engine and deployed using Triton. The model in the previous step is exported from Engine and deployed using Triton, and the deployment using Triton is 3 to 10 times faster than the deployment without Triton.
[0071] The Openbuddy-llama2-70b-v10.1-bf16 model was deployed through the vllm framework. The original vllm multi-card loading method was that one copy occupied multiple GPUs. However, after experiments, it was found that under the same total GPU occupancy, multiple copies were opened, and each copy occupied a small number of GPUs. The overall number of requests can be greater, so the multi-copy strategy (deploy one copy for every two graphics cards) was adopted, which not only fully utilized hardware resources, but also significantly improved the reasoning speed of local large models. The optimized deployment process and acceleration capabilities of the vllm framework make model reasoning more efficient, solving the shortcomings of traditional frameworks in deployment difficulty and acceleration effect.
[0072] In some specific implementations, a distributed cloud computing platform can also be used for deployment: Different from the deployment on local hardware using the vllm framework, large language models can be deployed on a distributed cloud computing platform, such as Google Cloud, AWS, or Alibaba Cloud. This can flexibly expand computing resources and dynamically adjust the inference speed according to demand, but this method will increase the cost of purchasing cloud servers, and data also needs to be transmitted.
[0073] Another existing method is not to use a large model directly for reasoning, but to first select a smaller pre-trained model and fine-tune it for overseas address resolution tasks. Although this method may sacrifice some resolution accuracy, due to the smaller model size, the reasoning speed will be faster and resource consumption will be less. This method requires data preparation in advance, and this application solution is implemented without labeled data.
[0074] An electronic device comprising a memory for storing a computer program;
[0075] The processor is used to execute the computer program to implement the overseas multi-country address resolution method.
[0076] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information.
[0077] In the description of the present invention, it is necessary to understand that the terms "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0078] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for overseas multi-country address resolution, characterized in that: include: Configure and deploy a large language model, and enable one or more replication strategies; Customized Prompt template, suitable for forming a general template; Using a large language model and a copy strategy, the universal template infers a specific country address based on a prompt in any language; The inference results are cleaned and the overseas address parsing model is trained with the cleaned data.
2. The method for overseas multi-country address resolution according to claim 1, characterized in that: Methods for customizing the Prompt template include: Set the initial prompt with a common format; Translate the initial prompt into English text, which contains the country address of a specific country; According to the format of the national address, the variable content of the national address is filled in and used as the real prompt of the large language model.
3. The overseas multi-country address resolution method according to claim 2 is characterized in that: The format of the Prompt template includes: Role setting, assigning a role to the agent in the large language model; Field settings, the input prompt contains [specific country fields]; The setting is required, and the large language model returns two fields: [Specific Country] and [Specific Country Address].
4. The overseas multi-country address resolution method according to claim 1 is characterized in that: The steps of inferring the corresponding country address include: using a multi-copy reasoning strategy, randomly sending the request to the request queue of any of the copies, and then continuously collecting the reasoning results.
5. The overseas multi-country address resolution method according to claim 1 is characterized in that: The inference results are cleaned by using regular expression extraction and field validation strategies to filter out inference results that conform to the format.
6. The overseas multi-country address resolution method according to claim 5, characterized in that: The following steps are involved: The output of the large language model is regulated to extract the JSON-style content, and then the JSON-formatted content is checked. If it passes, it is continued, otherwise it is discarded; Capitalize the large language model and the original address, and then check whether the fields in the json have appeared in the original address. If all of them appear, they will be used as training data for the next step, otherwise they will be discarded.
7. The overseas multi-country address resolution method according to claim 1, characterized in that: The cleaned data is selected as the training set, and a sequence labeling model is used to perform the address parsing task to obtain the overseas address parsing model.
8. The overseas multi-country address resolution method according to claim 7, characterized in that: The sequence labeling model includes a BERT model.
9. The overseas multi-country address resolution method according to claim 1, characterized in that: The overseas address resolution model is exported from Engine and deployed using Triton.
10. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the overseas multi-country address resolution method as described in any one of claims 1 to 9.