Skip to content

shubham0204/glove-android

Repository files navigation

glove-android: Using GloVe word embeddings in Android

glove-android is an Android library that provides an interface for using popular GloVe word embeddings.

Installation

  1. Download glove-android.aar from the latest release. (See Releases)
  2. Move the AAR to app/libs.
  3. In module-level build.gradle, add the dependency,
dependencies {
    ...
    implementation files('libs/glove-android.aar')
    ...
}

Usage

To load the embeddings from storage, use the GloVe.loadEmbeddings method, which returns a GloveEmbeddings object as a parameter in the given lambda function.

val gloveEmbeddings: GloVeEmbeddings

GloVe.loadEmbeddings {
    gloveEmbeddings = it
}

Call the gloveEmbeddings.getEmbedding method providing a word as parameter. The resultant embedding is returned as a FloatArray with size=50 (indicating a 50-D embedding).

val embedding = gloveEmbeddings.getEmbedding( "hello" )
println( embedding.contentToString() )

If no embedding is found for the given word, an empty FloatArray is returned

Citation

@inproceedings{pennington2014glove,
  author = {Jeffrey Pennington and Richard Socher and Christopher D. Manning},
  booktitle = {Empirical Methods in Natural Language Processing (EMNLP)},
  title = {GloVe: Global Vectors for Word Representation},
  year = {2014},
  pages = {1532--1543},
  url = {http://www.aclweb.org/anthology/D14-1162},
}

Useful Resources