TESTtm7873
commited on
Commit
•
088c92b
1
Parent(s):
75c7729
Update README.md
Browse files
README.md
CHANGED
@@ -1,21 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
-
license: mit
|
3 |
-
language:
|
4 |
-
- en
|
5 |
-
---
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
Developed of our VCC project
|
13 |
-
Finetuned with QLoRA
|
14 |
|
15 |
-
|
16 |
-
|
17 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
18 |
|
|
|
19 |
base_model_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
20 |
bnb_config = BitsAndBytesConfig(
|
21 |
load_in_4bit=True,
|
@@ -24,25 +33,29 @@ bnb_config = BitsAndBytesConfig(
|
|
24 |
bnb_4bit_compute_dtype=torch.bfloat16
|
25 |
)
|
26 |
|
|
|
27 |
base_model = AutoModelForCausalLM.from_pretrained(
|
28 |
-
base_model_id,
|
29 |
-
quantization_config=bnb_config,
|
30 |
device_map="auto",
|
31 |
trust_remote_code=True,
|
32 |
)
|
33 |
|
|
|
34 |
eval_tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
|
35 |
|
36 |
from peft import PeftModel
|
37 |
|
|
|
38 |
ft_model = PeftModel.from_pretrained(base_model, "mistral-journal-finetune/checkpoint-150")
|
39 |
|
|
|
40 |
eval_prompt = "You have the softest fur."
|
41 |
model_input = eval_tokenizer(eval_prompt, return_tensors="pt").to("cuda")
|
42 |
|
43 |
ft_model.eval()
|
44 |
with torch.no_grad():
|
45 |
-
print(eval_tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=100, repetition_penalty=1.15)[0], skip_special_tokens=True))
|
46 |
|
47 |
|
48 |
|
|
|
1 |
+
# Model Card: Model ID
|
2 |
+
|
3 |
+
## License
|
4 |
+
|
5 |
+
MIT License
|
6 |
+
|
7 |
+
## Languages Supported
|
8 |
+
|
9 |
+
- English (en)
|
10 |
+
|
11 |
---
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
## Overview
|
14 |
+
|
15 |
+
This model is part of the VCC project and has been fine-tuned on the TESTtm7873/ChatCat dataset using the `mistralai/Mistral-7B-Instruct-v0.2` as the base model. The fine-tuning process utilized QLoRA for improved performance.
|
16 |
+
|
17 |
+
---
|
18 |
|
19 |
+
## Getting Started
|
20 |
|
21 |
+
To use this model, you'll need to set up your environment first:
|
|
|
|
|
22 |
|
23 |
+
```python
|
24 |
+
import torch
|
25 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
26 |
|
27 |
+
# Base model configuration
|
28 |
base_model_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
29 |
bnb_config = BitsAndBytesConfig(
|
30 |
load_in_4bit=True,
|
|
|
33 |
bnb_4bit_compute_dtype=torch.bfloat16
|
34 |
)
|
35 |
|
36 |
+
# Loading the base model with quantization config
|
37 |
base_model = AutoModelForCausalLM.from_pretrained(
|
38 |
+
base_model_id,
|
39 |
+
quantization_config=bnb_config,
|
40 |
device_map="auto",
|
41 |
trust_remote_code=True,
|
42 |
)
|
43 |
|
44 |
+
# Setting up tokenizer
|
45 |
eval_tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
|
46 |
|
47 |
from peft import PeftModel
|
48 |
|
49 |
+
# Loading the fine-tuned model
|
50 |
ft_model = PeftModel.from_pretrained(base_model, "mistral-journal-finetune/checkpoint-150")
|
51 |
|
52 |
+
# Sample evaluation
|
53 |
eval_prompt = "You have the softest fur."
|
54 |
model_input = eval_tokenizer(eval_prompt, return_tensors="pt").to("cuda")
|
55 |
|
56 |
ft_model.eval()
|
57 |
with torch.no_grad():
|
58 |
+
print(eval_tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=100, repetition_penalty=1.15)[0], skip_special_tokens=True))
|
59 |
|
60 |
|
61 |
|