Views
No views yet
1from transformers import pipeline
2
3# Initialize the pipeline for masked language model
4unmasker = pipeline('fill-mask', model='dsfsi/zabantu-nso-120m')
5
6# The Sepedi sentence with a masked token
7sample_sentences = ["mopresidente wa <mask> wa afrika-borwa", # original token: maloba
8"bašomedi ba polase ya dinamune ya zebediela citrus ba hlomile magato a <mask> malebana le go se sepetšwe botse ga dilo ka polaseng eo." # original token: boipelaetšo
9]
10
11# Perform the fill-mask task
12results = unmasker(sentence)
13
14# Display the results
15for result in results:
16 print(f"Predicted word: {result['token_str']} - Score: {result['score']}")
17 print(f"Full sentence: {result['sequence']}\n")
18 print("=" * 80)