Views
No views yet
1pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
2pip install --no-deps trl peft accelerate bitsandbytes triton xformers1
2from operator import index
3from unsloth import FastLanguageModel
4import torch
5
6max_seq_length = 2048 # Choose any! Llama 3 is up to 8k
7dtype = None
8load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
9
10alpaca_prompt = """ حلل العاطفة متاع النص الموجود بين الأقواس المربعة، وقرّر إذا كان إيجابي ولا سلبي، ورجع الجواب كعلامة عاطفية متطابقة "إيجابي" ولا "سلبي".
11
12### Instruction:
13{}
14
15### Response:
16{}"""
17
18model, tokenizer = FastLanguageModel.from_pretrained(
19 model_name = "hedhoud12/Llama-3.2-1B-Instruct_Tunisian_sentiment_analysis", # your trained model
20 max_seq_length = max_seq_length,
21 dtype = dtype,
22 load_in_4bit = load_in_4bit,
23)
24FastLanguageModel.for_inference(model)
25
26
27inputs = tokenizer(
28[
29 alpaca_prompt.format(
30 "برا وليدي رابي يناجحك", # instruction
31 "", # output - leave this blank for generation!
32 )
33], return_tensors = "pt").to("cuda")
34
35outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
36tokenizer.batch_decode(outputs)[0].split("### Response:")[1].strip()1==((====))== Unsloth 2024.9.post4: Fast Llama patching. Transformers = 4.44.2.
2 \\ /| GPU: Tesla T4. Max memory: 14.748 GB. Platform = Linux.
3O^O/ \_/ \ Pytorch: 2.4.1+cu121. CUDA = 7.5. CUDA Toolkit = 12.1.
4\ / Bfloat16 = FALSE. FA [Xformers = 0.0.28.post1. FA2 = False]
5 "-____-" Free Apache license: http://github.com/unslothai/unsloth
6Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
7كلام إيجابي<|eot_id|>