{'fraction_non_alphanumeric': 0.030986530183102223, 'fraction_numerical': 0.01053383324406356, 'mean_word_length': 5.034957500299294, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning TFIDF Enhanced Joint Embedding for Recipe-Image Cross-Modal Retrieval Service

It is widely acknowledged that learning joint embeddings of recipes with images is challenging due to the diverse composition and deformation of ingredients in cooking procedures. We present a Multi-modal Semantics enhanced Joint Embedding approach (MSJE) for learning a common feature space between the two modalities (text and image), with the ultimate goal of providing high-performance cross-modal retrieval services. Our MSJE approach has three unique features. First, we extract the TFIDF feature from the title, ingredients and cooking instructions of recipes. By determining the significance of word sequences through combining LSTM learned features with their TFIDF features, we encode a recipe into a TFIDF weighted vector for capturing significant key terms and how such key terms are used in the corresponding cooking instructions. Second, we combine the recipe TFIDF feature with the recipe sequence feature extracted through two-stage LSTM networks, which is effective in capturing the unique relationship between a recipe and its associated image(s). Third, we further incorporate TFIDF enhanced category semantics to improve the mapping of image modality and to regulate the similarity loss function during the iterative learning of cross-modal joint embedding. Experiments on the benchmark dataset Recipe1M show the proposed approach outperforms the state-of-the-art approaches.


INTRODUCTION
C ROSS-MODAL retrieval is one of the most desired services in big data powered machine learning applications. Many real world datasets have more than one modality, such as Twitter tweets, Instagram messages, yelp restaurant/dish recommendations, Food-101 [1], RecipeIM [2], and other social platforms (e.g., www.food.com, cookeatshare.com). By training deep neural networks to learn a multi-modal joint embedding model, say a text-image crossmodal embedding model, one can predict the top-k most relevant images given a text document (e.g., finding the top 5 food images best matching a given tweet in Twitter), or the top-k most relevant text documents for a given image (e.g., finding the top 5 tweets best matching a given landslide photo image). Unsupervised learning of multi-modal joint embedding remains challenging [3], [4] for cross-modal retrieval.
Recently, a few proposals are put forward to address the cross-modal embedding problem [1], [2], [5], [6], [7] using Recipe1M, with over 800K structured cooking recipes (title, list of ingredients, and cooking instructions) and over 1 million associated images [2]. There are several reasons that the problem of learning cross-model embedding for recipes and food images is representative and challenging. First, Recipe1M is a public and unlabeled real world dataset, wellunderstood and well-structured, without concerns on user privacy risks. Second, user-generated and shared food images and recipes are prevalent on the Internet and in social media platforms [8], and most of them provide ingredients with their quantities, and cooking instructions on how ingredients are prepared and cooked (e.g., steamed, stir-fried, or deep-fried), providing a new source of references for food intake tracking and health monitoring and management, which are not provided in food label or FCT (Federal Capital Territory) [9]. Finally, most existing approaches differ in how they leverage deep neural networks to learn a cross-modal embedding for cooking recipes and food images. However, the reported test accuracy results have been low for both image to recipe retrieval and recipe to image retrieval. The top-1 recall and top-5 recall for image-to-recipe retrieval is 12.5% and 31% [7], 24% and 51% [2], 25.6% and 53.7% [6], or 39.8% and 69% [5]. Figure 1 provides an illustrative example, which is a recipe query to find the top-5 best matched food-image instances. The resulting 5 images are sorted by the relevance ranking in descending order. The red frame around an image indicates that it is the original image instance associated with this querying recipe. The first two rows are the top 5 results from two existing approaches and the last row is the top 5 results using our approach reported in the paper, in which the original image instance is included in the top 5 matched images (top 5 hit) and is also ranked as the top-1 matched image (top 1 hit). Unfortunately, most of the existing approaches will fail this recipe-to-image query in either top-5 or top-1 metric, because the original image is not included in the top 5 matched images at all (row 1), or the original image is included in the top 5 matched images but not ranked as the top-1 image (row 2).
In this paper, we present a Multi-modal Semantic enhanced Joint Embedding approach, coined as MSJE, for delivering high-performance cross-modal retrieval services that support image to recipe retrieval task and recipe to im-arXiv:2108.00724v1 [cs.CV] 2 Aug 2021 recipe query Retrieved food images(the one marked with red square is associated) Title: Sugar Cookie Fudge Instructions: Line an 8x8 in baking pan with parchment paper or foil. In a large microwave safe bowl, mix together sugar cookie mix and powder sugar. Cut butter into cubes and sprinkle over the top of the mixture.  Fig. 1: A recipe-to-image retrieval example.
age retrieval task. Given that the problem is to learn a multimodal joint embedding over an unlabeled dataset with each input containing two modalities, such as Recipe1M, by mapping features of different modalities onto the same latent space for similarity-based assessment and recommendation, such as cross-modal retrieval. We argue that (1) the quality of the features used from each modality for learning the joint embedding is critical for the effectiveness of learning; and (2) the semantic correlations of different modalities can be an effective optimization to regulate the cross-modal similarity loss function used in iterative learning of the cross-modal joint embedding.
This paper makes three main contributions. First, we extract the TFIDF feature from the title, ingredients and cooking instructions of recipes as recipe frequency semantics. By determining the significance of word sequences through combining LSTM learned features with their TFIDF features, we encode a recipe into a TFIDF weighted vector for capturing significant key terms and how such key terms are used in a sequence of sentences in the corresponding cooking instructions. This is in contrast to the existing approaches that treat every keyword and every sentence in a recipe equally when modeling joint text-visual (image) relevance, and overlooking the fact that some descriptions of words and sentences are not visually observable (w.r.t. the corresponding food images). Second, in addition to extracting the sequence feature by learning sentence sequences of cooking instructions through two-stage LSTM networks, we incorporate frequency and sequence semantics into the recipe embedding by combining the recipe TFIDF feature and recipe sequence feature. This TFIDF semantics enhanced sequence extraction enables our MSJE approach to effectively learn the unique relationship between the given recipe and its associated food image(s). Third, we further incorporate category semantics by combining TFIDF of recipe title with Food-101 classification of food images in both learning the mapping of food image modality and exercising semantic regularization to optimize the similarity loss function during the iterative learning of cross-modal joint embedding. We conduct an extensive experimental evaluation and our results show that MSJE outperforms the state-of-the-art approaches with high-quality cross-modal retrieval performance on the benchmark Recipe1M dataset in terms of top-1, top-5, top-10 recall measures for both image2recipe and recipe2image queries.
The novelty of our proposed MSJE framework centers on a suite of semantic optimizations introduced from multiple dimensions to improve the quality of cross-modal joint embedding learning: (1) We optimize the recipe text embedding using TFIDF features to refine the LSTM key term extraction in both key-term filtering and key-term weights. (2) We optimize the food image embedding using both image category embedding combined with image pixel embedding. (3) We optimize the joint embedding learning by introducing the semantics enhanced loss optimization that combines the batch-hard triplet loss with two semantic optimizations for modality alignment loss and modality independent semantic regularization loss. For instance, the titles of the two recipes in Figure 2(a) are identical, but only recipe (1) is the correct match to the query image on the left. This can be achieved by incorporating the TFIDF features from title, ingredients, and cooking instruction with (i) the sequence features from LSTM, (ii) the auto encoding of image modality and classification, and (iii) the loss function regulation for learning the joint embedding. To the best of our knowledge, the MSJE approach is unique in employing and combining semantics enhanced feature extraction, feature engineering and feature alignment in single modality embedding learning and cross-modality joint embedding learning.
The remainder of this paper is organized as follows. Section 2 outlines the most relevant previous works. Section 3 presents the detailed design of MSJE, including how different types of semantics are incorporated in feature engineering of each modality and in iterative learning of crossmodal joint embedding. We report the evaluation results by comparing our approach with the representative stateof-the-art methods to demonstrate the effectiveness of our MSJE in Section 4 and conclude the paper in Section 6.

RELATED WORK
The prevalence of social media has enabled the rapid growth of user-generated and shared online recipes and food images. There are three popular learning tasks on food datasets. (1) Food recognition from images, which evolves from kernel-based model [10] to DNN approaches [11], [12]; (2) food recommendation [13], [14], including ingre- (a) The titles of the recipe (1) and (2) both are "Baked Ziti", but only recipe (1) matches the left food image.
(b) Different recipes sharing the same recipe title.  dient identification [15], dietary recommendation for diabetics [16] and recipe popularity prediction [17]; (3) Crossmodal food retrieval [1], [2], [5], [6], [7]: Image to Recipe and Recipe to Image. Food images are diverse in terms of background, ingredient composition, visual appearance and ambiguity. Early works [18], [19] circumvented this problem by annotating images to perceive their latent semantics. These approaches, however, are supervised and require users to annotate at least a small portion of images. The unsupervised solutions map images and recipe texts into a shared latent space in which their feature vectors can be compared in terms of vector similarity. A classic example is to employ canonical correlation analysis (CCA) for learning joint embeddings for semantic visual annotation [20]. CCA utilizes global alignment to allow the mapping of different modalities, which are semantically similar, by maximizing the correlation between the input recipe and its associated image. Built on CCA, recent approaches have employed deep neural networks to cross-modal retrieval, such as DeViSE [21], correspondence auto-encoder [22], adversarial cross-modal retrieval [23].

Homemade Russian Salad Dressing
Most recent cross-modal recipe-image embedding approaches [2], [5], [6], [7], [24] resort to LSTM networks with word2vec and CNN networks to generate the recipe embedding and image embedding respectively. SAN [7] applied a stacked attention network to simultaneously locate ingredient regions in the image and learn multi-modal embedding features. JESR [2] proposed to learn a joint embedding between the two modalities by combining a pairwise cosine loss with a semantic regularization constraint. AMSR [6] improves JESR by using hierarchical attention on the recipes and using simple triplet loss for joint embedding regulation. AdaMine [5] extends JESR by using a double triplet loss, which simultaneously leverages retrieval and class-guided features in the shared latent space. ACME [24] proposed adversarial cross-modal embedding by using triplet loss with hard-sample mining [25].

MSJE CROSS-MODAL EMBEDDING LEARNING
The problem of training a cross-modal retrieval model is a multi-tasking learning problem with dual goals: (1) It learns the feature maps of training data from each of the modalities, and (2) It learns two independent embeddings iteratively, each of which maps the n dimensional feature vector from one modality to a common d dimensional latent vector representation space (d < n), such that the similarity loss of the two modality embeddings is minimized through joint embedding optimization.
There are several open challenges: (1) Recipes have three text sections: title, ingredients, and cooking instruction that are related to the content of food images. Recall Figure 2, Title tends to give out the core phrase for the recipe instance, while ingredients give out the key terms (one or more words), and cooking instruction consists of a sequence of sentences describing the food    Reexamining the extracted word sequence marked with a false label to recover the errors from bi-directional LSTM based ingredient extractor. The ingredient entity "baking potatoes" contained in the extracted word sequence "4 large baking potatoes" labeled as false would be missed in other approaches but recovered in our proposed MSJE approach due to its relatively high TFIDF value (Recall Figure 5, the TFIDF value is 0.2165 and the threshold is set as 0.1 in our work). preparation in the order of how ingredients are used in the cooking process. Not all the ingredients are descriptive of the associated food image(s), such as olive oil, salt. Some descriptions in cooking instruction are not directly relevant and thus cannot be translated to the visual appearance of food image content, such as add salt, garlic powder, preheat oven.
(2) Even though both recipe text and food images are confined in the food domain, the pairing of a recipe and its associated image is the only explicit reference linkage of the two modalities. However, several complications may add confusion for learning joint embedding during the feature engineering from different modalities. For instance, multiple recipe instances may correspond to the same name, such as baked ziti. A food image query about baked ziti will result in more than one recipe instance with baked ziti as the recipe title, as shown in Figure 2(a). However, only one recipe instance with baked ziti as the recipe title will be the top-1 perfect match, even though the second recipe shares the same title of baked ziti and has similar ingredients and instructions. Figure 2(b) shows another complication. The two recipe instances have the same title and similar ingredients, but the food images associated with the two recipes display very different visual appearances beyond optic variations, which are mainly the results of different cooking processes due to differences in specific cooking instructions. Finally, one recipe instance may be associated with more than one image instances as shown in Figure 2(c). These and other possible complications not only add significant complexity but also pose some unique challenges when learning cross-modal neural joint embedding, which are different from those in visual question-answering [26], visual annotation [27] and image captioning [28].

Semantics-Enhanced Recipe Embedding.
Learning recipe text embedding involves two subtasks: learning the text feature maps of recipes and learn the embedding of recipe feature maps to a d dimensional joint latent representation space. For recipe text feature extraction, we extract the frequency semantics and sequence semantics to generate the recipe embedding. For the recipe frequency feature, MSJE analyzes word sequence and sentence structure and annotates/enhances the learned features with TFIDF semantics of main ingredients in a recipe. TF-IDF (Term Frequency-Inverse Document Frequency) is a numerical statistic score that is intended to reflect how important and how discriminative a term is with respect to a document in a given corpus (e.g., training recipe set).  It is computed based on two metrics: term frequency per document and the inverse document frequency of the term over the set of documents. The recipe sequence feature is obtained by the two-stage LSTM networks [2]. LSTM (Long Short Term Memory networks) is a type of recurrent neural network (RNN), which is capable of learning long-term dependencies.
The recipe frequency feature mainly focuses on the significance of each ingredient entity to its recipe. Bi-directional LSTM networks and logistic regression are utilized as ingredient entity extractor [2]. We first use bi-directional LSTM networks to analyze the word sentence of each ingredient in the list, such as "1/4 cup of French fried onions", and learn to identify/extract only those word sequences that could be ingredients, like "French fried onions", "tomato sauce". Figure 3 shows an example, which uses the bi-directional LSTM networks to extract the ingredient entity from the original ingredient text. The word sequence "French fried onions" would be extracted according to the predicted "B", "I" and "E" labels from the original ingredient text "1/4 cup French fried onions".
Then we perform binary logistic regression on the set of word sequences extracted from LSTM into true or false to adjudicate if these extracted terms are real ingredient entities or not. Finally, each true word sequence is transformed to a single term ingredient entity by connecting the words with underline, e.g., "French fried onions", "tomato sauce". We create an ingredient entity dictionary to record the transformation between the word sequence of an ingredient to a single term ingredient entity, like "French fried onions" → "French fried onions". Due to the accuracy limitation of the ingredient entity extractor, we revisit those false word sequences with this ingredient entity dictionary in order to keep more real ingredient entities. Figure 4 shows an example. By reexamining those word sequences marked as "false", we correct errors of feature learning via ingredient entity extractor and recover important ingredient entities that would otherwise be missed, i.e., "Baking Potatoes" in Figure 4. This shows that unlike the existing approaches [2], [5], [24] that rely solely on the LSTM for recipe feature learning, the proposed approach provides more robust feature extractions and can recover important ingredient entities that were missed. For the cooking instruction (and title) of a recipe, before performing similar word and sentence sequence feature learning, we first utilize the ingredient entity dictionary to transform the word sequence of an ingredient entity into its single term format. Then we analyze sentence sequence patterns and extract the key terms in cooking instruction of a recipe with TFIDF enhanced semantics.
Next, a word2vec model [29] is trained over the TFIDF enhanced term corpus from all recipe texts in the training data, based on the Continuous Bags of Words (CBOW) model framework, which computes the target word probability based on its surrounding context words, and each word in the training corpus obtains its word2vec vector in the joint latent representation space. Every word in the training recipe corpus can obtain its word2vec vector through the learned word embedding matrix, which captures the word sequence and sentence sequence patterns in the text recipes.
The upper part of Figure 5 provides an example illustration of how to generate the recipe frequency feature. For each key-term kt i extracted from the recipe (i = 1, ..., N t , N t is the number of key terms extracted from the recipe), we compute the TFIDF value w i of each key-term. The word2vec representation x i for each key-term kt i can be obtained by the learned word2vec matrix. By combining the word2vec vectors X = [x 1 , x 2 , · · · , x Nt ] of all the keyterms from the recipe, weighted by their TFIDF values W = [w 1 , w 2 , · · · , w Nt ], we get the recipe frequency feature by W X T .
For the recipe sequence feature, we extract the sequence semantics from the word and sentence sequence in cooking instructions. In order to capture different levels of granularity in the instruction text, we utilize the two-stage LSTM networks to learn and obtain the recipe sequence features. The word-level feature of each instruction sentence is obtained by the pre-trained skip-instruction model [2], built upon LSTM networks and the technique of skip-thoughts [30], while the sentence-level feature of the sequence of instructions is learned from scratch by another LSTM networks. Figure 5 shows our semantics enhanced recipe embedding learning approach by combining recipe keyword (ingredient) frequency features and recipe (instruction) sequence semantics.

Semantics Enhanced Image Embedding
For image embedding learning, most of the existing works resort to pre-trained CNN networks as image encoder, e.g., VGG-16 [31] and ResNet-50 [32] models. However, different recipes for a dish may have different visual appearances due to different cooking procedures and use of ingredients. We argue that the neural features learned from the pixel grid of food image should be enhanced by the semantic knowledge specific to the corresponding recipe text to align the image embedding closer to the associated recipe text embedding in the jointly learned latent representation space. In our proposed MSJE, we incorporate the category semantics for food images based on the Food-101 dataset [1] as an additional dimension of recipe-image relationship semantics to strengthen the alignment between the recipe text embedding and the food image embedding. Figure 6 provides an illustrative example. First, we train a CNN classifier using WideResNet-50 [33] on the food101 dataset, which will predict one of the 101 food categories for a food image associated with a recipe. Similar to key term embedding during the recipe embedding process, we also generate the image category embedding E im−cat for this image category annotation using the word2vec model. We integrate this image category embedding E im−cat with the ResNet-50 auto-encoder generated food image embedding E im−res by vector concatenation operation, and then followed by a fully-connected layer to get the semantics enhanced image embedding. Figure 7 illustrates how the MSJE approach leverages the TFIDF semantics and the category semantics to optimize the cross-modal joint embedding learning over four objectives: to learn the recipe embedding and the food image embedding, to align the embeddings of the two modalities with the aim of making the feature distribution of cooking recipes and food images indistinguishable, and finally, to enforce the semantic regularization constraint such that both embeddings can be refined iteratively to perform well in the classification task.

Semantics Enhanced Joint Embedding Learning.
The goal of learning semantics enhanced joint embedding is to design an objective function that can leverage multimodal semantics to enhance the optimization for minimizing the similarity loss (distance) between the recipe embedding E rti r and the image embedding E f mi im for a given recipe input pair: recipe text (rt i ) and food image (f m i ). In MSJE, we utilize the batch hard triplet loss [25] to implement the constraint optimization for joint embedding learning: where λ 1 , λ 2 and λ 3 are trade-off parameters, which are set as 0.005, 0.005 and 0.005 respectively. L tri is the loss associated with the retrieval task over instance-based triplets (x a , x p , x n ). L ma is the adversarial loss to align the embeddings from two modalities. L sem−r and L sem−im are the losses over the recipe embedding E r and the image embedding E im respectively. For the batch-hard triplet loss, a triplet (x a , x p , x n ) is utilized to define the loss function: x a represents a feature embedding as an anchor point in one modality, x p denotes a positive feature embedding and x n denotes a negative feature embedding from the other modality. The optimization is to ensure that the positive instance is the one that should be close to the anchor point, and the negative instance should be far away from the anchor point. In the design of our MSJE, we consider two types of triplets: (1) using the recipe embedding as the anchor E a r , and (2) using the image embedding as the anchor E a im . In the case of using batch hard triplet loss, for a given anchor, we choose the most distant positive instance and the closest negative instance during the training process. The batch hard triplet loss is given as: Here d(·) is the euclidean distance, B is the number of recipe-image pairs in one batch, superscripts a, p and n refer to anchor, positive and negative instances respectively, superscripts i, j refer to the i-th and j-th recipe-image pair, and α is the margin of error. The second objective is to align the embeddings from two modalities to deal with the possibility of poor generalization and slow convergence due to the different distributions of encoded features. Unlike ACME in [24], our design of this modality alignment loss aims to align the distributions of ultimate layer features, instead of the penultimate layer features. By utilizing the competing strategy in GAN, we can view the modality alignment loss as an adversarial loss because when given an embedding from one modality,  Fig. 7: The framework of MSJE cross-modal embedding learning approach a discriminator D M cannot distinguish whether the feature embedding is generated from the food image or recipe text. Hence, one can make the distributions of the feature embeddings from two modalities more similar with the objective L ma calculated as follows:

Lsem-im
where φ im and φ r is the function to encode the raw image feature x im and recipe feature x r into image embedding and recipe embedding respectively. P im and P r are the data distributions of food images and cooking recipes. Finally, for each recipe (text and image pair), we use the learned image embedding and the learned recipe embedding to produce a fully-connected layer. First, this joint fullyconnected layer will be fed into the cross-modal embedding learning with equal contribution to the training of joint embedding (can be seen as using the equal weight). Second, we also leverage this joint fully-connected layer to perform the classification task, which assigns a proper categorization label to each input recipe (text and image). This learned categorization label provides additional semantics to the optimizations in joint embedding loss functions. In MSJE, we utilize this semantically enhanced category generation module to address the inherent problems of semantic regularization in JESR [2], such as the large number of recipe input under background category and mismatching between recipe text and its associate food image. Our categorization module can effectively categorize the input recipe (text and image pair) by integrating bigram-based recipe text categorization with the Food101 image categorization to ensure every input recipe (text and image pair) will be assigned a meaningful classification label instead of a background label. To ensure that the learned recipe embedding and image embedding contain the same category semantics during the joint embedding learning process, we keep the semantic regularization constraint on the two learned embeddings to facilitate the objective of minimizing the distance between matched recipe-image pairs and maximizing (enlarging) the distance of unmatched and irrelevant pairs, formulated as: where L sem−r is the loss of semantic regularization on the recipe branch, while L sem−im is on the image branch. N is the number of the different recipe-image pairs, N c is the number of category labels. y r i andŷ r i are the true and estimated possibilities that the recipe embedding belongs to the i th category label, while y im i andŷ im i are for image embedding.
Note that this semantic regularization adds an extra layer on the learned embeddings to perform the food classification, aiming for regularizing the latent space embeddings. There are two alternative designs for the category assignment algorithm: From the released codes of JESR [2], its category assignment algorithm uses Food 101 as a secondary source for category alignment by performing the following three tasks: (1) Obtain the top 2000 most frequent bigrams in recipe titles from the training set and manually remove those that do not have discriminative food properties (e.g., 5 minutes and & !, enjoy!). Assign the bigrams as the category to all recipes whose title contains the bigram. (2) The category labels of Food-101 dataset are assigned to the remaining recipes if their recipe titles contain the category label. (3) The remaining recipes whose titles contain neither one of the filtered bigrams nor one of the food101 categories are assigned to the background category.
Unfortunately, this approach assigns nearly half of the recipes with a "background" category label, due to the lack of matching to a real category label in JSER, which limits the effectiveness of JSER. In designing our semantic regulation algorithm for MSJE, we use the Food 101 categories as the primary source of recipe category labels and use bigram categories as the second source, followed by examining ingredients and cooking instructions for matching with the above two category sources. Further, we use the image classifier of Food 101 on the image associated with the recipe to predict and assign the top-1 category label to the recipe.
(1) For a recipe whose title contains a category label in the food101 categories, we first assign this category to the recipe. Note that if the recipe title is "meatloaf" or "sweet cookies", then it can be tagged with "meat loaf" or "sweet cookie" category label. (2) To make a fair comparison, in the prototype of MSJE, we also obtain the top 2000 most frequent bigrams in recipe titles of the training set in the same fashion as JESR and remove more inappropriate ones (e.g. home made, new style and oven fried). For those recipes that do not contain any of the category labels from Food 101, if a recipe title contains one of the filtered bigrams, then the bigram is assigned to this recipe as the category label. (3) For each of the remaining recipes, If the ingredients or the cooking instruction of this recipe contain one of the Food 101 or bigram categories, then this recipe will be assigned to the category. (4) All the remaining recipes are assigned with one of Food-101 categories based on the top 1 category label predicted by the food image classifier.
In summary, our cross-modal training framework MSJE incorporates different semantics for each modality at different learning stages of training the cross-modal joint embedding model, including extracting TFIDF features from title, ingredients and cooking instructions of recipes and incorporating them in LSTM based feature engineering, word2vec based auto-encoder for recipe feature mapping, CNN based auto-encoder for food image feature projection, as well as optimizing and regulating the loss function during iterative learning of cross-modal joint embedding. In the next section, we report our experimental evaluation on the effectiveness of MSJE design compared to the state-of-the-art approaches for both image-to-recipe and recipe-to-image queries on the benchmark Recipe1M dataset.

Dataset and Evaluation Metrics
We evaluate the effectiveness of our proposed approach on Recipe1M dataset [2], which was compiled from dozens of popular cooking websites. Each recipe has 1-5 associated images but every image only belongs to one recipe, and 51.4% of image-recipe pairs in the dataset have one of the 1047 category labels generated from category labels of Food-101 dataset and the frequent bigrams of recipe titles, while the rest of image-recipe pairs are categorized into a "background" category. Following preprocessing in [2], duplicate recipes, recipes without images, the unreadable recipes without any nouns or verbs are filtered out, resulting in 238,399 matching pairs of images and recipes for the training set, and 51,116 and 51,303 matching pairs for validation and test respectively. Experiment setups follow the same guidelines as the prior works [2], [5], [6], [24]. Specifically, we first sample 10 unique subsets of 1,000 or 10,000 matching recipe-image pairs from the test set. Then we consider each item in one modality as a query (e.g., an image), and rank instances in the other modality (e.g., recipes) using the Euclidean distance between the query embedding and each candidate embedding from the other modality in the test set. We calculate the median retrieval rank (MedR) and the recall percentage at top K (R@K), i.e., the percentage of queries for which the matching answer is included in the top K results.

Implementation Details
Public word2vec toolkit 1 is used to train the Continuous Bag-of-Words (CBOW) version of word2vec model [39] on the corpus of recipe texts in the Recipe1M dataset. The dimensions of joint embedding and word2vec embedding are set as 1024 and 300 respectively. Adam optimizer [40] is employed for model training with the initial learning rate set as 10 −4 in all experiments, with the mini bath size of 100. In each mini-batch, every recipe (image) is restricted to have exactly one ground-truth image (recipe), and the remaining images (recipes) are regarded as negative instances during training. The deep neural networks are implemented on the Pytorch platform and trained on a single NVidia Titan X Pascal server with 12GB of memory. The training phase for MSJE joint embedding on Recipe1M dataset requires about 13 hours to generate the trained model, meeting the convergence condition of the training. When using the trained cross-modal embedding model to perform recipeimage cross-modal retrieval, it takes only about 0.13 seconds to perform a cross-modal retrieval on the 1k test set, and about 1.5 seconds on the 10k test set. The model size for the MSJE trained recipe-image embedding model is 434.98MB (including the learned discriminator networks). In comparison, the model size of the JESR trained model is 540.85MB, and the model size for the ACME trained model is 376.11MB.

Baselines
We consider the following state-of-the-art methods as the baselines in evaluation: Canonical Correlation Analysis (CCA) [34]: CCA learns two linear projections for mapping text and image features to a common space that maximizes feature correlation.
Stacked Attention Networks (SAN) [7]: SAN applied a stacked attention network to simultaneously locate ingredient regions in the image and learn multi-modal embedding features between ingredient features and image features through a two-layer attention mechanism.
Joint Embedding with Semantic Regularization (JESR) [2]: JESR obtains the recipe representation using LSTM networks on the ingredients and instructions text, the image representation using ResNet-50, and train a joint embedding of the two modalities using pairwise cosine loss with a regularization term to penalize the learned embedding features if they fail in performing food categorization.
Recipe Retrieval with visual query of ingredients (Img2img+JESR) [35]: Based on the framework of JESR, Img2img+JESR appends the representation of the ingredient image set to the concatenation of ingredient embedding and instruction embedding, and then the concatenation of three embeddings will be transformed into one joint recipe embedding through a fully-connected layer.
Attention Mechanism with Semantic Regularization (AMSR) [6]: AMSR utilizes GRU networks and attention mechanism to encode recipe text at different levels (title,

Stir-Fried Tofu With Cabbage, Carrots and Red Peppers
Ingredients: firm tofu, soy sauce, Shao Hsing rice wine or dry sherry, dark Asian sesame oil, salt, ground pepper, sugar, peanut oil or canola oil, garlic, ginger, carrot, red bell pepper, cabbage, cilantro

Instructions:
Place the tofu dominoes on paper towels. Place another paper towel on top and prepare the remaining ingredients. In a small bowl or measuring cup combine the soy sauce, rice wine or sherry, and the sesame oil. ingredients and instructions), and adopts the triplet loss rather than the pairwise loss to train the model. ADAptive MINing Embedding (AdaMine) [5]: AdaMine utilizes a double triplet loss where the two triplets are built on the matching recipe-image relationship and their category labels, with the adaptive learning integrated into their triplet loss strategy.
Recipe Retrieval with GAN (R 2 GAN) [36]: R 2 GAN is built upon the embedding learning framework of JESR, the generative adversarial network with multiple generators and discriminators and two-level ranking loss to learn compatible embeddings for cross-modal similarity measure.
Modality-Consistent Embedding Network (MCEN) [37]: MCEN exploits the latent alignment with cross-modal attention mechanism and shares the cross-modal information to the joint embedding space with stochastic latent variable models.
Adversarial Cross-Modal Embedding (ACME) [24]: ACME uses the triplet loss empowered with hard sample mining and an adversarial loss to align the embeddings from the two modalities. Besides, they try to utilize the cross-modal translation consistency component to save the information lost in the training process.
Triplet+BOW+ResNet [38]: Triplet+BOW+ResNet pretrains a classifier based on the standard BOW model with category labels extracted by themselves. The average of word embeddings for the recipe text is used as recipe embedding. The results quoted in this paper is from the model trained on the same training dataset as ours.

Performance Comparison
We evaluate the performance of our proposed MSJE approach for image-to-recipe and recipe-to-image retrieval against the five baselines in Table 1. The results of CCA and JESR are quoted from [2], the results of SAN and AMSR are quoted from [6], the results of Img2img+JESR are quoted from [35], the results of AdaMine are quoted from [5], the results of R 2 GAN are quoted from [36], the results of MCEN are quoted from [37], the results of ACME are quoted from [24] and the results of Triplet+BOW+ResNet is from [38]. We make four observations.
(1) Our approach has consistently high Recall@K (K=1,5,10) for both image2recipe and recipe2image queries,  compared to all baselines on 1k and 10k test data, showing the effectiveness of incorporating TFIDF semantics and sequence semantics in learning cross-modal joint embedding.
(2) SAN and the global alignment model CCA are less effective than other models, because (a) other models utilize the deep neural networks for cross-modal joint embedding learning and (b) even though SAN adopts the stacked networks, it learns the recipe text embedding only by extracting recipe features from the ingredient list and it uses VGG-16 for image feature learning, compared to ResNet-50 in other baseline approaches.
(3) JESR is the first to show the use of LSTM networks to encode the ingredients and instructions for the recipe embedding and to add a semantic regularization term, improving CCA and SAN by a substantial margin.
(4) Img2img+JESR, AMSR, AdaMine, R 2 GAN, MCEN and ACME enhance JESR by incorporating more data or more semantics in feature engineering and joint embedding learning. One of the main reasons that the proposed MSJE approach outperforms all baselines is to incorporate TFIDF semantics, sequence semantics and category semantics in extracting recipe features, learning recipe embedding, enhancing image embedding learning, and enforcing semantics enhanced regulation and optimization for the cross-modal joint embedding learning. Figure 8 provides visualization on one recipe-to-image query using JESR, ACME and our MSJE. Obviously, JESR and ACME both fail to retrieve the matched food image in the top 5 results, but our MSJE can retrieve the associated image at the top 4 place. This is because our MSJE approach incorporates the TFIDF recipe semantics and successfully captures the discriminative ingredients (e.g. "tofu" and "red pepper" in this example). And almost all the images in the MSJE top 5 results contain the "tofu" and "red pepper" ingredients, while "tofu" is not easy to find in the top 5 results of JESR and ACME. Figure 9 visualizes en image-to-recipe queries. Using our proposed MSJE approach, the matched recipe for the image query will be included in the top 3 recipes although it did not make it to the top-1 result. However, using JESR and ACME methods, the matched recipe will not be included in the top-5 retrieved recipes, showing the effectiveness of incorporating TFIDF semantics and category semantics in our semantics enhanced crossmodal embedding learning.

Ablation studies
Here we report the design and the results of our ablation studies, which evaluate the contributions of the different components in our MSJE approach. Specifically, MSJE-b denotes a primitive baseline framework of MSJE using the simple batch-all triplet loss, without any other semantic components proposed in this paper. We then add the main semantic components proposed in this paper to the baseline framework MSJE-b one at a time. Concretely, we first evaluate the impact of the semantics enhanced image (MSJEb +SE V ) and the impact of the semantics enhanced recipe embedding learning (MSJE-b +SE R ) separately. Then we study the impact of incorporating both semantics enhanced image and recipe embedding learning, denoted by MSJE-b+SE.
Next, we evaluate the impact of semantic components utilized during the joint embedding learning of our MSJE framework. Three joint embedding loss optimizations are employed in our MSJE framework: (1) the optimized semantic regularization (OSR) on both recipe text embedding and food image embedding as the secondary loss regularization; (2) the modality alignment (MA) as another secondary loss regularization, which aligns the embeddings from two modalities to improve the loss regularization in the presence of poor generalization and slow convergence during the joint embedding learning due to different distributions of  Table 2 shows the results of the ablation studies on MSJE. We make two important observations. First, each semantic component in our MSJE approach provides a positive influence towards boosting the performance of the joint embedding learning, Second, by combining all of them in concert, our MSJE approach can further improve the overall performance of joint embedding than utilizing only a subset of these semantic optimizations. This ablation study further demonstrates the novelty of our MSJE approach in delivering high-performance joint embedding learning model for recipe-image cross-modal retrieval services. Figure 10 provides visualization on two recipe-to-image queries using MSJE. For the first query recipe, the correctly matched food image is the top-1 result thanks to the dual benefits of semantics-enhanced joint embedding. (1) The key-term "potatoes" and "spinach" are extracted from the recipe text with TFIDF enhanced recipe feature learning.
(2) The category "gnocchi" used in semantic regulariza-tion is captured in our category assignment algorithm, the food-101 category "gnocchi" is incorporated into the image embedding, and the semantics enhanced joint embedding learning is able to leverage these enhanced semantics to discriminate the matched food images from the other candidate images. Similarly, for the other recipe query, all the retrieved images are visually similar to the matched images (e.g., pears can be seen visually in the top 1 retrieved image for the second recipe query) and the assigned categories from the embeddings of both modalities are almost the same. Though our approach succeeds in the R@5 performance but failed to achieve R@1, while most of the baselines fail to include the matched images in R@5.

DISCUSSION
Potential Application to Other Non-Food Domains. Even though the proposed MSJE approach is designed and implemented on recipe text and food image for efficient crossmodal retrieval services, the overall design framework is applicable to solving general purpose text-image crossmodal retrieval problems in other non-food domains, such as medical procedure or health diagnosis with its associate image. In particular, the end-to-end workflow of text-image cross-modal embedding learning using MSJE, the suite of semantics based optimizations developed for learning text embedding, learning image embedding, and learning textimage cross-modal joint embedding iteratively with different loss optimizations can be easily transferred to other nonfood domain.
The MSJE framework benefits from the structure of the recipe in terms of title, ingredient list and cooking instruction. Most of the medical procedures or medical diagnoses have a similar structured layout, such as procedure title, the list of key medical equipment used in the procedure, and the instruction for the procedure. Hence, the application of MSJE approach to the collection of medical procedures and their associated images can be more straightforward than some other hard cases, such as news datasets or some social network datasets.
The main challenge for news dataset and some social network datasets, like amazon users' reviews and product images can be summarized as follows: First, when the text datasets are less well defined with respect to the images associated with those text components, it will make the cross embedding learning more challenging. Consider a News blog about a car accident but the associated image may be centered on the people injured in the presence of the car accident. Hence, the cross-modal joint embedding learning will require additional and richer semantic feature extraction, compared to recipe and food image datasets. We plan to make the open-source of our MSJE approach on GitHub to allow domain scientists with proprietary datasets to deploy our MSJE approach, such as medical procedures with associated images, for developing text-image crossmodal retrieval services.

CONCLUSION
We have presented MSJE, a multi-modal TFIDF semantics enhanced joint embedding learning approach for providing high performance cross-modality recipe retrieval tasks. This paper makes three unique contributions. First, our MSJE approach can extract and incorporate the TFIDF features in all three sections of a recipe (title, ingredients and cooking instruction). Second, our MSJE approach combines TFIDF features with sequence semantics to boost the effectiveness of learning cross-modal joint embedding. Third, our MSJE approach can leverage multi-modal semantics in different stages of our semantic enhanced joint embedding learning. By incorporating TFIDF semantics, sequence semantics and category semantics, MSJE can effectively regulate and optimize the cross-modal joint embedding learning by refining the assigned category labels and by utilizing the batch-hard triplet loss and modality alignment loss. Experiments show that our MSJE approach consistently outperforms the state of the art approaches for both image-to-recipe and recipeto-image retrieval services on Recipe1M benchmark dataset with over 1 million food images and 800K cooking recipes.
Zhongwei Xie received his M.S degree in computer science from Wuhan University of Technology, Wuhan, China in 2017. He is currently a visiting student in Georgia Institute of Technology and also a Ph.D candidate in Wuhan University of Technology. His research interests include deep learning and cross-modal retrieval.
Ling Liu is a Professor in the School of Computer Science at Georgia Institute of Technology. She directs the research programs in the Distributed Data Intensive Systems Lab (DiSL), examining various aspects of large scale big data-powered artificial intelligence (AI) systems, and machine learning (ML) algorithms and analytics, including performance, availability, privacy, security and trust. Prof. Liu is an elected IEEE Fellow, a recipient of IEEE Computer Society Technical Achievement Award (2012), and a recipient of the best paper award from numerous top venues, including IEEE ICDCS, WWW, ACM/IEEE CCGrid, IEEE Cloud, IEEE ICWS. Prof. Liu served on editorial board of over a dozen international journals, including the editor in chief of IEEE Transactions on Service Computing (2013-2016) and currently, the editor in chief of ACM Transactions on Internet Computing (TOIT). Prof. Liu has been given invited keynote speeches in many top tier venues in Big Data, AI and ML systems and applications, Cloud Computing, Services Computing, Privacy, Security and Trust. Her current research is primarily supported by USA National Science Foundation under CISE programs and IBM.
Yanzhao Wu Yanzhao Wu is currently a PhD student in the School of Computer Science, Georgia Institute of Technology. He received his B.E. degree from the School of Computer Science and Technology, University of Science and Technology of China. His research interests are centered primarily on systems for machine learning and big data, and machine learning algorithms for optimizing systems.
Lin Li received her Ph.D in computer science from University of Tokyo, Japan in 2009. She is currently the Professor and PhD supervisor in Wuhan University of Technology. She visited University of Technology, Sydney as a visiting scholar between February 2014 and February 2015. Dr. Li's research interests mainly include but not limited to machine learning, text mining, information retrieval and recommender system. Luo Zhong received his Ph.D in computer science from Wuhan University of Technology, China in 1996. He is currently the Professor and PhD supervisor in Wuhan University of Technology. Dr. Zhong's research interests mainly include but not limited to intelligent method and data mining.