# app.py – encoder-only demo for bert-beatrix-2048 # ----------------------------------------------- # launch: python app.py # (gradio UI appears at http://localhost:7860) import torch import gradio as gr import spaces from bert_handler import create_handler_from_checkpoint # ------------------------------------------------------------------ # 1. Model / tokenizer ------------------------------------------------- # ------------------------------------------------------------------ # # • We load one repo *once*, via its canonical name. # • BERTHandler handles the VRAM-safe cleanup & guarantees that the # tokenizer already contains all special tokens saved in the checkpoint. REPO_ID = "AbstractPhil/bert-beatrix-2048" handler, full_model, tokenizer = create_handler_from_checkpoint(REPO_ID) full_model = full_model.eval().cuda() # Grab the encoder + embedding stack only encoder = full_model.bert.encoder embeddings = full_model.bert.embeddings emb_ln = full_model.bert.emb_ln emb_drop = full_model.bert.emb_drop # ------------------------------------------------------------------ # 2. Symbolic token set ------------------------------------------- # ------------------------------------------------------------------ SYMBOLIC_ROLES = [ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "