bloomz-7b1-mt
  • 模型资讯
  • 模型资料

Use

How to use

CPU

Click to expand
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
 
checkpoint = "bigscience/bloomz-7b1-mt"
 
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint)
 
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))

GPU

Click to expand
# pip install -q transformers accelerate
from transformers import AutoModelForCausalLM, AutoTokenizer
 
checkpoint = "bigscience/bloomz-7b1-mt"
 
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, torch_dtype="auto", device_map="auto")
 
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))

GPU in 8bit

Click to expand
# pip install -q transformers accelerate bitsandbytes
from transformers import AutoModelForCausalLM, AutoTokenizer
 
checkpoint = "bigscience/bloomz-7b1-mt"
 
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", load_in_8bit=True)
 
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))

Limitations

Prompt Engineering: The performance may vary depending on the prompt. For BLOOMZ models, we recommend making it very clear when the input stops to avoid the model trying to continue it. For example, the prompt “Translate to English: Je t’aime” without the full stop (.) at the end, may result in the model trying to continue the French sentence. Better prompts are e.g. “Translate to English: Je t’aime.”, “Translate to English: Je t’aime. Translation:” “What is “Je t’aime.” in English?”, where it is clear for the model when it should answer. Further, we recommend providing the model as much context as possible. For example, if you want it to answer in Telugu, then tell the model, e.g. “Explain in a sentence in Telugu what is backpropagation in neural networks.”.

Training

Model

  • Architecture: Same as bloom-7b1, also refer to the config.json file
  • Finetuning steps: 1000
  • Finetuning tokens: 4.19 billion
  • Finetuning layout: 1x pipeline parallel, 1x tensor parallel, 64x data parallel
  • Precision: float16

Hardware

  • CPUs: AMD CPUs with 512GB memory per node
  • GPUs: 64 A100 80GB GPUs with 8 GPUs per node (8 nodes) using NVLink 4 inter-gpu connects, 4 OmniPath links
  • Communication: NCCL-communications network with a fully dedicated subnet

Software

Evaluation

We refer to Table 7 from our paper & bigscience/evaluation-results for zero-shot results on unseen tasks. The sidebar reports zero-shot performance of the best prompt per dataset config.

示例代码

from modelscope.utils.constant import Tasks
from modelscope.pipelines import pipeline
pipe = pipeline(task=Tasks.text_generation, model='AI-ModelScope/bloomz-7b1-mt', model_revision='v1.0.2', device_map='auto')
inputs="Translate to English: Je t’aime."
result = pipe(inputs, max_new_tokens=1024, do_sample=True, top_p=0.85, temperature=1.0, repetition_penalty=1., eos_token_id=2, bos_token_id=1, pad_token_id=0)
print(result['text'])

Citation

@misc{muennighoff2022crosslingual,
      title={Crosslingual Generalization through Multitask Finetuning}, 
      author={Niklas Muennighoff and Thomas Wang and Lintang Sutawika and Adam Roberts and Stella Biderman and Teven Le Scao and M Saiful Bari and Sheng Shen and Zheng-Xin Yong and Hailey Schoelkopf and Xiangru Tang and Dragomir Radev and Alham Fikri Aji and Khalid Almubarak and Samuel Albanie and Zaid Alyafeai and Albert Webson and Edward Raff and Colin Raffel},
      year={2022},
      eprint={2211.01786},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Clone with HTTP

git clone https://www.modelscope.cn/AI-ModelScope/bloomz-7b1-mt.git