Domain Specific BERT Model for Text Mining in Sustainable Investing

Hello, I’m trying to pass a text file containing text that the bert model will try to classify, taken from GitHub - mukut03/ESG-BERT: Domain Specific BERT Model for Text Mining in Sustainable Investing, my skills are low to configer the task. Any help will be much appreciated.

I have two text files i tried to classify, 1) which is about a page of text gave output , 2) which is 20 pages gave the below error:

(base) C:\Users\Administrator\Downloads\ESG-BERT\ESG-BERT>curl -X POST http://127.0.0.1:8080/predictions/bert -T Hith.txt
{
“code”: 503,
“type”: “InternalServerException”,
“message”: “Prediction failed”
}

Log:
2022-05-10T00:52:40,277 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652136760
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - Received text: 'In fiscal year 2019, we reduced our comprehensive carbon footprint for the fourth
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - consecutive year�down 35 percent compared to 2015, when Apple�s carbon emissions
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - peaked, even as net revenue increased by 11 percent over that same period. In the past
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - year, we avoided over 10 million metric tons from our emissions reduction initiatives�like
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - our Supplier Clean Energy Program, which lowered our footprint by 4.4 million metric tons. ’
2022-05-10T00:53:13,425 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - Model predicted: ‘25’
2022-05-10T23:22:50,303 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652217770
2022-05-10T23:22:50,316 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Received text: 'Dear colleague,
2022-05-10T23:22:50,317 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,318 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - As I finish my second year as CEO at Heathrow, I feel so proud of the work
2022-05-10T23:22:50,318 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,319 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - we�ve done to further push our performance across such a wide range of
2022-05-10T23:22:50,322 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,324 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - key sustainability issues. Because we�ve already achieved so much,
2022-05-10T23:22:50,326 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,327 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - I know the difference we can make and feel more excited than ever by the
2022-05-10T23:22:50,329 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,332 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - opportunity to do more for the passengers and communities we serve by
2022-05-10T23:22:50,333 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,334 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - creating a Heathrow that�s not only the world�s best airport for passenger
2022-05-10T23:22:50,335 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,337 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - service, but also the most responsible.
2022-05-10T23:22:50,338 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,339 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - And this year, Heathrow turns 70. While we have ambitious plans for
2022-05-10T23:22:50,340 [INFO ] W-90community and as we grow,
2022-05-10T23:22:50,432 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,433 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - we�re keen to do more.
2022-05-10T23:22:50,434 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,436 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Not only am I proud of our contribution in
2022-05-10T23:22:50,437 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,438 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - creating opportunities for local people, it�s so
2022-05-10T23:22:50,440 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,442 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - rewarding to see the people who pass through
2022-05-10T23:22:50,443 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,444 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - the Academy put what they�ve learnt into
2022-05-10T23:22:50,447 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,449 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - practice and make each journey better for
2022-05-10T23:22:50,450 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,455 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our passengers.
2022-05-10T23:22:50,456 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,458 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 2 � Transform Customer Service
2022-05-10T23:22:50,459 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,461 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Last year we delivered record levels of customer
2022-05-10T23:22:50,461 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,465 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - satisfaction with 81% of our passengers rating
2022-05-10T23:22:50,473 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,475 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - their Heathrow experience as �Excellent� or �Very
2022-05-10T23:22:50,477 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,478 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Good�. We achieved this by speeding up journeys
2022-05-10T23:22:50,479 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,480 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - through the airport with state-of-the-art body
2022-05-10T23:22:50,481 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,481 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - scanners and more biometric passport readers
2022-05-10T23:22:50,482 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,483 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - to reduce queues at security and immigration.
2022-05-10T23:22:50,483 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,484 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - But delivering great passenger experience
2022-05-10T23:22:50,485 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,486 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - means going beyond our terminal walls.
2022-05-10T23:22:50,487 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,488 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We�ve invested heavily in upgrading our
2022-05-10T23:22:50,488 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,489 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - existing Instrument Landing System so aircraft
2022-05-10T23:22:50,490 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,490 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - can continue to land on time, despite the British
2022-05-10T23:22:50,493 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,493 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - weather. This reduces the need for stacking and
2022-05-10T23:22:50,494 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,495 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - enables us to land aircraft more quickly � cutting
2022-05-10T23:22:50,495 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,496 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - the amount of fuel burnt and minimising
2022-05-10T23:22:50,499 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,499 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - disruptions for our passengers.
2022-05-10T23:22:50,500 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,501 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 3 � Beat the Plan
2022-05-10T23:22:50,501 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,502 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - To grow effectively, we�ve overhauled our
2022-05-10T23:22:50,503 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,503 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - operations to deliver a better return for our
2022-05-10T23:22:50,504 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,505 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - investors � and the environment. Since 2012,
2022-05-10T23:22:50,505 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,506 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our energy management programmes have
2022-05-10T23:22:50,506 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,507 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - reduced energy consumption, improving the
2022-05-10T23:22:50,507 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,508 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - passenger experience with more sophisticated
2022-05-10T23:22:50,508 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,509 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - LED lighting, as well as delivering over �10
2022-05-10T23:22:50,510 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,510 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - million in cost savings.
2022-05-10T23:22:50,511 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,512 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We�ve made great gains in conserving water,
2022-05-10T23:22:50,513 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,513 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - working with our partners at GE to save
2022-05-10T23:22:50,514 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,515 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - 100,000,000 litres of water through new facilities.
2022-05-10T23:22:50,516 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,516 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Elsewhere, a new waste treatment
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - plant has turned 1,885 metric tonnes of waste
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - into 2.4 MW of power, helping us to reduce
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - landfill while cutting emissions and costs.
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - By refocussing Heathrow�s operations and making
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - sustainability �business as usual�, we can grow
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - while still delivering on our environmental and
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - community commitments.
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 4 � Win Support for Expansion
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - As we know, travelling broadens horizons and
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - brings people and businesses together. Naturally,
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - at Heathrow, we see aviation as being at the
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - heart of the global economy and people�s desire
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - to explore. We recognise that sustainable growth
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - is essential to grow fairly and preserve a world
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - that�s worth travelling, for everyone.
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We�re proud to say that over 99% of our flights
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - are operated by the quietest category of aircraft
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - and the last two years shows a clear upward
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - trend of airlines using the quieter Continuous
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Descent Approach, showing Heathrow can grow
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - while still being sustainable and responsible.
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - To build on this, we�re going to do more, putting
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - passengers and communities at the heart of
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our new approach. With big advances in our
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - strategic thinking and the technology we use,
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - we are revolutionising Heathrow for all our
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - stakeholders as we match our achievements
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - with new ambitions.
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We know we have to cut carbon emissions
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - dramatically if we�re to avoid the worst effects
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - of climate change. But we�ve shown that by
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - rethinking our operations, we can deliver real
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - change and real benefits. Better public transport,
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - more innovative building materials and new
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - ways of working are already reducing Heathrow�s
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - impact on the environment while we keep on
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - growing our
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - 2015 saw 22% of eligible departures report
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - using reduced engine taxi, lowering emissions.

2022-05-10T23:22:50,848 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Invoking custom service failed.
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Traceback (most recent call last):
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\ts\service.py”, line 102, in predict
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - ret = self._entry_point(input_batch, self.context)
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\Scripts\models\12a909175cdb4fcfb175efec14fe311a\bertHandler.py”, line 108, in handle
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - raise e
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\Scripts\models\12a909175cdb4fcfb175efec14fe311a\bertHandler.py”, line 103, in handle
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - data = _service.inference(data)
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\Scripts\models\12a909175cdb4fcfb175efec14fe311a\bertHandler.py”, line 75, in inference
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - prediction = self.model(
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 1110, in _call_impl
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - return forward_call(*input, **kwargs)
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\transformers\models\bert\modeling_bert.py”, line 1545, in forward
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - outputs = self.bert(
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 1110, in _call_impl
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - return forward_call(*input, **kwargs)
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\transformers\models\bert\modeling_bert.py”, line 989, in forward
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - embedding_output = self.embeddings(
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 1110, in _call_impl
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - return forward_call(*input, **kwargs)
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - File “C:\Users\Administrator\anaconda3\lib\site-packages\transformers\models\bert\modeling_bert.py”, line 220, in forward
2022-05-10T23:22:50,852 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - embeddings += position_embeddings
2022-05-10T23:22:50,852 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - RuntimeError: The size of tensor a (4702) must match the size of tensor b (512) at non-singleton dimension 1
2022-05-10T23:38:50,994 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652218730
2022-05-10T23:38:51,000 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - Received text: 'In fiscal year 2019, we reduced our comprehensive carbon footprint for the fourth
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - consecutive year�down 35 percent compared to 2015, when Apple�s carbon emissions
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - peaked, even as net revenue increased by 11 percent over that same period. In the past
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - year, we avoided over 10 million metric tons from our emissions reduction initiatives�like
2022-05-10T23:38:51,002 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -
2022-05-10T23:38:51,002 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - our Supplier Clean Energy Program, which lowered our footprint by 4.4 million metric tons. ’
2022-05-10T23:38:51,802 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - Model predicted: ‘25’

bertHandler:
from abc import ABC

import json

import logging

import os

import torch

from transformers import AutoModelForSequenceClassification, AutoTokenizer

from ts.torch_handler.base_handler import BaseHandler

logger = logging.getLogger(name)

class TransformersClassifierHandler(BaseHandler, ABC):

"""

Transformers text classifier handler class. This handler takes a text (string) and

as input and returns the classification text based on the serialized transformers checkpoint.

"""

def __init__(self):

    super(TransformersClassifierHandler, self).__init__()

    self.initialized = False

def initialize(self, ctx):

    self.manifest = ctx.manifest

    properties = ctx.system_properties

    model_dir = properties.get("model_dir")

    self.device = torch.device("cuda:" + str(properties.get("gpu_id")) if torch.cuda.is_available() else "cpu")

    # Read model serialize/pt file

    self.model = AutoModelForSequenceClassification.from_pretrained(model_dir)

    self.tokenizer = AutoTokenizer.from_pretrained(model_dir)

    self.model.to(self.device)

    self.model.eval()

    logger.debug('Transformer model from path {0} loaded successfully'.format(model_dir))

    # Read the mapping file, index to object name

    mapping_file_path = os.path.join(model_dir, "index_to_name.json")

    if os.path.isfile(mapping_file_path):

        with open(mapping_file_path) as f:

            self.mapping = json.load(f)

    else:

        logger.warning('Missing the index_to_name.json file. Inference output will not include class name.')

    self.initialized = True

def preprocess(self, data):

    """ Very basic preprocessing code - only tokenizes.

        Extend with your own preprocessing steps as needed.

    """

    text = data[0].get("data")

    if text is None:

        text = data[0].get("body")

    sentences = text.decode('utf-8')

    logger.info("Received text: '%s'", sentences)

    inputs = self.tokenizer.encode_plus(

        sentences,

        add_special_tokens=True,

        return_tensors="pt"

    )

    return inputs

def inference(self, inputs):

    """

    Predict the class of a text using a trained transformer model.

    """

    # NOTE: This makes the assumption that your model expects text to be tokenized  

    # with "input_ids" and "token_type_ids" - which is true for some popular transformer models, e.g. bert.

    # If your transformer model expects different tokenization, adapt this code to suit

    # its expected input format.

    prediction = self.model(

        inputs['input_ids'].to(self.device),

        token_type_ids=inputs['token_type_ids'].to(self.device)

    )[0].argmax().item()

    logger.info("Model predicted: '%s'", prediction)

    if self.mapping:

        prediction = self.mapping[str(prediction)]

    return [prediction]

def postprocess(self, inference_output):

    # TODO: Add any needed post-processing of the model predictions here

    return inference_output

_service = TransformersClassifierHandler()

def handle(data, context):

try:

    if not _service.initialized:

        _service.initialize(context)

    if data is None:

        return None

    data = _service.preprocess(data)

    data = _service.inference(data)

    data = _service.postprocess(data)

    return data

except Exception as e:

    raise e

I will be happy if someone can show me my mistakes.