Skip to main content

Sunbird Sunflower Quantized Model Usage

Installation

  • torch: PyTorch library for model computation.
  • transformers: Hugging Face Transformers library for model handling.
  • accelerate: Optimizes model loading across devices.
  • bitsandbytes: Enables efficient 4-bit and 8-bit model quantization.

Import the necessary libraries for loading and running the model.

3. Authentication


4. Load Tokenizer and Model

Replace <MODEL_NAME> with the specific model you want to use, e.g., Sunbird/Sunflower-14B-4bit-nf4-bnb or Sunbird/Sunflower-14B-8bit-bnb.
Note: Only change <MODEL_NAME> and adjust quantization parameters. Everything else remains the same for any model.

5. Prepare Chat Prompt


6. Configure Text Generation

  • Beam search improves output quality but slows generation.
  • TextStreamer works only when num_beams == 1.

7. Generate Output

  • Single-beam: real-time streaming.
  • Multi-beam: output decoded after generation.

8. Notes for Future Models

  • The workflow is identical for any Sunflower model.
  • Only model-specific changes:
    1. <MODEL_NAME> in from_pretrained.
    2. Quantization parameters (load_in_4bit / load_in_8bit).
  • Everything else (chat template, streaming, generation) stays the same.