Hezam commited on
Commit
c47847c
1 Parent(s): 72eaca6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -5
README.md CHANGED
@@ -25,12 +25,21 @@ category_mapping = {
25
  ![image/png](https://cdn-uploads.huggingface.co/production/uploads/645817bb72b60ae7a37f8f40/6gZDjcAOhWLvN5xF-E2FE.png)
26
 
27
  # Example usage
28
- model_name = "Hezam/arabic-T5-news-classification-generation"
29
- from transformers import T5ForConditionalGeneration, T5Tokenizer
 
 
 
30
  model = T5ForConditionalGeneration.from_pretrained(model_name)
31
  tokenizer = T5Tokenizer.from_pretrained(model_name)
32
- input_text = " الاستاذ حزام جوبح يحصل على براعة اختراع في التعلم العميق"
33
 
34
- output_text = model.generate(input_text)
35
- print(generated_text)
 
 
 
 
 
 
36
 
 
25
  ![image/png](https://cdn-uploads.huggingface.co/production/uploads/645817bb72b60ae7a37f8f40/6gZDjcAOhWLvN5xF-E2FE.png)
26
 
27
  # Example usage
28
+ from transformers import T5ForConditionalGeneration, T5Tokenizer, pipeline
29
+ from arabert.preprocess import ArabertPreprocessor
30
+
31
+ arabert_prep = ArabertPreprocessor(model_name="aubmindlab/bert-base-arabertv2")
32
+ model_name="Hezam/arabic-T5-news-classification-generation"
33
  model = T5ForConditionalGeneration.from_pretrained(model_name)
34
  tokenizer = T5Tokenizer.from_pretrained(model_name)
35
+ generation_pipeline = pipeline("text2text-generation",model=model,tokenizer=tokenizer)
36
 
37
+ text = " الاستاذ حزام جوبح يحصل على براعة اختراع في التعلم العميق"
38
+ text_clean = arabert_prep.preprocess(text)
39
+ g=generation_pipeline(text_clean,
40
+ num_beams=10,
41
+ max_length=config.Generation_LEN,
42
+ top_p=0.9,
43
+ repetition_penalty = 3.0,
44
+ no_repeat_ngram_size = 3)[0]["generated_text"]
45