gb / app.py
groundedbase's picture
relax prompt for flan extraction
8f4db94 verified
Raw
History Blame Contribute Delete
802 Bytes
import gradio as gr
from transformers import pipeline
pipe = pipeline(
"text2text-generation",
model="google/flan-t5-xl",
max_new_tokens=256
)
def analyze(text):
prompt = f"""
TASK:
Extract key facts from the following business document.
INSTRUCTIONS:
- Use short phrases, not full sentences
- Do not repeat the document verbatim
- No polite language
- If a value is not mentioned, write "N/A"
Return the result in exactly this format:
Offer amount:
Budget limit:
Reply deadline:
Delivery time:
Decision options:
Document:
{text}
"""
return pipe(prompt)[0]["generated_text"]
gr.Interface(
fn=analyze,
inputs=gr.Textbox(lines=10, label="Text eingeben"),
outputs=gr.Textbox(lines=15, label="Ergebnis"),
title="Business-Text-Analyse (FLAN-T5)"
).launch()