I have a training and test set of food descriptions pairs (please, see example below) First name in a pair is a name of food in French and second word is this food description in English. Traing set has also a trans field that is True for correct descriptions and False for wrong descriptions. The task is to predict trans field in a test set, in other words to predict wich food description is corect and which is wrong.

dishes = [{"fr":"Agneau de lait", "eng":"Baby milk-fed lamb", "trans": True},
{"fr":"Agrume", "eng":"Blackcurrants", "trans": False},
{"fr":"Algue", "eng":"Buttermilk", "trans": False},
{"fr":"Aligot", "eng":"potatoes mashed with fresh mountain cheese", "trans": False},
{"fr":"Baba au rhum", "eng":"Star anise", "trans": True},
{"fr":"Babeurre", "eng":"seaweed", "trans": False},
{"fr":"Badiane", "eng":"Sponge cake (often soaked in rum)", "trans": False},
{"fr":"Boeuf bourguignon", "eng":"Créole curry", "trans": False},
{"fr":"Carbonade flamande", "eng":"Beef Stew", "trans": True},
{"fr":"Cari", "eng":"Beef stewed in red wine", "trans": False},
{"fr":"Cassis", "eng":"citrus", "trans": False},
{"fr":"Cassoulet", "eng":"Stew from the South-West of France", "trans": True},
{"fr":"Céleri-rave", "eng":"Celery root", "trans": True}]

df = pd.DataFrame(dishes)

    fr                  eng                                          trans
0   Agneau de lait      Baby milk-fed lamb                           True
1   Agrume              Blackcurrants                                False
2   Algue               Buttermilk                                   False
3   Aligot              potatoes mashed with fresh mountain cheese   False
4   Baba au rhum        Star anise                                   True
5   Babeurre            seaweed                                      False
6   Badiane             Sponge cake (often soaked in rum)            False
7   Boeuf bourguignon   Créole curry                                 False
8   Carbonade flamande  Beef Stew                                    True
9   Cari                Beef stewed in red wine                      False
10  Cassis              citrus                                       False
11  Cassoulet           Stew from the South-West of France           True
12  Céleri-rave         Celery root                                  True

I think to solve this as text classification problem, where text is a concatenation of French name and English description embeddings.


  • Which embeddings to use and how concatenate them?
  • Any other ideas on approach to this problem? BERT?


How about the following approach:

  • Translate (with BERT?) French names to English
  • Use embeddings to create two vectors: v1 - translated English vector and v2 - English description vector (from data set)
  • Compute v1 - v2
  • Create new data set with two columns: v1 - v2 and trans
  • Train classifier on this new data set

Update 2:

It looks like cross-lingual classification may be the right solution for my problem:


It is not clear yet from the description given on the page with the link above, where to fit my own training data set and how to run classifier on my test set. Please help to figure this out. It would be ideal to find end-to-end example / tutorial on cross-lingual classification.

  • $\begingroup$ How is this a statistics question? $\endgroup$ – Peter Flom Apr 11 at 12:24
  • $\begingroup$ This question is related to Natural Language Processing (NLP) which widely exploits today statistic methods, namely Deep Learning, Transformes, Attention and BERT. $\endgroup$ – dokondr Apr 11 at 19:48
  • $\begingroup$ You can't translate with BERT, it's not a translation model, it is a pre-trained representation model. Taking the difference of the vectors is not a good idea: if you concatenate the vector, the learned weights of the classifier can learn to emulate the subtraction if it is useful if not, they will learn something else. Let the data decide. $\endgroup$ – Jindřich Apr 16 at 7:54

I would recommend using a classifier based with Multilingual BERT or XLM-RoBERTa. They are implemented in the Huggingface's Transformers package, you can just follow a tutorial for BertForSequenceClassification. Note that this might be rather computationally demanding and you might need to use a GPU (or use, for instance, Google Colab.)

If you want a computationally cheaper solution, you can try aligned word embeddings, for instance from FastText. In that case, I would just compute an average over the word embeddings for each name. This means for a description with words $w_i, \ldots w_n$ and embedding table $V$ do:

$$\sum_{i=1..n} V[w_i] / n.$$

Then, you can simply concatenate the vectors (i.e., the French one and the English one) and train a classifier on top of that.

Running machine translation into and comparing monolingual embeddings (either contextual from BERT or English-only word embeddings) is also an option, but requires running an MT system which is an order of magnitude computationally more demanding than classification or embedding comparison.

| cite | improve this answer | |
  • $\begingroup$ It is not clear how you would compute average, please explain. Please, also see my question update. $\endgroup$ – dokondr Apr 14 at 18:56
  • 1
    $\begingroup$ I updated the answer. Is it clear now? $\endgroup$ – Jindřich Apr 16 at 7:52
  • $\begingroup$ Yes, it is clear now, thanks! What do you think about instead of word embedding average use concatenation of English and French vectors, where each vector is an embedding of a complete sentence (English / French). In this case using Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks (EMNLP 2019). github.com/UKPLab/sentence-transformers#pretrained-models $\endgroup$ – dokondr Apr 16 at 8:57
  • $\begingroup$ Please, also see my question Update 2 $\endgroup$ – dokondr Apr 17 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.