Views
No views yet

Correction of spelling errors in ndebele sentences or phrases.
Spelling correction
Language models, including Flan-T5, can potentially be used for language generation in a harmful way, according to Rae et al. (2021). Flan-T5 should not be used directly in any application, without a prior assessment of safety and fairness concerns specific to the application.
Flan-T5 is fine-tuned on a large corpus of text data that was not filtered for explicit content or assessed for existing biases. As a result the model itself is potentially vulnerable to generating equivalently inappropriate content or replicating inherent biases in the underlying data.
1
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("thaboe01/t5-spelling-corrector-ndebele")
5model = T5ForConditionalGeneration.from_pretrained("thaboe01/t5-spelling-corrector-ndebele")
6
7input_text = "Please correct the following sentence: ukuti yiles sivnmelwano"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))1# pip install accelerate
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("thaboe01/t5-spelling-corrector-ndebele")
5model = T5ForConditionalGeneration.from_pretrained("thaboe01/t5-spelling-corrector-ndebele", device_map="auto")
6
7input_text = "Please correct the following sentence: ukuti yiles sivnmelwano"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))1# pip install accelerate
2import torch
3from transformers import T5Tokenizer, T5ForConditionalGeneration
4
5tokenizer = T5Tokenizer.from_pretrained("thaboe01/t5-spelling-corrector-ndebele")
6model = T5ForConditionalGeneration.from_pretrained("thaboe01/t5-spelling-corrector-ndebele", device_map="auto", torch_dtype=torch.float16)
7
8input_text = "Please correct the following sentence: ukuti yiles sivnmelwano"
9input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
10
11outputs = model.generate(input_ids)
12print(tokenizer.decode(outputs[0]))1# pip install bitsandbytes accelerate
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("thaboe01/t5-spelling-corrector-ndebele")
5model = T5ForConditionalGeneration.from_pretrained("thaboe01/t5-spelling-corrector-ndebele", device_map="auto", load_in_8bit=True)
6
7input_text = "Please correct the following sentence: ukuti yiles sivnmelwano"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))