Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,15 +21,15 @@ print(f"β
Model loaded successfully on {device}!")
|
|
| 21 |
# ==========================
|
| 22 |
# 2. Summarization function
|
| 23 |
# ==========================
|
| 24 |
-
def summarize_khmer_text(text, max_length=150
|
| 25 |
"""
|
| 26 |
Summarize Khmer text
|
| 27 |
"""
|
| 28 |
if not text or text.strip() == "":
|
| 29 |
return "β οΈ ααΌααααα
αΌαα’ααααα / Please enter text"
|
| 30 |
|
| 31 |
-
if len(text.strip()) < 20:
|
| 32 |
-
|
| 33 |
|
| 34 |
try:
|
| 35 |
# Tokenize input
|
|
@@ -46,11 +46,11 @@ def summarize_khmer_text(text, max_length=150, min_length=40):
|
|
| 46 |
summary_ids = model.generate(
|
| 47 |
inputs["input_ids"],
|
| 48 |
max_length=max_length,
|
| 49 |
-
min_length=min_length,
|
| 50 |
length_penalty=2.0,
|
| 51 |
-
num_beams=
|
| 52 |
early_stopping=True,
|
| 53 |
-
no_repeat_ngram_size=3
|
| 54 |
)
|
| 55 |
|
| 56 |
# Decode output
|
|
|
|
| 21 |
# ==========================
|
| 22 |
# 2. Summarization function
|
| 23 |
# ==========================
|
| 24 |
+
def summarize_khmer_text(text, max_length=150):
|
| 25 |
"""
|
| 26 |
Summarize Khmer text
|
| 27 |
"""
|
| 28 |
if not text or text.strip() == "":
|
| 29 |
return "β οΈ ααΌααααα
αΌαα’ααααα / Please enter text"
|
| 30 |
|
| 31 |
+
# if len(text.strip()) < 20:
|
| 32 |
+
# return "β οΈ α’αααααααααΈααα / Text is too short to summarize"
|
| 33 |
|
| 34 |
try:
|
| 35 |
# Tokenize input
|
|
|
|
| 46 |
summary_ids = model.generate(
|
| 47 |
inputs["input_ids"],
|
| 48 |
max_length=max_length,
|
| 49 |
+
# min_length=min_length,
|
| 50 |
length_penalty=2.0,
|
| 51 |
+
num_beams=5,
|
| 52 |
early_stopping=True,
|
| 53 |
+
# no_repeat_ngram_size=3
|
| 54 |
)
|
| 55 |
|
| 56 |
# Decode output
|