Downloads · 30 days
6
7% of all-time downloads
wyluilipe/prehibiton-themes-clf
prehibiton-themes-clf is a text classification model from wyluilipe. Use it when you need a label for a piece of text. It is set up for transformers.
Downloads · 30 days
6
7% of all-time downloads
All-time downloads
88
Public
Repo size
1.4 GB
Likes
0
Public
Click a slice to open those files.
.bin711 MB · 100%
From the Hugging Face model README
from transformers import BertTokenizer, BertForSequenceClassification
import torch
import numpy as np
import json
class Prehibition:
def __init__(self):
model_name = 'wyluilipe/prehibiton-themes-clf'
self.tokenizer = BertTokenizer.from_pretrained(model_name)
self.model = BertForSequenceClassification.from_pretrained(model_name)
def predict(self, text):
tokenized = self.tokenizer.batch_encode_plus(
[text],
max_length = 512,
pad_to_max_length=True,
truncation=True,
return_token_type_ids=False
)
tokens_ids, mask = torch.tensor(tokenized['input_ids']), torch.tensor(tokenized['attention_mask'])
with torch.no_grad():
model_output = self.model(tokens_ids, mask)
return np.argmax(model_output['logits']).item()