Views
No views yet
bert-base-uncasedpip install zeroshot-classifier1>>> from zeroshot_classifier.models import BinaryBertCrossEncoder
2>>> model = BinaryBertCrossEncoder(model_name='claritylab/zero-shot-implicit-binary-bert')
3
4>>> text = "I'd like to have this track onto my Classical Relaxations playlist."
5>>> labels = [
6>>> 'Add To Playlist', 'Book Restaurant', 'Get Weather', 'Play Music', 'Rate Book', 'Search Creative Work',
7>>> 'Search Screening Event'
8>>> ]
9>>> aspect = 'intent'
10>>> aspect_sep_token = model.tokenizer.additional_special_tokens[0]
11>>> text = f'{aspect} {aspect_sep_token} {text}'
12
13>>> query = [[text, lb] for lb in labels]
14>>> logits = model.predict(query, apply_softmax=True)
15>>> print(logits)
16
17[[7.3497969e-04 9.9926502e-01]
18 [9.9988127e-01 1.1870124e-04]
19 [9.9988961e-01 1.1033980e-04]
20 [1.9227572e-03 9.9807727e-01]
21 [9.9985313e-01 1.4685343e-04]
22 [9.9938977e-01 6.1021477e-04]
23 [9.9838030e-01 1.6197052e-03]]