The present invention generally relates to search queries and more particularly relates to search queries of databases containing image data types.
A large amount of information remains latent within a relational database. For example, database columns that contain different types of data, e.g., numerical values, images, dates, etc., possess significant latent information in the form of inter-column and intra-column relationships. Further, a relational data model neglects many inter-column or intra-column relationships. Further still, the traditional Structured Query Language (SQL) queries lack a holistic view of the underlying relations, and thus are unable to extract and exploit semantic relationships that are collectively generated by database relations.
In various embodiments, a cognitive intelligence server computer program product and a computer-implemented method for adapting a relational database containing image data types are disclosed. The method comprises converting at least one image token in the relational database to a textual form, producing text based on relations of tokens in the relational database and producing a set of word vectors based on the text.
The accompanying figures where like reference numerals refer to identical or functionally similar elements throughout the separate views, and which together with the detailed description below are incorporated in and form part of the specification, serve to further illustrate various embodiments and to explain various principles and advantages all in accordance with the present invention, in which:
Some embodiments of the present invention facilitate responses to queries in relational databases using cognitive learning. For example, some computer-implemented method embodiments enable relational databases to capture and exploit semantic contextual similarities using standard SQL queries and a new class of SQL-based queries: Cognitive Intelligence (CI) queries.
By way of overview, for a given relational database, such as a database containing information about employees of a specific company, typical SQL queries only return a result if there is a match for the query. For example, if a query wants information for employee A, such as salary, title, etc., an answer is returned only if there is an employee A. However, using CI queries, in accordance with the present invention, an answer may be returned by examining the relationship of each word embedded in the database. For traditional SQL purposes, attributes such as name, age, gender, title, etc., are independent and this information is not exploited by the query.
Some embodiments of the present invention use word embedding, which is an unsupervised machine learning technique from natural language processing (NLP), to extract latent information. Disclosed techniques may also be applicable to other data models such as Multidimensional online analytical processing (MOLAP), JavaScript Object Notation (JSON), eXtensible Markup Language (XML), comma-separated value (CSV) files, spreadsheets, etc.
In word embedding, a d-dimensional vector space is fixed. Each word in a text corpus (e.g., collection of documents) is associated with a dimension d vector of real numbers. The assignment of words to vectors should be such that the vectors encode the meaning of the words. Ideally, if two words are closely related (i.e. have similar meaning), their vectors should point in similar directions. In other words, the cosine distance between their vectors should be relatively high. By closely related words we mean words that appear together often in the text corpus. By appear together, we mean within close proximity. Conversely, if words are unrelated, the cosine distance between their vectors should be relatively small. Some refinements of the calculation of closeness weigh the proximity and/or consider grammar rules.
Over the last few decades, a number of methods have been introduced for computing vector representations of words in a natural language, such as word2vec or GloVe. Recently, word2vec has gained prominence as the vectors produced appear to capture syntactic as well semantic properties of words. These vector representations seem to capture closeness of words and syntactic (e.g., present-past, singular-plural) as well as semantic closeness of words. One application of word2vec produced vectors was in solving analogy problems, such as . . . a king is to a man like what is to a woman? (answer: queen) by using vector algebra calculations.
Vectors may be produced by either learning on the database itself or using external text, or vector sources. In the relational database context, one way of generating vectors is to apply the word embedding method to a token sequence generated from the database: each row would correspond to a sentence and a relation would correspond to a document. Thus, vectors enable a dual view of the data: relational and (meaningful) text. Word embedding then may extract latent semantic information in terms of word associations and co-occurrences and encode it in word vectors. Thus, the vectors capture first inter- and intra-attribute relationships within a row (sentence) and then aggregate these relationships across the document to compute the collective semantic relationships. The encoded semantic information then may be used in querying the database. Some embodiments of the present invention integrate word embedding techniques and capabilities into traditional database systems.
Exemplary steps for enhancing a system 100 with the cognitive capabilities enabled by word vectors will be described with reference to
By way of introduction and overview (only) to the following example, it is assumed that the fields of a relational database are populated with information, e.g., relating to employees of a company (see e.g.,
Referring now to
Which rows or columns are textified (i.e., made into a sequence of tokens) may be controlled by defining a view using standard relational operations. The meaning of a word (i.e. token) can be inferred from by means of its neighbors. The neighborhood context contributes to the overall meaning of the word. A meaning of a database token can be determined from other tokens in the row, the columns of a row, in turn, can be determined by the schema of its view.
For example, meaningful data can be extracted and a model created by mapping, e.g., converting a relational row to a sentence (cf.
At step 204, machine learning is used to produce word vectors for all words (tokens, items) in the text. For example, an algorithm can compute word vector representations for all words (optionally excluding header words) in the meaningful text. In some embodiments, an external source (or corpus) can also be used for model training (see e.g.,
At step 206, the word vectors are stored for usage in queries. In some embodiments, word vectors include a vector for each token in the meaningful text. At step 208, vectors produced from other text sources (see e.g., step 204 and
At step 210, cognitive intelligence (CI) queries are used to produce database relation results. In some embodiments, CI queries can be expressed using standard SQL. Some embodiments enable CI queries using the word vectors in the vector space as user-defined functions (UDFs). Upon completion of step 210, the process exits.
Referring now to
In
Support for Multiple Datatypes
In addition to text and basic numeric values, CI queries are supported for SQL types (e.g., date) and other non-SQL types such as images, videos, time series, latitude and longitude, chemical structures, etc.
For actual query execution strategies, there are two approaches: a single model and an ensemble. In the single model approach, multiple data types are converted to text and a single word embedding model is generated from all tokens. For the ensemble approach, more than one embedding model or clustering strategy (discussed below) are used for different data types (e.g., latitude/longitude, images or time-series). A default clustering approach or user-provided similarity functions may be used. The results are computed for each model or clustering group and final results are computed by merging multiple result sets. The final results are merged by finding the intersection between row-sets that represent results for each clustering group. The default clustering approach may use traditional clustering algorithms, such as K-Means. Alternatively, specialized similarity functions for special types may be used, such as using spatial similarity function for latitude and longitude fields.
Support for Numeric Values
There are three approaches to providing meaningful text for numeric tokens. First, the number may simply be converted to a typed string of the form “column heading_number”. For example, in a column for an annual date, 2016 becomes “Year_2016”. From this point, the process continues as described above to convert the relational database information into meaningful text.
The second approach uses user controlled categorization. For example, the numeric value is converted to a range, such as low, med or high. The user defines the values in the range. A new token is created using the range such that a numeric value in a column becomes a string of the form “column heading_range”. Thus, in a relational database having a numerical value for the percentage of chocolate in a food, 75% becomes “chocolate_high” and 18% becomes “chocolate_low”.
The third approach uses user controlled clustering. Any traditional clustering algorithm may be used to cluster data (e.g., K-means, hierarchical clustering, etc.). Each numeric value in a column of the relational database is replaced by the ID of the cluster containing that number. For example, in a relational database having a number representing sales dollars, the actual dollar amount is converted to a cluster ID and expressed as “sales_clusterlD”. So, an actual token value of 5000 may be expressed as “sales_272” where 272 is the cluster ID of the cluster containing 5000.
Support for Images
Four different approaches may be used to convert images to text: image tagging, image classification, binary comparison, or user-specified similarity functions. Each approach can be used with both the single model or the ensemble query execution strategy where one or more of the approaches are used in combination. Image taggers, such as BABYTALK™ or ALCHEMY TAGGER™ may be used to convert images into tags. These textual tags may be used to generate an embedding model. Alternatively, a neural network classification model may be used to classify images into clusters. The images are replaced with their corresponding cluster identifiers and an embedding model is built using the cluster information. The third approach is simply to compare the binary image files for similarity. In this case, a bit-wise comparison for each binary image is performed and the results are compared using binary similarity measures. Finally, the images may be converted to text using user-specified similarity functions. Existing approaches, such as BABYTALK™ or ALCHEMY TAGGER™, may be used for converting images to text. Once an image has been converted to text, the methods described above may be used to develop CI queries.
Creating Word Vectors from Multiple Data Corpus
Externally produced word vectors may be utilized in at least four ways that we outline (other possibilities will become apparent to those versed in the art). (1) External pre-trained vectors, such as those produced by Google News word vector collection, may be used on the relational database content without having to develop a new model. (2) Alternatively, the database content is trained while initializing vectors for common tokens to the external source vectors, i.e. common tokens appear in both the source database as well as the external database. Common word vectors may be immutable or mutable with updates controlled via parameters, such as learning rate or maximum change. (3) Yet another option is follows: given k distinct external sources, each with a dimension D(i), i=1, . . . , k, a vector of dimension D=D(1)+ . . . +D(k) is composed. The first D(1) entries are initialized from the D(1) entries of the first source, the following D(2) entries are initialized from the D(2) entries of the second source, and so on, such that each succeeding j'th portion is initialized with the corresponding j'th source. Entries for an individual source can be weighted, for example, a higher weighting value may be given to older information and a lower weighting value may be given for new information as the older information may be deemed more reliable. (4) Finally, the second way (2) can be applied using the vectors produced by the third way (3).
Additionally, individual columns in the database can be encrypted, e.g., last_name. Common words that are also encrypted are treated as different words, thus providing more information concurrent with anonymization.
Similarity UDFs
When comparing two sets of vectors, similarity UDFs may be used to output a scalar similarity value. Similarity measures between any pair of vectors are determined using cosine and max-norm algorithms, however, max-norm is sensitive to contributions of individual vector entries. Precise distances may be needed to rank the results. The distance between a pair of vectors and average multiple distance values are computed to determine the overall similarity value.
Order awareness may be an issue as the relative order of words are being preserved or ignored during the overall similarity computation. In some instances, order conscious similarity is important. Additionally, precise O(n{circumflex over ( )}2) calculations for pairwise distance calculation of n vectors are computationally expensive. In practice, sampled implementations perform well. However, GPU or SIMD acceleration may be necessary for large vector sets. For large datasets, a combination of LSH and precise calculations are necessary.
CI Query Example: World Food Facts Database
The World Food Facts Database (WFFD) is an open source dataset from Kaggle. It stores information on food products from different countries. The WFFD is rich in both text and numeric fields. It contains around 50 MB of text, with over 65,000 rows and 150 columns. The columns contain information such as ingredients, categories, nutrients, etc.
To prepare the WFFD for CI queries, the nutrients were partitioned into groups (vitamins, amino acids, etc.). The numeric values were grouped into clusters using K-means, and the word2Vec model was trained using 200 dimensions. Similarity queries were run over ingredients (text), nutrients (text) and country (text). Both the single-model and the ensemble approach were used. Numeric fields in the WFFD are shown in Table 1.
An SQL CI Query example for querying the WFFD is shown below in
Results for products having similar ingredients and similar nutrients in similar countries is shown in Table 2. For example, Special K original from Kellogg's is similar to Crispy Flakes with Red Berries Cereal from Market Pantry in the United States.
Results for products having similar ingredients and similar nutrients in different countries is shown in Table 3. For example, Nutella—Ferrero in the United States is similar to Nutella—750 g in France.
Cognitive Intelligence Queries Use Cases
CI queries may be used in a number of retail cases, such as customer analytics to find similar customers based on buying patterns (e.g., purchased items, frequency, amount spent, etc.) Additionally, CI queries may be used for feature-based product substitution to suggest alternative item similar to a given item but different in some features, such as ingredients, price, nutritional values, etc., allowing for more intelligent recommendations than traditional market-basket recommendations. CI queries may also be used for advanced sales predictions using external data to predict sales of a new item being introduced based on sales of related or similar items currently being sold. CI queries may also be used to analyze historical sales data using external data, for example, using input from social media, recall notices, etc. Semantic associations may be performed via analogy queries to determine relationships, such as “bread:Nutella::chips:?” the answer may be “salsa” in one region or “guacamole” in a different region.
In the healthcare field, CI queries may also be used in a variety of applications. For example, CI queries may help determine drug-drug interaction using prescription label information (e.g., ingredients, side effects, etc.) from the Federal Drug Administration (FDA) website to identify adverse drug reactions. Patient similarity analytics may also be determined using multi-modal CI queries. For example, patients taking similar drugs, potentially with different brand names (e.g., ADVIL™, MOTRIN™) with similar dosages, may be identified. Also, patients with different scans, such as X-rays or magnetic resonance imaging (MRI) scans, but with similar drug regimens may be identified using a single CI query over text, numeric and image data. Patients with different electro-cardiograms (ECGs), but similar drug regimens may be identified using a single CI query over text, numeric and time series data. CI queries may also be used to give nutrition advice, such as given a food item, find substitute food items with similar ingredients but less sugar. Predictions may be provided using external data, such as given a recall notice affected patients or purchases of similar drugs may be identified.
CI queries may also be used in other fields, such as Information Technology (IT) incident ticket analysis to find accounts with similar ticket patterns (e.g., type of tickets, resolution status, problem cause, etc.). In the financial sector (e.g., consumer banking, investment advisors, etc.), CI queries may be used to find customers with similar transactions, identify similar investment plans for a given investment strategy, or detect anomalies in transactions for a given customer. In the insurance industry, CI queries may be used to identify similar or dissimilar claims using text and image features or to evaluate risk profiles by analyzing patient profiles (e.g., symptoms, diagnosis, etc.). For the Internet of Things (IoT), CI queries may assist in finding households or hotel rooms with similar energy patterns. In Human Resource (HR) management, CI queries may be used to find employees with similar skills and similar or different employment history. CI queries may also be used in other industries such as customer care, semantic web, log analytics, smart cities, etc. These are just a few of the many uses for CI queries using embodiments of the present invention.
Cognitive Intelligence Server
Referring now to
The bus 708 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnects (PCI) bus.
Although not shown in
Program/utility 716, having a set of program modules 718, may be stored in memory 706 by way of example, and not limitation, as well as an operating system, one or more application programs, other program modules, and program data. Each of the operating system, one or more application programs, other program modules, and program data or some combination thereof, may include an implementation of a networking environment. Program modules 718 generally carry out the functions and/or methodologies of embodiments of the present invention.
The information processing system 702 can also communicate with one or more external devices 720 (such as a keyboard, a pointing device, a display 722, etc.); one or more devices that enable a user to interact with the information processing system 702; and/or any devices (e.g., network card, modem, etc.) that enable computer system/server 702 to communicate with one or more other computing devices. Such communication can occur via I/O interfaces 724. Still yet, the information processing system 702 can communicate with one or more networks such as a local area network (LAN), a general wide area network (WAN), and/or a public network (e.g., the Internet) via network adapter 726. As depicted, the network adapter 726 communicates with the other components of information processing system 702 via the bus 708. Other hardware and/or software components can also be used in conjunction with the information processing system 702. Examples include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems. Although not shown, additional graphical processing units (GPUs) may sit of the bus 708 and act as co-processors.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method, or computer program product. Accordingly, aspects of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit”,” “module”, or “system.”
The present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, configuration data for integrated circuitry, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++, or the like, and procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the Figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the singular forms “a”, “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
The description of the present invention has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the invention. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
Number | Name | Date | Kind |
---|---|---|---|
5548749 | Kroenke et al. | Aug 1996 | A |
7158961 | Charikar | Jan 2007 | B1 |
8190555 | Venugopal et al. | May 2012 | B2 |
10068154 | Prest | Sep 2018 | B2 |
20140164036 | Prieto | Jun 2014 | A1 |
20150186739 | Lindsay | Jul 2015 | A1 |
20150293946 | Fong et al. | Oct 2015 | A1 |
20160062979 | Mote | Mar 2016 | A1 |
20170060993 | Pendar | Mar 2017 | A1 |
20170154314 | Mones | Jun 2017 | A1 |
20180114144 | Miranda | Apr 2018 | A1 |
Number | Date | Country |
---|---|---|
69419184 | Dec 1999 | DE |
Entry |
---|
Apache Foundation, “Apache spark: A fast and general engine for large scale data processing”, http://spark.apache.org., last visited on Dec. 28, 2016, pp. 1-2. |
Bengio, Y., et al., “A Neural Probabilistic Language Model”, Journal of Machine Learning Research, Feb. 2003, pp. 1137-1155. |
Gray, J., et al., “Data Cube: A Relational Aggregation Operator Generalizing Group-By, Cross-Tab, and Sub-Totals”, Data Mining and Knowledge Discovery, 1997, vol. 1, No. 1, pp. 1-16. |
Mikolov, T., et al., “Distributed Representations of Words and Phrases and their Compositionality”, Proceedings of the 27th Annual Conference on Neural Information Processing Systems, Dec. 5-10, 2013, pp. 1-9. |
Pennington, J., et al., “GloVe: Global Vectors for Word Representation”, Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing, Oct. 25-29, 2014, pp. 1-12. |
Mikolov, T., “word2vec: Tool for computing continuous distributed representations of words”, https://code.google.com/p/word2vec, last visited on Jan. 4, 2017, pp. 1-7. |
Bordawekar, R., et al., “Using Word Embedding to Enable Semantic Queries in Relational Databases”, Proceedings of the EDBT/ICDT Joint Conference, Mar. 21-24, 2017, pp. 1-4. |
List of IBM Patents or Patent Applications Treated as Related. |
Number | Date | Country | |
---|---|---|---|
20180268024 A1 | Sep 2018 | US |