Views
No views yet
pip install hf-hub-ctranslate2>=2.10.0 ctranslate2>=3.16.01# from transformers import AutoTokenizer
2model_name = "michaelfeil/ct2fast-falcon-7b-sft-top1-696"
3
4from hf_hub_ctranslate2 import GeneratorCT2fromHfHub
5model = GeneratorCT2fromHfHub(
6 # load in int8 on CUDA
7 model_name_or_path=model_name,
8 device="cuda",
9 compute_type="int8_float16",
10 # tokenizer=AutoTokenizer.from_pretrained("{ORG}/{NAME}")
11)
12outputs = model.generate(
13 text=["def fibonnaci(", "User: How are you doing? Bot:"],
14 max_length=64,
15 include_prompt_in_result=False
16)
17print(outputs)compute_type=int8_float16 for device="cuda"compute_type=int8 for device="cpu"ct2-transformers-converter --model OpenAssistant/falcon-7b-sft-top1-696 --output_dir ~/tmp-ct2fast-falcon-7b-sft-top1-696 --force --copy_files tokenizer.json README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization int8_float16 --trust_remote_code<|prompter|> and <|assistant|>. Each turn ends with a <|endoftext|> token.<|prompter|>What is a meme, and what's the history behind this word?<|endoftext|><|assistant|><|assistant|> token to signal that the model should
start generating the assistant reply.1from transformers import AutoTokenizer
2import transformers
3import torch
4
5model = "OpenAssistant/falcon-7b-sft-top1-696"
6
7tokenizer = AutoTokenizer.from_pretrained(model)
8pipeline = transformers.pipeline(
9 "text-generation",
10 model=model,
11 tokenizer=tokenizer,
12 torch_dtype=torch.bfloat16,
13 trust_remote_code=True,
14 device_map="auto",
15)
16
17input_text="<|prompter|>What is a meme, and what's the history behind this word?<|endoftext|><|assistant|>"
18
19sequences = pipeline(
20 input_text,
21 max_length=500,
22 do_sample=True,
23 return_full_text=False,
24 top_k=10,
25 num_return_sequences=1,
26 eos_token_id=tokenizer.eos_token_id,
27)
28for seq in sequences:
29 print(f"Result: {seq['generated_text']}")falcon-7b:
dtype: bf16
log_dir: "falcon_log_7b"
learning_rate: 1e-5
model_name: "tiiuae/falcon-7b"
deepspeed_config: configs/zero_config.json
output_dir: falcon
weight_decay: 0.0
max_length: 2048
save_strategy: steps
eval_steps: 80
save_steps: 80
warmup_steps: 20
gradient_checkpointing: true
gradient_accumulation_steps: 4
per_device_train_batch_size: 4
per_device_eval_batch_size: 8
num_train_epochs: 8
save_total_limit: 4
residual_dropout: 0.2
residual_dropout_lima: trueoasst-top1:
# oasst_export: 11123 (100.00%)
datasets:
- oasst_export:
lang: "bg,ca,cs,da,de,en,es,fr,hr,hu,it,nl,pl,pt,ro,ru,sl,sr,sv,uk" # sft-8.0
input_file_path: 2023-06-02_oasst_all_labels.jsonl.gz
val_split: 0.05
top_k: 1deepspeed trainer_sft.py --configs defaults falcon-7b oasst-top1 --cache_dir <data_cache_dir> --output_dir <output_path> --deepspeedpython export_model.py --dtype bf16 --hf_repo_name OpenAssistant/falcon-7b-sft-top1 --trust_remote_code --auth_token <auth_token> <output_path> --max_shard_size 2GB