FARM Versions Save

:house_with_garden: Fast & easy transfer learning for NLP. Harvesting language models for the industry. Focus on Question Answering.

0.4.6

3 years ago

Main changes

  • Upgrading to Pytorch 1.5.1 and transformers 3.0.2
  • Important bug fix for language model training from scratch
  • Bug fixes and big refactorings for Question Answering, incl. a specialized QAInferencer with dedicated In- and Output objects to simplify usage and code completion:
from farm.infer import QAInferencer
from farm.data_handler.inputs import QAInput, Question

nlp = QAInferencer.load(
    "deepset/roberta-base-squad2",
    task_type="question_answering",
    batch_size=16,
    num_processes=0)

input = QAInput(
    doc_text="My name is Lucas and I live on Mars.",
    questions=Question(text="Who lives on Mars?",
                       uid="your-id"))

res = nlp.inference_from_objects([input], return_json=False)[0]

# High level attributes for your query
print(res.question)
print(res.context)
print(res.no_answer_gap)
# ...
# Attributes for individual predictions (= answers)
pred = res.prediction[0]
print(pred.answer)
print(pred.answer_type)
print(pred.answer_support)
print(pred.offset_answer_start)
print(pred.offset_answer_end)
# ...

Details

Question Answering

  • Add meta attribute to QACandidate for Haystack #455
  • Fix start and end offset checks in QA #450
  • Fix offset_end character for QA #449
  • Dedicated Input Objects for QA #445
  • Question Answering improvements: cleaner code, more typed objects, better compatibility between SQuAD and Natural Questions #411, #438, #419

Other

  • Upgrade pytorch and python versions #447
  • Upgrade transformers version #448
  • Fix randomisation of train file for training from scratch #427
  • Fix loading of saved models with class weights #431
  • Remove raising exception errors in processor #451
  • Fix bug in benchmark tests with if statement #430
  • Remove hardcoded seeds from trainer #424
  • Conditional num_training_steps setting #437
  • Add badge with link to doc page #432
  • Fix for CI problem - closing multiprocessing.pool again #403

:man_farmer: :woman_farmer: Thanks to all contributors for making FARMer's life better! @PhilipMay, @tstadel, @brandenchan, @tanaysoni, @Timoeller, @tholor, @bogdankostic

0.4.5

3 years ago

Minor release including an important bug fix for Question Answering

Important Bug Fix QA

Fixing a bug that was introduced in 0.4.4 (#416 and #417) that resulted in returning only a single answer per document in certain situations. This caused particular trouble for open-domain QA settings like in haystack.

Speed optimization training from scratch

Adding multiple optimizations and bug fixes to improve training from scratch, incl.:

  • Enable usage of DistributedDataParallel
  • Enable Automatix Mixed Precision Training
  • Fix bugs in StreamingDataSilo
  • Fix bugs in Checkpointing (important for training via spot / on-demand instances)

This helped to boost training time in our benchmark from 616 hours down to 160 hours See #305 for details


Other changes:

  • Add model optimization to inference loading #415
  • Proper attribute assignment in QA with yes / no answer #414

0.4.4

3 years ago

ELECTRA Model

We welcome a new language model to the FARM family that we found to be a really powerful alternative to the existing ones. ELECTRA is trained using a small generator network that replaces tokens with plausible alternatives and a discriminative model that predicts which learns to detect these replaced tokens (see the paper for details: https://arxiv.org/abs/2003.10555). This makes pretraining more efficient and improves down-stream performance for quite many tasks.

You can load it as usual via

LanguageModel.load("google/electra-base-discriminator")

See HF's model hub for more model variants

Natural Questions Style QA

With QA being our favorite and focussed down-stream task, we are happy to support an additional style of QA in FARM ( #334). In contrast to the popular SQuAD-based models, these NQ models support binary answers, i.e. questions like "Is Berlin the capital of Germany?" can be answered with "Yes" and an additional span that the model used as a "supporting fact" to give this answer.

The implementation leverages the option of prediction heads in FARM by having one QuestionAnsweringHead that predicts a span (like in SQuAD) and one TextClassificationHead that predicts what type of answer the model should give (current options: span, yes, no, is_impossible).

Example:

    QA_input = [
        {
            "qas": ["Is Berlin the capital of Germany?"],
            "context":  "Berlin (/bɜːrˈlɪn/) is the capital and largest city of Germany by both area and population."
        }
    ]
    model = Inferencer.load(model_name_or_path="../models/roberta-base-squad2-nq", batch_size=batch_size, gpu=True)
    result = model.inference_from_dicts(dicts=QA_input, return_json=False)
    print(f"Answer: {result[0].prediction[0].answer}")

   >> Answer: yes

See this new example script for more details on training and inference.

Note: This release includes the initial version for NQ, but we are already working on some further simplifications and improvements in #411 .

New speed benchmarking

With inference speed being crucial for many deployments - especially for QA, we introduce a new benchmarking tool in #321. This allows us to easily compare the performance of different frameworks (e.g. ONNX vs. pytorch), parameters (e.g. batch size) and code optimizations of different FARM versions. See the readme for usage details and this spreadsheet for current results.


A few more changes ...

Modeling

  • Add support for Camembert-like models #396
  • Speed up in BERTLMHead by doing argmax on logits on GPU #377
  • Fix bug in BERT-style pretraining #369
  • Remove additional XLM-R tokens #360
  • ELECTRA: use gelu for pooled output of ELECTRA model #364

Data handling

  • Option to specify text col name in TextClassificationProcessor and RegressionProcessor #387
  • Document magic data loading in TextClassificationProcessor PR #383
  • multilabel support for data_silo.calculate_class_weights #389
  • Implement Prediction Objects for Question Answering #405
  • Removing lambda function from AdaptiveModel so the class can be pickable #345
  • Add target device optimisations for ONNX export #354

Examples / Docs

  • Add script to reproduce results from COVID-QA paper #412
  • Update tutorials #348
  • Docstring Format fix #382

Other

  • Adjust code to squad inferencing #367
  • Convert pydantic objects to regular classes #410
  • Rename top n recall to top n accuracy #409
  • Add test for embedding extraction #394
  • Quick fix CI problems with OOM and unclosed worker pool #406
  • Update transformers version to 2.11 #407
  • Managing pytorch pip find-links directive #393
  • Zero based Epoch Display in Training Progress Bar #398
  • Add stalebot #400
  • Update pytorch to 1.5.0 #392
  • Question answering accuracy test #357
  • Add init.py files for farm.conversion module #365
  • Make onnx imports optional #363
  • Make ONNXRuntime dependency optional #347

:man_farmer: :woman_farmer: Thanks to all contributors for making FARMer's life better! @PhilipMay , @stefan-it, @ftesser , @tstadel, @renaud, @skirdey, @brandenchan, @tanaysoni, @Timoeller, @tholor, @bogdankostic

0.4.3

4 years ago

:1234: Changed Multiprocessing in Inferencer

The Inferencer has now a fixed pool of processes instead of creating a new one for every inference call. This accelerates the processing a bit and solves some problems when using it in combination with Frameworks like gunicorn/FastAPI etc (#329)

Old:

...
inferencer.inference_from_dicts(dicts, num_processes=8)

New:

Inferencer(dicts, num_processes=8)
...

:fast_forward: Streaming Inferencer

You can now also use the Inferencer in a "streaming mode". This is especially useful in production scenarios where the Inferencer is part of a bigger pipeline (e.g. consuming documents from elasticsearch) and you want to get predictions as soon as they are available (#315)

Input: Generator yielding dicts with your text Output: Generator yielding your predictions

    dicts = sample_dicts_generator()  # it can be a list of dicts or a generator object
    results = inferencer.inference_from_dicts(dicts, streaming=True, multiprocessing_chunksize=20)
    for prediction in results:  # results is a generator object that yields predictions
        print(prediction)

:older_woman: :older_man: "Classic" baseline models for benchmarking + S3E Pooling

While Transformers are conquering many of the current NLP tasks, there are still quite some tasks (e.g. some document classification) where they are a complete overkill. Benchmarking Transformers with "classic" uncontextualized embedding models is a common, good practice and is now possible without switching frameworks. We added basic support for loading in embeddings models like GloVe, Word2vec and FastText and using them as a "LanguageModels" in FARM (#285)

See the example script

We also added a new pooling method to get sentence or document embeddings from these models that can act as a strong baseline for transformer-based approaches (e.g Sentence-BERT). The method is called S3E and was recently introduced by Wang et al in "Efficient Sentence Embedding via Semantic Subspace Analysis" (#286)

See the example script


A few more changes ...

Modeling

  • Cross-validation for Question-Answering #335
  • Add option to use max_seq_len tokens for LM Adaptation/Training-from-scratch instead of real sentences #314
  • Add english glove models #339
  • Implicitly connect heads with processor + check for connection #337

Evaluation & Inference

  • Registration of custom evaluation reports #331
  • Standalone Evaluation with pretrained models #330
  • tqdm progress bar in inferencer #338
  • Group NER preds by sample #327
  • Fix Processor configs when loading Inferencer #318

Other

  • Fix the IOB2 to simple tags check #324
  • Update config when saving model to include changes of parameters #323
  • Fix Issues with NER format Conversion #322
  • Fix error message in loading of Tokenizer #317
  • Less verbosity, Fix which Samples and Baskets being Thrown Away #313

:man_farmer: :woman_farmer: Thanks to all contributors for making FARMer's life better! @brandenchan, @tanaysoni, @Timoeller, @tholor, @bogdankostic, @gsarti

0.4.2

4 years ago

:fast_forward: Scalable preprocessing: StreamingDataSilo

Allows you to load data lazily from disk and preprocess a batch on-the-fly when needed during training.

stream_data_silo = StreamingDataSilo(processor=processor, batch_size=batch_size)

=> Allows large datasets that don't fit in memory (e.g. for training from scratch) => Training directly starts. No initial time for preprocessing needed.

:rocket: Better Inference: Speed, scalability, standardization

ONNX support:

Microsoft recently added optimizations to the ONNX-runtime and reported substantial speed-ups compared to PyTorch. Since these improvements can be particularly useful for inference-heavy tasks such as QA, we added a way to export your AdaptiveModel to the ONNX format and load it into the Inferencer:

model = AdaptiveModel (...)
model.convert_to_onnx(Path("./onnx_model"))
inferencer = Inferencer.load(model_name_or_path=Path("./onnx_model"))

=> See example
=> Speed improvements depend on device and batch size. On a Tesla V100 we measured improvements between 30% - 260% for doing end-to-end QA inference on a large document and we still see more potential for optimizations.

Batch Size PyTorch ONNX ONNX V100 optimizations Speedup
1 27.5 12.8 10.6 2.59
2 17.5 11.5 9.1 1.92
4 12.5 10.7 8.3 1.50
8 10.6 10.2 8.2 1.29
16 10.5 10.1 7.8 1.38
32 10.1 9.8 7.8 1.29
64 9.9 9.8 7.8 1.26
128 9.9 9.8 7.7 1.28
256 10.0 9.8 7.9 1.26

Embedding extraction:

Extracting embeddings from a model at inference time is now more similar to other inference modes.

Old

model = Inferencer.load(lang_model, task_type="embeddings", gpu=use_gpu, batch_size=batch_size)
result = model.extract_vectors(dicts=basic_texts, extraction_strategy="cls_token", extraction_layer=-1)

New

model = Inferencer.load(lang_model, task_type="embeddings", gpu=use_gpu, batch_size=batch_size,
                            extraction_strategy="cls_token", extraction_layer=-1)
result = model.inference_from_dicts(dicts=basic_texts, max_processes=1)

=> The preprocessing can now also utilize multiprocessing => It's easier to reuse other methods like Inference.inference_from_file()

:left_right_arrow: New tasks: TextPairClassification & Passage ranking

Added supprt for text pair classification and ranking. Both can be especially helpful in semantic search settings where you want to (re-)rank search results and will be incorporated in our haystack framework soon. Examples:


A few more changes ...

Faster & simpler Inference

  • Make extract_vectors more compatible to other inference types #292
  • Add test for onnx qa inference. Fix bug in loading PHs for ONNX. #297
  • Add ONNX Inference for Question Answering #288
  • Improve inferencer for better multiprocessing with QA / haystack #278
  • Scalable Qa aggregation #268
  • Allow for multiple queries in QA inference when using rest_api format #246
  • Decouple n_best in QA predictions #269
  • Correct keyword argument for max_processes when used by calc_chunksize() #255
  • Add document id to QA inference #265
  • Refactor no answer handling in Question Answering #258

Streaming Data Silo / Training from scratch

  • StreamingDataSilo for loading & preprocessing batches lazily during training #239
  • Fix dict chunking in StreamingDataSilo for LMFinetuning #284
  • Add example for training with AWS SageMaker #283
  • Fix deletion of old training checkpoints #282
  • Fix epoch number for saving a training checkpoint #281
  • Fix Train Step calculations for Checkpointing #279
  • Implement len() for StreamingDataSilo #274
  • Refactor StreamingDataSilo to support multiple train epochs #266
  • Fix serialization for saving train checkpoints #271

Modeling

  • Add support for text pair classification (ASNQ) and ranking (MSMarco) #237
  • Add conversion of lm_finetuned to HF transformers #290
  • Added next_sentence_head in examples/lm_finetuning.py. #273
  • Quickfix loading pred head #256
  • Maked use of 'language' **kwargs if present in LanguageModel.load. #262
  • Add the option to define the language model class manually #264
  • Fix XLMR Bug When Calculating Start of Second Sequence #240

Examples / Tutorials / Experiments

  • Add data handling for GermEval14, add checks for correct data files #259
  • Fix separator in CoNLL_de experiment config #254
  • Use correct German conll03 data + conversion #248
  • Bugfix parameter loading through experiment configs #252
  • Add early stopping to experiment #253
  • Fix Tutorial: Add missing param in initialize_optimizer #245

Other

  • Add Azure test pipeline #270
  • Fix progress bar in datasilo #267
  • Turn off prints and logging during testing #260
  • Pin Werkzeug version in requirements.txt #250
  • Add ConnectionError handling for MLFlow logger #236
  • Clearer message when DataSilo calculates Sequence Lengths #293
  • Add metric to text_pair_classification example #294
  • Add preprocessed CORD-19 dataset #295

:man_farmer: :woman_farmer: Thanks to all contributors for making FARMer's life better! @brandenchan, @tanaysoni, @Timoeller, @tholor, @bogdankostic, @andra-pumnea, @PhilipMay, @ftesser, @guggio

0.4.1

4 years ago

:man_farmer: :arrows_counterclockwise: :hugs: Full compatibility with Transformers' models

Open-source is more than just public code. It's a mindset of sharing, being transparent and collaborating across organizations. It's about building on the shoulders of other projects and advancing together the state of technology. That's why we built on the top of the great Transformers library by huggingface and are excited to release today an even deeper compatibility that simplifies the exchange & comparison of models.

1. Convert models from/to transformers

model = AdaptiveModel.convert_from_transformers("deepset/bert-base-cased-squad2", device="cpu", task_type="question_answering")
transformer_model = model.convert_to_transformers()

2. Load models from their new model hub:

LanguageModel.load("TurkuNLP/bert-base-finnish-cased-v1")
Inferencer.load("deepset/bert-base-cased-squad2",  task_type="question_answering")
...

:rocket: Better & Faster Training

Thanks to @BramVanroy and @johann-petrak we got some really hot new features here:

  • Automatic Mixed Precision (AMP) Training: Speed up your training by ~ 35%! Model params are usually stored with FP32 precision. Some model layers don't need that precision and can be reduced to FP16, which speeds up training and reduces memory footprint. AMP is a smart way of figuring out, for which params we can reduce precision without sacrificing performance (Read more). Test it by installing apex and setting "use_amp" to "O1" in one of the FARM example scripts.

  • More flexible Optimizers & Schedulers: Choose whatever optimizer you like from PyTorch, apex or Transformers. Take your preferred learning rate schedule from Transformers or PyTorch (Read more)

  • Cross-validation: Get more reliable eval metrics on small datasets (see example)

  • Early Stopping: With early stopping, the run stops once a chosen metric is not improving any further and you take the best model up to this point. This helps prevent overfitting on small datasets and reduces training time if your model doesn't improve any further (see example).

:fast_forward: Caching & Checkpointing

Save time if you run similar pipelines (e.g. only experimenting with model params): Store your preprocessed dataset & load it next time from cache:

data_silo = DataSilo(processor=processor, batch_size=batch_size, caching=True)

Start & stop training by saving checkpoints of the trainer:

trainer = Trainer.create_or_load_checkpoint(
            ...
            checkpoint_on_sigterm=True,
            checkpoint_every=200,
            checkpoint_root_dir=Path(“/opt/ml/checkpoints/training”),
            resume_from_checkpoint=“latest”)

The checkpoints include the state of everything that matters (model, optimizer, lr_schedule ...) to resume training. This is particularly useful, if your training crashes (e.g. because you are using spot cloud instances).

:cloud: Integration with AWS SageMaker & Training from scratch

We are currently working a lot on simplifying large scale training and deployment. As a first step, we are adding support for training on AWS SageMaker. The interesting part here is the option to use Spot Instances and save about 70% of costs compared to regular instances. This is particularly relevant for training models from scratch, which we introduce in a basic version in this release and will improve over the next weeks. See this tutorial to get started with using SageMaker for training on down-stream tasks.

:computer: Windows support

FARM now also runs on Windows. This implies one breaking change: We now use pathlib and therefore expect all directory paths to be of type Path instead of str #172


A few more changes ...

Modelling

  • [enhancement] ALBERT support #169
  • [enhancement] DistilBERT support #187
  • [enhancement] XLM-Roberta support #181
  • [enhancement] Automatically infer layer dims of prediction head #195
  • [bug] Implement next_sent_pred flag #198

QA

  • [enhancement] Encoding of QA IDs #171
  • [enhancement] Remove repeat QA preds from overlapping passages #186
  • [enhancement] More options to control predictions of Question Answering Head #183
  • [bug] Fix QA example #203

Training

  • [enhancement] Use AMP instead of naive fp16. More optimizers. More LR Schedules. #133
  • [bug] Fix for use AMP instead of naive fp16 (#133) #180
  • [enhancement] Add early stopping and custom metrics #165
  • [enhancement] Add checkpointing for training #188
  • [enhancement] Add train loss to tqdm. add desc for data preproc. log only 2 samples #175
  • [enhancement] Allow custom functions to aggregate loss of prediction heads #220

Eval

  • [bug] Fixed micro f1 score #179
  • [enhancement] Rename classification_report to report #173

Data Handling

  • [enhancement] Add caching of datasets in DataSilo #177
  • [enhancement] Add option to limit number of processes in datasilo #174
  • [enhancement] Add max_multiprocessing_chunksize as a param for DataSilo #168
  • [enhancement] Issue59 - Add cross-validation for small datasets #167
  • [enhancement] Add max_samples argument to TextClassificationProcessor #204
  • [bug] Fix bug with added tokens #197

Other

  • [other] Disable multiprocessing in lm_finetuning tests to reduce memory footprint #176
  • [bug] Fix device arg in examples #184
  • [other] Add error message to train/dev split fn #190
  • [enhancement] Add more seeds #192

:man_farmer: :woman_farmer: Thanks to all contributors for making FARMer's life better! @brandenchan, @tanaysoni, @Timoeller, @tholor, @maknotavailable, @johann-petrak, @BramVanroy

0.3.2

4 years ago

:paintbrush: Fundamental Re-design of Question Answering

We believe QA is one of the most exciting tasks for transfer learning. However, the complexity of the task lets pipelines easily become messy, complicated and slow. This is unacceptable for production settings and creates a high barrier for developers to modify or improve them.

We put substantial effort in re-designing QA in FARM with two goals in mind: making it the simplest & fastest pipeline out there. Results:

  • :bulb: Simplicity: The pipeline is cleaner, more modular and easier to extend.
  • :rocket: Speed: Preprocessing of SQuAD 2.0 got down to 42s on a AWS p3.8xlarge (vs. ~ 20min in transformers and early versions of FARM). This will not only speed up training cycles and reduce GPU costs, but has also a big impact at inference time, where most time is actually spend on preprocessing.

See this blog post for more details and to learn about the key steps in a QA pipeline.

:briefcase: Support of proxy servers

Good news for our corporate users: Many of you approached us that the automated downloads of datasets / models caused problem in environments with proxy servers. You can now pass the proxy details to Processor and LanguageModel in the format used by the requests library

Example:

proxies = {"https": "http://user:[email protected]:8000"}

language_model = LanguageModel.load(pretrained_model_name_or_path = "bert-base-cased", 
                                    language = "english",
                                    proxies=proxies
                                    )
...
processor = BertStyleLMProcessor(data_dir="data/lm_finetune_nips", 
                                 tokenizer=tokenizer,
                                 max_seq_len=128, 
                                 max_docs=25,
                                 next_sent_pred=True,
                                 proxies = proxies,
                                )

Modelling

  • [enhancement] QA redesign #151
  • [enhancement] Add backwards compatibility for loading prediction head #159
  • [enhancement] Raise an Exception when an invalid path is supplied for loading a saved model #137
  • [bug] fix context in QA formatted preds #163
  • [bug] Fix loading custom vocab in transformers style for LM finetuning #155

Data Handling

  • [enhancement] Allow to load dataset from dicts in DataSilo #127
  • [enhancement] Option to supply proxy server #136
  • [bug] Fix tokenizer for multiple whitespaces #156

Inference

  • [enhancement] Change context in QA formatted preds to not split words #138

Other

  • [enhancement] Add test for output format of QA Inferencer #149
  • [bug] Fix classification report for multilabel #150
  • [bug] Fix inference in doc_classification_cola example #147

Thanks to all contributors for making FARMer's life better! @johann-petrak, @brandenchan, @tanaysoni, @Timoeller, @tholor, @cregouby

0.3.1

4 years ago

Improved Question Answering

Aggregation over multiple passages

When asking questions on long documents, the underlying Language Model needs to cut the document in multiple passages and answer the question on each of them. The output needs to be aggregated.

Improved QA Inferencer

The QA Inferencer

  • projects model predictions back to character space
  • can be used in the FARM demos UI
  • writes predictions in SQuAD style format, so you can compare the model accuracy with other frameworks

Modelling

  • [closed] Refactor squad qa #131
  • [enhancement][part: model] Fix passing kwargs to LM loading (e.g. proxy) #132

0.3.0

4 years ago

Major Changes

Adding Roberta & XLNet

Welcome RoBERTa and XLNet on the FARM :tada:! We did some intense refactoring in FARM to make it easier to add more language models. However, we will only add models where we see some decent advantages. One of the next models to follow will very likely be ALBERT ...

For now, we support Roberta/XLNet on (Multilabel) Textclassification, Text Regression and NER. QA will follow soon.

:warning: Breaking Change - Loading of Language models has changed: Bert.load("bert-base-cased") -> LanguageModel.load("bert-base-cased")

Migrating to tokenizers from the transformers repo.

Pros:

  • It's quite easy to add a tokenizer for any of the models implemented in transformers.
  • We rather support the development there than building something in parallel
  • The additional metadata during tokenization (offsets, start_of_word) is still created via tokenize_with_metadata
  • We can use encode_plus to add model specific special tokens (CLS, SEP ...)

Cons:

  • We had to deprecate our attribute "never_split_chars" that allowed to adjust the BasicTokenizer of BERT.
  • Custom vocab is now realized by increasing vocab_size instead of replacing unused tokens

:warning: Breaking Change - Loading of tokenizers has changed: BertTokenizer.from_pretrained("bert-base-cased") -> Tokenizer.load("bert-base-cased")

:warning: Breaking Change - never_split_chars: is no longer supported as an argument for the Tokenizer


Modelling:

  • [enhancement] Add Roberta, XLNet and redesign Tokenizer #125
  • [bug] fix loading of old tokenizer style #129

Data Handling:

  • [bug] Fix name of squad labels in experiment config #121
  • [bug] change arg in squadprocessor from labels to label_list #123

Inference:

  • [enhancement] Add option to disable multiprocessing in Inferencer(#117) #128
  • [bug] Fix logging verbosity in Inferencer (#117) #122

Other

  • [enhancement] Tutorial update #116
  • [enhancement] Update docs for api/ui docker #118

0.2.2

4 years ago

Major Changes

Parallelization of Data Preprocessing :rocket:

Data preprocessing via the Processor is now fast while maintaining a low memory footprint. Before, the parallelization via multiprocessing was causing serious memory issues on larger data sets (e.g. for Language Model fine-tuning). Now, we are running a small chunk through the whole processor (-> Samples -> Featurization -> Dataset ...). The multiprocessing is handled by the DataSilo now which simplifies implementation.

With this new approach we can still easily inspect & debug all important transformations for a chunk, but only keep the resulting dataset in memory once a process has finished with a chunk.

Multilabel classification

We support now also multilabel classification. Prepare your data by simply setting multilabel=true in the TextClassificationProcessor and use the new MultiLabelTextClassificationHead for your model. => See an example here

Concept of Tasks

To further simplify multi-task learning we added the concept of "tasks". With this you can now use one TextClassificationProcessor to preprocess data for multiple tasks (e.g. using two columns in your CSV for classification). Example:

  1. Add the tasks to the Processor:
    processor = TextClassificationProcessor(...)

    news_categories = ["Sports", "Tech", "Politics", "Business", "Society"]
    publisher = ["cnn", "nytimes","wsj"]

    processor.add_task(name="category", label_list=news_categories, metric="acc", label_column_name="category_label")
    processor.add_task(name="publisher", label_list=publisher, metric="acc", label_column_name="publisher_label")
  1. Link the data to right PredictionHead by supplying the task name at initialization:
category_head = MultiLabelTextClassificationHead(layer_dims=[768,5)], task_name="action_type")
publisher_head = MultiLabelTextClassificationHead(layer_dims=[768, 3], task_name="parts")

Update to transformers 2.0

We are happy to see how huggingface's repository is growing and how they made another major step with the new 2.0 release. Since their collection of language models is awesome, we will continue building upon their language models and tokenizers. However, we will keep following a different philosophy for all other components (dataprocessing, training, inference, deployment ...) to improve usability, allow multitask learning and simplify usage in the industry.


Modelling:

  • ['enhancement] Add Multilabel Classification (#89)
  • ['enhancement] Add PredictionHead for Regression task (#50)
  • [enhancement] Introduce concept of "tasks" to support of multitask training using multiple heads of the same type (e.g. for multiple text classification tasks) (#75)
  • [enhancement] Update dependency to transformers 2.0 (#106)
  • [bug] TypeError: classification_report() got an unexpected keyword argument 'target_names' #93
  • [bug] Fix issue with class weights (#82)

Data Handling:

  • [enhancement] Chunkwise multiprocessing to reduce memory footprint in preprocessing large datasets (#88)
  • [bug] Threading Error upon building Data Silo #90
  • [bug] Multiprocessing causes data preprocessing to crash #110 (https://github.com/deepset-ai/FARM/issues/102)
  • [bug] Multiprocessing Error with PyTorch Version 1.2.0 #97
  • [bug] Windows fixes (#109)

Inference:

  • [enhancement] excessive uncalled-for warnings when using the inferencer #104
  • [enhancement] Get probability distribution over all classes in Inference mode (#102)
  • [enhancement] Add InferenceProcessor (#72)
  • [bug] Fix classifcation report bug with binary doc classification

Other:

  • [enhancement] Add more tests (#108)
  • [enhancement] do logging within run_experiment() (#37)
  • [enhancement] Improved logging (#82, #87 #105)
  • [bug] fix custom vocab for bert-base-cased (#108)

Thanks to all contributors: @tripl3a, @busyxin, @AhmedIdr, @jinnerbichler, @Timoeller, @tanaysoni, @brandenchan , @tholor

👩‍🌾 Happy FARMing!