""" Multi-page Hallucination Detection System. Pages: Analyzer | Explanation | Evaluation | Detailed Metrics | History """ import streamlit as st import ui_pages.page_analyzer as p1 import ui_pages.page_evaluation as p3 import ui_pages.page_explanation as p2 import ui_pages.page_history as p5 import ui_pages.page_metrics as p4 st.set_page_config( page_title="HalluciScan - Hallucination Detection", page_icon="H", layout="wide", initial_sidebar_state="expanded", ) st.markdown( """ """, unsafe_allow_html=True, ) st.sidebar.markdown( """
H

HalluciScan

Hallucination Detection System


""", unsafe_allow_html=True, ) PAGE_ICONS = { "Analyzer": p1, "Explanation": p2, "Evaluation": p3, "Detailed Metrics": p4, "History": p5, } page = st.sidebar.radio("Navigate", list(PAGE_ICONS.keys()), label_visibility="collapsed") st.sidebar.markdown("
", unsafe_allow_html=True) st.sidebar.subheader("Model Settings") MODEL_LABELS = { "gpt2": "GPT-2 (117M)", "gpt2-medium": "GPT-2 Medium (345M)", "gpt2-large": "GPT-2 Large (774M)", "EleutherAI/gpt-neo-125M": "GPT-Neo 125M", "EleutherAI/gpt-neo-1.3B": "GPT-Neo 1.3B", "EleutherAI/gpt-neo-2.7B": "GPT-Neo 2.7B", "EleutherAI/pythia-2.8b": "Pythia 2.8B", "facebook/opt-6.7b": "OPT 6.7B (High VRAM/RAM)", } model_name = st.sidebar.selectbox( "Model", list(MODEL_LABELS.keys()), format_func=lambda x: MODEL_LABELS[x], ) semantic_threshold = st.sidebar.slider("Semantic Match Threshold", 0.50, 1.00, 0.80, 0.05) num_responses = st.sidebar.slider("Number of Responses", 1, 10, 5) max_length = st.sidebar.slider("Max Generation Length", 10, 100, 50) temperature = st.sidebar.slider("Temperature", 0.1, 2.0, 0.8, 0.1) st.sidebar.subheader("Risk Weights") alpha = st.sidebar.slider("Alpha (Internal)", 0.0, 1.0, 0.6, 0.1) beta = st.sidebar.slider("Beta (External)", 0.0, 1.0, 0.4, 0.1) st.sidebar.subheader("Metric Weights") w1 = st.sidebar.slider("w1 - EigenScore", 0.0, 1.0, 0.4, 0.1) w2 = st.sidebar.slider("w2 - Stability", 0.0, 1.0, 0.3, 0.1) w3 = st.sidebar.slider("w3 - Grounding", 0.0, 1.0, 0.3, 0.1) cfg = dict( model_name=model_name, semantic_threshold=semantic_threshold, num_responses=num_responses, max_length=max_length, temperature=temperature, alpha=alpha, beta=beta, w1=w1, w2=w2, w3=w3, ) PAGE_ICONS[page].render(cfg) if page in {"Analyzer", "Evaluation"} else PAGE_ICONS[page].render() st.markdown( "", unsafe_allow_html=True, )