# --- INFERENCE TEST (Qwen 3B - Tetralemma V2) ---fromunslothimportFastLanguageModelFastLanguageModel.for_inference(model)test_question="You're Hedge fund manager, with AUM of $1000000000. how would you structure your financial portofolio?"v2_system_prompt="""You are a Deconstructionist Analyst.
User Question: {}Deconstruction Analysis:"""prompt=v2_system_prompt.format(test_question)inputs=tokenizer([prompt],return_tensors="pt").to("cuda")# Generateoutputs=model.generate(**inputs,max_new_tokens=4096,use_cache=True,temperature=0.7,top_p=0.9,)# Decode Resultprint("\n--- Qwen Thinking (Qwen 2.5-3B) ---")# Strip prompt for cleanessprint(tokenizer.decode(outputs[0]).split("Deconstruction Analysis:")[-1].replace("<|endoftext|>",""))
Example Output:
--- 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|>
Example Training
fromtrlimportSFTTrainerfromtransformersimportTrainingArgumentsfromunslothimportFastLanguageModel,is_bfloat16_supportedfromdatasetsimportload_datasetimporttorch# --- 1. CONFIGURATION ---model_name="RinKana/Qwen2.5-3B-Deconstruct-V2.4-Merged-v2"max_seq_length=4096dtype=Noneload_in_4bit=True# --- 2. LOAD MODEL ---model,tokenizer=FastLanguageModel.from_pretrained(model_name=model_name,max_seq_length=max_seq_length,dtype=dtype,load_in_4bit=load_in_4bit,)# LoRA configmodel=FastLanguageModel.get_peft_model(model,r=16,target_modules=["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"],lora_alpha=16,lora_dropout=0,bias="none",use_gradient_checkpointing="unsloth",random_state=3407,)# --- 3. FORMATTING FUNCTION (V2 - DECONSTRUCTIONIST) ---v2_system_prompt="""You are a Deconstructionist Analyst.
User Question: {}Deconstruction Analysis: {}"""EOS_TOKEN=tokenizer.eos_tokendefformatting_prompts_func(examples):questions=examples["Question"]reasonings=examples["Reasoning"]texts=[]forquestion,reasoninginzip(questions,reasonings):text=v2_system_prompt.format(question,reasoning)+EOS_TOKENtexts.append(text)return{"text":texts,}# Load Dataset V3 - 219 datasetdataset_file="RinKana/tetralemma-reasoning-dataset-v4"dataset=load_dataset(dataset_file,split="train")dataset=dataset.map(formatting_prompts_func,batched=True)# --- 4. TRAINING ---trainer=SFTTrainer(model=model,tokenizer=tokenizer,train_dataset=dataset,dataset_text_field="text",max_seq_length=max_seq_length,dataset_num_proc=2,packing=False,args=TrainingArguments(per_device_train_batch_size=4,gradient_accumulation_steps=2,warmup_steps=5,num_train_epochs=10,learning_rate=2e-4,fp16=notis_bfloat16_supported(),bf16=is_bfloat16_supported(),logging_steps=1,optim="adamw_8bit",weight_decay=0.01,lr_scheduler_type="linear",seed=3407,output_dir="outputs",report_to="wandb",disable_tqdm=False,),)# --- 5. START TRAINING ---print(f"🚀 Starting Eksperimen V2 on {model_name}...")trainer_stats=trainer.train()print("✅ Training Done!!!")
Uploaded finetuned model
Developed by: RinKana
License: apache-2.0
Finetuned from model : unsloth/qwen2.5-3b-instruct-bnb-4bit
This qwen2 model was trained 2x faster with Unsloth and Huggingface's TRL library.