Spaces:
Sleeping
Sleeping
File size: 1,603 Bytes
3304957 16b1e1b ab45f59 3304957 5febdcf dbf8ef1 5febdcf dbf8ef1 5febdcf dbf8ef1 5febdcf 64f1afa 5febdcf a19d371 dbf8ef1 5febdcf 3304957 ab45f59 3304957 ab45f59 3304957 5febdcf ab45f59 3304957 16b1e1b 3304957 | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import gradio as gr
def build_demo(retrieve_and_answer):
with gr.Blocks(title="Financial RAG Demo") as demo:
gr.Markdown("# Financial RAG Demo")
gr.Markdown(
"Architecture: GLiNER (CPU Router) → GTE-7B (Retrieval) → Qwen2-VL (Vision Analysis)"
)
gr.Markdown(
"""
### About this demo
- Entity-aware routing (Apple / Microsoft)
- Prevents *accidental* cross-company document mixing
- Tables processed as images (no OCR flattening)
- Explicit refusals for out-of-scope or ambiguous queries
### Try these prompts
- `What was Apple's total revenue in 2023?`
- `What is Microsoft's operating income?`
- `Compare Apple and Microsoft revenues` -> explicit multi-entity reasoning
- `What was Google's revenue in 2023?` -> rejected
i Full details are in the GitHub repo.
"""
)
with gr.Row():
query_input = gr.Textbox(
label="User Question",
placeholder=(
"Example: Compare Apple and Microsoft revenue, "
"or ask about a specific company metric."
),
)
submit_btn = gr.Button("Run Analysis", variant="primary")
with gr.Row():
output_gallery = gr.Gallery(label="Source Documents", columns=3, height=300)
output_meta = gr.Markdown(label="System Trace")
output_text = gr.Markdown(label="Answer")
submit_btn.click(
retrieve_and_answer,
inputs=query_input,
outputs=[output_gallery, output_meta, output_text],
)
return demo
|