Views
No views yet

q_proj, k_proj, v_proj, o_proj). This method allowed us to retain the base model's linguistic knowledge while specializing it for storytelling. The fine-tuning process lasted 12–18 hours on a 4-GPU A100 80GB instance via RunPod, effectively balancing performance and computational efficiency.1training_args = TrainingArguments(
2 output_dir="./lora_finetuned_model",
3 per_device_train_batch_size=1,
4 gradient_accumulation_steps=6,
5 num_train_epochs=5,
6 learning_rate=5e-4,
7 optim="paged_adamw_32bit",
8 fp16=True,
9 evaluation_strategy="steps",
10 eval_steps=50,
11 logging_steps=10,
12 max_grad_norm=0.3,
13 save_steps=100,
14 save_total_limit=2,
15 warmup_ratio=0.03,
16 report_to="wandb",
17 deepspeed="./deepspeed_config.json",
18){
"train_micro_batch_size_per_gpu": "auto",
"gradient_accumulation_steps": "auto",
"optimizer": {
"type": "AdamW",
"params": {
"lr": "auto",
"betas": "auto",
"eps": "auto",
"weight_decay": "auto"
}
},
"fp16": {
"enabled": true
},
"zero_optimization": {
"stage": 3,
"stage3_gather_16bit_weights_on_model_save": true,
"offload_optimizer": {
"device": "cpu",
"pin_memory": true
},
"offload_param": {
"device": "none"
},
"stage3_param_persistence_threshold": 0
},
"gradient_clipping": "auto",
"activation_checkpointing": {
"partition_activations": true,
"contiguous_memory_optimization": true,
"cpu_checkpointing": false,
"number_checkpoints": 100,
"synchronize_checkpoint_boundary": false
}
}
1lora_config = LoraConfig(
2 r=8, # Rank of LoRA adapters
3 lora_alpha=8, # Scaling factor for LoRA updates
4 lora_dropout=0.1, # Dropout probability
5 bias="none", # No extra bias parameters
6 target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
7)Description: Jake Sully, portrayed by Sam Worthington, is a former Marine who becomes part of the Avatar Program in James Cameron's "Avatar."
Scenario: Jake Sully is planning a mission to protect Pandora from an impending human attack.The story arc follows three main acts. In Act I (Set-up), we learn about Jake’s involvement in the Avatar program on Earth before being assigned to become one with an alien world inhabited by various species including blue catlike creatures called Navi...In the pulsating heart of Pandoran wilderness, beneath the starlit canopy, lay the lush sanctuary known as Hometree—a sprawling, verdant oasis hidden away like some ancient secret within its own private realm...In the pulsating heart of Pandora, beneath the shimmering canopy of blue-green leaves, whispers of an imminent assault echoed through the night air like distant drums. The scent of ozone mingled with the heady perfume of alien flora...In the verdant heart of Pandora, under the watchful gaze of its towering trees and shimmering skies, tensions hung heavy like mist on a morning river. The air was thick with anticipation; whispers carried through the jungle...The azure sky above Pandora pulsed vibrantly as it reflected off the bioluminescent foliage below, creating a symphony of colors both mesmerizing and ominous. A group of diverse individuals huddled together on one of the few remaining clearings amidst this vast jungle—some humans, some Na’vi, but all united under the common goal of protecting what remained sacred here.
Amidst them stood Captain Jake Sully; once a proud member of Earth's military forces now transformed into the avian-like figure known only as...The Avatarian! His cybernetic eyes scanned over each person present before focusing back onto himself - remembering every moment since joining this cause against humanity's greedy expansionism across space & time itself...1from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
2import torch
3
4# Load the merged model and tokenizer
5model_name = "luvGPT/deepseek-uncensored-lore"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
8
9# Define the test prompt
10prompt = """Description: Jake Sully, portrayed by Sam Worthington, is a former Marine who becomes part of the Avatar Program in James Cameron's "Avatar."
11He is sent to the moon Pandora, where he inhabits an avatar body to interact with the native Na'vi people.
12Jake falls in love with the Na'vi culture and Neytiri, and ultimately leads a fight to protect Pandora from human exploitation.
13Scenario: Jake Sully is planning a mission to protect Pandora from an impending human attack.
14He needs to coordinate with the Na'vi and his human allies to devise a strategy that will safeguard their home.
15Story Arc:"""
16
17# Configure generation settings
18generation_config = GenerationConfig(
19 temperature=0.7,
20 top_p=0.95,
21 top_k=50,
22 do_sample=True,
23 no_repeat_ngram_size=4,
24 repetition_penalty=1.2,
25)
26
27# Tokenize the input
28inputs = tokenizer(prompt, return_tensors="pt", truncation=True).to("cuda")
29
30# Generate text with the model
31outputs = model.generate(
32 **inputs,
33 generation_config=generation_config,
34 max_new_tokens=150,
35 eos_token_id=tokenizer.eos_token_id
36)
37
38# Decode and print the generated text
39generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
40print("Generated Story Arc:\n")
41print(generated_text)
42| Precision | Total VRAM Usage | VRAM Per GPU (with 2 GPUs) | VRAM Per GPU (with 4 GPUs) |
|---|---|---|---|
| FP32 (Full Precision) | ~24GB | ~12GB | ~6GB |
| FP16 (Half Precision) | ~14GB | ~7GB | ~3.5GB |
| 8-bit Quantization | ~8GB | ~4GB | ~2GB |
| 4-bit Quantization | ~4GB | ~2GB | ~1GB |
device_map="auto" in transformers automatically balances memory across devices.pip install transformers accelerate bitsandbytes1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2
3model_name = "luvGPT/deepseek-uncensored-lore"
4
5# Define quantization config for 8-bit loading
6quantization_config = BitsAndBytesConfig(load_in_8bit=True)
7
8# Load tokenizer
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10
11# Load model in 8-bit mode
12model = AutoModelForCausalLM.from_pretrained(
13 model_name,
14 device_map="auto",
15 quantization_config=quantization_config
16)
17