2026-05-11
{"messages": [
{"role": "user", "content": "What are the main risks of investing in bonds?"},
{"role": "assistant", "content": "The main risks include interest rate risk, credit risk, and inflation risk..."},
{"role": "user", "content": "Can you explain interest rate risk more?"},
{"role": "assistant", "content": "When interest rates rise, existing bond prices fall because..."},
{"role": "user", "content": "So should I avoid bonds when rates are rising?"},
{"role": "assistant", "content": "Not necessarily. Short-duration bonds are less affected..."}
]}# Extarct the BERT model
bert_model = AutoModelForSequenceClassification.from_pretrained(
"answerdotai/ModernBERT-base", num_labels=3)
# Setup the training, this is the analog of the pytorch lightning trainer
bert_trainer = HFTrainer(
model=bert_model,
args=bert_training_args,
train_dataset=hf_train_tok,
eval_dataset=hf_val_tok,
data_collator=DataCollatorWithPadding(bert_tokenizer), # Trick to save computation time
compute_metrics=compute_metrics,
)
# Perform training
bert_trainer.train()\[ L = M_1 \times M_2^t \]
\[ Q_{FT} = Q + \alpha L \]
#Get model
qwen_model = AutoModelForCausalLM.from_pretrained(
qwen_model_id,
quantization_config=bnb_config,
torch_dtype=torch.float16, # force all non-quantized weights to float16
device_map="auto"
)
# Setup LoRA
lora_config = LoraConfig(
r=16, lora_alpha=32, lora_dropout=0.05,
target_modules=["q_proj", "v_proj"],
task_type="CAUSAL_LM", # Let it know that this model produces text recursively
)Fine-Tuning leads to stunning performance improvements with relatively little effort
Original Model:



DATA 622