{
  "id": 294785,
  "title": "BERT Embeddings and the Baseline",
  "url": "/competitions/cs5785-fall-2021-final/discussion/294785",
  "author_name": "JiaZZZZZ",
  "post_date": "2021-12-12T18:10:32.150000",
  "votes": 4,
  "comment_count": 7,
  "views": 0,
  "content": "<p>Team: TILAPIA</p>\n<p>The baseline is basically three steps:</p>\n<ol>\n<li>vectorize descriptions;</li>\n<li>reduce the dimension of ResNet features;</li>\n<li>Use Ridge regression model to find the relationship between descriptions and ResNet features.</li>\n</ol>\n<p>We used BERT embeddings, instead of the provided word2vec, to get the feature vectors and boost the baseline performance by 30% (0.12-&gt;0.16). For anyone wanna try BERT:</p>\n<ol>\n<li>you need GPU and Google Colab is a good choice.</li>\n<li>download sentence_transformers and import SentenceTransformer.</li>\n<li>choose a model from <a href=\"https://huggingface.co/sentence-transformers?sort=downloads\" target=\"_blank\">https://huggingface.co/sentence-transformers?sort=downloads</a>. We chose ‘bert-base-nli-mean-tokens’.</li>\n</ol>\n<p>One interesting point using BERT: text processing (remove punctuation, stopwords, stemmer, feature reduction via PCA) doesn't lead to significantly better results. In fact, most of the processing methods lead to noticeably worse performance. Our hypothesis is that BERT embeddings are sophisticated pre-trained models on paragraphs and generate embedding vectors when applied to new paragraphs. So processing complete sentences to a bunch of random words actually ruins the semantic meaning of sentences. We haven't tested the hypothesis yet so feel free to comment your ideas!</p>\n<p>Update:<br>\nFor anyone interested in BERT - <a href=\"https://www.kaggle.com/jamesan2020\" target=\"_blank\">@jamesan2020</a> and <a href=\"https://www.kaggle.com/epickens\" target=\"_blank\">@epickens</a> provide great explanations and resources in the comment below!</p>",
  "messages": [
    {
      "id": 1615821,
      "postDate": "2021-12-12T18:10:32.150Z",
      "content": "<p>Team: TILAPIA</p>\n<p>The baseline is basically three steps:</p>\n<ol>\n<li>vectorize descriptions;</li>\n<li>reduce the dimension of ResNet features;</li>\n<li>Use Ridge regression model to find the relationship between descriptions and ResNet features.</li>\n</ol>\n<p>We used BERT embeddings, instead of the provided word2vec, to get the feature vectors and boost the baseline performance by 30% (0.12-&gt;0.16). For anyone wanna try BERT:</p>\n<ol>\n<li>you need GPU and Google Colab is a good choice.</li>\n<li>download sentence_transformers and import SentenceTransformer.</li>\n<li>choose a model from <a href=\"https://huggingface.co/sentence-transformers?sort=downloads\" target=\"_blank\">https://huggingface.co/sentence-transformers?sort=downloads</a>. We chose ‘bert-base-nli-mean-tokens’.</li>\n</ol>\n<p>One interesting point using BERT: text processing (remove punctuation, stopwords, stemmer, feature reduction via PCA) doesn't lead to significantly better results. In fact, most of the processing methods lead to noticeably worse performance. Our hypothesis is that BERT embeddings are sophisticated pre-trained models on paragraphs and generate embedding vectors when applied to new paragraphs. So processing complete sentences to a bunch of random words actually ruins the semantic meaning of sentences. We haven't tested the hypothesis yet so feel free to comment your ideas!</p>\n<p>Update:<br>\nFor anyone interested in BERT - <a href=\"https://www.kaggle.com/jamesan2020\" target=\"_blank\">@jamesan2020</a> and <a href=\"https://www.kaggle.com/epickens\" target=\"_blank\">@epickens</a> provide great explanations and resources in the comment below!</p>",
      "rawMarkdown": "Team: TILAPIA\n\nThe baseline is basically three steps:\n1. vectorize descriptions;\n2. reduce the dimension of ResNet features;\n3. Use Ridge regression model to find the relationship between descriptions and ResNet features.\n\nWe used BERT embeddings, instead of the provided word2vec, to get the feature vectors and boost the baseline performance by 30% (0.12->0.16). For anyone wanna try BERT:\n1. you need GPU and Google Colab is a good choice.\n2. download sentence_transformers and import SentenceTransformer.\n3. choose a model from https://huggingface.co/sentence-transformers?sort=downloads. We chose ‘bert-base-nli-mean-tokens’.\n\nOne interesting point using BERT: text processing (remove punctuation, stopwords, stemmer, feature reduction via PCA) doesn't lead to significantly better results. In fact, most of the processing methods lead to noticeably worse performance. Our hypothesis is that BERT embeddings are sophisticated pre-trained models on paragraphs and generate embedding vectors when applied to new paragraphs. So processing complete sentences to a bunch of random words actually ruins the semantic meaning of sentences. We haven't tested the hypothesis yet so feel free to comment your ideas!\n\nUpdate:\nFor anyone interested in BERT - @jamesan2020 and @epickens provide great explanations and resources in the comment below!",
      "votes": 3
    },
    {
      "id": 1616808,
      "postDate": "2021-12-13T16:28:31.990Z",
      "content": "<p>hey any reason you used the ‘bert-base-nli-mean-tokens’ model? on huggingface site has warning:<br>\n This model is deprecated. Please don't use it as it produces sentence embeddings of low quality. You can find recommended sentence embedding models here: SBERT.net - Pretrained Models</p>",
      "rawMarkdown": "hey any reason you used the ‘bert-base-nli-mean-tokens’ model? on huggingface site has warning:\n This model is deprecated. Please don't use it as it produces sentence embeddings of low quality. You can find recommended sentence embedding models here: SBERT.net - Pretrained Models",
      "replies": [
        {
          "id": 1616916,
          "postDate": "2021-12-13T17:56:01.950Z",
          "content": "<p>We tried 5 different models suggested in 'SBERT.net - Pretrained Models': some take much longer to run, some are much larger to download but produce similar overall results as ‘bert-base-nli-mean-tokens’. Since the descriptions are short and relatively simple (compared to long texts with complicated semantics), I would say we used 'bert-base-nli-mean-tokens' because of the tradeoff between training time and training result. We didn't have time to try more models but it's definitely interesting to see how the results look like!</p>",
          "rawMarkdown": "We tried 5 different models suggested in 'SBERT.net - Pretrained Models': some take much longer to run, some are much larger to download but produce similar overall results as ‘bert-base-nli-mean-tokens’. Since the descriptions are short and relatively simple (compared to long texts with complicated semantics), I would say we used 'bert-base-nli-mean-tokens' because of the tradeoff between training time and training result. We didn't have time to try more models but it's definitely interesting to see how the results look like!"
        },
        {
          "id": 1616925,
          "postDate": "2021-12-13T17:58:36.210Z",
          "content": "<p>If regular BERT is taking too long to compute embeddings for you I would suggest using DistilBERT. It is a lot lighter weight, but with almost the same performance as regular BERT. </p>\n<p>Check it out: <a href=\"https://huggingface.co/docs/transformers/model_doc/distilbert\" target=\"_blank\">https://huggingface.co/docs/transformers/model_doc/distilbert</a></p>",
          "rawMarkdown": "If regular BERT is taking too long to compute embeddings for you I would suggest using DistilBERT. It is a lot lighter weight, but with almost the same performance as regular BERT. \n\nCheck it out: https://huggingface.co/docs/transformers/model_doc/distilbert",
          "votes": 1
        }
      ]
    },
    {
      "id": 1615828,
      "postDate": "2021-12-12T18:33:24.830Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 1615837,
          "postDate": "2021-12-12T18:42:18.373Z",
          "content": "<p>That's a pro-level explanation! Thanks, James!</p>",
          "rawMarkdown": "That's a pro-level explanation! Thanks, James!"
        },
        {
          "id": 1616071,
          "postDate": "2021-12-13T05:52:04.020Z",
          "content": "<p>For a little more background you might want to check out the paper \"Attention Is All You Need:\" <a href=\"https://arxiv.org/pdf/1706.03762.pdf\" target=\"_blank\">https://arxiv.org/pdf/1706.03762.pdf</a></p>\n<p>It introduced transformers, which underpin many modern embedding methods. It's pretty cool and you can even get some of the stuff up in running in pytorch without too much trouble. </p>\n<p>Here's some documentation for how you can go about getting started on some language modeling with transformers: <a href=\"https://pytorch.org/tutorials/beginner/transformer_tutorial.html\" target=\"_blank\">https://pytorch.org/tutorials/beginner/transformer_tutorial.html</a></p>",
          "rawMarkdown": "For a little more background you might want to check out the paper \"Attention Is All You Need:\" https://arxiv.org/pdf/1706.03762.pdf\n\nIt introduced transformers, which underpin many modern embedding methods. It's pretty cool and you can even get some of the stuff up in running in pytorch without too much trouble. \n\nHere's some documentation for how you can go about getting started on some language modeling with transformers: https://pytorch.org/tutorials/beginner/transformer_tutorial.html\n\n",
          "votes": 2
        },
        {
          "id": 1616906,
          "postDate": "2021-12-13T17:44:28.203Z",
          "content": "<p>Thanks for sharing all the great resources! </p>",
          "rawMarkdown": "Thanks for sharing all the great resources! "
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1616808,
      "author_name": "Achal Amin",
      "author_url": "",
      "post_date": "2021-12-13T16:28:31.990000",
      "content": "<p>hey any reason you used the ‘bert-base-nli-mean-tokens’ model? on huggingface site has warning:<br>\n This model is deprecated. Please don't use it as it produces sentence embeddings of low quality. You can find recommended sentence embedding models here: SBERT.net - Pretrained Models</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1616916,
          "author_name": "JiaZZZZZ",
          "author_url": "",
          "post_date": "2021-12-13T17:56:01.950000",
          "content": "<p>We tried 5 different models suggested in 'SBERT.net - Pretrained Models': some take much longer to run, some are much larger to download but produce similar overall results as ‘bert-base-nli-mean-tokens’. Since the descriptions are short and relatively simple (compared to long texts with complicated semantics), I would say we used 'bert-base-nli-mean-tokens' because of the tradeoff between training time and training result. We didn't have time to try more models but it's definitely interesting to see how the results look like!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1616925,
          "author_name": "Elliot",
          "author_url": "",
          "post_date": "2021-12-13T17:58:36.210000",
          "content": "<p>If regular BERT is taking too long to compute embeddings for you I would suggest using DistilBERT. It is a lot lighter weight, but with almost the same performance as regular BERT. </p>\n<p>Check it out: <a href=\"https://huggingface.co/docs/transformers/model_doc/distilbert\" target=\"_blank\">https://huggingface.co/docs/transformers/model_doc/distilbert</a></p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1615828,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-12-12T18:33:24.830000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 1615837,
          "author_name": "JiaZZZZZ",
          "author_url": "",
          "post_date": "2021-12-12T18:42:18.373000",
          "content": "<p>That's a pro-level explanation! Thanks, James!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1616071,
          "author_name": "Elliot",
          "author_url": "",
          "post_date": "2021-12-13T05:52:04.020000",
          "content": "<p>For a little more background you might want to check out the paper \"Attention Is All You Need:\" <a href=\"https://arxiv.org/pdf/1706.03762.pdf\" target=\"_blank\">https://arxiv.org/pdf/1706.03762.pdf</a></p>\n<p>It introduced transformers, which underpin many modern embedding methods. It's pretty cool and you can even get some of the stuff up in running in pytorch without too much trouble. </p>\n<p>Here's some documentation for how you can go about getting started on some language modeling with transformers: <a href=\"https://pytorch.org/tutorials/beginner/transformer_tutorial.html\" target=\"_blank\">https://pytorch.org/tutorials/beginner/transformer_tutorial.html</a></p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1616906,
          "author_name": "JiaZZZZZ",
          "author_url": "",
          "post_date": "2021-12-13T17:44:28.203000",
          "content": "<p>Thanks for sharing all the great resources! </p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1615821": "Team: TILAPIA\n\nThe baseline is basically three steps:\n1. vectorize descriptions;\n2. reduce the dimension of ResNet features;\n3. Use Ridge regression model to find the relationship between descriptions and ResNet features.\n\nWe used BERT embeddings, instead of the provided word2vec, to get the feature vectors and boost the baseline performance by 30% (0.12->0.16). For anyone wanna try BERT:\n1. you need GPU and Google Colab is a good choice.\n2. download sentence_transformers and import SentenceTransformer.\n3. choose a model from https://huggingface.co/sentence-transformers?sort=downloads. We chose ‘bert-base-nli-mean-tokens’.\n\nOne interesting point using BERT: text processing (remove punctuation, stopwords, stemmer, feature reduction via PCA) doesn't lead to significantly better results. In fact, most of the processing methods lead to noticeably worse performance. Our hypothesis is that BERT embeddings are sophisticated pre-trained models on paragraphs and generate embedding vectors when applied to new paragraphs. So processing complete sentences to a bunch of random words actually ruins the semantic meaning of sentences. We haven't tested the hypothesis yet so feel free to comment your ideas!\n\nUpdate:\nFor anyone interested in BERT - @jamesan2020 and @epickens provide great explanations and resources in the comment below!",
    "1616808": "hey any reason you used the ‘bert-base-nli-mean-tokens’ model? on huggingface site has warning:\n This model is deprecated. Please don't use it as it produces sentence embeddings of low quality. You can find recommended sentence embedding models here: SBERT.net - Pretrained Models",
    "1615828": ""
  }
}