SuperSl6 commited on
Commit
a827e42
·
verified ·
1 Parent(s): 8321f61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -3,10 +3,20 @@ import gradio as gr
3
 
4
  # Load tokenizer with use_fast=False
5
  tokenizer = AutoTokenizer.from_pretrained("SuperSl6/Arabic-Text-Correction", use_fast=False)
6
- model = pipeline("text2text-generation", model="SuperSl6/Arabic-Text-Correction", tokenizer=tokenizer)
 
 
 
 
7
 
8
  def correct_text(input_text):
9
- result = model(input_text)[0]['generated_text']
 
 
 
 
 
 
10
  return result
11
 
12
  # Gradio Interface
@@ -19,4 +29,4 @@ interface = gr.Interface(
19
  description="أداة لتصحيح النصوص العربية باستخدام نموذج SuperSl6/Arabic-Text-Correction."
20
  )
21
 
22
- interface.launch(debug=True)
 
3
 
4
  # Load tokenizer with use_fast=False
5
  tokenizer = AutoTokenizer.from_pretrained("SuperSl6/Arabic-Text-Correction", use_fast=False)
6
+ model = pipeline(
7
+ "text2text-generation",
8
+ model="SuperSl6/Arabic-Text-Correction",
9
+ tokenizer=tokenizer
10
+ )
11
 
12
  def correct_text(input_text):
13
+ result = model(
14
+ input_text,
15
+ max_length=50, # Limit output length
16
+ no_repeat_ngram_size=2, # Prevent repeating bigrams
17
+ repetition_penalty=1.5, # Penalize repetitions
18
+ num_return_sequences=1 # Return a single output
19
+ )[0]['generated_text']
20
  return result
21
 
22
  # Gradio Interface
 
29
  description="أداة لتصحيح النصوص العربية باستخدام نموذج SuperSl6/Arabic-Text-Correction."
30
  )
31
 
32
+ interface.launch()