0% found this document useful (0 votes)
15 views4 pages

HVAC Repair in Delhi Office

The document discusses the renewal of an annual subscription to Adobe Creative Cloud by the marketing department, which includes tools like Photoshop and Illustrator. It also contains code snippets for loading a JSON file, checking CUDA availability, and initializing a language model using the 'unsloth' library. Additionally, it mentions the use of a Tesla T4 GPU for processing.

Uploaded by

learn180599
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

HVAC Repair in Delhi Office

The document discusses the renewal of an annual subscription to Adobe Creative Cloud by the marketing department, which includes tools like Photoshop and Illustrator. It also contains code snippets for loading a JSON file, checking CUDA availability, and initializing a language model using the 'unsloth' library. Additionally, it mentions the use of a Tesla T4 GPU for processing.

Uploaded by

learn180599
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

k1y3fg84b

July 12, 2025

[1]: import json

file = [Link](open("/content/[Link]", "r"))


print(file[1])

{'input': 'Marketing department renewed the annual subscription to Adobe


Creative Cloud, covering tools like Photoshop and Illustrator for branding
campaigns.', 'output': {'l1': 'IT & Software', 'l2': 'Software Licenses', 'l3':
'Design Tools', 'l4': 'Adobe Creative Cloud'}}

[ ]: !pip install -q unsloth trl peft accelerate bitsandbytes

[3]: import torch


print(f"CUDA available: {[Link].is_available()}")
print(f"GPU: {[Link].get_device_name(0) if [Link].is_available() else␣
↪'None'}")

CUDA available: True


GPU: Tesla T4

[5]: from unsloth import FastLanguageModel


import torch

model_name = "unsloth/Qwen3-4B-unsloth-bnb-4bit"
max_seq_length = 2048
dtype = None

model, tokenizer = FastLanguageModel.from_pretrained(


model_name=model_name,
max_seq_length=max_seq_length,
dtype=dtype,
load_in_4bit=True,
load_in_8bit = False,
full_finetuning = False
)

==((====))== Unsloth 2025.7.3: Fast Qwen3 patching. Transformers: 4.53.1.


\\ /| Tesla T4. Num GPUs = 1. Max memory: 14.741 GB. Platform: Linux.

1
O^O/ \_/ \ Torch: 2.7.1+cu126. CUDA: 7.5. CUDA Toolkit: 12.6. Triton: 3.3.1
\ / Bfloat16 = FALSE. FA [Xformers = 0.0.31.post1. FA2 = False]
"-____-" Free license: [Link]
Unsloth: Fast downloading is enabled - ignore downloading bars which are red
colored!

[6]: from datasets import Dataset

def format_prompt(example):
return f"### Input: {example['input']}\n### Output: {json.
↪dumps(example['output'])}<|endoftext|>"

formatted_data = [format_prompt(item) for item in file]


dataset = Dataset.from_dict({"text": formatted_data})

[9]: model = FastLanguageModel.get_peft_model(


model,
r=64,
target_modules=[
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj",
],
lora_alpha=128,
lora_dropout=0,
bias = "none",
use_gradient_checkpointing="unsloth",
random_state=3407,
use_rslora=False,
loftq_config=None,
)

Unsloth 2025.7.3 patched 36 layers with 36 QKV layers, 36 O layers and 36 MLP
layers.

[11]: from trl import SFTTrainer


from transformers import TrainingArguments

trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
train_dataset=dataset,
dataset_text_field="text",
max_seq_length=max_seq_length,
dataset_num_proc=2,
args=TrainingArguments(
per_device_train_batch_size=2,
gradient_accumulation_steps=4,

2
warmup_steps=10,
num_train_epochs=3,
learning_rate=2e-4,
fp16=not [Link].is_bf16_supported(),
bf16=[Link].is_bf16_supported(),
logging_steps=25,
optim="adamw_8bit",
weight_decay=0.01,
lr_scheduler_type="linear",
seed=3407,
output_dir="outputs",
save_strategy="epoch",
save_total_limit=2,
dataloader_pin_memory=False,
report_to="none",
),
)

Unsloth: Tokenizing ["text"]: 0%| | 0/640 [00:00<?, ? examples/s]

[ ]: trainer_stats = [Link]()

[13]: FastLanguageModel.for_inference(model) # Enable native 2x faster inference

# Test prompt
messages = [
{"role": "user", "content": "The HVAC system in our Delhi office was␣
↪inspected and repaired after repeated complaints about airflow"},

inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to("cuda")

outputs = [Link](
input_ids=inputs,
max_new_tokens=256,
use_cache=True,
temperature=0.7,
do_sample=True,
top_p=0.9,
)

response = tokenizer.batch_decode(outputs)[0]

3
print(response)

The attention mask is not set and cannot be inferred from input because pad
token is same as eos token. As a consequence, you may observe unexpected
behavior. Please pass your input's `attention_mask` to obtain reliable results.
<|im_start|>user
The HVAC system in our Delhi office was inspected and repaired after repeated
complaints about airflow<|im_end|>
<|im_start|>assistant
<think>l1: Facilities
l2: Maintenance
l3: HVAC
l4: Delhi Office Repair<|endoftext|>

[ ]: model.save_pretrained_gguf("gguf_model", tokenizer,␣
↪quantization_method="q4_k_m")

[16]: from [Link] import files


import os

gguf_files = [f for f in [Link]("gguf_model") if [Link](".gguf")]


if gguf_files:
gguf_file = [Link]("gguf_model", gguf_files[0])
print(f"Downloading: {gguf_file}")
[Link](gguf_file)

Downloading: gguf_model/unsloth.Q4_K_M.gguf
<[Link] object>
<[Link] object>

[ ]:

Common questions

Powered by AI

Structured fine-tuning techniques influence language model performance by allowing precise adjustments and enhancements in targeted areas of the model, improving task-specific capabilities without affecting general performance. Unsloth and FastLanguageModel utilize this by adjusting parameters like 'lora_alpha' and leveraging modules related to projection and gate layers, enabling efficient adaptation to specific tasks while maintaining overall robustness and accuracy .

The upgraded Fast Qwen3 patching benefits AI model processing by enhancing the model's efficiency through improvements in speed and memory management. These upgrades allow for better handling of large datasets and complex models, enabling more effective use of GPU resources and facilitating faster training and inference times .

The configuration of a large language model with the FastLanguageModel library involves several key components. These include setting the model name (e.g., 'unsloth/Qwen3-4B-unsloth-bnb-4bit'), specifying the max sequence length (e.g., 2048), and configuring dtype settings. Additionally, the loading configuration includes options for 4-bit or 8-bit loading, full fine-tuning, and peft configurations involving parameters like 'r', target modules (e.g., 'q_proj', 'k_proj', 'v_proj'), lora_alpha, lora_dropout, and use of gradient checkpointing .

The Adobe Creative Cloud subscription is crucial for a marketing department as it provides access to essential tools such as Photoshop and Illustrator. These tools are fundamental for branding campaigns, allowing for the creation of high-quality visuals and design elements essential in marketing efforts .

Using a library like Unsloth affects AI model development and deployment by providing optimized tools for downloading, configuring, and training large language models efficiently. It supports structured fine-tuning techniques and quantization strategies, allowing developers to manage resources effectively, addressing issues like model weight optimization and hardware compatibility. Unsloth's streamlined processes, such as fast downloads and peft model support, further simplify complex tasks in AI workflow management .

The SFTTrainer class facilitates training of the FastLanguageModel by integrating the model with specific training arguments and data. Critical parameters influencing this process include the batch size per device, gradient accumulation steps, number of warmup steps, number of training epochs, learning rate, and weight decay. Optimizer types such as 'adamw_8bit' and other settings like fp16/bf16 support, logging steps, scheduling type ('linear'), and seeding for reproducibility are also essential .

Deploying large AI models like FastLanguageModel for inference involves challenges such as handling attention masks to prevent unexpected behaviors since the pad token may coincide with the end-of-sequence token. This necessitates explicit attention mask passing for reliable results. Additionally, leveraging hardware acceleration for faster inference (e.g., enabling native 2x faster inference) requires careful configuration of system resources like CUDA devices and memory management .

Challenges from having the same pad token as eos token include potential misinterpretation during training and inference, as the model might unexpectedly trigger end-of-sequence actions, disrupting flow and accuracy. This can be mitigated by explicitly defining and passing attention masks during data processing steps to ensure correct contextual understanding and preventing unintended token-based behaviors .

CUDA plays a crucial role in training and deploying AI models by providing GPU acceleration which is essential for handling complex computations efficiently, speeding up both the training and inference processes. The document highlights the availability of CUDA and the use of a Tesla T4 GPU, allowing for enhanced computational power .

Different quantization methods like q4_k_m are significant because they affect the model's size and computational efficiency during inference and storage. Quantization reduces the precision of the model weights, which can result in faster computation and decreased memory usage, making these methods crucial in optimizing performance without significantly compromising model accuracy .

You might also like