{"id":17978291,"url":"https://github.com/likejazz/siamese-lstm","last_synced_at":"2025-07-21T05:04:21.680Z","repository":{"id":82011839,"uuid":"125470427","full_name":"likejazz/Siamese-LSTM","owner":"likejazz","description":"Siamese LSTM for evaluating semantic similarity between sentences of the Quora Question Pairs Dataset.","archived":false,"fork":false,"pushed_at":"2018-03-22T02:23:30.000Z","size":30,"stargazers_count":254,"open_issues_count":5,"forks_count":70,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-08T21:27:30.451Z","etag":null,"topics":["deep-learning","keras","lstm","nlp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/likejazz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-16T05:56:58.000Z","updated_at":"2025-03-21T16:07:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f580b117-379f-4c4d-b887-9160f1a2e2fa","html_url":"https://github.com/likejazz/Siamese-LSTM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/likejazz/Siamese-LSTM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likejazz%2FSiamese-LSTM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likejazz%2FSiamese-LSTM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likejazz%2FSiamese-LSTM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likejazz%2FSiamese-LSTM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/likejazz","download_url":"https://codeload.github.com/likejazz/Siamese-LSTM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likejazz%2FSiamese-LSTM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266242072,"owners_count":23898102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","keras","lstm","nlp"],"created_at":"2024-10-29T17:32:57.350Z","updated_at":"2025-07-21T05:04:21.662Z","avatar_url":"https://github.com/likejazz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Siamese-LSTM\n\nUsing MaLSTM model(Siamese networks + LSTM with Manhattan distance) to detect semantic similarity between question pairs. Training dataset used is a subset of the original Quora Question Pairs Dataset(~363K pairs used).\n\nIt is Keras implementation based on [Original Paper(PDF)](http://www.mit.edu/~jonasm/info/MuellerThyagarajan_AAAI16.pdf) and [Excellent Medium Article](https://medium.com/mlreview/implementing-malstm-on-kaggles-quora-question-pairs-competition-8b31b0b16a07).\n\n![](https://cloud.githubusercontent.com/assets/9861437/20479493/6ea8ad12-b004-11e6-89e4-53d4d354d32e.png)\n\n## Prerequisite\n\n- Paper, Articles\n    - [Siamese Recurrent Architectures for Learning Sentence Similarity](http://www.mit.edu/~jonasm/info/MuellerThyagarajan_AAAI16.pdf)\n    - [How to predict Quora Question Pairs using Siamese Manhattan LSTM](https://medium.com/mlreview/implementing-malstm-on-kaggles-quora-question-pairs-competition-8b31b0b16a07)\n- Data\n    - [GoogleNews-vectors-negative300.bin.gz](https://drive.google.com/file/d/0B7XkCwpI5KDYNlNUTTlSS21pQmM/edit?usp=sharing)\n    - [Kaggle's Quora Question Pairs Dataset](https://www.kaggle.com/c/quora-question-pairs/data)\n- References\n    - [aditya1503/Siamese-LSTM](https://github.com/aditya1503/Siamese-LSTM) Original author's GitHub\n    - [dhwajraj/deep-siamese-text-similarity](https://github.com/dhwajraj/deep-siamese-text-similarity) TensorFlow based implementation\n\nKaggle's `test.csv` is too big, so I had extracted only the top 20 questions and created a file called `test-20.csv` and It is used in the `predict.py`.\n\nYou should put all data files to `./data` directory.\n\n## How to Run\n### Training\n```\n$ python3 train.py\n```\n\n### Predicting\nIt uses `test-20.csv` file mentioned above.\n```\n$ python3 predict.py\n```\n\n## The Results\nI have tried with various parameters such as number of hidden states of LSTM cell, activation function of LSTM cell and repeated count of epochs.\nI have used NVIDIA Tesla P40 GPU x 2 for training and 10% data was used as the validation set(batch size=1024*2).\nAs a result, I have reached about 82.29% accuracy after 50 epochs about 10 mins later.\n\n```\nEpoch 50/50\n363861/363861 [==============================] - 12s 33us/step - loss: 0.1172 - acc: 0.8486 - val_loss: 0.1315 - val_acc: 0.8229\nTraining time finished.\n50 epochs in       601.24\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flikejazz%2Fsiamese-lstm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flikejazz%2Fsiamese-lstm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flikejazz%2Fsiamese-lstm/lists"}