New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

neural-sentence-search

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neural-sentence-search

Simple neural sentence search.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Sentence search using Tensorflow sentence embeddings that works in the browser - this is a one shot learning method. The user provides a sentence or a list of sentences (as examples) to the model and an object that should be returned if a searched for sentence falls into that class. This is meant to be a little like elasticsearch where the search result is actually an object. The approach uses tensorflow sentence embedding and k nearest neighbors to compute the nearest class (there is no neural network training). It does not run using an external database so it can be run in the browser - however, you may need to set up some tensorflow specific initialization depending on where you decide to run it. The code is very simple.

Using

let { NeuralSentenceSearch } = require("neural-sentence-search")

let b = async ()=>{
    
    let nn = new NeuralSentenceSearch()

    await nn.initialize();

    await nn.addSameClass({a : "firstClass"}, "This is a test")
    await nn.addSameClass({a : "secondClass"}, ["My name is John", "Me llamo Sarah"])
    await nn.addSameClass({d : {c : "the last class"}}, ["In the galaxy", "solar system"])

    let ans1 = await nn.search("the sun")
    console.log(ans1)

    let ans2 = await nn.search("his name is Jerry")
    console.log(ans2)
}

b()

with output

    {
      result: {
        classIndex: 2,
        label: '2',
        confidences: { '0': 0, '1': 0, '2': 1 }
      },
      object: { d: { c: 'the last class' } }
    }

and

    {
      result: {
        classIndex: 1,
        label: '1',
        confidences: { '0': 0, '1': 1, '2': 0 }
      },
      object: { a: 'secondClass' }
    }

Keywords

FAQs

Package last updated on 08 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc