boltuix commited on
Commit
d1937d6
Β·
verified Β·
1 Parent(s): 7151f12

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -38
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"\nInput: {sentence}")
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) Demo
119
-
120
- Input: The robot can [MASK] the room in minutes.
121
- ✨ β†’ The robot can clean the room in minutes. (score: 0.3124)
122
- ✨ β†’ The robot can scan the room in minutes. (score: 0.1547)
123
- ✨ β†’ The robot can paint the room in minutes. (score: 0.0983)
124
-
125
- Input: He decided to [MASK] the project early.
126
- ✨ β†’ He decided to finish the project early. (score: 0.3876)
127
- ✨ β†’ He decided to start the project early. (score: 0.2109)
128
- ✨ β†’ He decided to abandon the project early. (score: 0.0765)
129
-
130
- Input: This device is [MASK] for small tasks.
131
- ✨ β†’ This device is perfect for small tasks. (score: 0.2458)
132
- ✨ β†’ This device is great for small tasks. (score: 0.1894)
133
- ✨ β†’ This device is useful for small tasks. (score: 0.1321)
134
-
135
- Input: The weather will [MASK] by tomorrow.
136
- ✨ β†’ The weather will improve by tomorrow. (score: 0.2987)
137
- ✨ β†’ The weather will change by tomorrow. (score: 0.1765)
138
- ✨ β†’ The weather will clear by tomorrow. (score: 0.1034)
139
-
140
- Input: She loves to [MASK] in the garden.
141
- ✨ β†’ She loves to work in the garden. (score: 0.3542)
142
- ✨ β†’ She loves to play in the garden. (score: 0.1986)
143
- ✨ β†’ She loves to relax in the garden. (score: 0.0879)
144
-
145
- Input: Please [MASK] the door before leaving.
146
- ✨ β†’ Please close the door before leaving. (score: 0.4673)
147
- ✨ β†’ Please lock the door before leaving. (score: 0.3215)
148
- ✨ β†’ Please open the door before leaving. (score: 0.0652)
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