Updated README, bumped version

This commit is contained in:
Guillaume B 2020-02-25 18:37:02 +01:00
parent afa606152b
commit fe4f7c689d
3 changed files with 30 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "rust-bert"
version = "0.4.2"
version = "0.4.3"
authors = ["Guillaume Becquin <guillaume.becquin@gmail.com>"]
edition = "2018"
default-run = "rust-bert"

View File

@ -20,7 +20,28 @@ Multiple choices| |✅ |✅
## Ready-to-use pipelines
Leveraging Huggingface's pipelines, ready to use end-to-end NLP pipelines are available as part of this crate. The following capabilities are currently available:
#### 1. Sentiment analysis
#### 1. Question Answering
Extractive question answering from a given question and context. DistilBERT model finetuned on SQuAD (Stanford Question Answering Dataset)
```rust
let device = Device::cuda_if_available();
let qa_model = QuestionAnsweringModel::new(vocab_path,
config_path,
weights_path, device)?;
let question = "Where does Amy live ?";
let context = "Amy lives in Amsterdam";
let answers = qa_model.predict(question, context, 1);
```
Output:
```
[Answer { score: 0.9976814985275269, start: 13, end: 21, answer: "Amsterdam" }]
```
#### 2. Sentiment analysis
Predicts the binary sentiment for a sentence. DistilBERT model finetuned on SST-2.
```rust
let device = Device::cuda_if_available();
@ -47,20 +68,20 @@ Output:
]
```
#### 2. Named Entity Recognition
#### 3. Named Entity Recognition
Extracts entities (Person, Location, Organization, Miscellaneous) from text. BERT cased large model finetuned on CoNNL03, contributed by the [MDZ Digital Library team at the Bavarian State Library](https://github.com/dbmdz)
```rust
// Set-up model
let device = Device::cuda_if_available();
let ner_model = NERModel::new(vocab_path,
config_path,
weights_path, device)?;
// Define input
let input = [
"My name is Amy. I live in Paris.",
"Paris is a city in France."
];
let output = ner_model.predict(input.to_vec());
```
Output:
```

View File

@ -2,7 +2,7 @@ extern crate failure;
extern crate dirs;
use std::path::PathBuf;
use rust_bert::pipelines::question_answering::{QuestionAnsweringModel};
use rust_bert::pipelines::question_answering::QuestionAnsweringModel;
use tch::Device;
@ -17,7 +17,9 @@ fn main() -> failure::Fallible<()> {
// Set-up Question Answering model
let device = Device::Cpu;
let qa_model = QuestionAnsweringModel::new(vocab_path, config_path, weights_path, device)?;
let qa_model = QuestionAnsweringModel::new(vocab_path,
config_path,
weights_path, device)?;
// Define input
let question = "Where does Amy live ?";