MCPcopy
hub / github.com/appvision-ai/fast-bert / predict

Method predict

fast_bert/prediction.py:127–134  ·  view source on GitHub ↗
(self, text, verbose=False)

Source from the content-addressed store, hash-verified

125 self.model = load_model(Path(self.model_path) / model_name)
126
127 def predict(self, text, verbose=False):
128 # Inputs are provided through numpy array
129 model_inputs = self.tokenizer(text, return_tensors="pt")
130 inputs_onnx = {k: v.cpu().detach().numpy() for k, v in model_inputs.items()}
131 outputs = self.model.run(None, inputs_onnx)
132 softmax_preds = softmax(outputs[0])
133 preds = list(zip(self.labels, softmax_preds[0]))
134 return sorted(preds, key=lambda x: x[1], reverse=True)
135
136
137

Callers

nothing calls this directly

Calls 2

softmaxFunction · 0.70
detachMethod · 0.45

Tested by

no test coverage detected