Text Classification
Transformers
PyTorch
bert
feature-extraction
custom_code
text-embeddings-inference
Instructions to use Wellcome/WellcomeBertMesh with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Wellcome/WellcomeBertMesh with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Wellcome/WellcomeBertMesh", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Wellcome/WellcomeBertMesh", trust_remote_code=True) model = AutoModel.from_pretrained("Wellcome/WellcomeBertMesh", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Nick Sorros commited on
Commit ·
da5a2e2
1
Parent(s): 6d3d5fc
Fix handler
Browse files- handler.py +3 -3
handler.py
CHANGED
|
@@ -18,9 +18,9 @@ class EndpointHandler():
|
|
| 18 |
- "label": A string representing what the label/class is. There can be multiple labels.
|
| 19 |
- "score": A score between 0 and 1 describing how confident the model is for this label/class.
|
| 20 |
"""
|
| 21 |
-
|
| 22 |
-
inputs = self.tokenizer(
|
| 23 |
-
preds = self.model(
|
| 24 |
|
| 25 |
with open("label_binarizer.pkl", "rb") as f:
|
| 26 |
label_binarizer = pickle.loads(f.read())
|
|
|
|
| 18 |
- "label": A string representing what the label/class is. There can be multiple labels.
|
| 19 |
- "score": A score between 0 and 1 describing how confident the model is for this label/class.
|
| 20 |
"""
|
| 21 |
+
text = data.pop("inputs", data)
|
| 22 |
+
inputs = self.tokenizer(text, padding="max_length")
|
| 23 |
+
preds = self.model(input_ids=[inputs["input_ids"]])
|
| 24 |
|
| 25 |
with open("label_binarizer.pkl", "rb") as f:
|
| 26 |
label_binarizer = pickle.loads(f.read())
|