Downloads · 30 days
0
Vaira-Selvi24/pred_nxt_wrds
pred_nxt_wrds is a machine learning model from Vaira-Selvi24. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This model predicts the next most probable word based on a given input sentence using an LSTM neural network built with TensorFlow/Keras.
Downloads · 30 days
0
Access
Public
Updated Jul 18, 2025
Repo size
949 KB
Likes
0
Public
Click a slice to open those files.
.h5869 KB · 91%
From the Hugging Face model README
This model predicts the next most probable word based on a given input sentence using an LSTM neural network built with TensorFlow/Keras.
Tokenizer (word-level)model_wrd.keras — Trained LSTM modeltokenizer.pkl — Tokenizer used during trainingmax_len.pkl — Max sequence length used for paddingimport pickle
import numpy as np
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.sequence import pad_sequences
# Load resources
with open('tokenizer.pkl', 'rb') as f:
tokenizer = pickle.load(f)
with open('max_len.pkl', 'rb') as f:
max_len = pickle.load(f)
model = load_model('model_wrd.keras')
# Predict function
def predict_next_word(seed_text):
sequence = tokenizer.texts_to_sequences([seed_text])[0]
sequence = pad_sequences([sequence], maxlen=max_len, padding='pre')
pred_index = np.argmax(model.predict(sequence), axis=-1)[0]
for word, index in tokenizer.word_index.items():
if index == pred_index:
return word
return "<unknown>"
---
### ✅ Also, update the following fields in the Metadata UI:
| Field | Value |
|----------------|--------------------|
| `language` | English |
| `pipeline_tag` | text-generation |
| `library_name` | tensorflow |
| `tags` | lstm, keras, next-word-prediction, nlp, text-generation |
Let me know when you're done or if you'd like me to walk you through the fields too!