Spaces:
Sleeping
Sleeping
Filip
commited on
Commit
·
56f22d1
1
Parent(s):
09cc62e
readme
Browse files
README.md
CHANGED
@@ -19,14 +19,14 @@ The models were finetuned using [Unsloth](https://unsloth.ai/), a framework whic
|
|
19 |
|
20 |
Both models were trained with a [Tesla T4 GPU](https://www.nvidia.com/en-us/data-center/tesla-t4/) with 16GB of GDDR6 memory and 2560 CUDA cores.
|
21 |
|
22 |
-
### forestav/LoRA-2000
|
23 |
|
24 |
Finetuned on 2000 steps.\
|
25 |
Quantization method: `float16`
|
26 |
|
27 |
-
### KolumbusLindh/LoRA-
|
28 |
|
29 |
-
Finetuned on
|
30 |
Quantization method: `float16`
|
31 |
|
32 |
### Hyperparameters
|
@@ -56,32 +56,76 @@ We chose float16 as the quantization method as it according to [Unsloth wiki](ht
|
|
56 |
|
57 |
## Judge
|
58 |
|
59 |
-
We are using the KolumbusLindh/LoRA-
|
60 |
|
61 |
## Evaluation using GPT-4
|
62 |
|
63 |
-
To better evaluate our fine-tuned models, we let GPT-4 be our judge, when the respective model answered the following prompts:
|
64 |
|
65 |
1. Describe step-by-step how to set up a tent in a windy environment.
|
66 |
|
67 |
-
2.
|
68 |
|
69 |
-
3.
|
70 |
|
71 |
-
4.
|
72 |
|
73 |
-
5.
|
74 |
|
75 |
-
6.
|
76 |
|
77 |
-
7.
|
78 |
|
79 |
-
8.
|
80 |
|
81 |
-
9.
|
82 |
|
83 |
-
10.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
### Results
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
Both models were trained with a [Tesla T4 GPU](https://www.nvidia.com/en-us/data-center/tesla-t4/) with 16GB of GDDR6 memory and 2560 CUDA cores.
|
21 |
|
22 |
+
### [forestav/LoRA-2000](https://huggingface.co/forestav/LoRA-2000)
|
23 |
|
24 |
Finetuned on 2000 steps.\
|
25 |
Quantization method: `float16`
|
26 |
|
27 |
+
### [KolumbusLindh/LoRA-6150](https://huggingface.co/KolumbusLindh/LoRA-6150)
|
28 |
|
29 |
+
Finetuned on 6150 steps.\
|
30 |
Quantization method: `float16`
|
31 |
|
32 |
### Hyperparameters
|
|
|
56 |
|
57 |
## Judge
|
58 |
|
59 |
+
We are using the KolumbusLindh/LoRA-6150 model as a judge. However, for better accuracy one should use a stronger model such as GPT-4, which can evaluate the responses more thoroughly.
|
60 |
|
61 |
## Evaluation using GPT-4
|
62 |
|
63 |
+
To better evaluate our fine-tuned models, we let GPT-4 be our judge, when the respective model answered the following prompts with different kinds of instructions:
|
64 |
|
65 |
1. Describe step-by-step how to set up a tent in a windy environment.
|
66 |
|
67 |
+
2. Explain how to bake a chocolate cake without using eggs.
|
68 |
|
69 |
+
3. Provide instructions for troubleshooting a laptop that won’t turn on.
|
70 |
|
71 |
+
4. Teach a beginner how to solve a Rubik’s Cube in simple steps.
|
72 |
|
73 |
+
5. Give detailed instructions for building a birdhouse using basic tools.
|
74 |
|
75 |
+
6. Design a beginner-friendly 15-minute workout routine that requires no equipment.
|
76 |
|
77 |
+
7. Explain how to properly season and cook a medium-rare steak.
|
78 |
|
79 |
+
8. Write a step-by-step guide for setting up a local Git repository and pushing code to GitHub.
|
80 |
|
81 |
+
9. Provide instructions for administering first aid to someone with a sprained ankle.
|
82 |
|
83 |
+
10. Outline a simple plan for a beginner to learn Spanish in 30 days.
|
84 |
+
|
85 |
+
Each model was evaluated by GPT using the following prompt:
|
86 |
+
|
87 |
+
```
|
88 |
+
Prompt:
|
89 |
+
|
90 |
+
Response 1:
|
91 |
+
|
92 |
+
Response 2:
|
93 |
+
|
94 |
+
Response 3:
|
95 |
+
|
96 |
+
Response 4:
|
97 |
+
|
98 |
+
Evaluation Criteria: Relevance, Coherence and Completeness
|
99 |
+
|
100 |
+
Please evaluate the responses based on the selected criteria. For each criterion, rate the response on a scale from 1 to 4. Answer only with the total sum for each response.
|
101 |
+
```
|
102 |
|
103 |
### Results
|
104 |
|
105 |
+

|
106 |
+
**p1** : `temperature=0.5` and `min_p=0.05` during inference\
|
107 |
+
**p2**: `temperature=1.5` and `min_p=0.1` `during inference
|
108 |
+
|
109 |
+
### Discussion
|
110 |
+
|
111 |
+
We can see on the results that all models perform relatively good. However, we see that changing inference parameters significantly influenced the results. Setting `min_p=0.1` and `temperature=0.5` improved the quality of the answers, being more creative but still relevant. We saw this in this [Tweet](https://x.com/menhguin/status/1826132708508213629) as well.
|
112 |
+
|
113 |
+
#### The temperature
|
114 |
+
|
115 |
+
The temperature essentially controls how creative the generation should be, by scaling the logits (raw output probabilities) before they are converted into probabilities via the softmax function. A higher temperature (>1) allows the model to explore less common words or phrases, whereas a lower temperature (<1) makes the output more deterministic and favoring the most probable tokens.
|
116 |
+
|
117 |
+
#### The minimum p parameter ("top-p" or nucleus sampling parameter)
|
118 |
+
|
119 |
+
This parameter controls which subset of tokens that are considered when generating the next token, with only the most probable tokens being in the sample pool. The cumulative probabilities of the tokens are calculated and sorted, and tokens are included in the sampling pool until the cumulative probability exceeds min_p. Then, the model samples from this reduced set of tokens. A higher min_p (closer to 1) allows more tokens into the pool, leading to a more diverse output. Lower min_p values (e.g. 0.1) restricts the pool to a few of the most probable tokens.
|
120 |
+
|
121 |
+
The combination of a relatively high temperature but a small nucleus sampling parameter makes the model generate a diverse and somewhat random output due to the high temperature, while still limiting it to only the most topmost likely tokens within a cumulative probability of 10%.
|
122 |
+
|
123 |
+
#### More steps needed to get more significant difference
|
124 |
+
|
125 |
+
Something to mention, however, is that the different between the model trained on 2000 steps versus 6150 steps is not that different regarding the evaluation results. We believe that we still need more data to finetune this model for it to make a more signifiant difference. Since the model trained on 2000 steps is capable of providing instructions (and the learning rate increases the most in the beginning), just training the model on more instructions will have a diminishing return. We likely need to train the model on 2 epochs or something like that in order for us to really see a large difference.
|
126 |
+
|
127 |
+
#### Further improvements
|
128 |
+
|
129 |
+
For further improvement, we should finetuned the model on more data. We should do at least 1-2 epochs on the FineTome-100k dataset, and then watch out closely for overfitting.
|
130 |
+
|
131 |
+
For even further improvement, the entire [The Tome](https://huggingface.co/datasets/arcee-ai/The-Tome) dataset (which the FineTome-100k is a subset of), with almost 20x the amount of data should be used for finetuning. However, this requires substantial time and/or more computational resources.
|
app.py
CHANGED
@@ -11,7 +11,7 @@ def load_user_model(repo_id, model_file):
|
|
11 |
|
12 |
# Generate a response using the specified model and prompt
|
13 |
def generate_response(model, prompt):
|
14 |
-
response = model(prompt, max_tokens=
|
15 |
return response["choices"][0]["text"]
|
16 |
|
17 |
# Evaluate responses using the LoRA evaluation model
|
@@ -44,7 +44,8 @@ Please evaluate the responses based on the selected criteria. For each criterion
|
|
44 |
evaluation_response = lora_model.create_completion(
|
45 |
prompt=evaluation_prompt,
|
46 |
max_tokens=512,
|
47 |
-
temperature=
|
|
|
48 |
)
|
49 |
evaluation_results = evaluation_response["choices"][0]["text"]
|
50 |
|
@@ -56,7 +57,7 @@ Please evaluate the responses based on the selected criteria. For each criterion
|
|
56 |
|
57 |
# Load the LoRA evaluation model
|
58 |
def load_lora_model():
|
59 |
-
repo_id = "KolumbusLindh/LoRA-
|
60 |
model_file = "unsloth.F16.gguf"
|
61 |
print(f"Downloading LoRA evaluation model from repository {repo_id}...")
|
62 |
local_path = hf_hub_download(repo_id=repo_id, filename=model_file)
|
@@ -74,7 +75,7 @@ with gr.Blocks(title="LLM as a Judge") as demo:
|
|
74 |
# Model inputs
|
75 |
repo_a_input = gr.Textbox(label="Model A Repository", placeholder="Enter the Hugging Face repo name for Model A...", value="forestav/LoRA-2000")
|
76 |
model_a_input = gr.Textbox(label="Model A File Name", placeholder="Enter the model filename for Model A...", value="unsloth.F16.gguf")
|
77 |
-
repo_b_input = gr.Textbox(label="Model B Repository", placeholder="Enter the Hugging Face repo name for Model B...", value="KolumbusLindh/LoRA-
|
78 |
model_b_input = gr.Textbox(label="Model B File Name", placeholder="Enter the model filename for Model B...", value="unsloth.F16.gguf")
|
79 |
|
80 |
# Prompt and criteria inputs
|
|
|
11 |
|
12 |
# Generate a response using the specified model and prompt
|
13 |
def generate_response(model, prompt):
|
14 |
+
response = model(prompt, max_tokens=1024, temperature=1.5, min_p=0.1)
|
15 |
return response["choices"][0]["text"]
|
16 |
|
17 |
# Evaluate responses using the LoRA evaluation model
|
|
|
44 |
evaluation_response = lora_model.create_completion(
|
45 |
prompt=evaluation_prompt,
|
46 |
max_tokens=512,
|
47 |
+
temperature=1.5,
|
48 |
+
min_p=0.1
|
49 |
)
|
50 |
evaluation_results = evaluation_response["choices"][0]["text"]
|
51 |
|
|
|
57 |
|
58 |
# Load the LoRA evaluation model
|
59 |
def load_lora_model():
|
60 |
+
repo_id = "KolumbusLindh/LoRA-6150"
|
61 |
model_file = "unsloth.F16.gguf"
|
62 |
print(f"Downloading LoRA evaluation model from repository {repo_id}...")
|
63 |
local_path = hf_hub_download(repo_id=repo_id, filename=model_file)
|
|
|
75 |
# Model inputs
|
76 |
repo_a_input = gr.Textbox(label="Model A Repository", placeholder="Enter the Hugging Face repo name for Model A...", value="forestav/LoRA-2000")
|
77 |
model_a_input = gr.Textbox(label="Model A File Name", placeholder="Enter the model filename for Model A...", value="unsloth.F16.gguf")
|
78 |
+
repo_b_input = gr.Textbox(label="Model B Repository", placeholder="Enter the Hugging Face repo name for Model B...", value="KolumbusLindh/LoRA-6150")
|
79 |
model_b_input = gr.Textbox(label="Model B File Name", placeholder="Enter the model filename for Model B...", value="unsloth.F16.gguf")
|
80 |
|
81 |
# Prompt and criteria inputs
|