File size: 4,146 Bytes
dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee 851dccb dfc0eee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
---
license: apache-2.0
language:
- en
tags:
- llm
- fine-tune
- qlora
- llama
- bitcoin
- finance
- cryptocurrency
pipeline_tag: text-generation
base_model: meta-llama/Llama-3.2-3B-Instruct
datasets:
- tahamajs/bitcoin-llm-finetuning-dataset
---
#### **Overview**
This model, `tahamajs/llama-3.2-3b-instruct-bitcoin-analyst_best`, is a fine-tuned version of **Llama-3.2-3B-Instruct**, a large language model. It has been specialized for **Bitcoin analysis** and cryptocurrency-related questions. The fine-tuning process, using **QLoRA**, aimed to improve the model's ability to provide accurate and contextually relevant information, effectively acting as a virtual Bitcoin analyst.
#### **Usage**
To use this model, you can load the fine-tuned adapter weights on top of the base model. This approach is memory-efficient as it only loads the small LoRA adapter weights, not the entire base model.
```python
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# Define the model IDs
base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
peft_model_id = "tahamajs/llama-3.2-3b-instruct-bitcoin-analyst_best"
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# Load the base model with 4-bit quantization
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto"
)
# Load the fine-tuned PEFT adapter
model = PeftModel.from_pretrained(base_model, peft_model_id)
# Example inference
prompt = "What is the Bitcoin halving and how does it affect the price?"
messages = [
{"role": "user", "content": prompt}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(input_ids=input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
-----
#### **Training Details**
This section summarizes the fine-tuning process.
* **Base Model:** `meta-llama/Llama-3.2-3B-Instruct`
* **Dataset:** `tahamajs/bitcoin-llm-finetuning-dataset`
* **Fine-Tuning Method:** QLoRA (Quantized Low-Rank Adaptation)
* **Training Framework:** `trl.SFTTrainer` with a custom data collator
* **Target Modules:** `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`
* **Data Collator:** A custom data collator was used to ensure that the loss is only calculated on the assistant's response, ignoring the user's prompt. This helps the model focus on learning to generate helpful responses.
#### ⚙️ **Hyperparameters**
The following hyperparameters were used for fine-tuning:
| Hyperparameter | Value |
| :--------------------------- | :-------------- |
| `num_train_epochs` | 1 |
| `per_device_train_batch_size`| 1 |
| `gradient_accumulation_steps`| 2 |
| `learning_rate` | 2e-5 |
| `optim` | `paged_adamw_32bit` |
| `r` (LoRA rank) | 32 |
| `lora_alpha` | 32 |
-----
#### **Limitations and Biases**
As a model fine-tuned on a specific dataset, it may have limitations:
* **Domain Specificity:** The model's knowledge is primarily focused on Bitcoin and cryptocurrency. It may not perform as well on general knowledge tasks.
* **Data Cutoff:** The model's knowledge is limited to the data it was trained on. It will not be aware of recent events or market changes that occurred after the dataset's creation.
* **Potential Biases:** The model's responses may reflect biases present in the training data.
-----
#### **License**
This model is licensed under the **Apache 2.0 license**, inherited from its base model.
A video about getting started with generative text and fine-tuning LLMs with Hugging Face is available [here](https://www.youtube.com/watch?v=i51OAQ0h-gQ).
http://googleusercontent.com/youtube_content/2
|