2

I'm trying to use my pre-trained huggingface model to predict.

    outputs = model(
        ids,
        mask,
        token_type_ids
    )
    outputs = torch.sigmoid(outputs.last_hidden_state).cpu().detach().numpy()
    return outputs[0][0]

The I got is

[[[0.5144298  0.68467325 0.4045368  ... 0.5698948  0.6843927  0.230076  ]
  [0.526383   0.6108195  0.46920577 ... 0.6635995  0.70778817 0.22947823]
  [0.47112644 0.6557672  0.49308282 ... 0.61219037 0.5811446  0.22059086]
  ...
  [0.46904904 0.66370267 0.4091996  ... 0.5381582  0.70973885 0.2500361 ]
  [0.47025025 0.6625398  0.40454543 ... 0.5423772  0.71071064 0.24768841]
  [0.47398427 0.658539   0.40038437 ... 0.53121835 0.7094869  0.2417065 ]]]

What I want is

[{'label': 'POSITIVE', 'score': 0.9998743534088135},
 {'label': 'NEGATIVE', 'score': 0.9996669292449951}]

Thanks ahead!!!

ZL RONG
  • 41
  • 4

0 Answers0