Views
No views yet
1pip install -q -U bitsandbytes accelerate torch huggingface_hub
2pip install -q -U git+https://github.com/huggingface/transformers.git # Install latest version of transformers
3pip install -q -U git+https://github.com/huggingface/peft.git
4pip install flash-attn --no-build-isolation1import torch
2import os
3from torch import bfloat16
4from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig, LlamaForCausalLM1model_id_falcon = "alokabhishek/falcon-7b-instruct-bnb-4bit"
2
3tokenizer_falcon = AutoTokenizer.from_pretrained(model_id_falcon, use_fast=True)
4
5model_falcon = AutoModelForCausalLM.from_pretrained(
6 model_id_falcon,
7 device_map="auto"
8)
9
10
11pipe_falcon = pipeline(model=model_falcon, tokenizer=tokenizer_falcon, task='text-generation')
12
13prompt_falcon = "Tell me a funny joke about Large Language Models meeting a Blackhole in an intergalactic Bar."
14
15output_falcon = pipe_falcon(prompt_falcon, max_new_tokens=512)
16
17print(output_falcon[0]["generated_text"])
18