File size: 3,013 Bytes
c52262e
78bb25c
 
 
05828e0
 
 
78bb25c
d597fc1
 
 
c52262e
 
 
 
 
 
 
78bb25c
c52262e
 
 
 
 
 
78bb25c
c52262e
78bb25c
c52262e
 
 
05828e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b6cbcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
from utils.uploadAndExample import add_upload
from utils.config import model_dict
from utils.vulnerability_classifier import label_dict
import appStore.doc_processing as processing
import appStore.vulnerability_analysis as vulnerability_analysis
import appStore.target as target_analysis

st.set_page_config(page_title = 'Vulnerability Analysis', 
                   initial_sidebar_state='expanded', layout="wide") 

with st.sidebar:
    # upload and example doc
    choice = st.sidebar.radio(label = 'Select the Document',
                            help = 'You can upload the document \
                            or else you can try a example document', 
                            options = ('Upload Document', 'Try Example'), 
                            horizontal = True)
    add_upload(choice)

    # Create a list of options for the dropdown
    model_options = ['Llama3.1-8B','Llama3.1-70B','Llama3.1-405B','Zephyr 7B β','Mistral-7B','Mixtral-8x7B']

    # Dropdown selectbox: model
    model_sel = st.selectbox('Select a model:', model_options)
    model_sel_name = model_dict[model_sel]

    st.session_state['model_sel_name'] = model_sel_name

with st.container():
    st.markdown("<h2 style='text-align: center;'> Vulnerability Analysis 3.1 </h2>", unsafe_allow_html=True)
    st.write(' ')

with st.expander("ℹ️ - About this app", expanded=False):
    st.write(
        """
        The Vulnerability Analysis App is an open-source\
        digital tool which aims to assist policy analysts and \
        other users in extracting and filtering references \
        to different groups in vulnerable situations from public documents. \
        We use Natural Language Processing (NLP), specifically deep \
        learning-based text representations  to search context-sensitively \
        for mentions of the special needs of groups in vulnerable situations 
        to cluster them thematically. 
        For more understanding on Methodology [Click Here](https://vulnerability-analysis.streamlit.app/)
        """)
    
    st.write("""
        What Happens in background?
        
        - Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
        In this step the document is broken into smaller paragraphs \
        (based on word/sentence count).
        - Step 2: The paragraphs are then fed to the **Vulnerability Classifier** which detects if
        the paragraph contains any or multiple references to vulnerable groups.
        """)
                  
    st.write("")

# Define the apps used
apps = [processing.app, vulnerability_analysis.app, target_analysis.app]

multiplier_val =1/len(apps)
if st.button("Analyze Document"):
    prg = st.progress(0.0)
    for i,func in enumerate(apps):
        func()
        prg.progress((i+1)*multiplier_val)

# If there is data stored
if 'key0' in st.session_state:

    vulnerability_analysis.vulnerability_display()
    target_analysis.target_display(model_sel_name=model_sel_name)