Views
No views yet
1# Install packages
2%%capture
3import torch
4major_version, minor_version = torch.cuda.get_device_capability()
5!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
6if major_version >= 8:
7 # Use this for new GPUs like Ampere, Hopper GPUs (RTX 30xx, RTX 40xx, A100, H100, L40)
8 !pip install --no-deps packaging ninja einops flash-attn xformers trl peft accelerate bitsandbytes
9else:
10 # Use this for older GPUs (V100, Tesla T4, RTX 20xx)
11 !pip install --no-deps xformers trl peft accelerate bitsandbytes
12pass1from unsloth import FastLanguageModel
2import torch
3max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
4dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
5load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
6
7
8model, tokenizer = FastLanguageModel.from_pretrained(
9 model_name = "Omartificial-Intelligence-Space/al-baka-16bit-llama3-8b",
10 max_seq_length = max_seq_length,
11 dtype = dtype,
12 load_in_4bit = load_in_4bit,
13 # token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
14)1alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
2
3### Instruction:
4{}
5
6### Input:
7{}
8
9### Response:
10{}"""
11
12# alpaca_prompt = Copied from above
13FastLanguageModel.for_inference(model) # Enable native 2x faster inference
14inputs = tokenizer(
15[
16 alpaca_prompt.format(
17 "استخدم البيانات المعطاة لحساب الوسيط.", # instruction
18 "[2 ، 3 ، 7 ، 8 ، 10]", # input
19 "", # output - leave this blank for generation!
20 )
21], return_tensors = "pt").to("cuda")
22
23outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
24tokenizer.batch_decode(outputs)