wink-embeddings-sg-100d
100-dimensional English word embeddings for wink-nlp
This pre-trained 100-dimensional English word embedding set is specifically optimized for winkNLP. This package (~110MB download, ~310MB installed) includes embeddings for over 350K English words. Boost accuracy in semantic similarity, text classification, and more – even in the browser.
Getting Started
Prerequisite
It requires Node.js version 16.0.0
or above and winkNLP version 2.1.0
or above.
Installation
The model must be installed along with the wink-nlp and the wink-eng-lite-web-model:
npm install wink-nlp --save
npm install wink-eng-lite-web-model --save
npm install wink-embeddings-sg-100d --save
Example
We start by requiring the wink-nlp package, the wink-eng-lite-web-model and the wink-embeddings-sg-100d. Then we instantiate wink-nlp using the language model and the embeddings:
const winkNLP = require( 'wink-nlp' );
const model = require( 'wink-eng-lite-web-model' );
const vectors = require( 'wink-embeddings-sg-100d' );
const similarity = require( 'wink-nlp/utilities/similarity.js' );
const nlp = winkNLP( model, [ 'sbd' ], vectors );
const its = nlp.its;
const as = nlp.as;
const text = `The cat rested on the carpet. The kitten slept on the rug.
The table was in the drawing room. The desk was in the study room.`;
const v = [];
const doc = nlp.readDoc( text );
doc
.sentences()
.each( ( s, k ) => {
v[ k ] = s
.tokens()
.filter( (t) => (t.out(its.type) === 'word' && !t.out(its.stopWordFlag)))
.out(its.value, as.vector);
})
for ( let i = 0; i < v.length; i += 1 ) {
for ( let j = i; j < v.length; j += 1 ) {
if ( i !== j )
console.log(
doc.sentences().itemAt( i ).out(), ' & ',
doc.sentences().itemAt( j ).out(),
+similarity.vector.cosine( v[ i ], v[ j ] ).toFixed( 2 )
);
}
}
The output of the above example is visually illustrated below:
Need Help?
If you spot a bug and the same has not yet been reported, raise a new issue.
About winkJS
WinkJS is a family of open source packages for Natural Language Processing, Machine Learning, and Statistical Analysis in NodeJS. The code is thoroughly documented for easy human comprehension and has a test coverage of ~100% for reliability to build production grade solutions.
Copyright & License
Wink NLP is copyright 2017-24 GRAYPE Systems Private Limited.
It is licensed under the terms of the MIT License.