In this three week long project we investigated domain transfer between sentiment analysis for reviews to sentiment analysis for stock-related news, compared to sentiment analysis for financial phrases (found labeled on huggingface) to sentiment analysis for financial news. In order to be able to process and classify large documents such as news articles, we implemented a so called DocBERT based on this article. The main principle is to segment the document into chunks with overlap, which leads to a time complexity of $O(n)$ instead of $O(n^2)$, which a transformer usually has due to the attention mechanism.
The news articles that we tested on where gathered, and marked as positive/neutral/negative based on the stock price movement within 5 minutes after the news article was published. The tresholds for a positive/negative news article was a movement of + or - 3% respectively.
When DocBERT was implemented, it was still a bit slow due to the varying lengths of the documents, since all entries in a batch need to be padded to the same length. One way to mitigate this a bit, which we implemented is to sort the entries by length to minimize the unneccesary padding, and thus the length of our batches. You can see this visualized in an image we drew in ms-paint one late evening. This image also shows how the splitting was made, in order to ensure that an equal amount of splits were made each batch. 
Unsurprisingly, the sentiment of financial phrases ended up having better domain transfer to financial news compared to amazon reviews. The final results on the gathered testing data can be seen in the following confusion matrixes.
The performance of the model trained on amazon reviews

The performance of the model trained on financial phrases

During the project we made weekly status reports for the examiner, these can be found here.
This week we sucessfully implemented a docbert which is able to process larger documents in an efficient manner. Our own collected news were nicely processed, and we got started on our presentation and abstract for the report.
This week we will have a lot to do.
Instead of short, medium long and long, we have dataset with the same document length as our training dataset and test dataset. No significant difference was seen.
Secondly, we should process the rest of our data similarly to how the own-collected news were processed.
We should also thoroughly examine our litterature, mainly the text-splitting with overlap article and the original docbert article, to see if anything is missing in our BERT arcitechture.
Furthermore, we should train a BERT on our training datasets and evaluate it on the test dataset.
Besides a lot of work in front of us, we do not have any current problems.
Starting with what we are supposed to have done.
This week we will preform the experiments, and hopefully address our current problems in an efficient manner. We will start by contacting the examiner of the course in hope of receiving some guidance.
Jupyter Notebook
99.1%
In this three week long project we investigated domain transfer between sentiment analysis for reviews to sentiment analysis for stock-related news, compared to sentiment analysis for financial phrases (found labeled on huggingface) to sentiment analysis for financial news. In order to be able to process and classify large documents such as news articles, we implemented a so called DocBERT based on this article. The main principle is to segment the document into chunks with overlap, which leads to a time complexity of $O(n)$ instead of $O(n^2)$, which a transformer usually has due to the attention mechanism.
The news articles that we tested on where gathered, and marked as positive/neutral/negative based on the stock price movement within 5 minutes after the news article was published. The tresholds for a positive/negative news article was a movement of + or - 3% respectively.
When DocBERT was implemented, it was still a bit slow due to the varying lengths of the documents, since all entries in a batch need to be padded to the same length. One way to mitigate this a bit, which we implemented is to sort the entries by length to minimize the unneccesary padding, and thus the length of our batches. You can see this visualized in an image we drew in ms-paint one late evening. This image also shows how the splitting was made, in order to ensure that an equal amount of splits were made each batch. 
Unsurprisingly, the sentiment of financial phrases ended up having better domain transfer to financial news compared to amazon reviews. The final results on the gathered testing data can be seen in the following confusion matrixes.
The performance of the model trained on amazon reviews

The performance of the model trained on financial phrases

During the project we made weekly status reports for the examiner, these can be found here.
This week we sucessfully implemented a docbert which is able to process larger documents in an efficient manner. Our own collected news were nicely processed, and we got started on our presentation and abstract for the report.
This week we will have a lot to do.
Instead of short, medium long and long, we have dataset with the same document length as our training dataset and test dataset. No significant difference was seen.
Secondly, we should process the rest of our data similarly to how the own-collected news were processed.
We should also thoroughly examine our litterature, mainly the text-splitting with overlap article and the original docbert article, to see if anything is missing in our BERT arcitechture.
Furthermore, we should train a BERT on our training datasets and evaluate it on the test dataset.
Besides a lot of work in front of us, we do not have any current problems.
Starting with what we are supposed to have done.
This week we will preform the experiments, and hopefully address our current problems in an efficient manner. We will start by contacting the examiner of the course in hope of receiving some guidance.
Jupyter Notebook
99.1%