Text Classification
Transformers
Safetensors
English
bert
fill-mask
BERT
transformer
nlp
bert-lite
edge-ai
low-resource
micro-nlp
quantized
iot
wearable-ai
offline-assistant
intent-detection
real-time
smart-home
embedded-systems
command-classification
toy-robotics
voice-ai
eco-ai
english
lightweight
mobile-nlp
ner
on-device-nlp
privacy-first
cpu-inference
speech-intent
offline-nlp
tiny-bert
bert-variant
efficient-nlp
edge-ml
tiny-ml
aiot
embedded-nlp
low-latency
smart-devices
edge-inference
ml-on-microcontrollers
android-nlp
offline-chatbot
esp32-nlp
tflite-compatible
text-embeddings-inference
Update README.md
Browse files
README.md
CHANGED
|
@@ -88,12 +88,8 @@ MIT License β free to use, modify, and share.
|
|
| 88 |
from transformers import pipeline
|
| 89 |
|
| 90 |
# π’ Start demo
|
| 91 |
-
print("\nπ€ Masked Language Model (MLM) Demo")
|
| 92 |
-
|
| 93 |
-
# π§ Load masked language model : eg boltuix/bert-lite
|
| 94 |
mlm_pipeline = pipeline("fill-mask", model="boltuix/bert-lite")
|
| 95 |
|
| 96 |
-
# βοΈ Masked sentences
|
| 97 |
masked_sentences = [
|
| 98 |
"The robot can [MASK] the room in minutes.",
|
| 99 |
"He decided to [MASK] the project early.",
|
|
@@ -103,9 +99,8 @@ masked_sentences = [
|
|
| 103 |
"Please [MASK] the door before leaving.",
|
| 104 |
]
|
| 105 |
|
| 106 |
-
# π€ Predict missing words
|
| 107 |
for sentence in masked_sentences:
|
| 108 |
-
print(f"
|
| 109 |
predictions = mlm_pipeline(sentence)
|
| 110 |
for pred in predictions[:3]:
|
| 111 |
print(f"β¨ β {pred['sequence']} (score: {pred['score']:.4f})")
|
|
@@ -115,35 +110,51 @@ for sentence in masked_sentences:
|
|
| 115 |
---
|
| 116 |
|
| 117 |
|
| 118 |
-
## π€ Masked Language Model (MLM)
|
| 119 |
-
|
| 120 |
-
Input: The robot can [MASK] the room in minutes.
|
| 121 |
-
β¨ β
|
| 122 |
-
β¨ β
|
| 123 |
-
β¨ β
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
β¨ β
|
| 127 |
-
β¨ β
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
β¨ β
|
| 132 |
-
|
| 133 |
-
β¨ β
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
β¨ β
|
| 138 |
-
β¨ β
|
| 139 |
-
|
| 140 |
-
Input:
|
| 141 |
-
β¨ β
|
| 142 |
-
β¨ β
|
| 143 |
-
β¨ β
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
from transformers import pipeline
|
| 89 |
|
| 90 |
# π’ Start demo
|
|
|
|
|
|
|
|
|
|
| 91 |
mlm_pipeline = pipeline("fill-mask", model="boltuix/bert-lite")
|
| 92 |
|
|
|
|
| 93 |
masked_sentences = [
|
| 94 |
"The robot can [MASK] the room in minutes.",
|
| 95 |
"He decided to [MASK] the project early.",
|
|
|
|
| 99 |
"Please [MASK] the door before leaving.",
|
| 100 |
]
|
| 101 |
|
|
|
|
| 102 |
for sentence in masked_sentences:
|
| 103 |
+
print(f"Input: {sentence}")
|
| 104 |
predictions = mlm_pipeline(sentence)
|
| 105 |
for pred in predictions[:3]:
|
| 106 |
print(f"β¨ β {pred['sequence']} (score: {pred['score']:.4f})")
|
|
|
|
| 110 |
---
|
| 111 |
|
| 112 |
|
| 113 |
+
## π€ Masked Language Model (MLM)'s Output
|
| 114 |
+
|
| 115 |
+
Input: The robot can [MASK] the room in minutes.
|
| 116 |
+
β¨ β the robot can leave the room in minutes. (score: 0.1608)
|
| 117 |
+
β¨ β the robot can enter the room in minutes. (score: 0.1067)
|
| 118 |
+
β¨ β the robot can open the room in minutes. (score: 0.0498)
|
| 119 |
+
Input: He decided to [MASK] the project early.
|
| 120 |
+
β¨ β he decided to start the project early. (score: 0.1503)
|
| 121 |
+
β¨ β he decided to continue the project early. (score: 0.0812)
|
| 122 |
+
β¨ β he decided to leave the project early. (score: 0.0412)
|
| 123 |
+
Input: This device is [MASK] for small tasks.
|
| 124 |
+
β¨ β this device is used for small tasks. (score: 0.4118)
|
| 125 |
+
β¨ β this device is useful for small tasks. (score: 0.0615)
|
| 126 |
+
β¨ β this device is required for small tasks. (score: 0.0427)
|
| 127 |
+
Input: The weather will [MASK] by tomorrow.
|
| 128 |
+
β¨ β the weather will be by tomorrow. (score: 0.0980)
|
| 129 |
+
β¨ β the weather will begin by tomorrow. (score: 0.0868)
|
| 130 |
+
β¨ β the weather will come by tomorrow. (score: 0.0657)
|
| 131 |
+
Input: She loves to [MASK] in the garden.
|
| 132 |
+
β¨ β she loves to live in the garden. (score: 0.3112)
|
| 133 |
+
β¨ β she loves to stay in the garden. (score: 0.0823)
|
| 134 |
+
β¨ β she loves to be in the garden. (score: 0.0796)
|
| 135 |
+
Input: Please [MASK] the door before leaving.
|
| 136 |
+
β¨ β please open the door before leaving. (score: 0.3421)
|
| 137 |
+
β¨ β please shut the door before leaving. (score: 0.3208)
|
| 138 |
+
β¨ β please closed the door before leaving. (score: 0.0599)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## π‘ Who's It For?
|
| 143 |
+
π¨βπ» Developers: Lightweight NLP apps for mobile or IoT
|
| 144 |
+
π€ Innovators: Power wearables, smart homes, or robots
|
| 145 |
+
π§ͺ Enthusiasts: Experiment on a budget
|
| 146 |
+
πΏ Eco-Warriors: Reduce AIβs carbon footprint
|
| 147 |
+
|
| 148 |
+
## π Metrics That Matter
|
| 149 |
+
β
Accuracy: Competitive with larger models
|
| 150 |
+
π― F1 Score: Balanced precision and recall
|
| 151 |
+
β‘ Inference Time: Optimized for real-time use
|
| 152 |
+
|
| 153 |
+
## π§ͺ Trained On
|
| 154 |
+
π Wikipedia
|
| 155 |
+
π BookCorpus
|
| 156 |
+
π§Ύ MNLI (Multi-Genre NLI)
|
| 157 |
+
π sentence-transformers/all-nli
|
| 158 |
+
|
| 159 |
+
## π Tags
|
| 160 |
+
#tiny-bert #iot #wearable-ai #intent-detection #smart-home #offline-assistant #nlp #transformers
|