Views
No views yet
1# Installs Unsloth, Xformers (Flash Attention) and all other packages!
2!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
3!pip install --no-deps xformers trl peft accelerate bitsandbytes
4
5from unsloth import FastLanguageModel
6
7max_seq_length = 2048
8dtype = None
9load_in_4bit = True
10
11model, tokenizer = FastLanguageModel.from_pretrained(
12 model_name = "AhmedBou/Gemma-7b-EngText-ArabicSummary",
13 max_seq_length = max_seq_length,
14 dtype = dtype,
15 load_in_4bit = load_in_4bit,
16)
17FastLanguageModel.for_inference(model)
18
19input = """
20past a news article here
21"""
22
23FastLanguageModel.for_inference(model) # Enable native 2x faster inference
24inputs = tokenizer(
25[
26 alpaca_prompt.format(
27 input, # input
28 "", # output - leave this blank for generation!
29 )
30], return_tensors = "pt").to("cuda")
31
32outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
33tokenizer.batch_decode(outputs)
34
35