Views
No views yet
tahamajs/llama-3.2-3b-instruct-bitcoin-analyst_best, is a specialized version of the Llama-3.2-3B-Instruct large language model. It has been fine-tuned for the domain of Bitcoin and cryptocurrency analysis. The fine-tuning process, which used QLoRA on the tahamajs/bitcoin-llm-finetuning-dataset dataset, was designed to train the model to act as a virtual Bitcoin analyst.1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
4
5# Define the model IDs
6base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
7peft_model_id = "tahamajs/llama-3.2-3b-instruct-bitcoin-analyst_best"
8
9# Load the tokenizer
10tokenizer = AutoTokenizer.from_pretrained(base_model_id)
11
12# Load the base model with 4-bit quantization
13bnb_config = BitsAndBytesConfig(
14 load_in_4bit=True,
15 bnb_4bit_quant_type="nf4",
16 bnb_4bit_compute_dtype=torch.bfloat16,
17)
18base_model = AutoModelForCausalLM.from_pretrained(
19 base_model_id,
20 quantization_config=bnb_config,
21 device_map="auto"
22)
23
24# Load the fine-tuned PEFT adapter on top of the base model
25model = PeftModel.from_pretrained(base_model, peft_model_id)
26
27# Example inference
28prompt = "What are the key technical differences between Bitcoin and Ethereum?"
29messages = [
30 {"role": "user", "content": prompt}
31]
32input_ids = tokenizer.apply_chat_template(
33 messages,
34 add_generation_prompt=True,
35 return_tensors="pt"
36).to(model.device)
37
38outputs = model.generate(input_ids=input_ids, max_new_tokens=256)
39print(tokenizer.decode(outputs[0], skip_special_tokens=True))trl.SFTTrainer. A key aspect of the training was the use of a custom data collator, which ensures that the model's loss is calculated only on the assistant's response, not on the user's prompt or the special tokens used to format the conversation. This technique helps the model learn to generate better responses without overfitting to the input.| Hyperparameter | Value |
|---|---|
num_train_epochs | 1 |
per_device_train_batch_size | 1 |
gradient_accumulation_steps | 4 |
learning_rate | 2e-4 |
optim | paged_adamw_32bit |
r (LoRA rank) | 32 |
lora_alpha | 32 |