tahamajs commited on
Commit
bf93392
·
verified ·
1 Parent(s): e135f6e

Update readme

Browse files
Files changed (1) hide show
  1. README.md +86 -38
README.md CHANGED
@@ -1,58 +1,106 @@
 
1
  ---
2
- base_model: meta-llama/Llama-3.2-3B-Instruct
3
- library_name: transformers
4
- model_name: results
5
  tags:
6
- - generated_from_trainer
7
- - sft
8
- - trl
9
- licence: license
 
 
 
 
 
 
 
10
  ---
11
 
12
- # Model Card for results
 
 
13
 
14
- This model is a fine-tuned version of [meta-llama/Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct).
15
- It has been trained using [TRL](https://github.com/huggingface/trl).
16
 
17
- ## Quick start
 
 
 
 
18
 
19
  ```python
20
- from transformers import pipeline
 
 
 
 
 
 
21
 
22
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
- generator = pipeline("text-generation", model="mikleeeeemmm/results", device="cuda")
24
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
- print(output["generated_text"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ```
27
 
28
- ## Training procedure
 
 
 
 
29
 
30
-
31
 
 
32
 
33
- This model was trained with SFT.
 
 
 
 
 
 
 
 
34
 
35
- ### Framework versions
36
 
37
- - TRL: 0.21.0
38
- - Transformers: 4.55.0
39
- - Pytorch: 2.6.0+cu124
40
- - Datasets: 4.0.0
41
- - Tokenizers: 0.21.4
42
 
43
- ## Citations
 
 
44
 
 
45
 
 
46
 
47
- Cite TRL as:
48
-
49
- ```bibtex
50
- @misc{vonwerra2022trl,
51
- title = {{TRL: Transformer Reinforcement Learning}},
52
- author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
53
- year = 2020,
54
- journal = {GitHub repository},
55
- publisher = {GitHub},
56
- howpublished = {\url{https://github.com/huggingface/trl}}
57
- }
58
- ```
 
1
+
2
  ---
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
  tags:
7
+ - llm
8
+ - fine-tune
9
+ - qlora
10
+ - llama
11
+ - bitcoin
12
+ - finance
13
+ - cryptocurrency
14
+ pipeline_tag: text-generation
15
+ base_model: meta-llama/Llama-3.2-3B-Instruct
16
+ datasets:
17
+ - tahamajs/bitcoin-llm-finetuning-dataset
18
  ---
19
 
20
+ -----
21
+
22
+ ### **Overview**
23
 
24
+ This model, `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.
 
25
 
26
+ -----
27
+
28
+ ### **Usage**
29
+
30
+ This model uses a PEFT (Parameter-Efficient Fine-Tuning) adapter. To use it, you must first load the base model and then attach the fine-tuned adapter. The adapter itself is very small, making the overall model efficient to load and use.
31
 
32
  ```python
33
+ import torch
34
+ from peft import PeftModel
35
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
36
+
37
+ # Define the model IDs
38
+ base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
39
+ peft_model_id = "tahamajs/llama-3.2-3b-instruct-bitcoin-analyst_best"
40
 
41
+ # Load the tokenizer
42
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id)
43
+
44
+ # Load the base model with 4-bit quantization
45
+ bnb_config = BitsAndBytesConfig(
46
+ load_in_4bit=True,
47
+ bnb_4bit_quant_type="nf4",
48
+ bnb_4bit_compute_dtype=torch.bfloat16,
49
+ )
50
+ base_model = AutoModelForCausalLM.from_pretrained(
51
+ base_model_id,
52
+ quantization_config=bnb_config,
53
+ device_map="auto"
54
+ )
55
+
56
+ # Load the fine-tuned PEFT adapter on top of the base model
57
+ model = PeftModel.from_pretrained(base_model, peft_model_id)
58
+
59
+ # Example inference
60
+ prompt = "What are the key technical differences between Bitcoin and Ethereum?"
61
+ messages = [
62
+ {"role": "user", "content": prompt}
63
+ ]
64
+ input_ids = tokenizer.apply_chat_template(
65
+ messages,
66
+ add_generation_prompt=True,
67
+ return_tensors="pt"
68
+ ).to(model.device)
69
+
70
+ outputs = model.generate(input_ids=input_ids, max_new_tokens=256)
71
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
72
  ```
73
 
74
+ -----
75
+
76
+ ### **Training Details** ⚙️
77
+
78
+ This model was fine-tuned using Supervised Fine-Tuning (SFT) with the `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.
79
 
80
+ #### **Hyperparameters**
81
 
82
+ The following hyperparameters were used for fine-tuning:
83
 
84
+ | Hyperparameter | Value |
85
+ | :--------------------------- | :-------------- |
86
+ | `num_train_epochs` | 1 |
87
+ | `per_device_train_batch_size`| 1 |
88
+ | `gradient_accumulation_steps`| 4 |
89
+ | `learning_rate` | 2e-4 |
90
+ | `optim` | `paged_adamw_32bit` |
91
+ | `r` (LoRA rank) | 32 |
92
+ | `lora_alpha` | 32 |
93
 
94
+ -----
95
 
96
+ ### **Limitations and Biases** ⚠️
 
 
 
 
97
 
98
+ * **Domain Specificity:** The model's expertise is concentrated on Bitcoin and cryptocurrency. Its performance on general knowledge tasks may be limited.
99
+ * **Data Cutoff:** The model's knowledge is static and based on the training data. It will not be aware of recent events or market changes.
100
+ * **Potential Biases:** Responses may reflect biases present in the training data.
101
 
102
+ -----
103
 
104
+ ### **License** 📜
105
 
106
+ This model is licensed under the **Apache 2.0 license**, inherited from its base model.