How sricharanadontula/next_word_ai works
This is a Flask-based next-word prediction application backed by a trained LSTM. The main workflow accepts a seed phrase and generation settings, converts the phrase to token IDs, repeatedly predicts and samples a word, then returns the generated text to the web page. The README also describes Shakespeare-baseline and combined-corpus training, evaluation, and generation experiments; the corresponding notebooks are present, but their internals were not sampled. The README’s dataset paths do not match the supplied tree, so the graph uses only paths that exist there.
Main entry points: app.py Text generation loop · 02_combined_corpus_model.ipynb Combined corpus model · index.html Input and results page · 01_shakespeare_baseline.ipynb Shakespeare baseline
Components 16
Web interface
- Input and results page
templates/index.html - Flask home route
app.py
Prediction runtime
- Text generation loop
app.py - Tokenizer
models/tokenizer_small.pkl - Sequence padding
app.py - Top-k sampler
app.py - Word index mapping
app.py
Model artifacts
- Small LSTM model
models/next_word_model_small.keras - Baseline model artifact
models/next_word_model.keras - Fixed model artifact
models/next_word_model_fixed.keras - Small tokenizer artifact
models/tokenizer_small.pkl - Tokenizer artifact
models/tokenizer.pkl
Training experiments
- Shakespeare baseline
notebooks/01_shakespeare_baseline.ipynb - Combined corpus model
notebooks/02_combined_corpus_model.ipynb - Notebook text dataset
notebooks/dataset/text.txt
Other components
- User
Connections 16
- User → Input and results page: enters prompt
- Input and results page → Flask home route: submits form
app.py - Flask home route → Text generation loop: calls generation
app.py - Flask home route → Input and results page: renders results
app.py - Text generation loop → Tokenizer: encodes prompt
app.py - Text generation loop → Sequence padding: pads context
app.py - Text generation loop → Small LSTM model: predicts probabilities
app.py - Text generation loop → Top-k sampler: samples index
app.py - Top-k sampler → Word index mapping: resolves word
app.py - Shakespeare baseline → Baseline model artifact: trains baseline
README.md - Combined corpus model → Combined corpus model: trains combined model
README.md - Notebook text dataset → Combined corpus model: supplies text
- Combined corpus model → Fixed model artifact: saves model
README.md - Combined corpus model → Tokenizer artifact: saves tokenizer
README.md - Shakespeare baseline → Combined corpus model: compares performance
README.md - Small tokenizer artifact → Text generation loop: loaded by runtime
app.py