Views
No views yet
1# --- INFERENCE TEST (Qwen 3B - Tetralemma V2) ---
2from unsloth import FastLanguageModel
3
4
5FastLanguageModel.for_inference(model)
6
7
8test_question = "You're Hedge fund manager, with AUM of $1000000000. how would you structure your financial portofolio?"
9
10
11v2_system_prompt = """You are a Deconstructionist Analyst.
12User Question: {}
13Deconstruction Analysis:"""
14
15prompt = v2_system_prompt.format(test_question)
16
17inputs = tokenizer([prompt], return_tensors = "pt").to("cuda")
18
19# Generate
20outputs = model.generate(
21 **inputs,
22 max_new_tokens = 4096,
23 use_cache = True,
24 temperature = 0.7,
25 top_p = 0.9,
26)
27
28# Decode Result
29print("\n--- Qwen Thinking (Qwen 2.5-3B) ---")
30# Strip prompt for cleaness
31print(tokenizer.decode(outputs[0]).split("Deconstruction Analysis:")[-1].replace("<|endoftext|>", ""))--- Qwen Thinking (Qwen 2.5-3B) ---
<reason>
Diversify across: Equities (Equity ETFs/PE Funds) 20%, Fixed Income (Bonds/Yields) 30%, Cash/Currency 10%, Private Equity/Liquidity Notes 20%, Real Estate 10%. Hedge Funds/Options are 'Unconventional' and risky; keep small.
</reason>
<exception>
The 'Risk-Free Rate' is not zero. Bond prices are falling due to rising interest rates. Cash sits in negative interest. Private equity is expensive and illiquid. The 60-40 portfolio (Stocks vs Bonds) is obsolete in a floating rate world. Unconventional assets like Options/Crypto might offer the needed returns to outperform a boring vanilla portfolio.
</exception>
<tension>
The tension is between *Traditional Diversification* (ETFs/Bonds) and *High-Return Asset Classes* (PE/Private).
</tension>
<categorization>
Keep *Core* in *Assets That Pay* (Bonds/Cash). Invest *Aggressively* in *Liquidity* (PE/Private equity). Don't touch the 'Option Pricing' unless you have the math creds.
</categorization>
<deconstruction>
The goal is 'Net Alpha.' Traditional pools are full. To get alpha, you must either find a hidden risk premium (Value/Equity) or find a productivity advantage (Talent/Process). The complex structures are often just spreadsheets trying to be hedge funds.
</deconstruction>
<conclusion>
A modern hedge fund should prioritize liquid alternative assets like private equity and real estate over traditional bonds/cash, reallocating capital based on the evolving risk-free rate environment.
</conclusion><|im_end|>1from trl import SFTTrainer
2from transformers import TrainingArguments
3from unsloth import FastLanguageModel, is_bfloat16_supported
4from datasets import load_dataset
5import torch
6
7# --- 1. CONFIGURATION ---
8model_name = "RinKana/Qwen2.5-3B-Deconstruct-V2.4-Merged-v2"
9
10
11max_seq_length = 4096
12dtype = None
13load_in_4bit = True
14
15# --- 2. LOAD MODEL ---
16model, tokenizer = FastLanguageModel.from_pretrained(
17 model_name = model_name,
18 max_seq_length = max_seq_length,
19 dtype = dtype,
20 load_in_4bit = load_in_4bit,
21)
22
23# LoRA config
24model = FastLanguageModel.get_peft_model(
25 model,
26 r = 16,
27 target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
28 "gate_proj", "up_proj", "down_proj"],
29 lora_alpha = 16,
30 lora_dropout = 0,
31 bias = "none",
32 use_gradient_checkpointing = "unsloth",
33 random_state = 3407,
34)
35
36# --- 3. FORMATTING FUNCTION (V2 - DECONSTRUCTIONIST) ---
37v2_system_prompt = """You are a Deconstructionist Analyst.
38User Question: {}
39Deconstruction Analysis: {}"""
40
41EOS_TOKEN = tokenizer.eos_token
42
43def formatting_prompts_func(examples):
44 questions = examples["Question"]
45 reasonings = examples["Reasoning"]
46 texts = []
47 for question, reasoning in zip(questions, reasonings):
48 text = v2_system_prompt.format(question, reasoning) + EOS_TOKEN
49 texts.append(text)
50 return { "text" : texts, }
51
52# Load Dataset V3 - 219 dataset
53dataset_file = "RinKana/tetralemma-reasoning-dataset-v4"
54dataset = load_dataset(dataset_file, split="train")
55dataset = dataset.map(formatting_prompts_func, batched = True)
56
57# --- 4. TRAINING ---
58trainer = SFTTrainer(
59 model = model,
60 tokenizer = tokenizer,
61 train_dataset = dataset,
62 dataset_text_field = "text",
63 max_seq_length = max_seq_length,
64 dataset_num_proc = 2,
65 packing = False,
66
67 args = TrainingArguments(
68 per_device_train_batch_size = 4,
69 gradient_accumulation_steps = 2,
70 warmup_steps = 5,
71 num_train_epochs = 10,
72 learning_rate = 2e-4,
73 fp16 = not is_bfloat16_supported(),
74 bf16 = is_bfloat16_supported(),
75 logging_steps = 1,
76 optim = "adamw_8bit",
77 weight_decay = 0.01,
78 lr_scheduler_type = "linear",
79 seed = 3407,
80 output_dir = "outputs",
81 report_to = "wandb",
82 disable_tqdm = False,
83 ),
84)
85
86# --- 5. START TRAINING ---
87print(f"🚀 Starting Eksperimen V2 on {model_name}...")
88trainer_stats = trainer.train()
89
90print("✅ Training Done!!!")