Finbert Integration
FinBERT is a pre-trained NLP model to analyze sentiment of financial text. It is built by further training the BERT language model in the finance domain, using a large financial corpus and thereby fine-tuning it for financial sentiment classification.
Ensure you have the following software installed:
- Python (v3.10+ recommended)
- Poetry (A Python packaging and dependency management tool)
Setup
-
For the demo to work, you need to get HuggingFaceAPI Token:
- Visit HuggingFace.
- Sign up or log in.
- Navigate to
Profile -> Settings -> Access Tokens. - Copy an existing token or create a new one.
-
In the
finbert/srcdirectory, create a.envfile and set your HuggingFaceAPI Token:export HUGGING_FACE_ACCESS_TOKEN="{Your HuggingFaceAPI Token}" -
To load the environment variables from
.envand install the dependencies:cd src source .env poetry install
Running The Script
To run the project, use the command:
poetry run python main.py
In the console look for the following output:
Adding agent to Bureau: {agent_address}
Copy the {agent_address} address and replace AI_MODEL_AGENT_ADDRESS value in agents/finbert_user.py.
You can change the input text to what you like, just open the src/finbert_user.py file, and change the value of INPUT_TEXT variable in agents/finbert_user.py.
The finbert model will give softmax outputs for three labels: positive, negative or neutral.