|
import streamlit as st |
|
from datasets import load_dataset |
|
from transformer_ranker import TransformerRanker, prepare_popular_models |
|
|
|
st.title("Choose Your Transformer") |
|
|
|
model_options = { |
|
'bert-tiny': 'prajjwal1/bert-tiny', |
|
'bert-small': 'prajjwal1/bert-small', |
|
'electra-small': 'google/electra-small-discriminator', |
|
'deberta-small': 'microsoft/deberta-v3-small', |
|
'distilbert-cased': 'distilbert-base-cased', |
|
'distilbert-uncased': 'distilbert-base-uncased', |
|
} |
|
|
|
|
|
dataset_options = ['trec', 'conll2003'] |
|
selected_dataset = st.selectbox("Select Dataset", dataset_options) |
|
|
|
|
|
downsample_values = [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] |
|
downsample_ratio = st.select_slider("Dataset Downsample Ratio", options=downsample_values, value=0.2) |
|
|
|
|
|
model_names = list(model_options.keys()) |
|
selected_models = st.multiselect("Select Models", model_names, default=['bert-tiny', 'electra-small']) |
|
selected_models = [model_options[model_name] for model_name in selected_models] |
|
|
|
|
|
layer_options = ['lastlayer', 'layermean', 'bestlayer'] |
|
selected_layer = st.selectbox("Layer Selection", layer_options, index=1) |
|
|
|
|
|
log_expander = st.expander("Expand to view log") |
|
log_placeholder = log_expander.empty() |
|
|
|
|
|
if st.button("Run Model Ranking"): |
|
with st.spinner("Running the transformer-ranker..."): |
|
|
|
|
|
dataset = load_dataset(selected_dataset, trust_remote_code=True) |
|
|
|
|
|
language_models = prepare_popular_models('base') if selected_models == [] else selected_models |
|
|
|
|
|
ranker = TransformerRanker(dataset, dataset_downsample=downsample_ratio) |
|
|
|
|
|
log_placeholder.text("Real-time logging will be added here...") |
|
|
|
|
|
results = ranker.run(language_models, batch_size=64) |
|
|
|
|
|
st.write(results) |
|
|
|
st.success("Ranking is Done!") |
|
|