Text universality degree scoring method based on big language model token
Through the text universality scoring method based on the open source large language model token, using SentencePiece and the maximum reverse matching word segmentation algorithm, the shortcomings of text universality evaluation in large language models are solved, and effective assessment and early warning of text universality are achieved, ensuring that Continuous training of large models and accuracy of business data.
Patent Information
- Application Number
- CN202410774677.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-10
AI Technical Summary
Existing technologies fail to effectively assess and monitor the generality of texts in large language models, resulting in potential anomalies and specialized texts not being discovered in time during model training and data analysis, affecting model performance and business decisions.
Using the text universality scoring method based on the open source large language model token, through SentencePiece training word list, maximum reverse matching word segmentation algorithm and general dictionary word segmentation, the compression ratio of the text is calculated, and scoring rules are formulated to judge the universality of the text, and for large models Training and business analysis provide early warning.
It achieves an effective assessment of the generality of texts, can detect knowledge system migration and specialized texts in advance, provides early warning, ensures the continuous training of large models and the accuracy of business data, and reduces the risk of model depreciation.
Smart Images

Figure SMS_3 
Figure SMS_1 
Figure QLYQS_1
Abstract
Description
Technical Field
[0001] The present invention relates to the field of AI language model processing technology, and in particular to a text universality scoring method based on a large language model token. Background Art
[0002] In 2024, the big language model has officially started to be widely used in the industry. RAG technology, Agent technology, plug-in technology, and SQL generation technology related to the big language model are in full swing. However, the industry has not paid enough attention to the tokens that are generally required for each basic big language model. This patent aims to propose a method for evaluating the universality of text based on big model tokens. First of all, the ability to score the universality of text based on open source big language model tokens is proposed for the first time in this patent. At the same time, from the perspective of the use value of this patent, the universality of the text reflects the universality of the text to a certain extent, that is, it reflects that the content of the text is more universal. If a piece of text is not universal, then the universality score of the text is low, and the text may be abnormal, that is, it needs to be paid special attention; at the same time, for a large language model that has been trained, if the user's batch data is judged to be abnormal through the implementation method of this patent, it can be warned whether the large model needs to be trained. Summary of the invention
[0003] In the process of developing large language models, word segmenters, i.e. tokenization, are often involved. However, when the main business of human beings changes, the data will also change. The existing large models will gradually depreciate with the changes of the times. This patent proposes tokens based on traditional technology and existing large model construction, and uses the maximum reverse matching word segmenter to perform word segmentation, statistical compression ratio, and formulate scoring rules to reflect the universality of the text. For texts with low universality, they can be focused on in advance, so that the large model can formulate new tokens and conduct large model training. At the same time, the universality of the text can be judged and analyzed by relevant business personnel, such as the business focus of abnormal text data. At the same time, the present invention proposes a complete, feasible, and low-cost technical implementation solution. At the same time, it is based on the open source large model token to implement the calculation of the universality of the text, which is unique to the industry. This patent has not been proposed by the industry from the technical implementation level, and has not been proposed from the perspective of capacity building, and has practical application value.
[0004] The following technical solutions are used to solve the existing technical problems: A method for scoring the universality of text based on a large language model token comprises the following steps: S1. Collect tokens of open source general large models The text dataset uses SentencePiece to train a vocabulary. The tokens of each open source general large model are trained from the general corpus. The tokens of the open source large model are summarized into a vocabulary. Based on these vocabulary, the general dictionary word segmentation algorithm is used to segment words, and the compression ratio will be obtained. S2. Aggregate tokens of open source general large models Summarize the tokens of the open source big model and import them into the Tokenizer function of the open source big model. The Tokenizer loads the tokenizer.model file and decodes the corresponding token for each index according to the vocabulary size of the open source big model, i.e., the code tokenizer.decode([index]). Then, all decoded tokens are stored in token_LLM. _ MMM.txt; collect tokens of multiple open source general large models, and then put them into a txt file, while removing duplicate tokens to form a general large model vocabulary; S3. Calculate the average text compression ratio based on the open source large model pre-training dataset Based on the open source high-quality large model pre-training data set, the current text character length is len_chars. After the open source general tokens are aggregated by S3 and segmented by the maximum reverse matching segmentation algorithm, the length is len_tokens. The compression ratio is len_tokens / len_chars, which is usually less than 1. The reverse maximum matching segmentation algorithm is used to segment the tokens of the open source general large model collected in the above tokens.txt. If a match is found, the token is segmented. The above operation is the text tokenization token segmentation compression ratio Ratio_ave_press, which represents the average compression degree of the current general tokens for the general corpus; S4. Develop a scoring rule for the universality of texts The current user's text to be tested is recorded as: Text, the text is tokenized, and the calculated compression ratio is recorded as: Ratio_Text_press. Then the text universality scoring method formulated by this patent is: That is to say, when the user test text has a higher compression ratio than the average, the score drops rapidly, indicating that the text is not universal and there is a high probability that the user's knowledge system has migrated, which means that special attention needs to be paid. For large models, it is also necessary to issue a warning as to whether the large model needs secondary training.
[0005] This patent proposes a method of collecting and aggregating open source tokens based on an open source general data set, aiming to make full use of the general tokens trained by the existing large model to form a calculation method for judging the universality of the text. The innovation of this patent is mainly reflected in the design of a technical idea that has not yet been realized in the industry to evaluate the universality of the text. This patent can realize a method for judging the universality of a text through a simple combination of operations in the current industry, but it is completely different from the implementation ideas of the traditional industry, and the idea scheme has not been proposed by the industry so far. At the same time, the calculation is simple to implement, and it has its own capabilities and practical value. It can judge whether there is obvious knowledge transfer in the current text, so as to judge whether a large model needs to be trained. At the same time, another use of this patent can tell users whether the text is special, too specialized, and domain-specific, and give reminders to knowledge managers. This patent focuses on protecting an implementation scheme for scoring the universality of text. DETAILED DESCRIPTION
[0006] A method for scoring the universality of text based on a large language model token comprises the following steps: S1. Collect tokens of open source general large models The text dataset uses SentencePiece to train a vocabulary. The tokens of each open source general large model are trained from the general corpus. The tokens of the open source large model are summarized into a vocabulary. Based on these vocabulary, the general dictionary word segmentation algorithm is used to segment words, and the compression ratio will be obtained. S2. Aggregate tokens of open source general large models Summarize the tokens of the open source big model and import them into the Tokenizer function of the open source big model. The Tokenizer loads the tokenizer.model file and decodes the corresponding token for each index according to the vocabulary size of the open source big model, i.e., the code tokenizer.decode([index]). Then, all decoded tokens are stored in token_LLM. _ MMM.txt; collect tokens of multiple open source general large models, and then put them into a txt file, while removing duplicate tokens to form a general large model vocabulary; S3. Calculate the average text compression ratio based on the open source large model pre-training dataset Based on the open source high-quality large model pre-training data set, the current text character length is len_chars. After the open source general tokens are aggregated by S3 and segmented by the maximum reverse matching segmentation algorithm, the length is len_tokens. The compression ratio is len_tokens / len_chars, which is usually less than 1. The reverse maximum matching segmentation algorithm is used to segment the tokens of the open source general large model collected in the above tokens.txt. If a match is found, the token is segmented. The above operation is the text tokenization token segmentation compression ratio Ratio_ave_press, which represents the average compression degree of the current general tokens for the general corpus; S4. Develop a scoring rule for the universality of texts The current user's text to be tested is recorded as: Text, the text is tokenized, and the calculated compression ratio is recorded as: Ratio_Text_press. Then the text universality scoring method formulated by this patent is: That is to say, when the user test text has a higher compression ratio than the average, the score drops rapidly, indicating that the text is not universal and there is a high probability that the user's knowledge system has migrated, which means that special attention needs to be paid. For large models, it is also necessary to issue a warning as to whether the large model needs secondary training.
[0007] The following is described in conjunction with specific embodiments: In the process of developing the open source big model in the industry in S1, massive, general, high-quality, useful, and harmless text data sets are usually collected, and then a vocabulary is trained through SentencePiece based on these text data sets. Because the main ability of the big language model is the general large language model, the trained vocabulary has a wide range of versatility. This is the source of the innovation of this patent. This patent makes full use of the versatility of the general vocabulary in the development process of the open source general big model to establish the source of innovation of this patent. The tokens of each open source general big model are trained from the general corpus. The tokens of the open source big model are summarized into a vocabulary. Based on these vocabulary, the general dictionary segmentation algorithm is used for word segmentation, and the compression ratio will be obtained, thereby reflecting the versatility of the text. Please refer to the subsequent steps of S2 for details.
[0008] Almost every open source industry model in S2 must have a tokens vocabulary. Because the tokens of each manufacturer focus on slightly different areas of corpus, to develop the ability to evaluate the universality of a text, only using the tokens of a company's model will usually be one-sided. Therefore, this patent adopts the method of aggregating the tokens of the open source large models. If a certain open source general large model is LLM_MMM, and there are 256,000 vocabularies in total, then obtain its vocabulary through the following steps, import the Tokenizer function of the tokenizer of the open source large model, and the Tokenizer loads the tokenizer.model file. According to the vocabulary size of the open source large model, the corresponding token is de-decoded for each index (that is, the code tokenizer.decode([index])). Then all decoded tokens are stored in token_LLM _ In MMM.txt, taking Google's Gemma model as an example, the corresponding tokens vocabulary will be obtained. The content of some tokens of the Gemma model is as follows: Using the same method as above, you can collect tokens from various open source general large models, put them into a txt file, and remove duplicate tokens to form a general large model vocabulary.
[0009] S3 is based on open source high-quality large model pre-training data sets, such as China Telecom's open source large model pre-training set TeleChat-PTD. This patent only selects 1G of data (each text character length is greater than 200) to statistically analyze the text token segmentation compression ratio. The text token segmentation compression ratio is defined in this patent as follows: the current text character length is len_chars, and the length of the open source general tokens aggregated by S3 and segmented by the maximum reverse matching segmentation algorithm is len_tokens. The compression ratio is len_tokens / len_chars, which is usually less than 1. The reverse maximum matching segmentation algorithm is a commonly used segmentation algorithm based on a definition dictionary (i.e., the tokens of the open source general large model collected in the above tokens.txt): it is a method for searching and matching tokens from the end of a sentence to the beginning of a sentence. It uses the longest token unit to match tokens from right to left, and segmentation occurs when a match is found. The above operation is called text tokenization. The token segmentation compression ratio is calculated based on the above method for each text in the above 1G data set in the open source pre-trained large model data set, and then the compression ratio of each text in the 1G data set is averaged, which is recorded as Ratio_ave_press in this patent. The token segmentation compression ratio Ratio_ave_press represents the average compression degree of the current common tokens for the common corpus. The innovation of this patent is that the current user's test text is too large than the average compression ratio after passing through the word segmenter, which means that the defined tokens fail to play a sufficient word segmentation role. After the text is tokenized, the granularity of the tokens is too fine, which means that the text is likely to belong to a non-common data set, that is, there are anomalies or data belonging to unknown fields, which requires special attention. If the tokens after word segmentation are higher than the average compression ratio, it means that the tokens in the common vocabulary tokens.txt have fully played a role in the word segmentation of the text, thereby indicating that the text belongs to a more general text.
[0010] Ratio_ave_press in S4 is the average compression ratio of each text in 1G data, which is usually a constant less than 1. The current user's test text is recorded as: Text, and the text is tokenized and the calculated compression ratio is recorded as: Ratio_Text_press. The text universality scoring method formulated by this patent is: That is to say, when the user test text has a higher compression ratio than the average, the score drops rapidly, indicating that the text is not universal and there is a high probability that the user's knowledge system has migrated, which means that special attention needs to be paid. For large models, it is also necessary to issue a warning as to whether the large model needs secondary training.
[0011] Take the following text content as an example, "The big language model is a deep learning model trained based on massive text data. It can not only generate natural language text, but also deeply understand the meaning of the text and handle various natural language tasks, such as text summarization, question answering, translation, etc.". The sentence has a character length of 74. After tokenization, it is ['big language model', 'is based on', 'massive', 'text data', 'training', 'of', 'deep learning model', '. ', 'it', 'can', 'generate', 'natural language text', ',', 'also can', 'deeply understand', 'text', 'meaning', ',', 'handle', 'various', 'natural language tasks', ',', 'such as', 'text summarization', ',', 'question answering', ',', 'translation', 'etc.', '. '] is 30 characters long, so the compression ratio is 30 / 74=0.405. If the average compression ratio is 0.3, the text universality score is 100*0.3 / 0.405=74 points. To prove the validity of this patent, this patent tests another abnormal non-universal text "Electrons in nanowires are quantum bound laterally, and the energy levels are discontinuous. This quantum bound characteristic is manifested as discontinuous resistance values in some nanowires. This discrete value is caused by the limitation of the number of electrons passing through the nanowire by quantum effects at the nanoscale. These isolated values are usually referred to as resistance quantization. As an important component of nanotechnology, nanowires have many properties that are not found in large or three-dimensional objects." The character length of this sentence is 139, and after tokens segmentation, it is 75. The text universality score is 100*0.3 / (75 / 139)=55.6 points. Because the following text is too specialized and domain-specific, its universality is very low, while the knowledge related to the above-mentioned universal large model is a popular and universal direction at present, so it has a higher score.
[0012] Glossary LLM: LLM usually refers to "Large Language Model". These models are an important breakthrough in the field of artificial intelligence, capable of understanding and generating natural language text. With the advancement of technology, LLM has grown to a huge scale and is capable of handling complex language tasks such as text translation, question answering, writing, and conversation.
[0013] Text universality: The universality of a text reflects the universality of the text to a certain extent. If a large language model has been trained, if a text is tokenized through a universal vocabulary and the word segmentation is too fine, the universality of the text is very low and the text has special professionalism, etc., and special attention should be paid to it.
[0014] Token: A token is a basic element in a text. It can be a character, Chinese word, English word, punctuation mark, subword, idiom, tool name, common function name, or common place name.
[0015] Tokenization: The role of tokenization is to split text into the smallest processable units for subsequent text analysis and application. That is, through tokenization, the text is converted into a token sequence, and then the corresponding index is assigned, and then through the embedding layer, a vector representation is assigned, and then the language model technology can be used for text generation or text understanding.
Claims
1. A text universality scoring method based on large language model tokens, characterized by The steps include: S1. Collect tokens of open source general large models The text dataset uses SentencePiece to train a vocabulary. The tokens of each open source general large model are trained from the general corpus. The tokens of the open source large model are summarized into a vocabulary. Based on these vocabulary, the general dictionary word segmentation algorithm is used to segment words, and the compression ratio will be obtained. S2. Aggregate tokens of open source general large models Summarize the tokens of the open source big model and import them into the Tokenizer function of the open source big model. The Tokenizer loads the tokenizer.model file and decodes the corresponding token for each index according to the vocabulary size of the open source big model, i.e., the code tokenizer.decode([index]). Then, all decoded tokens are stored in token_LLM. _ In MMM.txt; Collect tokens from multiple open source general large models, put them into a txt file, and remove duplicate tokens to form a general large model vocabulary; S3. Calculate the average text compression ratio based on the open source large model pre-training dataset Based on the open source high-quality large model pre-training data set, the current text character length is len_chars. After the open source general tokens are aggregated by S3 and segmented by the maximum reverse matching segmentation algorithm, the length is len_tokens. The compression ratio is len_tokens / len_chars, which is usually less than 1. The reverse maximum matching segmentation algorithm is used to segment the tokens of the open source general large model collected in the above tokens.txt. If a match is found, the token is segmented. The above operation is the text tokenization token segmentation compression ratio Ratio_ave_press, which represents the average compression degree of the current general tokens for the general corpus; S4. Develop a scoring rule for the universality of texts The current user's text to be tested is recorded as: Text, the text is tokenized, and the calculated compression ratio is recorded as: Ratio_Text_press. The text universality scoring formula formulated by this patent is: That is, when the user test text has a higher compression ratio than the average, the score drops rapidly, indicating that the text has a low degree of universality.
