Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Informers

🙂 State-of-the-art natural language processing for Ruby

Supports:

  • Sentiment analysis
  • Question answering
  • Named-entity recognition
  • Text generation - in development
  • Summarization - in development
  • Translation - in development

Build Status

Installation

Add this line to your application’s Gemfile:

gem 'informers'

On Mac, also install OpenMP:

brew install libomp

Getting Started

Sentiment Analysis

First, download the pretrained model.

Predict sentiment

model = Informers::SentimentAnalysis.new("sentiment-analysis.onnx")
model.predict("This is super cool")

This returns

{label: "positive", score: 0.999855186578301}

Predict multiple at once

model.predict(["This is super cool", "I didn't like it"])

Question Answering

First, download the pretrained model and add Numo to your application’s Gemfile:

gem 'numo-narray'

Ask a question with some context

model = Informers::QuestionAnswering.new("question-answering.onnx")
model.predict(
  question: "Who invented Ruby?",
  context: "Ruby is a programming language created by Matz"
)

This returns

{answer: "Matz", score: 0.9980658360049758, start: 42, end: 46}

Named-Entity Recognition

First, export the pretrained model.

Get entities

model = Informers::NER.new("ner.onnx")
model.predict("Nat works at GitHub in San Francisco")

This returns

[
  {text: "Nat",           tag: "person",   score: 0.9840519576513487, start: 0,  end: 3},
  {text: "GitHub",        tag: "org",      score: 0.9426134775785775, start: 13, end: 19},
  {text: "San Francisco", tag: "location", score: 0.9952414982243061, start: 23, end: 36}
]

Models

Task Description Contributor License Link
Sentiment analysis DistilBERT fine-tuned on SST-2 Hugging Face Apache-2.0 Link
Question answering DistilBERT fine-tuned on SQuAD Hugging Face Apache-2.0 Link
Named-entity recognition BERT fine-tuned on CoNLL03 Bayerische Staatsbibliothek In-progress Link

Models are quantized to make them faster and smaller.

Credits

This project uses many state-of-the-art technologies:

Some code was ported from Transformers and is available under the same license.

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/informers.git
cd informers
bundle install

export MODELS_PATH=path/to/onnx/models
bundle exec rake test
You can’t perform that action at this time.