🧠 pred_nxt_wrds β€” LSTM Next Word Prediction

This model predicts the next most probable word based on a given input sentence using an LSTM neural network built with TensorFlow/Keras.


🏷️ Model Details

  • Architecture: LSTM (Long Short-Term Memory)
  • Framework: TensorFlow 2 / Keras
  • Input: A sequence of English words
  • Output: The most likely next word
  • Tokenizer: Keras Tokenizer (word-level)
  • Training Data: English text corpus

πŸ“ Files Included

  • model_wrd.keras β€” Trained LSTM model
  • tokenizer.pkl β€” Tokenizer used during training
  • max_len.pkl β€” Max sequence length used for padding

πŸš€ How to Use

import 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!
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support