Adaptable transformer models via key term replacement
Techniques are disclosed relating to storing, by a computer system, a map file that includes a new term that is mapped to a particular one of a plurality of category names that a natural-language processing (NLP) model is trained to identify, wherein the NLP model is not trained to identify the new term. The technique may further include receiving, by the computer system, user-generated content (UGC) that includes the new term. Additionally, the technique may include generating, by the computer system using the map file, a modified version of the UGC by substituting the particular category name for text in the UGC that is associated with the new term, and using, by the computer system, the NLP model on the modified text to classify the modified version of the UGC without retraining the NLP model to identify the new term.
1 . A method comprising:
storing, by a computer system, a map file that includes a new term that is mapped to a particular one of a plurality of category names that a natural-language processing (NLP) model is trained to identify;
receiving, by the computer system, user-generated content (UGC) that includes a plurality of terms, including the new term;
determining, by the computer system, that the map file includes an entry for the new term, wherein the entry includes one or more terms associated with the new term;
identifying, by the computer system using the entry for the new term, a particular category name that is mapped to the new term;
generating, by the computer system, a modified version of the UGC by substituting the particular category name for the new term in the UGC wherein remaining ones of the plurality of terms are retained in the modified version of the UGC; and
using, by the computer system, the NLP model on the modified version of the UGC to classify the modified version of the UGC, wherein the NLP model is trained to identify the particular category name but not the new term, and wherein classifying the modified version of the UGC includes:
identifying whether any of the one or more associated terms are included in the UGC; and
selecting a classification based on a number of the associated terms identified in the UGC and proximity of the identified associated terms to the category name.
2 . The method of claim 1 , further comprising training the NLP model to identify and define ones of the category names as an atomic unit.
3 . The method of claim 2 , wherein defining the category names as atomic units includes mapping ones of the category names to a respective generic term that represents one or more characteristics of terms mapped to a corresponding category name.
4 . The method of claim 1 , wherein mapping the new term to the particular category name includes graphing the new term with surrounding ones of the plurality of terms in the UGC to select an initial category name of the plurality of category names.
5 . The method of claim 1 , further comprising:
receiving a new category name and a list of terms associated with the new category name; and
identifying training terms in existing training data that surround terms on the list.
6 . The method of claim 5 , further comprising:
using the identified training terms and the NLP model, generating default associations for the new category name; and
adding the new category name to the map file and mapping one or more of the identified training terms to the new category name.
7 . The method of claim 1 , further comprising using the NLP model to identify additional new terms in a different UGC by:
iteratively generating a respective modified version of the different UGC by substituting a given category name for an unfamiliar term in the different UGC, wherein a different category name is substituted in ones of the iterations;
using the NLP model to generate a respective classification of the respective modified different UGCs; and
selecting a particular category name for the unfamiliar term using the respective classifications.
8 . The method of claim 1 , wherein mapped terms included in the map file are respective names of a plurality of institutions, and wherein the category names indicate a respective type of institution.
9 . The method of claim 1 , wherein mapped terms included in the map file are respective identities of flagged users, and wherein the category names indicate a respective reason for being flagged.
10 . The method of claim 1 , wherein mapped terms included in the map file are respective instances of undesired language, and wherein the category names indicate a respective indication of a type of undesired language.
11 . A computer-readable, non-transient memory including instructions that when executed by a computer system within a computer network, cause the computer system to perform operations including:
maintaining a map file that includes a plurality of keywords that are mapped to respective ones of a plurality of category names that a natural-language processing (NLP) model is trained to identify;
retrieving user-generated content (UGC) that includes a plurality of terms, including one or more of the keywords;
determining that the map file includes respective entries for the one or more keywords;
using the respective entries to identify a respective category name that is mapped to ones of the one or more keywords;
generating a modified version of the UGC by substituting the respective category names for the keywords included in the UGC, wherein remaining ones of the plurality of terms are retained in the modified version of the UGC; and
classifying, using the NLP model, the modified version of the UGC, the classifying including:
retrieving one or more associated terms from the respective entries, the associated terms indicating a context for usage of respective ones of the one or more keywords; and
selecting a classification based on a proximity of the identified associated terms to the respective category name.
12 . The computer-readable, non-transient memory of claim 11 , wherein the operations further include training the NLP model to define ones of the category names as an atomic unit by mapping ones of the category names to a respective generic term that represents one or more characteristics of keywords mapped to a corresponding category name.
13 . The computer-readable, non-transient memory of claim 11 , wherein the operations further include:
receiving a new category name and one or more keywords associated with the new category name; and
search existing training data to identify training keywords that are adjacent to keywords of the one or more keywords.
14 . The computer-readable, non-transient memory of claim 13 , wherein the operations further include:
using the identified training keywords and the NLP model to generate default associations for the new category name; and
adding the new category name to the map file and mapping one or more of the identified training keywords to the new category name.
15 . The computer-readable, non-transient memory of claim 11 , wherein the operations further include using the NLP model to identify additional new keywords in a different UGC by:
generating a modified version of the different UGC by substituting a given category name for an unfamiliar term in the different UGC; and
using the NLP model to generate a respective classification of the respective modified different UGCs.
16 . A system comprising:
a processor circuit; and
a memory circuit including instructions that when executed by processor circuit, cause the system to perform operations including:
updating a map file to include a new keyword mapped to one of a plurality of category names that a natural-language processing (NLP) model is trained to identify, wherein the map file also includes one or more associated terms that are indicative of a usage context of the new keyword;
receiving user-generated content (UGC) that includes a plurality of terms, including the new keyword;
determining that the map file includes an entry for the new keyword;
extracting, from the entry, the one category name that is mapped to the new keyword;
generating a modified version of the UGC by substituting the one category name for content included in the UGC that matches the new keyword, wherein remaining ones of the plurality of terms are retained in the modified version of the UGC; and
classifying, using the NLP model, the modified version of the UGC, wherein the classifying includes selecting a classification based on a number of the associated terms identified in the UGC and proximity of the identified associated terms to the category name.
17 . The system of claim 16 , wherein to add the new keyword to the map file, the operations further include graphing the new keyword with adjacent ones of the plurality of terms in the UGC to select an initial category name of the plurality of category names to map to the new keyword.
18 . The system of claim 16 , wherein the operations further include:
generating a modified version of a different UGC by substituting a given category name for an unfamiliar term in the different UGC; and
using the NLP model to generate a respective classification of the respective modified different UGCs.
19 . The system of claim 18 , wherein the operations further include:
generating a set of category names for the unfamiliar term by repeating the generation of respective classifications, substituting a different category name for the unfamiliar term in corresponding iterations; and
selecting, from the set of category names, a particular category name for the unfamiliar term.
20 . The system of claim 16 , wherein the operations further include:
receiving a new category name and a list of keywords associated with the new category name;
identifying training keywords in existing training data that surround keywords on the list; and
generating, using the identified training keywords and the NLP model, default associations for the new category name.