--- title: Masked Word Predictor emoji: πŸŒ– colorFrom: green colorTo: indigo sdk: gradio sdk_version: 5.31.0 app_file: app.py pinned: false license: apache-2.0 short_description: Masked Word Predicto CPU --- # πŸ” Masked Word Predictor [![Hugging Face Space](https://img.shields.io/badge/HuggingFace-Spaces-blue?logo=huggingface)](https://huggingface.co/spaces/your-username/masked-word-predictor) [![Gradio UI](https://img.shields.io/badge/Gradio-5.31.0-green?logo=gradio)] [![Model](https://img.shields.io/badge/Model-distilroberta--base-orange)](https://huggingface.co/distilroberta-base) [![License](https://img.shields.io/badge/License-MIT-lightgrey)](LICENSE) --- ## πŸš€ Overview Tap into **Masked Language Modeling** with **DistilRoBERTa**β€”no training required. Type a sentence containing the special `[MASK]` token and get the model’s **top-K** completions instantly, all on **free CPU**. > **Key AI concepts:** > β€’ Masked Language Modeling (MLM) β€’ Transformer-based NLP β€’ Distilled Architectures β€’ Real-time Inference β€’ Edge Deployment β€’ Cloud-native Demo --- ## ✨ Features | πŸ”‘ Feature | πŸ” Why It’s Cool | |----------------------------|----------------------------------------------| | **🧠 Transformer MLM** | Uses DistilRoBERTa for lightning-fast fills | | **⚑ CPU-Only Inference** | Runs on free-tier Space (2 vCPU / 16 GB RAM) | | **πŸ”’ Top-K Control** | Slider to choose how many predictions to show | | **🎨 Interactive UI** | Gradio Blocks: input, button, and DataFrame | | **πŸ”§ Zero-Config Deploy** | Commit three filesβ€”Spaces auto-builds | | **πŸ’‘ Educational Demos** | Great for teaching how MLM works | --- ## πŸ—οΈ How It Works 1. **User Input** – Sentence with one or more `[MASK]` tokens. 2. **MLM Pipeline** – `pipeline("fill-mask")` computes token-level likelihoods. 3. **Ranking** – Returns the top-K predicted tokens with scores. 4. **UI Rendering** – Gradio shows each filled sentence and its confidence. --- ## πŸ› οΈ Local Development ```bash git clone https://github.com/your-username/masked-word-predictor.git cd masked-word-predictor python3 -m venv venv && source venv/bin/activate pip install -r requirements.txt python app.py