Mukesh0606 commited on
Commit
2033b3e
Β·
verified Β·
1 Parent(s): f92230b

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: AlfredPros/CodeLlama-7b-Instruct-Solidity
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - peft
7
+ - lora
8
+ - qlora
9
+ - code-llama
10
+ - solidity
11
+ - smart-contracts
12
+ - causal-lm
13
+ license: llama2
14
+ language:
15
+ - en
16
+ ---
17
+
18
+ # CodeLlama-7B Solidity β€” QLoRA Fine-Tuned Adapter (deployable export)
19
+
20
+ This repository contains a **LoRA / PEFT adapter** (not a full model) fine-tuned with **QLoRA**
21
+ (4-bit base, bitsandbytes) on top of
22
+ [`AlfredPros/CodeLlama-7b-Instruct-Solidity`](https://huggingface.co/AlfredPros/CodeLlama-7b-Instruct-Solidity).
23
+
24
+ This is a **clean, inference-ready export** of the final fine-tune β€” it contains only the adapter,
25
+ tokenizer, and config (no optimizer / scheduler / RNG / trainer state), so it is meant for
26
+ **inference / deployment**, not for resuming training.
27
+
28
+ ## Model Details
29
+
30
+ | Property | Value |
31
+ |---|---|
32
+ | Base model | `AlfredPros/CodeLlama-7b-Instruct-Solidity` (CodeLlama-7B, Solidity-tuned) |
33
+ | Fine-tuning method | QLoRA (4-bit base) β†’ LoRA adapter |
34
+ | Adapter type | LoRA |
35
+ | PEFT version | 0.14.0 |
36
+ | Task type | `CAUSAL_LM` |
37
+ | Rank (`r`) | 64 |
38
+ | `lora_alpha` | 16 |
39
+ | `lora_dropout` | 0.1 |
40
+ | Target modules | `q_proj`, `v_proj` |
41
+ | Bias | none |
42
+ | Tokenizer | `CodeLlamaTokenizerFast` |
43
+ | Adapter size | ~134 MB (`adapter_model.safetensors`) |
44
+
45
+ > Note: 4-bit quantization is a training/loading-time setting (bitsandbytes) and is not recorded in
46
+ > `adapter_config.json`. The adapter can be applied to the base model loaded in 4-bit, 8-bit, fp16,
47
+ > or bf16.
48
+
49
+ ## Files in this repository
50
+
51
+ | File | Purpose |
52
+ |---|---|
53
+ | `adapter_config.json` | LoRA/PEFT configuration |
54
+ | `adapter_model.safetensors` | LoRA adapter weights (~134 MB) |
55
+ | `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` | Tokenizer |
56
+ | `training_args.bin` | Serialized `TrainingArguments` from the run |
57
+
58
+ > **Note:** The ~13 GB base model weights are **not** included β€” they are pulled separately from
59
+ > `AlfredPros/CodeLlama-7b-Instruct-Solidity`. The training **dataset and script are not included**.
60
+ > Optimizer/scheduler/RNG state are **not** present, so this export cannot resume training; use a
61
+ > full checkpoint folder for that.
62
+
63
+ ## How to use (inference)
64
+
65
+ ```python
66
+ from peft import PeftModel
67
+ from transformers import AutoModelForCausalLM, AutoTokenizer
68
+
69
+ BASE = "AlfredPros/CodeLlama-7b-Instruct-Solidity"
70
+ ADAPTER = "Mukesh0606/solidity-codellama-qlora-r64" # or a local path to this folder
71
+
72
+ tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
73
+ base_model = AutoModelForCausalLM.from_pretrained(BASE, device_map="auto")
74
+ model = PeftModel.from_pretrained(base_model, ADAPTER)
75
+ model.eval()
76
+
77
+ prompt = "// Write a secure ERC20 token contract in Solidity\n"
78
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
79
+ out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
80
+ print(tokenizer.decode(out[0], skip_special_tokens=True))
81
+ ```
82
+
83
+ ### Load with a 4-bit base (matches QLoRA training, low VRAM)
84
+
85
+ ```python
86
+ from transformers import BitsAndBytesConfig
87
+ import torch
88
+
89
+ bnb = BitsAndBytesConfig(
90
+ load_in_4bit=True,
91
+ bnb_4bit_quant_type="nf4",
92
+ bnb_4bit_compute_dtype=torch.float16,
93
+ bnb_4bit_use_double_quant=True,
94
+ )
95
+ base_model = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=bnb, device_map="auto")
96
+ model = PeftModel.from_pretrained(base_model, ADAPTER)
97
+ ```
98
+
99
+ ### Merge the adapter into a standalone model (optional)
100
+
101
+ ```python
102
+ # Merge requires the base in fp16/bf16 (not 4-bit).
103
+ base_fp16 = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype="float16", device_map="auto")
104
+ merged = PeftModel.from_pretrained(base_fp16, ADAPTER).merge_and_unload()
105
+ merged.save_pretrained("codellama-7b-solidity-merged")
106
+ tokenizer.save_pretrained("codellama-7b-solidity-merged")
107
+ ```
108
+
109
+ ## Hardware notes
110
+
111
+ - **Inference (4-bit):** ~6 GB GPU.
112
+ - **Inference (fp16):** ~16 GB GPU.
113
+
114
+ ## Framework versions
115
+
116
+ - PEFT 0.14.0
117
+ - Transformers (Hugging Face `Trainer`)
118
+ - Base: CodeLlama-7B-Instruct (Solidity-tuned)
119
+
120
+ ## License
121
+
122
+ Inherits the base model's license (Llama 2 Community License via CodeLlama). Review the base
123
+ model card before commercial use.
adapter_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "AlfredPros/CodeLlama-7b-Instruct-Solidity",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 16,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.1,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 64,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "q_proj",
27
+ "v_proj"
28
+ ],
29
+ "task_type": "CAUSAL_LM",
30
+ "use_dora": false,
31
+ "use_rslora": false
32
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be7eaa721f2a1f7a776dcf3e923147e359dec29d83bb2f2042cb0d9882770e7b
3
+ size 134235048
special_tokens_map.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "▁<PRE>",
4
+ "▁<MID>",
5
+ "▁<SUF>",
6
+ "▁<EOT>",
7
+ "▁<PRE>",
8
+ "▁<MID>",
9
+ "▁<SUF>",
10
+ "▁<EOT>",
11
+ "▁<PRE>",
12
+ "▁<MID>",
13
+ "▁<SUF>",
14
+ "▁<EOT>"
15
+ ],
16
+ "bos_token": {
17
+ "content": "<s>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "eos_token": {
24
+ "content": "</s>",
25
+ "lstrip": false,
26
+ "normalized": true,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "</s>",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "unk_token": {
38
+ "content": "<unk>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ }
44
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": true,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": true,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "32007": {
30
+ "content": "▁<PRE>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "32008": {
38
+ "content": "▁<SUF>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "32009": {
46
+ "content": "▁<MID>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "32010": {
54
+ "content": "▁<EOT>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "32016": {
62
+ "content": "[PAD]",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ }
69
+ },
70
+ "additional_special_tokens": [
71
+ "▁<PRE>",
72
+ "▁<MID>",
73
+ "▁<SUF>",
74
+ "▁<EOT>",
75
+ "▁<PRE>",
76
+ "▁<MID>",
77
+ "▁<SUF>",
78
+ "▁<EOT>",
79
+ "▁<PRE>",
80
+ "▁<MID>",
81
+ "▁<SUF>",
82
+ "▁<EOT>"
83
+ ],
84
+ "bos_token": "<s>",
85
+ "clean_up_tokenization_spaces": false,
86
+ "eos_token": "</s>",
87
+ "eot_token": "▁<EOT>",
88
+ "extra_special_tokens": {},
89
+ "fill_token": "<FILL_ME>",
90
+ "legacy": null,
91
+ "middle_token": "▁<MID>",
92
+ "model_max_length": 1000000000000000019884624838656,
93
+ "pad_token": "</s>",
94
+ "prefix_token": "▁<PRE>",
95
+ "sp_model_kwargs": {},
96
+ "suffix_token": "▁<SUF>",
97
+ "tokenizer_class": "CodeLlamaTokenizerFast",
98
+ "unk_token": "<unk>",
99
+ "use_default_system_prompt": false
100
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84aaa494f1b744164efe39c1884b2c349611951e1529a5d570b4897f366fefb3
3
+ size 5560