Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
|
3 |
+
# Doc / guide: https://huggingface.co/docs/hub/model-cards
|
4 |
+
{}
|
5 |
+
---
|
6 |
+
to use : code:
|
7 |
+
```
|
8 |
+
PEFT_MODEL = "Bepitic/DM-falcon-7b-shared"
|
9 |
+
config = PeftConfig.from_pretrained(PEFT_MODEL)
|
10 |
+
model = AutoModelForCausalLM.from_pretrained(
|
11 |
+
config.base_model_name_or_path,
|
12 |
+
return_dict=True,
|
13 |
+
quantization_config=bnb_config,
|
14 |
+
device_map="auto",
|
15 |
+
trust_remote_code=True
|
16 |
+
)
|
17 |
+
|
18 |
+
tokenizer=AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
19 |
+
tokenizer.pad_token = tokenizer.eos_token
|
20 |
+
|
21 |
+
model = PeftModel.from_pretrained(model, PEFT_MODEL)
|
22 |
+
|
23 |
+
generation_config = model.generation_config
|
24 |
+
generation_config.max_new_tokens = 200
|
25 |
+
generation_config.temperature = 0.7
|
26 |
+
generation_config.top_p = 0.7
|
27 |
+
generation_config.num_return_sequences = 1
|
28 |
+
generation_config.pad_token_id = tokenizer.eos_token_id
|
29 |
+
generation_config.eos_token_id = tokenizer.eos_token_id
|
30 |
+
|
31 |
+
# new cell colab
|
32 |
+
%%time
|
33 |
+
device = "cuda:0"
|
34 |
+
|
35 |
+
prompt = """
|
36 |
+
<human>: Explain how Aelar Windrider a Human tried to Attack with a melee weapon of Extremely Easy difficulty and got an Catastrophic Failure.
|
37 |
+
<assistant>:
|
38 |
+
""".strip()
|
39 |
+
|
40 |
+
encoding = tokenizer(prompt, return_tensors="pt").to(device)
|
41 |
+
with torch.inference_mode():
|
42 |
+
outputs = model.generate(
|
43 |
+
input_ids = encoding.input_ids,
|
44 |
+
attention_mask = encoding.attention_mask,
|
45 |
+
generation_config = generation_config
|
46 |
+
)
|
47 |
+
|
48 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
49 |
+
```
|
50 |
+
|
51 |
+
|