Update README.md
Browse files
README.md
CHANGED
|
@@ -33,167 +33,58 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
| 33 |
- **Paper [optional]:** [More Information Needed]
|
| 34 |
- **Demo [optional]:** [More Information Needed]
|
| 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 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
[More Information Needed]
|
|
|
|
| 33 |
- **Paper [optional]:** [More Information Needed]
|
| 34 |
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
+
# full_model_comparison.py
|
| 37 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 38 |
+
from peft import PeftModel
|
| 39 |
+
import torch
|
| 40 |
+
|
| 41 |
+
# ---------------------------
|
| 42 |
+
# 1. Model setup
|
| 43 |
+
# ---------------------------
|
| 44 |
+
base_model_name = "microsoft/Phi-4-mini-instruct"
|
| 45 |
+
lora_model_name = "JeloH/phi4_src_lora"
|
| 46 |
+
|
| 47 |
+
# Load tokenizer
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
|
| 49 |
+
|
| 50 |
+
# Load base model
|
| 51 |
+
base_model = AutoModelForCausalLM.from_pretrained(base_model_name)
|
| 52 |
+
|
| 53 |
+
# Load fine-tuned LoRA model
|
| 54 |
+
finetuned_model = PeftModel.from_pretrained(base_model, lora_model_name)
|
| 55 |
+
|
| 56 |
+
# ---------------------------
|
| 57 |
+
# 2. Define prompts
|
| 58 |
+
# ---------------------------
|
| 59 |
+
prompts = [
|
| 60 |
+
"Translate the following assembly code to high-level source code. input: push ebp\nmov ebp, esp\nsub esp, 3Ch\nmov eax, ___security_cookie\nxor eax, ebp\nmov [ebp+var_4], eax\npush ebx\npush esi\npush edi\npush 0; hWnd\ncall ds:GetDC\nmov edi, eax\npush edi; hdc\ncall ds:CreateCompatibleDC\nmov esi, ds:GetSystemMetrics\npush 0; nIndex\nmov [ebp+hdc], eax\ncall esi ; GetSystemMetrics\npush 1; nIndex\nmov [ebp+var_38], eax\ncall esi ; GetSystemMetrics\nmov esi, [ebp+var_38]\nmov ebx, eax\npush 0; offset\npush 0; hSection\nlea eax, [ebp+ppvBits]\nmov [ebp+ppvBits], 0\npush eax; ppvBits\npush 0; usage\nxorps xmm0, xmm0\nmov [ebp+pbmi.bmiHeader.biSize], 2Ch ; ','\nlea eax, [ebp+pbmi]\nmovq qword ptr [ebp+pbmi.bmiHeader.biClrImportant], xmm0\nmovups xmmword ptr [ebp+pbmi.bmiHeader.biWidth], xmm0\npush eax; pbmi\npush edi; hdc\nmovups xmmword ptr [ebp+pbmi.bmiHeader.biSizeImage], xmm0\nmov dword ptr [ebp+pbmi.bmiHeader.biPlanes], 200001h\nmov [ebp+pbmi.bmiHeader.biWidth], esi\nmov [ebp+pbmi.bmiHeader.biHeight], ebx\ncall ds:CreateDIBSection\npush eax; h\npush [ebp+hdc]; hdc\ncall ds:SelectObject\nmov edi, ebx\nimul edi, esi\nnop dword ptr [eax+00h]\npush 0; hWnd\ncall ds:GetDC\npush 0CC0020h; rop\npush 0; y1\npush 0; x1\nmov esi, eax\npush esi; hdcSrc\npush ebx; cy\npush [ebp+var_38]; cx\npush 0; y\npush 0; x\npush [ebp+hdc]; hdc\ncall ds:BitBlt\nxor eax, eax\ntest edi, edi\njle short loc_40127F\nnop dword ptr [eax+eax+00h]\nmov ecx, [ebp+ppvBits]\nadd dword ptr [ecx+eax*4], 0E1h\ninc eax\ncmp eax, edi\njl short loc_401270\npush 0CC0020h; rop\npush 0Ah; y1\npush 0; x1\npush [ebp+hdc]; hdcSrc\npush ebx; cy\npush [ebp+var_38]; cx\npush 0; y\npush 0; x\npush esi; hdc\ncall ds:BitBlt\npush 0CC0020h; rop\nmov eax, 0Ah\nsub eax, ebx\npush eax; y1\npush 0; x1\npush [ebp+hdc]; hdcSrc\npush ebx; cy\npush [ebp+var_38]; cx\npush 0; y\npush 0; x\npush esi; hdc\ncall ds:BitBlt\npush 64h ; 'd'; dwMilliseconds\ncall ds:Sleep\npush esi; hDC\npush 0; hWnd\ncall ds:ReleaseDC\npush esi; hdc\ncall ds:DeleteDC\njmp loc_40124",
|
| 61 |
+
"Write a short story about a robot learning emotions."]
|
| 62 |
+
|
| 63 |
+
# ---------------------------
|
| 64 |
+
# 3. Generate outputs
|
| 65 |
+
# ---------------------------
|
| 66 |
+
def generate_text(model, tokenizer, prompt, max_length=1000):
|
| 67 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
| 68 |
+
output_ids = model.generate(input_ids, max_length=max_length, do_sample=True, temperature=0.7)
|
| 69 |
+
return tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 70 |
+
|
| 71 |
+
# ---------------------------
|
| 72 |
+
# 4. Run comparison
|
| 73 |
+
# ---------------------------
|
| 74 |
+
for i, prompt in enumerate(prompts, 1):
|
| 75 |
+
print(f"\n=== Prompt {i} ===")
|
| 76 |
+
print(f"Prompt: {prompt}\n")
|
| 77 |
+
|
| 78 |
+
base_output = generate_text(base_model, tokenizer, prompt)
|
| 79 |
+
print("Base Model Output:")
|
| 80 |
+
print(base_output)
|
| 81 |
+
print("\nFine-Tuned LoRA Model Output:")
|
| 82 |
+
ft_output = generate_text(finetuned_model, tokenizer, prompt)
|
| 83 |
+
print(ft_output)
|
| 84 |
+
print("="*60)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
[More Information Needed]
|