Update README.md
Browse files
README.md
CHANGED
|
@@ -25,20 +25,18 @@ The additional details of the Aquila model will be presented in the official tec
|
|
| 25 |
```python
|
| 26 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 27 |
import torch
|
| 28 |
-
device = torch.device("cuda")
|
| 29 |
-
model_info = "BAAI/AquilaChat2-
|
| 30 |
tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
|
| 31 |
-
model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True)
|
| 32 |
model.eval()
|
| 33 |
model.to(device)
|
| 34 |
text = "请给出10个要到北京旅游的理由。"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
out = tokenizer.decode(out.cpu().numpy().tolist())
|
| 41 |
-
print(out)
|
| 42 |
```
|
| 43 |
|
| 44 |
|
|
|
|
| 25 |
```python
|
| 26 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 27 |
import torch
|
| 28 |
+
device = torch.device("cuda:0")
|
| 29 |
+
model_info = "BAAI/AquilaChat2-34B"
|
| 30 |
tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
|
| 31 |
+
model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.bfloat16)
|
| 32 |
model.eval()
|
| 33 |
model.to(device)
|
| 34 |
text = "请给出10个要到北京旅游的理由。"
|
| 35 |
+
from predict import predict
|
| 36 |
+
out = predict(model, text, tokenizer=tokenizer, max_gen_len=200, top_p=0.95,
|
| 37 |
+
seed=1234, topk=100, temperature=0.9, sft=True, device=device,
|
| 38 |
+
model_name="AquilaChat2-34B")
|
| 39 |
+
print(out)
|
|
|
|
|
|
|
| 40 |
```
|
| 41 |
|
| 42 |
|