Andrew Luo commited on
Commit ·
d83d72b
1
Parent(s): c98f9e5
update handler
Browse files- handler.py +1 -1
handler.py
CHANGED
|
@@ -19,6 +19,7 @@ class EndpointHandler():
|
|
| 19 |
A :obj:`list` | `dict`: will be serialized and returned
|
| 20 |
"""
|
| 21 |
# get inputs
|
|
|
|
| 22 |
tokens = self.tokenizer(text, return_tensors='pt')
|
| 23 |
output = self.model(**tokens)
|
| 24 |
vec = torch.max(
|
|
@@ -26,7 +27,6 @@ class EndpointHandler():
|
|
| 26 |
1 + torch.relu(output.logits)
|
| 27 |
) * tokens.attention_mask.unsqueeze(-1),
|
| 28 |
dim=1)[0].squeeze()
|
| 29 |
-
instruction = data.pop("instruction", data)
|
| 30 |
cols = vec.nonzero().squeeze().cpu().tolist()
|
| 31 |
# extract the non-zero values
|
| 32 |
weights = vec[cols].cpu().tolist()
|
|
|
|
| 19 |
A :obj:`list` | `dict`: will be serialized and returned
|
| 20 |
"""
|
| 21 |
# get inputs
|
| 22 |
+
text = data.pop("text", data)
|
| 23 |
tokens = self.tokenizer(text, return_tensors='pt')
|
| 24 |
output = self.model(**tokens)
|
| 25 |
vec = torch.max(
|
|
|
|
| 27 |
1 + torch.relu(output.logits)
|
| 28 |
) * tokens.attention_mask.unsqueeze(-1),
|
| 29 |
dim=1)[0].squeeze()
|
|
|
|
| 30 |
cols = vec.nonzero().squeeze().cpu().tolist()
|
| 31 |
# extract the non-zero values
|
| 32 |
weights = vec[cols].cpu().tolist()
|