Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
Below is the reference code for inference. First load the tokenizer and the model.
|
6 |
+
|
7 |
+
```
|
8 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained("KLGR123/WEPO-llama-3-8b", trust_remote_code=True)
|
10 |
+
model = AutoModelForCausalLM.from_pretrained("KLGR123/WEPO-llama-3-8b", trust_remote_code=True).to('cuda:0')
|
11 |
+
```
|
12 |
+
|
13 |
+
Run a test-demo with random input.
|
14 |
+
|
15 |
+
```
|
16 |
+
messages = [
|
17 |
+
{"role": "system", "content": "You are a web navigation intelligence who interacts with webpage environments to achieve human user intent."},
|
18 |
+
{"role": "user", "content": "Who are you?"},
|
19 |
+
]
|
20 |
+
|
21 |
+
input_ids = tokenizer.apply_chat_template(
|
22 |
+
messages,
|
23 |
+
add_generation_prompt=True,
|
24 |
+
return_tensors="pt"
|
25 |
+
).to(model.device)
|
26 |
+
|
27 |
+
terminators = [
|
28 |
+
tokenizer.eos_token_id,
|
29 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
30 |
+
]
|
31 |
+
|
32 |
+
outputs = model.generate(
|
33 |
+
input_ids,
|
34 |
+
max_new_tokens=128,
|
35 |
+
eos_token_id=terminators,
|
36 |
+
do_sample=True,
|
37 |
+
temperature=0.2,
|
38 |
+
top_p=0.9,
|
39 |
+
)
|
40 |
+
|
41 |
+
response = outputs[0][input_ids.shape[-1]:]
|
42 |
+
output = tokenizer.decode(response, skip_special_tokens=True)
|
43 |
+
output
|
44 |
+
```
|