Spaces:
Running on Zero
Running on Zero
Two-column layout (inputs left, outputs right) for each task tab
Browse files
app.py
CHANGED
|
@@ -185,23 +185,26 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
|
|
| 185 |
with gr.Tabs():
|
| 186 |
with gr.Tab("🏷️ Entity Extraction"):
|
| 187 |
gr.Markdown("Extract named entities with custom labels.")
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
gr.Examples(
|
| 207 |
examples=[
|
|
@@ -218,19 +221,22 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
|
|
| 218 |
|
| 219 |
with gr.Tab("📋 Text Classification"):
|
| 220 |
gr.Markdown("Classify text into custom categories (zero-shot).")
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
gr.Examples(
|
| 236 |
examples=[
|
|
@@ -247,22 +253,25 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
|
|
| 247 |
|
| 248 |
with gr.Tab("🔗 Relation Extraction"):
|
| 249 |
gr.Markdown("Detect relationships between entities in text.")
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
gr.Examples(
|
| 268 |
examples=[
|
|
@@ -279,19 +288,22 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
|
|
| 279 |
|
| 280 |
with gr.Tab("📦 Structured Data Extraction"):
|
| 281 |
gr.Markdown("Parse text into structured JSON records with typed fields.")
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
gr.Examples(
|
| 297 |
examples=[
|
|
|
|
| 185 |
with gr.Tabs():
|
| 186 |
with gr.Tab("🏷️ Entity Extraction"):
|
| 187 |
gr.Markdown("Extract named entities with custom labels.")
|
| 188 |
+
with gr.Row():
|
| 189 |
+
with gr.Column():
|
| 190 |
+
ner_text = gr.Textbox(
|
| 191 |
+
label="Input Text",
|
| 192 |
+
placeholder="Enter text to analyze…",
|
| 193 |
+
lines=5,
|
| 194 |
+
value="Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday. The event was held at Apple Park.",
|
| 195 |
+
)
|
| 196 |
+
ner_labels = gr.Textbox(
|
| 197 |
+
label="Entity Labels (comma-separated)",
|
| 198 |
+
value="company, person, product, location",
|
| 199 |
+
placeholder="person, organization, location…",
|
| 200 |
+
)
|
| 201 |
+
ner_btn = gr.Button("Extract Entities", variant="primary")
|
| 202 |
+
with gr.Column():
|
| 203 |
+
ner_output = gr.HighlightedText(
|
| 204 |
+
label="Extracted Entities",
|
| 205 |
+
combine_adjacent=True,
|
| 206 |
+
show_legend=True,
|
| 207 |
+
)
|
| 208 |
|
| 209 |
gr.Examples(
|
| 210 |
examples=[
|
|
|
|
| 221 |
|
| 222 |
with gr.Tab("📋 Text Classification"):
|
| 223 |
gr.Markdown("Classify text into custom categories (zero-shot).")
|
| 224 |
+
with gr.Row():
|
| 225 |
+
with gr.Column():
|
| 226 |
+
cls_text = gr.Textbox(
|
| 227 |
+
label="Input Text",
|
| 228 |
+
placeholder="Enter text to classify…",
|
| 229 |
+
lines=3,
|
| 230 |
+
value="This laptop has amazing performance but terrible battery life!",
|
| 231 |
+
)
|
| 232 |
+
cls_schema = gr.Textbox(
|
| 233 |
+
label="Classification Schema (one task per line: task: label1, label2, …)",
|
| 234 |
+
value="sentiment: positive, negative, neutral",
|
| 235 |
+
lines=3,
|
| 236 |
+
)
|
| 237 |
+
cls_btn = gr.Button("Classify Text", variant="primary")
|
| 238 |
+
with gr.Column():
|
| 239 |
+
cls_output = gr.Code(label="Result (JSON)", language="json", lines=8)
|
| 240 |
|
| 241 |
gr.Examples(
|
| 242 |
examples=[
|
|
|
|
| 253 |
|
| 254 |
with gr.Tab("🔗 Relation Extraction"):
|
| 255 |
gr.Markdown("Detect relationships between entities in text.")
|
| 256 |
+
with gr.Row():
|
| 257 |
+
with gr.Column():
|
| 258 |
+
rel_text = gr.Textbox(
|
| 259 |
+
label="Input Text",
|
| 260 |
+
placeholder="Enter text to analyze…",
|
| 261 |
+
lines=4,
|
| 262 |
+
value="Alice works for Acme Corp in Paris. Bob joined Acme last year and lives in London.",
|
| 263 |
+
)
|
| 264 |
+
rel_labels = gr.Textbox(
|
| 265 |
+
label="Relation Labels (comma-separated)",
|
| 266 |
+
value="works_for, located_in",
|
| 267 |
+
placeholder="works_for, located_in, founded_by…",
|
| 268 |
+
)
|
| 269 |
+
with gr.Accordion("Options", open=False):
|
| 270 |
+
rel_conf = gr.Checkbox(label="Include confidence scores", value=True)
|
| 271 |
+
rel_spans = gr.Checkbox(label="Include character spans", value=True)
|
| 272 |
+
rel_btn = gr.Button("Extract Relations", variant="primary")
|
| 273 |
+
with gr.Column():
|
| 274 |
+
rel_output = gr.Code(label="Result (JSON)", language="json", lines=15)
|
| 275 |
|
| 276 |
gr.Examples(
|
| 277 |
examples=[
|
|
|
|
| 288 |
|
| 289 |
with gr.Tab("📦 Structured Data Extraction"):
|
| 290 |
gr.Markdown("Parse text into structured JSON records with typed fields.")
|
| 291 |
+
with gr.Row():
|
| 292 |
+
with gr.Column():
|
| 293 |
+
json_text = gr.Textbox(
|
| 294 |
+
label="Input Text",
|
| 295 |
+
placeholder="Enter text to extract structured data from…",
|
| 296 |
+
lines=4,
|
| 297 |
+
value="iPhone 15 Pro Max with 256GB storage, A17 Pro chip, priced at $1199. Available in titanium and black colors.",
|
| 298 |
+
)
|
| 299 |
+
json_schema = gr.Textbox(
|
| 300 |
+
label="Schema (one field per line: field::type::description)",
|
| 301 |
+
value="name::str::Full product name and model\nstorage::str::Storage capacity\nprocessor::str::Chip or processor\nprice::str::Product price with currency\ncolors::list::Available color options",
|
| 302 |
+
lines=5,
|
| 303 |
+
)
|
| 304 |
+
json_btn = gr.Button("Extract Structured Data", variant="primary")
|
| 305 |
+
with gr.Column():
|
| 306 |
+
json_output = gr.Code(label="Result (JSON)", language="json", lines=12)
|
| 307 |
|
| 308 |
gr.Examples(
|
| 309 |
examples=[
|