Classification processing program and method
The classification processing program and method leverage a large language model to classify natural language strings into predefined categories, addressing the complexity of natural language processing and enhancing accuracy.
Patent Information
- Application Number
- JP2025020382
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2023-03-21
- Filing Date
- 2025-02-11
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2044-01-20
AI Technical Summary
Existing technologies face challenges in efficiently performing classification processing of character strings consisting of natural language due to the complexity of natural language processing.
A classification processing program and method that utilizes a large language model, such as GPT-4, to classify character strings into predefined categories by inputting them through a terminal connected to a generation AI server via a network, enhancing accuracy by preprocessing the strings and providing specific classification instructions.
Enables accurate classification of natural language strings into predefined categories, improving the efficiency and effectiveness of natural language processing tasks.
Smart Images

Figure 0007710775000001 
Figure 0007710775000002 
Figure 0007710775000003
Abstract
Description
Technical Field
[0001] The present invention relates to a classification processing program and and a method.
Background Art
[0002] Patent Document 1 discloses a patent map generation program.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] In Patent Document 1, text mining processing is used for the classification processing of character strings. However, the processing of classifying character strings consisting of natural language is highly difficult.
[0005] The present invention has been made to solve such conventional problems, and an object thereof is to perform classification processing of character strings consisting of natural language.
Means for Solving the Problems
[0006] The present invention is a classification processing program that causes a computer to input, into a large language model, each of a plurality of character strings related to a specific target and classification instruction information including an instruction to classify each of the plurality of character strings into any one of a plurality of classifications expressed in natural language, and to execute a process of obtaining classification result information in which each of the plurality of character strings is classified into any one of the plurality of classifications expressed in natural language from the large language model.
[0007] The present invention is a classification processing method in which a computer inputs, into a large language model, each of a plurality of character strings related to a specific target and classification instruction information including an instruction to classify each of the plurality of character strings into any one of a plurality of classifications expressed in natural language, and executes a process of obtaining classification result information in which each of the plurality of character strings is classified into any one of the plurality of classifications expressed in natural language from the large language model.
[0008] The present invention is a classification processing method executed in a system in which a generation AI server that provides natural language processing by a large language model and a terminal are connected via a network. The terminal transmits string information consisting of natural language and classification instruction information including classification by a plurality of natural languages to the generation AI server, and the generation AI server classifies the string information consisting of natural language into classifications by a plurality of natural languages based on the classification instruction information and transmits it to the terminal.
Effects of the Invention
[0009] The classification processing program of the present invention and According to the method, it becomes possible to perform classification processing of a string consisting of natural language.
Brief Description of the Drawings
[0010]
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Modes for Carrying Out the Invention
[0011] Hereinafter, the classification processing program and and method of the embodiment will be described in detail with reference to the drawings.
[0012] Figure 1 is a schematic diagram of a system that executes a classification processing program. An information processing device (Terminal 1) for executing the classification processing program is connected to a generative AI server 2 via a network.
[0013] The generative AI server 2 is a computer that executes classification of the input string. The generative AI server 2 of the embodiment is, for example, a cloud-based service incorporating large language models such as ChatGPT (above, conversational service) of OpenAI, GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, GPT-3.5, GPT-3 (above, API service). Note that the generative AI server 2 is not limited to this, and may be a generative AI server that provides a natural language processing service incorporating a large language model that provides similar functions (for example, Bard (above, conversational service) and Gemini (above, API service) developed by Google).
[0014] The generative AI server 2 of the embodiment has a CPU, a memory, an input / output device, and an external interface, and executes and outputs natural language processing (classification processing in the embodiment) incorporating a large language model in response to an input from an external device.
[0015] Figure 2 is a block diagram of an information processing device (Terminal 1) for executing the classification processing program of the embodiment.
[0016] Via a system bus 108, a CPU (Central Processing Unit) 101, a ROM (Read Only Memory) 102, a RAM (Random Access Memory) 103, an HDD (Hard Disk Drive) 105, an external I / F (Interface) 106, and an input unit 107 are connected. The control unit 104 is constituted by the CPU 101, the ROM 102, and the RAM 103.
[0017] The ROM 102 stores in advance programs and threshold values to be executed by the CPU 101. The RAM 103 has various memory areas such as an area for expanding the programs executed by the CPU 101 and a work area that serves as a work area for data processing by the programs.
[0018] The HDD 105 stores natural language text data (such as patent data and questionnaire data) input from the input unit 107. The external I / F 106 is an interface for communicating with an external device such as an external server.
[0019] The external I / F 106 may be any interface for data communication with an external device. For example, it may be a device (such as a USB memory) that is locally connected to the external device, or it may be a network interface for communication via a wired or wireless network.
[0020] The control unit 104 exchanges data with an external device (such as a generation AI server) via the external I / F 106 to obtain python libraries necessary for program execution, transmit string data, and receive classification results.
[0021] The external I / F 106 is connected to a display device (not shown) such as a liquid crystal display. The input unit 107 is an input device such as a keyboard, a mouse, and a scanner (reading device).
[0022] (Embodiment 1: Patent Data Analysis) Next, the processing procedures of the classification processing program and method of Embodiment 1 will be described. In Embodiment 1, an example of creating a problem - solution means map for absorbent articles is shown. The following Code Blocks 1 to 9 connected continuously are the program and method of the embodiment and should basically be described continuously. However, for ease of explanation, they are divided into 9 parts for description.
[0023] Figure 3 is a flowchart of the processing of the classification processing program and method of the embodiment. In STEP1, the problem part and the solution part are extracted from the summary (string information). In STEP2, the extracted problems (first category classification) are classified. In STEP3, the extracted solution means (second category classification) are classified. In STEP4, a cross-tabulation is performed using the classified problems and solution means. In STEP5, the tabulation result is visualized.
[0024] Note that in the embodiment, patent data (summary) is used as the string to be processed, but the target of the string is not limited to this, and the strings in the specification text and claims may be used, or strings such as questionnaires and user reviews other than patent data may be used as the processing target.
[0025] (STEP1: Step for Extracting Problems and Solution Means) First, the control unit 104 extracts the problem string and the solution means string from the summaries of a plurality of patent data. The program is as follows. The following program is a Python program stored in the control unit of the information processing device (terminal 1). However, other programming tools and programming languages may be used. Also, the following program is just an example, and the processing order, the libraries, functions, and variable names used may be changed.
[0026] (Code Block 1) import pandas as pd from google.colab import drive drive.mount(' / content / drive') df = pd.read_excel(' / content / drive / MyDrive / patdata.xlsx') df['problem'] = df['summary'].str.extract('[Problem](.+?)[Solution]', expand=False) df['solution'] = df['summary'].str.extract('[[Solution means]](.+?)[[Selected drawing]]', expand=False)
[0027] To explain this program in detail, it is as follows. First, the control unit 104 imports a module called pandas. Pandas is a tool for data analysis in Python. Next, it imports a function called drive from a module called google.colab. Drive is a function for accessing Google Drive.
[0028] The control unit 104 executes the drive function to mount Google Drive at the path ' / content / drive'. Mounting means making the files and folders on Google Drive operable on Colab.
[0029] The control unit 104 uses the pd.read_excel function to read the Excel file named patdata.xlsx located at the path ' / content / drive / MyDrive / patdata.xlsx'. This Excel file stores patent data containing multiple pieces of abstract data. A part of the data frame is shown in Figure 4. The content of the patent abstract is stored in the summary column of the patent data. Note that in Figure 4, only 3 cases (3 rows) are exemplified due to space limitations, but in the embodiment, a data frame of 50 cases (50 rows) is used. Of course, more cases are also possible.
[0030] The control unit 104 assigns the read file to a variable called df. Df is a tabular data structure called a data frame. By doing df['summary'], only the column named summary is extracted from df. The content of the patent abstract consisting of natural language is stored in the summary column.
[0031] The control unit 104 uses the str.extract function to extract the character string from the "problem" to the "solution means" part from the summary column. This part of the character string represents the problem of the patent (referred to as problem string information). Add the extracted part of the character string to a new column named problem. By setting df['problem'] =..., a new column problem is created in df.
[0032] Similarly, the control unit 104 uses the str.extract function to extract the character string from the "solution means" to the "selected figure" part from the summary column. This part of the character string represents the solution means of the patent (referred to as solution means string information). Add the extracted part of the character string to a new column named solution. By setting df['solution'] =..., a new column solution is created in df.
[0033] Figure 5 shows the data frame in which the problem column and the solution column are added by the processing of STEP1. Note that in Figure 5, only 3 cases (3 rows) are illustrated due to space limitations, but in the embodiment, a data frame consisting of 50 cases (50 rows) is generated. Note that the character string in the summary column is omitted because it is described in Figure 4.
[0034] Note that the process of extracting the character strings of "problem" and "solution means" from this summary is not essential. That is, it is also possible to directly send the entire summary as character string information to the generation AI server for classification. However, by extracting and classifying the character strings of "problem" and "solution means" individually, the classification accuracy by the generation AI server 2 can be improved. Therefore, it is preferable to provide a process for extracting the character strings of "problem" and "solution means".
[0035] (STEP2: Problem Classification Step) Next, the control unit 104 sends problem classification instruction information including a plurality of problem string information and a plurality of problem classifications (classification of the first category) to the generation AI server and receives problem classification result information from the generation AI server. The program is as follows.
[0036] (Code block 2) ! pip install openai import openai import re
[0037] This command is used to install the OpenAI Python library. The! indicates that the command should be interpreted as a shell command. pip is a Python package manager, and install is the command used to install a library.
[0038] The control unit 104 imports the Python libraries openai and re. The openai library is used to execute various natural language processing tasks using the OpenAI API, and the re library is used for regular expressions. Note that in actual use of the openai library, an API key needs to be input, but since it would be an obstacle to publication, it is omitted from the program description.
[0039] (Code block 3) def generate_p_class(text): response = openai.ChatCompletion.create( model="gpt-4", messages= {"role": "system", "content": "· For the following input text, assign it to one of the five classifications: 'non-leaking property','non-stuffy property', 'easy-to-move property', 'gentle-to-skin property', 'other'."}, {"role": "user", "content": text}]) p_class = response["choices"][0]["message"]["content"] return p_class
[0040] This program uses OpenAI's language model "GPT-4" to provide the function of classifying a given text into one of five categories. Note that the language model is not limited to "GPT-4", and it may be "GPT-4 Turbo", "GPT-3.5 Turbo", or the next version of the GPT series. These are known to exhibit high accuracy in natural language processing tasks.
[0041] The generate_p_class(text) function takes one text as an argument, and the control unit 104 calls OpenAI's Chat Completion API to classify the text. The API sends a message composed of two roles, the system and the user, and sends an instruction from the system side: "Please assign one of the five classifications of 'non-leakage property','non-stuffy property', 'easy-to-move property', 'gentle-to-skin property', and 'others' to the next input text." This instruction information is referred to as task classification instruction information.
[0042] Note that 'non-leakage property', 'non-stuffy property', 'easy-to-move property', 'gentle-to-skin property', and 'others' are pre-defined classifications of tasks consisting of natural language (the first category of classification). Also, the expression of the task is not limited to "~ property", and other expressions may be used. Also, the instruction content (prompt) in natural language may be made more detailed. In the embodiment, it is an instruction to classify into one of them, but it may also be an instruction to classify into multiple ones. Also, the number of classifications is not limited to five, and it may be more or less.
[0043] The generation AI server 2 classifies the given text (task string information) into an appropriate classification based on the task classification instruction information and returns it. The response from the generation AI server 2 includes the text of the classified classification (task classification result information). The task classification result information is stored in the p_class variable and returned as the output of the function.
[0044] (Code block 4) def clean_text(text): text = re.sub(r'\s+', ' ', text) text = re.sub(r'[^\w\s]', '', text) return text
[0045] This program is a function that returns a string with special characters and extra whitespace removed from the string (text) received as an argument. Specifically, it performs string operations using re (regular expression operations), which is a standard library in Python.
[0046] re.sub(r'\s+', ' ', text) replaces consecutive whitespace characters with a single whitespace character. \s represents whitespace characters, and + indicates that it should occur one or more times. That is, it replaces multiple whitespace characters with one.
[0047] Next, re.sub(r'[^\w\s]', '', text) deletes characters other than alphanumeric characters and whitespace. [^\w\s] represents characters other than alphanumeric characters and whitespace, and ^ represents negation. That is, this means removing characters other than alphanumeric characters and whitespace.
[0048] Finally, it returns the cleaned string. return text indicates that the function returns the cleaned string as its output. Note that this code block 4 is not essential.
[0049] (Code block 5) df['p_class'] = df['problem'].apply(lambda x: generate_p_class(clean_text(x)))
[0050] This program is used to add the classification (p_class) generated by the generate_p_class function after cleaning each line of text stored in the 'problem' column of the Pandas DataFrame df using the clean_text function to a new column 'p_class' in df.
[0051] The control unit 104 uses the apply method to apply the clean_text function to each line of the string in the df['problem'] column to clean the text. lambda x: represents the argument applied to the clean_text function.
[0052] Next, the control unit 104 passes the cleaned text to the generate_p_class function and assigns the result of classifying the text into one of five classifications to the df['p_class'] column. Finally, as shown in Figure 6, a DataFrame df containing the new 'p_class' column is returned.
[0053] (STEP3: Solution Classification Step) Next, the control unit 104 sends the solution classification instruction information including a plurality of solution string information and a plurality of solution classifications (second category classification) to the generation AI server and receives the solution result information from the generation AI server. The program is as follows.
[0054] (Code Block 6) def generate_s_class(text): response = openai.ChatCompletion.create( model="gpt-4", messages= {"role": "system", "content": "· For the following text, assign one of the five classifications: 'absorption structure', 'ventilation structure', 'texture structure', 'fixing structure', 'other'."}, {"role": "user", "content": text}]) s_class = response["choices"][0]["message"]["content"] return s_class
[0055] This program is a function for classifying the structure of a sentence using OpenAI's GPT-4 (GPT-3.5 is also acceptable) for the string (text) received as an argument.
[0056] The generate_s_class(text) function takes one text as an argument, and the control unit 104 calls OpenAI's Chat Completion API to classify the text. The API sends a message consisting of two roles, the system and the user, and sends an instruction from the system side: "For the next sentence to be input, please assign one of the five classifications: 'absorption structure', 'ventilation structure', 'texture structure', 'fixing structure', 'others'." This instruction information is referred to as solution classification instruction information.
[0057] Note that 'absorption structure','ventilation structure', 'texture structure', 'fixing structure', 'others' are classifications of solution means consisting of predefined natural languages (classification of the second category). Also, the expression of the solution means is not limited to "~ structure", and other expressions may be used. Also, the instruction content in natural language may be made more detailed. Also, in the embodiment, it is an instruction to classify into one of them, but it may be an instruction to classify into multiple. Also, the number of classifications is not limited to five, and may be more or less.
[0058] The generative AI server 2 classifies the given text (solution means string information) into an appropriate classification based on the solution classification instruction information and returns it. The response from the generative AI server 2 includes the classified classification text (solution classification result information). The solution classification result information is stored in the s_class variable and returned as the output of the function.
[0059] For requests to the API, the openai.ChatCompletion.create() method is used. The messages sent to the API are given as a list with two elements. The first element is a message with the role of "system" that represents the classification instructions. The next element has the role of "user" and represents the input text. When the API receives these messages, it generates and returns an appropriate classification. Finally, the classification result (s_class) is returned.
[0060] (Code block 7) df['s_class'] = df['solution'].apply(lambda x: generate_s_class(clean_text(x)))
[0061] This program creates the s_class column by applying a function for classifying the structure of the text in each row of the solution column of the data frame df using OpenAI's GPT-4.
[0062] Specifically, the control unit 104 preprocesses each text in df['solution'] using the clean_text function, and then stores the result of classifying the text structure using the generate_s_class function in the s_class column. Here too, a lambda expression is used to apply the function to each text.
[0063] The generate_s_class function classifies the given text using the OpenAI API as described earlier. Specifically, it prompts to assign one of the classifications of 'absorption structure', 'ventilation structure', 'texture structure', 'fixing structure', 'others' based on the structure included in the text. Finally, as shown in Figure 6, the classification results for each solution means are stored in df['s_class'].
[0064] FIG. 6 shows a data frame in which the p_class column and the s_class column are added by the processes of STEP2 and 3. Note that in FIG. 6, only an example of 20 cases (20 rows) is shown due to space limitations, but in the embodiment, a data frame df consisting of 50 cases (50 rows) is generated. Also, the descriptions of the summary column, problem column, and solution column are omitted because they are described in FIGS. 4 and 5.
[0065] (STEP4: Aggregation Step) Next, the control unit 104 performs a cross-tabulation on a plurality of summaries (string information) for each problem classification and solution means classification. The program is as follows.
[0066] (Code Block 8) result = df.groupby(['p_class','s_class']).size().reset_index(name='Counts')
[0067] In this program, the control unit 104 groups the data frame by p_class and s_class, and performs a so-called cross-tabulation to count (aggregate) the summaries for each problem classification and solution means classification. By this operation, the appearance frequency of solution means for each problem can be known. (STEP5: Visualization Step) Next, the control unit 104 visualizes the aggregation result. The program is as follows.
[0068] (Code Block 9) ! pip install japanize-matplotlib import matplotlib.pyplot as plt import numpy as np import matplotlib.cm as cm import japanize_matplotlib y = result['p_class'].tolist() x = result['s_class'].tolist() sizes = [size * 100 for size in result['Counts'].tolist()] nums = [num for num in result['Counts'].tolist()] categories = list(set(y)) colors = cm.rainbow(np.linspace(0, 1, len(categories))) colors = {categories[i]: colors[i] for i in range(len(categories))} colors = [colors[item] for item in y] fig, ax = plt.subplots(figsize=[8,8]) ax.scatter(x, y, s=sizes, c=colors) for i, txt in enumerate(nums): ax.annotate(txt, (x[i], y[i]), textcoords="offset points", xytext=(0,0), ha='left', va='bottom') ax.set_xlabel("Solution means") ax.set_ylabel("Problem") ax.set_title("Problem - Solution means map") plt.xticks(rotation=90) plt.show()
[0069] This program creates a so-called problem - solution means map. The control unit 104 creates a scatter plot using matplotlib. The s_class is placed on the x - axis and the p_class is placed on the y - axis, and the size and color of each point are set based on their respective categories. Specifically, the color corresponding to the value of the y - column (category of the problem) in the grouped result is obtained from the color list generated by the rainbow color map. Also, the count number of the category represented by each point is displayed at each point.
[0070] Finally, the control unit 104 sets the style of the graph and displays the graph on a display device (not shown), such as a liquid crystal display, connected via the external I / F 106 (Figure 7). Note that for mapping, other libraries such as seaborn may be used instead of matplotlib, or cross - tabulation may be performed using the crosstab function and output in the form of a contingency table or heat map.
[0071] Also, the visualization is not limited to this. It may be a time - series diagram showing the relationship between the filing date of the patent data and the above classification, or a line graph or bar graph showing the relationship between the applicant of the patent data and the above classification. By using matplotlib, various forms of visualization are possible.
[0072] (Embodiment 2: Questionnaire Analysis) Next, the processing procedures of the classification processing program and method of Embodiment 2 will be described. In Embodiment 2, an example of classifying, aggregating, and visualizing the user reviews of a vacuum cleaner is shown. The following code blocks 1 to 6 connected continuously are the program and method of the embodiment, and basically should be described continuously. However, for ease of explanation, they are divided into six parts for description.
[0073] In the processing of the classification processing program and method of Embodiment 2, in STEP1, the user reviews are classified, in STEP2, the classified user reviews are aggregated, and in STEP3, the aggregation result is visualized (the flowchart is omitted).
[0074] (STEP1: Classification Step) First, the control unit 104 creates a data frame from a plurality of user reviews. The program is as follows. Note that the following program is a Python program stored in the control unit of the information processing apparatus (terminal 1). However, other programming tools or programming languages may be used. Also, the following program is just an example, and the processing order, the libraries, functions, and variable names used may be changed.
[0075] (Code Block 1) import pandas as pd from google.colab import drive drive.mount(' / content / drive') df = pd.read_excel(' / content / drive / MyDrive / reviewdata.xlsx')
[0076] To explain this program in detail, it is as follows. First, the control unit 104 imports the pandas module. Pandas is a tool for data analysis in Python. Next, the drive function is imported from the google.colab module. Drive is a function for accessing Google Drive.
[0077] The control unit 104 executes the drive function to mount Google Drive to the path ' / content / drive'. Mounting means making the files and folders of Google Drive operable on Colab.
[0078] The control unit 104 uses the pd.read_excel function to read the Excel file reviewdata.xlsx located at the path ' / content / drive / MyDrive / reviewdata.xlsx'. This Excel file stores multiple user reviews. A part of the data frame is shown in Figure 8. The content of the user reviews is stored in the review column of the review data. Note that in Figure 8, only 3 cases (3 rows) are illustrated due to space limitations, but in the embodiment, a data frame of 100 cases (100 rows) is used. Of course, a larger number of cases is also possible.
[0079] The control unit 104 assigns the read file to a variable named df. Df is a tabular data structure called a data frame. By doing df['review'], only the column named review is extracted from df. The review column stores the content of the user reviews (review string information) consisting of natural language.
[0080] Next, the control unit 104 sends the review string information and the need classification instruction information including multiple need classifications to the generation AI server and receives the need classification result information from the generation AI server. The program is as follows.
[0081] (Code block 2) ! pip install openai import openai
[0082] This command is for installing the Python library of OpenAI. The! indicates that the command is to be interpreted as a shell command. Pip is a Python package manager, and install is the command used to install the library.
[0083] The control unit 104 imports a Python library called openai. The openai library is used to execute various natural language processing tasks using the OpenAI API. Although the input of an API key is actually required for using the openai library, it is omitted from the program description because it would cause problems in public disclosure.
[0084] (Code block 3) def generate_n_class(text): response = openai.ChatCompletion.create( model="gpt-4", messages= {"role": "system", "content": "· For the following input text, assign it to one of the 10 classifications: 'Comfortable cleanliness', 'Sense of reduced effort', 'Improved housework efficiency', 'Assured hygiene management','Stress-free operation', 'Pride in one's home', 'Satisfaction with usability', 'Comfortable living environment', 'Fullness of time savings', 'Confidence in wise choices'."}, {"role": "user", "content": text}]) n_class = response["choices"][0]["message"]["content"] return n_class
[0085] This program provides a function to classify a given text into one of five classifications using OpenAI's language model "GPT-4". Note that the language model is not limited to "GPT-4", and it may be "GPT-4 Turbo" or "GPT-3.5 Turbo", or even the next version of the GPT series. These are known to exhibit high accuracy in natural language processing tasks.
[0086] The `generate_n_class(text)` function takes one piece of text (`text`) as an argument, and the control unit 104 calls OpenAI's Chat Completion API to classify that text. The API sends a message composed of two roles, the system and the user, and from the system side, it sends an instruction: "Regarding the next sentence to be input, please assign one of the following 10 classifications: 'Comfortable sense of cleanliness', 'Sense of reduced effort', 'Improved efficiency of housework', 'Assured hygiene management', 'Stress-free operation', 'Pride in one's home', 'Satisfaction with comfort', 'Comfortable living environment', 'Fulfillment of time savings', 'Confidence in wise choices'." This instruction information is referred to as need classification instruction information.
[0087] Note that 'Comfortable sense of cleanliness','Sense of reduced effort', 'Improved efficiency of housework', 'Assured hygiene management', 'Stress-free operation', 'Pride in one's home', 'Satisfaction with comfort', 'Comfortable living environment', 'Fulfillment of time savings', 'Confidence in wise choices' are classifications of needs consisting of predefined natural language. Also, for the expression of needs, other expressions may be used. Also, the instruction content (prompt) may be made more detailed. Also, in the embodiment, it is an instruction to classify into one of them, but it may also be an instruction to classify into multiple. Also, the number of classifications is not limited to 10, and it may be more or less.
[0088] The generation AI server 2 classifies the given text (need string information) into an appropriate classification based on the need classification instruction information and returns it. The response from the generation AI server 2 contains the text of the classified classification (need classification result information). The need classification result information is stored in the `n_class` variable and returned as the output of the function.
[0089] (Code block 4) df['n_class'] = df['review'].apply(lambda x: generate_n_class(x))
[0090] This program is used to process each line of text stored in the'review' column of the Pandas DataFrame df using the generate_n_class function, generate the classification (n_class), and add the result to a new column 'n_class' in df.
[0091] The control unit 104 uses the apply method to apply lambda x: to each string in the rows of the df['review'] column, where x represents the argument to be applied to x.
[0092] The control unit 104 passes the text to the generate_n_class function and assigns the result of classifying the text into one of 10 categories to the df['n_class'] column. Finally, as shown in Figure 9, a DataFrame df containing the new 'n_class' column is returned.
[0093] Figure 9 shows the DataFrame with the 'n_class' column added by the processing in STEP2. Note that in Figure 9, only 20 examples (20 rows) are shown due to space limitations, but in the embodiment, a DataFrame df consisting of 100 examples (100 rows) is generated. Also, the description of the'review' column is omitted as it is described in Figure 8.
[0094] (STEP2: Aggregation Step) Next, based on the control unit 104 and the classification result information (needs classification result), a process of aggregating multiple reviews (string information) for each of multiple classifications (needs classification) is performed.
[0095] (Code Block 5) df_n_class_counts = df['n_class'].value_counts().sort_index().reset_index() df_n_class_counts.columns = ["Needs Classification", "Count"]
[0096] df['n_class'].value_counts(): This part calculates the frequency of occurrence of values in a column called n_class in a dataframe df. The value_counts() function counts how frequently different values occur in a dataframe and returns a new Dataframe or Series with those frequencies.
[0097] .sort_index(): This method sorts the obtained frequency data based on an index (here the n_class value). This is used to re-sort based on the original values (n_class) since by default it is sorted based on the frequency of occurrence of the values.
[0098] .reset_index(): This method resets the index and converts the existing index to a regular column, which preserves the original index (the n_class value) as a column in the new DataFrame.
[0099] df_n_class_counts.columns = ["Needs Class", "Count"]: Finally, we rename the columns in the newly created dataframe df_n_class_counts. We name the first column (which contains the original n_class values) as "Needs Class", and the second column with frequency values as "Count". (STEP 3: Visualization step) Next, the control unit 104 visualizes the tallying results. The program is as follows.
[0100] (Code Block 6) ! pip install japanize-matplotlib import matplotlib.pyplot as plt import japanize_matplotlib plt.figure(figsize=(10, 6)) plt.plot(df_n_class_counts['Needs Classification'], df_n_class_counts['Number of Cases']) plt.title('Number of Cases by Needs Classification') plt.xlabel('Needs Classification') plt.ylabel('Number of Cases') plt.show()
[0101] !pip install japanize-matplotlib: This is the command to install the japanize-matplotlib package. This package is used to correctly display Japanese in matplotlib.
[0102] import matplotlib.pyplot as plt: Here, the pyplot module of matplotlib is imported as plt.
[0103] import japanize_matplotlib: In this line, the japanize-matplotlib library installed earlier is imported.
[0104] plt.figure(figsize=(10, 6)): This specifies the size of the graph. Here, a figure (graph) with a width of 10 inches and a height of 6 inches is created.
[0105] plt.plot(df_n_class_counts['Needs Classification'], df_n_class_counts['Number of Cases']): In this line, the Needs Classification column of the df_n_class_counts dataframe is plotted on the x-axis and the Number of Cases column is plotted on the y-axis. This shows the relationship between Needs Classification and the number of cases as a line chart (line graph).
[0106] plt.title('Number of Cases for Each Need Classification'): Here, the title of the graph is set. The title is 'Number of Cases for Each Need Classification'.
[0107] plt.xlabel('Need Classification') and plt.ylabel('Number of Cases'): These lines set the labels for the x-axis and y-axis respectively. The label for the x-axis is 'Need Classification', and the label for the y-axis is 'Number of Cases'.
[0108] plt.show(): Finally, this line is used to display the graph created with matplotlib. As a result, the graph based on the above settings is displayed on the screen.
[0109] The control unit 104 displays the graph on a display device (not shown) such as a liquid crystal display connected via the external I / F 106 (Fig. 10).
[0110] Also, the visualization is not limited to this, and it may be a bar graph. By using matplotlib, various forms of visualization are possible.
[0111] In the above embodiment, the processing using Python has been described, but it is not limited to this. Similar processing can also be performed by combining a spreadsheet such as Excel with ChatGPT and APIs.
[0112] Also, the classification categories are not limited to problems, solutions, and needs. Depending on the purpose of the analysis, they may be classifications of categories in natural language such as quality, effect, use, and benefit. Also, the string to be classified is not limited to patent data, and there is no limitation as long as it is a string in natural language such as a paper, for example.
[0113] Although the embodiments have been described above, these embodiments are presented by way of example and are not intended to limit the scope of the invention. This novel embodiment can be implemented in various other forms, and various omissions, replacements, and changes can be made without departing from the gist of the invention. This embodiment and its modifications are included in the scope and gist of the invention, and are also included in the invention described in the claims and the equivalent scope thereof.
Explanation of Reference Numerals
[0114] 1 Terminal, 2 Generation AI Server, 101 CPU, 102 ROM, 103 RAM, 104 Control Unit, 105 HDD, 106 External I / F, 107 Input Unit, 108 System Bus
Claims
Claim 1 A computer causes a large language model to receive each of a plurality of character strings related to a specific target and classification instruction information that enumerates classifications expressed in a plurality of natural languages set according to the object and purpose of analysis and instructs the assignment of any of the classifications, and to obtain classification result information obtained by classifying each of the plurality of character strings into any of the plurality of classifications expressed in the natural language, and a classification processing program for executing the process. Claim 2 The classification processing program according to claim 1, further causing a process of visualizing an aggregation result of classifications of each of the plurality of character strings based on the classification result information. Claim 3 A classification processing method in which a computer causes a large language model to receive each of a plurality of character strings related to a specific target and classification instruction information that enumerates classifications expressed in a plurality of natural languages set according to the object and purpose of analysis and instructs the assignment of any of the classifications, and to obtain classification result information obtained by classifying each of the plurality of character strings into any of the plurality of classifications expressed in the natural language, and executes the process.
Citation Information
Patent Citations
Sentence classification device, sentence classification method and program
JP2007004233A
Automatic information classification method, and information retrieval and analysis method
JP2008112208A
Document classification apparatus, document classification method, and program
JP2010146222A
Classification adding method and classification adding system
JP2016206748A
Literature data analysis program and system
JP2018049430A