Huggingface Bloom Documentation

The Huggingface Bloom documentation provides an overview of the BLOOM model and its various versions, along with instructions on how to use the model for different tasks using the Huggingface Transformers library.

Overview

  • BLOOM is a large language model proposed by the BigScience Workshop, inspired by open science initiatives.

  • The architecture is similar to GPT-3, an auto-regressive model for next token prediction.

  • BLOOM has been trained on 46 different languages and 13 programming languages.

  • It comes in several versions with different parameter counts: bloom-560m, bloom-1b1, bloom-1b7, bloom-3b, bloom-7b1, and bloom (176B parameters).

Resources

  • The documentation lists official Huggingface and community resources for getting started with BLOOM.

  • It includes links to example scripts and notebooks for various tasks like text generation, text classification, token classification, and question answering.

  • There are also blog posts on optimizing BLOOM inference, training, and using it with DeepSpeed and Accelerate.

BloomConfig

  • This is the configuration class for the BLOOM model, used to store hyperparameters and other settings.

  • It inherits from PretrainedConfig and allows controlling the model outputs.

  • The config class takes various arguments like vocab_size, hidden_size, n_layer, n_head, etc.

  • Instantiating the config with default values yields a configuration similar to the BLOOM architecture.

BloomTokenizerFast

  • This is a "fast" tokenizer for BLOOM, based on the Huggingface Tokenizers library and using byte-level Byte-Pair-Encoding (BPE).

  • The tokenizer treats spaces as part of tokens, so a word will be encoded differently depending on whether it's at the beginning of a sentence or not.

  • The tokenizer inherits from PreTrainedTokenizerFast, which provides various methods for encoding and decoding text.

BloomModel

  • This is the bare BLOOM model transformer that outputs raw hidden states without any specific head on top.

  • It inherits from PreTrainedModel and is also a PyTorch nn.Module subclass.

  • The forward() method takes input_ids, attention_mask, past_key_values, and other arguments, and returns a BaseModelOutputWithPastAndCrossAttentions object or a tuple.

  • The model can be used for tasks that don't require a specific head on top of the hidden states.

BloomForCausalLM

  • This is the BLOOM model with a language modeling head on top (linear layer with weights tied to the input embeddings).

  • It's used for causal language modeling tasks, like next token prediction.

  • The forward() method is similar to BloomModel but also takes labels as input and can return a CausalLMOutputWithCrossAttentions object.

BloomForSequenceClassification

  • This is the BLOOM model with a sequence classification head on top (linear layer).

  • It's used for sequence classification tasks, like sentiment analysis or text classification.

  • The forward() method takes input_ids, attention_mask, labels, and other arguments, and returns a SequenceClassifierOutputWithPast object.

  • The documentation provides examples of single-label and multi-label classification.

BloomForTokenClassification

  • This is the BLOOM model with a token classification head on top (linear layer).

  • It's used for token-level classification tasks, like named entity recognition (NER).

  • The forward() method is similar to BloomForSequenceClassification but returns a TokenClassifierOutput object.

BloomForQuestionAnswering

  • This is the BLOOM model with a span classification head on top for extractive question answering tasks like SQuAD.

  • It has a linear layer on top of the hidden states to compute start and end logits for the answer span.

  • The forward() method takes input_ids, attention_mask, start_positions, end_positions, and other arguments, and returns a QuestionAnsweringModelOutput object.

FlaxBloomModel and FlaxBloomForCausalLM

  • These are the Flax/JAX implementations of the BLOOM model and the causal language modeling variant.

  • They inherit from FlaxPreTrainedModel and are also Flax nn.Module subclasses.

  • The call() method is similar to the PyTorch versions but uses JAX arrays and supports JIT compilation, automatic differentiation, vectorization, and parallelization.

Relation to TensorRT

  • The BLOOM model and its variants can be optimized for inference using TensorRT, which is a library for high-performance deep learning inference on NVIDIA GPUs.

  • TensorRT can optimize the model by fusing layers, using reduced precision (e.g., FP16 or INT8), and taking advantage of tensor cores on modern GPUs.

  • The optimized model can be deployed in various environments, like embedded systems or servers, for efficient inference.

Last updated

Logo

Continuum - Accelerated Artificial Intelligence

Continuum WebsiteAxolotl Platform

Copyright Continuum Labs - 2023