Coder Social home page Coder Social logo

yya518 / finbert Goto Github PK

View Code? Open in Web Editor NEW
524.0 16.0 121.0 982 KB

A Pretrained BERT Model for Financial Communications. https://arxiv.org/abs/2006.08097

License: Apache License 2.0

Python 18.38% Jupyter Notebook 81.62%
bert nlp financial-analysis financial-sentiment-analysis sentiment-analysis

finbert's People

Contributors

mcsuy avatar mcsuy1998 avatar mikaeldusenne avatar yya518 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finbert's Issues

FinBERT pretrained model in ONNX format

Do you have a ONNX format available? My environment is ML.Net and DON’T want to go through the full conversion process and setting up the environment..

using CPU error

first, I really appreciate this model.

In my environment CUDA is available, but if i run the model, the process will die since using only CPU.
Is there a separate setting method for using CUDA?

Thank you again for this model.

error when running FinBert Model Example.ipynb

when running model.load_state_dict(torch.load(fine_tuned_weight_path, map_location=device)) from FinBert Model Example.ipynb from my local machine, I ran into this error:

RuntimeError: Error(s) in loading state_dict for BertClassification:
	Missing key(s) in state_dict: "bert.embeddings.position_ids".

For those of us without a CUDA compatible device: Note to use 'cpu' rather than 'cuda:1' as device.

Thank you for providing us with your trained model! I finally have the fine-tuned model working on my machine. But after struggling for a long time, here are some notes that may help future users who like me have little experience with these types of models.

In working through your example for using the fine-tuned FinBERT, I had issues installing torch==1.2.0 until I first ran pip install pytorch-pretrained-bert, which did the installation of torch for me and eliminated that issue.

I do not have a CUDA compatible GPU and so had to change device='cuda:1' to device='cpu'. I then needed to add map_location=device or map_location='cpu' when running model.load_state_dict(torch.load(fine_tuned_weight_path,map_location=device)).

These are rather simple changes, but they held me up for some time.

MisMatch between labels during dataPrep v.s. during inference

I might be missing something, but it seems there is a mis-match between the label ordering when preparing the training data v.s. when doing the inference in the provided jupyter notebook.

In the 'datasets.py' file, in the 'transform_labels' method, the order is: "dict_labels = {'positive': 0, 'neutral':1, 'negative':2}"
But in the notebook: "labels = {0:'neutral', 1:'positive', 2:'negative'}"

In both cases, 'negative'=2, but 'positive' and 'neutral' are switched.
Is there a reason I am missing?
Thank you!

The sentiments are varying every time when i run it for the same sentence.

I have created my own sentence "there is a abundance of capital because of good profits" to test the sentiment prediction for the fine-tuned model using the notebook given: "FinBert Model Example.ipynb".

When I ran for the first time I got the result as 'positive': https://prnt.sc/vf3fnb
When I ran for the second time I got the result as 'neutral': https://prnt.sc/vf3fcr

Why is this variation happening? How can we trust the results from this model if it is not stable?

sentiment predictions are not consistent

I am using your sentiment model to predict sentences from calls. There are two sentences:

  • The probability of neutral is .99 for the sentence 'Thanks, Martin.'
  • The probability of positive is .94 for the sentence 'Thank you.'

I am trying to understand why it gives quite different labels. Initially I thought it was the label confusion, but you have answered the question in Issue #17.
Could you explain more about how you fine-tuning the model for analyst tones and what date you use for the classification model? Thank you!

Migration to transformers

Are there any plans on migrating the current model to the newer transformers library by hugging face? I want to use it with the sentence-transformer library but it seems like it can only run with the newer transformer model.

Is there a prediction script available?

HI,

Congrats for the wonderful work.

I would much appreciate if you would construct a prediction script which could work like this:

python bert_prediction.py --input "Sentence for classification" -- weights (path to weights)

Analyst Tone

Hi!
Thank you for this repository.
Do you know where I can find the Analyst Tone dataset that you mention in the paper?
Thank you,
Maxime.

FinBERT pipeline vs Finbert Model Example code result difference

My collaborators and I were experimenting with FinBERT by comparing the results of your code from the Finbert Model Example notebook to the results of using the transformer code in a HuggingFace pipeline. of the 7 we tested it on, all came out with different scores, but 3 came out with different labels altogether. We were wondering if you knew what the reason for that might be? I can upload the code that we used if that would be helpful.

Is there sentiment score or probability of positive/neutral/negative?

Thank you for the great library.

I went through example and there are only labels, i.e. positive, neutral and negative for the text's sentiment. I'm wondering if there's any score or probability deciding what text is positive, neutral or negative?

I was looking in attributes, i.e. dir(outputs) or dir(tourch) but did not find any such value, which would be indeed useful to know.

Data is missing to run finetune Notebook

This is a really interesting project.
Can you please provide a version of the analysttone.csv file? The NB will not run without it.

At a minimum provide a specification and a few hundred examples.

Thank you.

Richard

TF Model

Hello,

Will you be generating a TF version of this model? I will need it to import on SparkNLP.

RuntimeError: The size of tensor a (538) must match the size of tensor b (512) at non-singleton dimension 1

I'm parsing conference calls and run into this error a couple of times. I used NLTK to parse the text components into sentences and then pass those sentences into the classifier following your example. It largely works, but I ran into this issue. From what I read, it arises because there are too many tokens (words) in the sentence. I manually inspect where I think the issue is occurring to identify a piece that is extra long. It occurs when there is a lot of semi-colons. So I could break up sentences with semi-colons, but that doesn't seem quite right. Using word_tokenize from nltk, there are only 488 tokens. How do you tokenize the words? I'm thinking I will truncate the sentence before passing to the model, but to do so accurately, I need to know how many tokens are created by the model.

Is my assessment of why this is happening correct and do you have a better solution than truncating? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.