🙂 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
Add this line to your application’s Gemfile:
gem 'informers'
On Mac, also install OpenMP:
brew install libomp
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"])
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}
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}
]
Task | Description | Contributor | License | Link |
---|---|---|---|---|
Sentiment analysis | DistilBERT fine-tuned on SST-2 | Hugging Face | Apache-2.0 | Link |
Question answering | DistilBERT | 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.
This project uses many state-of-the-art technologies:
- Transformers for transformer models
- Bling Fire and BERT for high-performance text tokenization
- ONNX Runtime for high-performance inference
Some code was ported from Transformers and is available under the same license.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
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