Domain Specific BERT Model for Text Mining in Sustainable Investing

username: Kefilwe_Mathumo
cooked: <p>Hello, I’m trying to pass a text file containing text that the bert model will try to classify, taken from <a href="https://github.com/mukut03/ESG-BERT" class="inline-onebox" rel="noopener nofollow ugc">GitHub - mukut03/ESG-BERT: Domain Specific BERT Model for Text Mining in Sustainable Investing</a>, my skills are low to configer the task. Any help will be much appreciated.</p>
<p>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:</p>
<p>(base) C:\Users\Administrator\Downloads\ESG-BERT\ESG-BERT&gt;curl -X POST <a href="http://127.0.0.1:8080/predictions/bert" rel="noopener nofollow ugc">http://127.0.0.1:8080/predictions/bert</a> -T Hith.txt<br>
{<br>
“code”: 503,<br>
“type”: “InternalServerException”,<br>
“message”: “Prediction failed”<br>
}</p>
<p>Log:<br>
2022-05-10T00:52:40,277 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652136760<br>
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<br>
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T00:52:40,293 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG -<br>
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. ’<br>
2022-05-10T00:53:13,425 [INFO ] W-9000-bert_1.0-stdout MODEL_LOG - Model predicted: ‘25’<br>
2022-05-10T23:22:50,303 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652217770<br>
2022-05-10T23:22:50,316 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Received text: 'Dear colleague,<br>
2022-05-10T23:22:50,317 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,318 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,322 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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,<br>
2022-05-10T23:22:50,326 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,329 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,333 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,335 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,337 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - service, but also the most responsible.<br>
2022-05-10T23:22:50,338 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,340 [INFO ] W-90community and as we grow,<br>
2022-05-10T23:22:50,432 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,433 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - we�re keen to do more.<br>
2022-05-10T23:22:50,434 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,436 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Not only am I proud of our contribution in<br>
2022-05-10T23:22:50,437 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,438 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - creating opportunities for local people, it�s so<br>
2022-05-10T23:22:50,440 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,442 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - rewarding to see the people who pass through<br>
2022-05-10T23:22:50,443 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,444 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - the Academy put what they�ve learnt into<br>
2022-05-10T23:22:50,447 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,449 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - practice and make each journey better for<br>
2022-05-10T23:22:50,450 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,455 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our passengers.<br>
2022-05-10T23:22:50,456 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,458 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 2 � Transform Customer Service<br>
2022-05-10T23:22:50,459 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,461 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Last year we delivered record levels of customer<br>
2022-05-10T23:22:50,461 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,465 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - satisfaction with 81% of our passengers rating<br>
2022-05-10T23:22:50,473 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,475 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - their Heathrow experience as �Excellent� or �Very<br>
2022-05-10T23:22:50,477 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,478 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Good�. We achieved this by speeding up journeys<br>
2022-05-10T23:22:50,479 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,480 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - through the airport with state-of-the-art body<br>
2022-05-10T23:22:50,481 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,481 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - scanners and more biometric passport readers<br>
2022-05-10T23:22:50,482 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,483 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - to reduce queues at security and immigration.<br>
2022-05-10T23:22:50,483 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,484 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - But delivering great passenger experience<br>
2022-05-10T23:22:50,485 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,486 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - means going beyond our terminal walls.<br>
2022-05-10T23:22:50,487 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,488 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We�ve invested heavily in upgrading our<br>
2022-05-10T23:22:50,488 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,489 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - existing Instrument Landing System so aircraft<br>
2022-05-10T23:22:50,490 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,490 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - can continue to land on time, despite the British<br>
2022-05-10T23:22:50,493 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,493 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - weather. This reduces the need for stacking and<br>
2022-05-10T23:22:50,494 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,495 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - enables us to land aircraft more quickly � cutting<br>
2022-05-10T23:22:50,495 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,496 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - the amount of fuel burnt and minimising<br>
2022-05-10T23:22:50,499 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,499 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - disruptions for our passengers.<br>
2022-05-10T23:22:50,500 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,501 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 3 � Beat the Plan<br>
2022-05-10T23:22:50,501 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,502 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - To grow effectively, we�ve overhauled our<br>
2022-05-10T23:22:50,503 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,503 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - operations to deliver a better return for our<br>
2022-05-10T23:22:50,504 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,505 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - investors � and the environment. Since 2012,<br>
2022-05-10T23:22:50,505 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,506 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our energy management programmes have<br>
2022-05-10T23:22:50,506 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,507 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - reduced energy consumption, improving the<br>
2022-05-10T23:22:50,507 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,508 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - passenger experience with more sophisticated<br>
2022-05-10T23:22:50,508 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,509 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - LED lighting, as well as delivering over �10<br>
2022-05-10T23:22:50,510 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,510 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - million in cost savings.<br>
2022-05-10T23:22:50,511 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,512 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We�ve made great gains in conserving water,<br>
2022-05-10T23:22:50,513 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,513 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - working with our partners at GE to save<br>
2022-05-10T23:22:50,514 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,515 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - 100,000,000 litres of water through new facilities.<br>
2022-05-10T23:22:50,516 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,516 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Elsewhere, a new waste treatment<br>
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - plant has turned 1,885 metric tonnes of waste<br>
2022-05-10T23:22:50,517 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - landfill while cutting emissions and costs.<br>
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,518 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - By refocussing Heathrow�s operations and making<br>
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - sustainability �business as usual�, we can grow<br>
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - while still delivering on our environmental and<br>
2022-05-10T23:22:50,519 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - community commitments.<br>
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Priority 4 � Win Support for Expansion<br>
2022-05-10T23:22:50,520 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - As we know, travelling broadens horizons and<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - brings people and businesses together. Naturally,<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - at Heathrow, we see aviation as being at the<br>
2022-05-10T23:22:50,521 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - heart of the global economy and people�s desire<br>
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - to explore. We recognise that sustainable growth<br>
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,522 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - is essential to grow fairly and preserve a world<br>
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - that�s worth travelling, for everyone.<br>
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,523 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - are operated by the quietest category of aircraft<br>
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - and the last two years shows a clear upward<br>
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,524 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - trend of airlines using the quieter Continuous<br>
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Descent Approach, showing Heathrow can grow<br>
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - while still being sustainable and responsible.<br>
2022-05-10T23:22:50,525 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - passengers and communities at the heart of<br>
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,526 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - our new approach. With big advances in our<br>
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - strategic thinking and the technology we use,<br>
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,527 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - we are revolutionising Heathrow for all our<br>
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - stakeholders as we match our achievements<br>
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - with new ambitions.<br>
2022-05-10T23:22:50,528 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - We know we have to cut carbon emissions<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - dramatically if we�re to avoid the worst effects<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - of climate change. But we�ve shown that by<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,529 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - rethinking our operations, we can deliver real<br>
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - change and real benefits. Better public transport,<br>
2022-05-10T23:22:50,530 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - more innovative building materials and new<br>
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - ways of working are already reducing Heathrow�s<br>
2022-05-10T23:22:50,531 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - impact on the environment while we keep on<br>
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,532 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - growing our<br>
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - 2015 saw 22% of eligible departures report<br>
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -<br>
2022-05-10T23:22:50,652 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - using reduced engine taxi, lowering emissions.</p>
<p>2022-05-10T23:22:50,848 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Invoking custom service failed.<br>
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG - Traceback (most recent call last):<br>
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<br>
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     ret = self._entry_point(input_batch, self.context)<br>
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<br>
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     raise e<br>
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<br>
2022-05-10T23:22:50,849 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     data = _service.inference(data)<br>
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<br>
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     prediction = self.model(<br>
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<br>
2022-05-10T23:22:50,850 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     return forward_call(*input, **kwargs)<br>
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<br>
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     outputs = self.bert(<br>
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<br>
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     return forward_call(*input, **kwargs)<br>
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<br>
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     embedding_output = self.embeddings(<br>
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<br>
2022-05-10T23:22:50,851 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     return forward_call(*input, **kwargs)<br>
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<br>
2022-05-10T23:22:50,852 [INFO ] W-9002-bert_1.0-stdout MODEL_LOG -     embeddings += position_embeddings<br>
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<br>
2022-05-10T23:38:50,994 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - Backend received inference at: 1652218730<br>
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<br>
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:38:51,001 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -<br>
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<br>
2022-05-10T23:38:51,002 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG -<br>
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. ’<br>
2022-05-10T23:38:51,802 [INFO ] W-9001-bert_1.0-stdout MODEL_LOG - Model predicted: ‘25’</p>
<p>bertHandler:<br>
from abc import ABC</p>
<p>import json</p>
<p>import logging</p>
<p>import os</p>
<p>import torch</p>
<p>from transformers import AutoModelForSequenceClassification, AutoTokenizer</p>
<p>from ts.torch_handler.base_handler import BaseHandler</p>
<p>logger = logging.getLogger(<strong>name</strong>)</p>
<p>class TransformersClassifierHandler(BaseHandler, ABC):</p>
<pre><code>"""

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
</code></pre>
<p>_service = TransformersClassifierHandler()</p>
<p>def handle(data, context):</p>
<pre><code>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
</code></pre>
<p>I will be happy if someone can show me my mistakes.</p>