This update significantly enhances the "Gramformer Demo" application by modernizing its architecture, improving performance, and refining the user interface. It transitions the application from a class-based structure to a more functional, modular design that is idiomatic for Streamlit, improving readability and maintainability.
The most critical improvement is the update from the legacy @st.cache
to the current @st.cache_resource
for loading the Gramformer model. This ensures the large model is loaded into memory only once and is efficiently reused across sessions, providing a much faster user experience after the initial startup.
The UI has been redesigned into a clean, two-column layout, allowing users to compare the original text and the corrected results side-by-side. Additionally, the code now includes logic to automatically detect and utilize a CUDA-enabled GPU if available, while gracefully falling back to CPU.
sequenceDiagram