File size: 897 Bytes
0fadadf
 
 
 
10c5e8e
 
 
bc233ce
64eca7c
10c5e8e
 
64eca7c
613aa57
10c5e8e
0fadadf
 
 
64eca7c
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import torch
import gradio as gr
from transformers import pipeline

# Use the Dicta IL model for summarization with a manual prompt in Hebrew
model_name = "dicta-il/dictalm2.0"
text_summary = pipeline("text2text-generation", model=model_name, torch_dtype=torch.bfloat16)

def summary(input):
    # Create a prompt in Hebrew for summarization
    prompt = f"סכם את הטקסט הבא: {input}"
    # Increase max_length and set max_new_tokens to avoid input length issues
    output = text_summary(prompt, max_new_tokens=512, min_length=30, do_sample=False)
    return output[0]['generated_text']

gr.close_all()

demo = gr.Interface(
    fn=summary,
    inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
    outputs=[gr.Textbox(label="Summarized text", lines=4)],
    title="Hebrew Text Summarizer",
    description="This application will summarize Hebrew text."
)

demo.launch()