Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,57 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- bn
|
5 |
+
---
|
6 |
+
|
7 |
+
To run:
|
8 |
+
```
|
9 |
+
bnb_config = BitsAndBytesConfig(
|
10 |
+
load_in_4bit=True,
|
11 |
+
bnb_4bit_use_double_quant=True,
|
12 |
+
bnb_4bit_quant_type="nf4",
|
13 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
14 |
+
)
|
15 |
+
|
16 |
+
config = {
|
17 |
+
'base_model_name_or_path': 'deepseek-ai/deepseek-math-7b-base'
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
PEFT_MODEL = "trained-model3"
|
22 |
+
|
23 |
+
config = PeftConfig.from_pretrained(PEFT_MODEL)
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(
|
25 |
+
config.base_model_name_or_path,
|
26 |
+
return_dict=True,
|
27 |
+
quantization_config=bnb_config,
|
28 |
+
device_map="sequential",
|
29 |
+
trust_remote_code=True
|
30 |
+
)
|
31 |
+
|
32 |
+
tokenizer=AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
33 |
+
tokenizer.pad_token = tokenizer.eos_token
|
34 |
+
|
35 |
+
model = PeftModel.from_pretrained(model, PEFT_MODEL)
|
36 |
+
|
37 |
+
|
38 |
+
generation_config = model.generation_config
|
39 |
+
generation_config.max_new_tokens = 2048
|
40 |
+
generation_config.temperature = 0.7
|
41 |
+
generation_config.top_p = 0.7
|
42 |
+
generation_config.do_sample = True
|
43 |
+
generation_config.num_return_sequences = 1
|
44 |
+
generation_config.pad_token_id = tokenizer.eos_token_id
|
45 |
+
generation_config.eos_token_id = tokenizer.eos_token_id
|
46 |
+
|
47 |
+
prompt = f"""Problem Statement: {ques}"""
|
48 |
+
encoding = tokenizer(prompt, return_tensors="pt").to(device)
|
49 |
+
with torch.inference_mode():
|
50 |
+
outputs = model.generate(
|
51 |
+
input_ids = encoding.input_ids,
|
52 |
+
attention_mask = encoding.attention_mask,
|
53 |
+
generation_config = generation_config
|
54 |
+
)
|
55 |
+
|
56 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
57 |
+
```
|