Spaces:
Sleeping
Sleeping
unknown commited on
Commit ·
d754586
1
Parent(s): 4f31af8
Fix HF hero CSS and expose Modal endpoint
Browse files- app.py +68 -9
- modal_refine.py +33 -61
app.py
CHANGED
|
@@ -967,9 +967,9 @@ footer {
|
|
| 967 |
overflow: hidden !important;
|
| 968 |
}
|
| 969 |
|
| 970 |
-
/* General text */
|
| 971 |
-
.gradio-container .markdown,
|
| 972 |
-
.gradio-container p,
|
| 973 |
.gradio-container li,
|
| 974 |
.gradio-container td,
|
| 975 |
.gradio-container th,
|
|
@@ -1219,12 +1219,12 @@ footer {
|
|
| 1219 |
|
| 1220 |
/* EMERGENCY READABILITY FIX */
|
| 1221 |
|
| 1222 |
-
.gradio-container h1,
|
| 1223 |
-
.gradio-container h2,
|
| 1224 |
-
.gradio-container h3,
|
| 1225 |
-
.gradio-container h4,
|
| 1226 |
-
.gradio-container h5,
|
| 1227 |
-
.gradio-container h6 {
|
| 1228 |
color: #111827 !important;
|
| 1229 |
opacity: 1 !important;
|
| 1230 |
visibility: visible !important;
|
|
@@ -1536,6 +1536,65 @@ footer {
|
|
| 1536 |
color: #111827 !important;
|
| 1537 |
-webkit-text-fill-color: #111827 !important;
|
| 1538 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1539 |
"""
|
| 1540 |
|
| 1541 |
theme = gr.themes.Soft(
|
|
|
|
| 967 |
overflow: hidden !important;
|
| 968 |
}
|
| 969 |
|
| 970 |
+
/* General text - exclude hero */
|
| 971 |
+
.gradio-container .markdown:not(.hero):not(.hero *),
|
| 972 |
+
.gradio-container p:not(.hero p),
|
| 973 |
.gradio-container li,
|
| 974 |
.gradio-container td,
|
| 975 |
.gradio-container th,
|
|
|
|
| 1219 |
|
| 1220 |
/* EMERGENCY READABILITY FIX */
|
| 1221 |
|
| 1222 |
+
.gradio-container h1:not(.hero h1),
|
| 1223 |
+
.gradio-container h2:not(.hero h2),
|
| 1224 |
+
.gradio-container h3:not(.hero h3),
|
| 1225 |
+
.gradio-container h4:not(.hero h4),
|
| 1226 |
+
.gradio-container h5:not(.hero h5),
|
| 1227 |
+
.gradio-container h6:not(.hero h6) {
|
| 1228 |
color: #111827 !important;
|
| 1229 |
opacity: 1 !important;
|
| 1230 |
visibility: visible !important;
|
|
|
|
| 1536 |
color: #111827 !important;
|
| 1537 |
-webkit-text-fill-color: #111827 !important;
|
| 1538 |
}
|
| 1539 |
+
|
| 1540 |
+
/* HF SPACE HERO FINAL OVERRIDE */
|
| 1541 |
+
.gradio-container .hero,
|
| 1542 |
+
.gradio-container .hero * {
|
| 1543 |
+
opacity: 1 !important;
|
| 1544 |
+
filter: none !important;
|
| 1545 |
+
mix-blend-mode: normal !important;
|
| 1546 |
+
}
|
| 1547 |
+
|
| 1548 |
+
.gradio-container .hero h1,
|
| 1549 |
+
.gradio-container .hero h1 *,
|
| 1550 |
+
.gradio-container .hero p,
|
| 1551 |
+
.gradio-container .hero .logo-text {
|
| 1552 |
+
color: #ffffff !important;
|
| 1553 |
+
-webkit-text-fill-color: #ffffff !important;
|
| 1554 |
+
}
|
| 1555 |
+
|
| 1556 |
+
.gradio-container .hero .kicker {
|
| 1557 |
+
color: #67e8f9 !important;
|
| 1558 |
+
-webkit-text-fill-color: #67e8f9 !important;
|
| 1559 |
+
}
|
| 1560 |
+
|
| 1561 |
+
.gradio-container .hero h1 span {
|
| 1562 |
+
color: #c4b5fd !important;
|
| 1563 |
+
-webkit-text-fill-color: #c4b5fd !important;
|
| 1564 |
+
}
|
| 1565 |
+
|
| 1566 |
+
.gradio-container .hero p {
|
| 1567 |
+
color: rgba(255, 255, 255, 0.92) !important;
|
| 1568 |
+
-webkit-text-fill-color: rgba(255, 255, 255, 0.92) !important;
|
| 1569 |
+
}
|
| 1570 |
+
|
| 1571 |
+
/* ABSOLUTE FINAL HERO FIX FOR HF */
|
| 1572 |
+
.gradio-container .hero {
|
| 1573 |
+
color: #ffffff !important;
|
| 1574 |
+
}
|
| 1575 |
+
|
| 1576 |
+
.gradio-container .hero h1,
|
| 1577 |
+
.gradio-container .hero h1 *,
|
| 1578 |
+
.gradio-container .hero p,
|
| 1579 |
+
.gradio-container .hero p *,
|
| 1580 |
+
.gradio-container .hero .logo-text,
|
| 1581 |
+
.gradio-container .hero .hero-badge,
|
| 1582 |
+
.gradio-container .hero .hero-badge * {
|
| 1583 |
+
color: #ffffff !important;
|
| 1584 |
+
-webkit-text-fill-color: #ffffff !important;
|
| 1585 |
+
opacity: 1 !important;
|
| 1586 |
+
filter: none !important;
|
| 1587 |
+
}
|
| 1588 |
+
|
| 1589 |
+
.gradio-container .hero .kicker {
|
| 1590 |
+
color: #67e8f9 !important;
|
| 1591 |
+
-webkit-text-fill-color: #67e8f9 !important;
|
| 1592 |
+
}
|
| 1593 |
+
|
| 1594 |
+
.gradio-container .hero h1 span {
|
| 1595 |
+
color: #c4b5fd !important;
|
| 1596 |
+
-webkit-text-fill-color: #c4b5fd !important;
|
| 1597 |
+
}
|
| 1598 |
"""
|
| 1599 |
|
| 1600 |
theme = gr.themes.Soft(
|
modal_refine.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import modal
|
|
|
|
| 4 |
|
| 5 |
app = modal.App("paper2lab-nemotron")
|
| 6 |
|
| 7 |
image = (
|
| 8 |
modal.Image.debian_slim(python_version="3.11")
|
| 9 |
-
.pip_install("requests")
|
| 10 |
.add_local_dir("src/paper2lab", remote_path="/root/paper2lab")
|
| 11 |
)
|
| 12 |
|
|
@@ -16,70 +17,41 @@ secret = modal.Secret.from_name("nvidia-api-key")
|
|
| 16 |
@app.function(
|
| 17 |
image=image,
|
| 18 |
secrets=[secret],
|
| 19 |
-
timeout=
|
| 20 |
)
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
model: str = "nvidia/nemotron-3-nano-30b-a3b",
|
| 24 |
-
return_comparison: bool = True,
|
| 25 |
-
) -> dict:
|
| 26 |
from paper2lab.inference.nemotron_refiner import refine_with_nemotron
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
@app.local_entrypoint()
|
| 36 |
def main():
|
| 37 |
-
|
| 38 |
-
"candidate_paper_card": {
|
| 39 |
-
"title": "Attention Is All You Need",
|
| 40 |
-
"field": "Natural Language Processing",
|
| 41 |
-
"paper_type": "machine_learning",
|
| 42 |
-
"research_question": "The paper proposes the Transformer architecture.",
|
| 43 |
-
"contributions": [
|
| 44 |
-
"The paper proposes a Transformer architecture based on attention."
|
| 45 |
-
],
|
| 46 |
-
"methodology": [
|
| 47 |
-
"The model uses multi-head self-attention and feed-forward layers."
|
| 48 |
-
],
|
| 49 |
-
"datasets_or_data_sources": [
|
| 50 |
-
"WMT 2014 English-German dataset",
|
| 51 |
-
"RNN",
|
| 52 |
-
"BerkleyParser"
|
| 53 |
-
],
|
| 54 |
-
"models_or_methods": [
|
| 55 |
-
"Transformer",
|
| 56 |
-
"multi-head attention"
|
| 57 |
-
],
|
| 58 |
-
"metrics_or_measurements": [
|
| 59 |
-
"BLEU"
|
| 60 |
-
],
|
| 61 |
-
"key_findings": [],
|
| 62 |
-
"limitations": [],
|
| 63 |
-
"missing_reproducibility_info": [
|
| 64 |
-
"random seed is not specified"
|
| 65 |
-
],
|
| 66 |
-
"metadata": {},
|
| 67 |
-
"source_pdf": "attention is all you need.pdf",
|
| 68 |
-
"annotation_version": "v1.0",
|
| 69 |
-
},
|
| 70 |
-
"section_previews": [
|
| 71 |
-
{
|
| 72 |
-
"title": "Training Data and Batching",
|
| 73 |
-
"role_hint": "methodology",
|
| 74 |
-
"page_start": 7,
|
| 75 |
-
"page_end": 7,
|
| 76 |
-
"preview": "We trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million sentence pairs. For English-French, we used the significantly larger WMT 2014 English-French dataset consisting of 36M sentences."
|
| 77 |
-
}
|
| 78 |
-
],
|
| 79 |
-
"captions": [],
|
| 80 |
-
"tables": [],
|
| 81 |
-
"metadata": {}
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
result = refine_remote.remote(sample_pack)
|
| 85 |
-
print(result)
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import modal
|
| 4 |
+
from fastapi import Request
|
| 5 |
|
| 6 |
app = modal.App("paper2lab-nemotron")
|
| 7 |
|
| 8 |
image = (
|
| 9 |
modal.Image.debian_slim(python_version="3.11")
|
| 10 |
+
.pip_install("requests", "fastapi")
|
| 11 |
.add_local_dir("src/paper2lab", remote_path="/root/paper2lab")
|
| 12 |
)
|
| 13 |
|
|
|
|
| 17 |
@app.function(
|
| 18 |
image=image,
|
| 19 |
secrets=[secret],
|
| 20 |
+
timeout=300,
|
| 21 |
)
|
| 22 |
+
@modal.fastapi_endpoint(method="POST")
|
| 23 |
+
async def refine_remote(request: Request):
|
|
|
|
|
|
|
|
|
|
| 24 |
from paper2lab.inference.nemotron_refiner import refine_with_nemotron
|
| 25 |
|
| 26 |
+
body = await request.json()
|
| 27 |
+
|
| 28 |
+
llm_evidence_pack = body.get("llm_evidence_pack")
|
| 29 |
+
model = body.get("model", "nvidia/nemotron-3-nano-30b-a3b")
|
| 30 |
+
return_comparison = body.get("return_comparison", True)
|
| 31 |
+
|
| 32 |
+
if not llm_evidence_pack:
|
| 33 |
+
return {
|
| 34 |
+
"status": "error",
|
| 35 |
+
"error": "Missing llm_evidence_pack",
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
try:
|
| 39 |
+
result = refine_with_nemotron(
|
| 40 |
+
llm_evidence_pack=llm_evidence_pack,
|
| 41 |
+
model=model,
|
| 42 |
+
return_comparison=return_comparison,
|
| 43 |
+
)
|
| 44 |
+
return {
|
| 45 |
+
"status": "ok",
|
| 46 |
+
"result": result,
|
| 47 |
+
}
|
| 48 |
+
except Exception as exc:
|
| 49 |
+
return {
|
| 50 |
+
"status": "error",
|
| 51 |
+
"error": str(exc),
|
| 52 |
+
}
|
| 53 |
|
| 54 |
|
| 55 |
@app.local_entrypoint()
|
| 56 |
def main():
|
| 57 |
+
print("Deploy this app with: modal deploy modal_refine.py")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|