Views
No views yet
1>>> from transformers import pipeline
2>>> ner = pipeline('ner', model='winberto-ner-uncased')
3>>> tokens = ner("Heitz Cabernet Sauvignon California Napa Valley Napa US this tremendous 100% varietal wine hails from oakville and was aged over three years in oak. juicy red-cherry fruit and a compelling hint of caramel greet the palate, framed by elegant, fine tannins and a subtle minty tone in the background. balanced and rewarding from start to finish, it has years ahead of it to develop further nuance. enjoy 2022")
4>>> for t in toks:
5>>> print(f"{t['word']}: {t['entity_group']}: {t['score']:.5}")
6
7heitz: producer: 0.99988
8cab: wine: 0.9999
9##ernet sauvignon: wine: 0.95893
10california: province: 0.99992
11napa valley: region: 0.99991
12napa: subregion: 0.99987
13us: country: 0.99996
14oak: flavor: 0.99992
15juicy: mouthfeel: 0.99992
16cherry: flavor: 0.99994
17fruit: flavor: 0.99994
18cara: flavor: 0.99993
19##mel: flavor: 0.99731
20mint: flavor: 0.99994
21balanced: mouthfeel: 0.99992adjective: nice, exciting, strong etc
country: countries specified in label or description
flavor: fruit, apple, toast, smoke etc
grape: Cab, Cabernet Sauvignon, etc
mouthfeel: lucious, smooth, textured, rough etc
producer: wine maker
province, region: province and region of wine - sometimes these get mixed upmodel_id = 'bert-base-uncased'
arguments = TrainingArguments(
evaluation_strategy="epoch",
learning_rate=2e-5,
per_device_train_batch_size=8,
per_device_eval_batch_size=8,
num_train_epochs=5,
weight_decay=0.01,
)
...
trainer.train()