rust-bert/examples
Anna Melnikov a34cf9f8e4
Make predict methods in ZeroShot pipeline return Result instead of panicking on unwrap (#301)
* Add checked prediction methods

- Add checked prediction methods to ZeroShotClassificationModel.
These methods return Option and convert any underlying errors into None,
to allow callers to implement appropriate error handling logic.

* Update ZeroShot example to use checked method.

* Add tests for ZeroShot checked methods

* Change checked prediction methods to return Result

* refactor: rename *_checked into try_*

Rename *_checked methods into try_* methods.
This is more idiomatic vis-a-vis the Rust standard library.

* refactor: remove try_ prefix from predict methods

* refactor: change return from Option to Result

Change return type of ZeroShotClassificationModel.prepare_for_model
from option into Result. This simplifies the code, and returns
the error closer to its origin.

This addresses comments from @guillaume-be.

* refactor: address clippy lints in tests

Co-authored-by: guillaume-be <guillaume.becquin@gmail.com>
2022-12-04 09:10:01 +00:00
..
async-sentiment.rs add async example, documentation and fix clippy (#217) 2022-01-30 11:51:58 +00:00
conversation.rs Fixed greedy generation method 2020-10-13 18:52:09 +02:00
generation_gpt2.rs Make max_length optional (#296) 2022-11-15 19:20:51 +00:00
generation_gpt_neo.rs Make max_length optional (#296) 2022-11-15 19:20:51 +00:00
generation_reformer.rs Make max_length optional (#296) 2022-11-15 19:20:51 +00:00
generation_xlnet.rs Make max_length optional (#296) 2022-11-15 19:20:51 +00:00
keyword_extraction.rs Keyword/Keyphrase extraction (#295) 2022-11-13 08:51:10 +00:00
masked_language_model_bert.rs Refactor: Feature gate remote resource (#223) 2022-02-25 21:24:03 +00:00
named_entities_recognition.rs Merge remote-tracking branch 'origin/master' into entity_consolidation 2021-11-20 11:03:05 +01:00
natural_language_inference_deberta.rs Refactor: Feature gate remote resource (#223) 2022-02-25 21:24:03 +00:00
part_of_speech_tagging.rs Updated offsets fixing overlapping spans 2021-08-18 09:07:23 +02:00
question_answering_bert.rs Refactor: Feature gate remote resource (#223) 2022-02-25 21:24:03 +00:00
question_answering_longformer.rs Refactor: Feature gate remote resource (#223) 2022-02-25 21:24:03 +00:00
question_answering_squad.rs Updated documentation, cleaned examples, added integration tests 2021-06-06 13:01:33 +02:00
question_answering.rs Reverted DistilBertForQuestionAnswering example 2021-02-14 10:53:00 +01:00
sentence_embeddings_local.rs Prepare for 0.19 release (#272) 2022-07-25 06:36:02 +01:00
sentence_embeddings.rs Add sbert implementation for inference (#250) 2022-06-21 20:24:09 +01:00
sentiment_analysis_fnet.rs Update to tch=0.9.0 (#293) 2022-11-07 17:45:52 +00:00
sentiment_analysis_sst2.rs Fixed Clippy warnings (#204) 2021-12-09 09:33:27 +01:00
sentiment_analysis.rs Update to tch=0.9.0 (#293) 2022-11-07 17:45:52 +00:00
sequence_classification_multilabel.rs Updated T5 (clippy) 2020-09-13 12:25:22 +02:00
sequence_classification.rs Update to tch=0.9.0 (#293) 2022-11-07 17:45:52 +00:00
summarization_bart.rs Make max_length optional (#296) 2022-11-15 19:20:51 +00:00
summarization_pegasus.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
summarization_prophetnet.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
summarization_t5.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
token_classification.rs Refactor: Feature gate remote resource (#223) 2022-02-25 21:24:03 +00:00
translation_builder.rs Updated doctests 2021-07-28 18:10:20 +02:00
translation_m2m100.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
translation_marian.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
translation_mbart.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
translation_t5.rs Mixed resources (#291) 2022-10-30 07:39:52 +00:00
zero_shot_classification.rs Make predict methods in ZeroShot pipeline return Result instead of panicking on unwrap (#301) 2022-12-04 09:10:01 +00:00