{"id":17717990,"url":"https://github.com/chaitjo/lstm-context-embeddings","last_synced_at":"2025-05-07T02:42:18.954Z","repository":{"id":47986666,"uuid":"63848895","full_name":"chaitjo/lstm-context-embeddings","owner":"chaitjo","description":"Augmenting word embeddings with their surrounding context using bidirectional RNN","archived":false,"fork":false,"pushed_at":"2020-02-18T12:05:56.000Z","size":24331,"stargazers_count":59,"open_issues_count":0,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-05T10:08:17.563Z","etag":null,"topics":["cnn","context-embeddings","deep-learning","lstm","neural-networks","sentence-classification","tensorflow","word-embeddings"],"latest_commit_sha":null,"homepage":"https://chaitjo.github.io/context-embeddings/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaitjo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-21T07:53:45.000Z","updated_at":"2022-11-03T08:17:51.000Z","dependencies_parsed_at":"2022-08-12T16:00:26.574Z","dependency_job_id":null,"html_url":"https://github.com/chaitjo/lstm-context-embeddings","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitjo%2Flstm-context-embeddings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitjo%2Flstm-context-embeddings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitjo%2Flstm-context-embeddings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitjo%2Flstm-context-embeddings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaitjo","download_url":"https://codeload.github.com/chaitjo/lstm-context-embeddings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802580,"owners_count":21806530,"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":["cnn","context-embeddings","deep-learning","lstm","neural-networks","sentence-classification","tensorflow","word-embeddings"],"created_at":"2024-10-25T14:33:33.383Z","updated_at":"2025-05-07T02:42:18.928Z","avatar_url":"https://github.com/chaitjo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nPresented here is a method to modify the word embeddings of a word in a sentence with its surrounding context using a bidirectional Recurrent Neural Network (RNN). The hypothesis is that these modified embeddings are a better input for performing text classification tasks like sentiment analysis or polarity detection. \n\n**Read the full blog post here: [chaitjo.github.io/context-embeddings](https://chaitjo.github.io/context-embeddings/)**\n\n---\n\n![Bidirectional RNN layer](res/bidirectional-rnn.png)\n\n# Implementation\nThe code implements the proposed model as a pre-processing layer before feeding it into a [Convolutional Neural Network for Sentence Classification](https://arxiv.org/pdf/1408.5882v2.pdf) (Kim, 2014). Two implementations are provided to run experiments: one with [tensorflow](https://www.tensorflow.org/) and one with [tflearn](http://tflearn.org/) (A high-level API for tensorflow). Training happens end-to-end in a supervised manner: the RNN layer is simply inserted as part of the existing model's architecture for text classification.\n\nThe tensorflow version is built on top of [Denny Britz's implementation of Kim's CNN](https://github.com/dennybritz/cnn-text-classification-tf), and also allows loading pre-trained word2vec embeddings. \n\nAlthough both versions work exactly as intended, results in the blog post are from experiments with the tflearn version only.\n\n# Usage\nI used Python 3.6 and Tensorflow 0.12.1 for my experiments.\nTensorflow code is divided into `model.py` which abstracts the model as a class, and `train.py` which is used to train the model. It can be executed by running the `train.py` script (with optional flags to set hyperparameters)-\n```\n$ python train.py [--flag=1]\n```\n(Tensorflow code for Kim's baseline CNN can be found in `/cnn-model`.)\n\nTflearn code can be found in the `/tflearn` folder and can be run directly to start training (with optional flags to set hyperparameters)-\n```\n$ python tflearn/model.py [--flag=1]\n```\n\nThe summaries generated during training (saved in `/runs` by default) can be used to visualize results using tensorboard with the following command-\n```\n$ tensorboard --logdir=\u003cpath_to_summary\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaitjo%2Flstm-context-embeddings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaitjo%2Flstm-context-embeddings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaitjo%2Flstm-context-embeddings/lists"}