File size: 539 Bytes
4027d82 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from transformers import CamembertTokenizer, CamembertForTokenClassification, TokenClassificationPipeline
OUTPUT_PATH = './'
tokenizer = CamembertTokenizer.from_pretrained(OUTPUT_PATH)
model = CamembertForTokenClassification.from_pretrained(OUTPUT_PATH)
pos = TokenClassificationPipeline(model=model, tokenizer=tokenizer)
def make_prediction(sentence):
labels = [l['entity'] for l in pos(sentence)]
return list(zip(sentence.split(" "), labels))
res = make_prediction("George Washington est allé à Washington")
|