Practical overview
When it fits
Use it when you can prepare labeled sentence pairs and want a documented training-to-prediction workflow for a Keras Siamese LSTM.
Who it is for
- Developers building sentence-pair similarity experiments in Python and Keras.
- Teams with labeled sentence pairs who want to train a similarity scorer for a specific text domain.
Documented uses
- Train a model from sentence pairs labeled by similarity.
- Save the trained model and load it for prediction.
- Rank new sentence pairs by their predicted similarity scores.
Requirements & limits
The repository is public and specifies an MIT license.
- Training requires paired sentence examples and similarity labels in the format shown by the README.
- The example creates word-embedding metadata from the supplied sentences and uses configuration values for sequence length and model parameters.
- The prediction example uses a locally saved Keras model and returns scores; application integration is not shown.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Train the model on labeled sentence pairs
Prepare paired sentences and similarity labels, then train and save a model.
Before you start
- Python environment with dependencies installed using
pip install -r requirements.txt. - CSV data containing
sentences1,sentences2andis_similarcolumns.
Steps
Read the CSV and collect the two sentence columns and similarity labels.
Create tokenizer and embedding metadata from the combined sentence lists.
Build sentence pairs and configure the model using values from
siamese_config.Call
train_modelwith the pairs, labels and embedding metadata, specifying./as the model save directory.
Expected outcome
The training call returns a path for the saved model.
Guide limitations
- The example does not establish performance for any particular dataset or domain.
Score new sentence pairs with a saved model
Load a trained model and produce prediction scores for input sentence pairs.
Before you start
- A saved model path from training.
- The tokenizer and
siamese_configvalues used to prepare test data.
Steps
Load the saved model with Keras
load_model.Prepare the input pairs with
create_test_dataand the configured maximum sequence length.Pass the prepared inputs to
model.predictand pair each resulting score with its input sentences.
Expected outcome
A list of sentence pairs with prediction scores; the example sorts it by score.
Guide limitations
- Integration into a separate application is not demonstrated.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 21 November 2026
- Original website title
- amansrivastava17/lstm-siamese-text-similarity · Official homepage title · retained in its source language

