leavoigt's picture
Update app.py
9fd798a verified
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 = 'Climate 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']
#model_options = ['Llama3.2-3B','Llama3.2-1B','Gemma2-2B']
model_options = ['Llama-3.1-8B']
# 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;'> Climate Vulnerability Analysis </h2>", unsafe_allow_html=True)
st.write(' ')
st.write("""The **Climate Vulnerability App** is an **AI-based tool** to get a quick, high-level overview of the extent to which different marginalised groups are
represented in climate policies. Upload a document, and the app uses AI to **identify references to groups vulnerable to climate change**
and to **summarize key mentions**. Please note that the app is designed to support rapid screening and provide a quick overview over potentially
relevant information. The displayed information may not always be complete and should not replace an in-depth human analysis.""")
with st.expander("ℹ️ - About this app", expanded=False):
st.subheader("About this app")
st.write(
"""
The Climate Vulnerability 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. The identified references are then provided \
as a summary, using a LLM chosen by the user.
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 and the **Target Classifier** which
checks whether the reference is general or includes a target to be reached / concrete action formulated.
- Step 3: The identified references are then summarized using a LLM chosen by the user. \
""")
st.subheader("Disclaimer")
st.write("""This app is intended for specific use of retrieving information on groups in vulnerable situations of documents (e.g. climate documents)
and retrieving an overview of the most relevant points. For any use beyond this scope we have no liability to a response provided by this app.
We have implemented measures to ensure the technical robustness and security of our AI system,
minimizing unexpected behaviour, however we do not guarantee the full reliability, or completeness of any information and disclaim any liability
or responsibility for actions taken based on its responses.
The app may occasionally provide inaccurate or inappropriate responses, and it is important to exercise judgment and critical thinking when interpreting
its output. The use of AI within this application is transparent. When interacting with the AI, users are informed that they are engaging with an AI system
The app responses should not be considered professional or authoritative advice and are generated based on patterns in the data it has been trained on.
The app's responses do not reflect the opinions or policies of our organization or its affiliates.
By using this app, you agree to these terms and acknowledge that you are solely responsible for any reliance on or actions taken based on its responses.
User can read more about the technical information about the tool in Readme of this tool.
This is just a prototype and being tested and worked upon, so its not perfect and may sometimes give irrelevant answers.
If you are not satisfied with the answer, please ask a more specific question or report your feedback to help us improve the system.""")
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)