Update README.md
Browse files
README.md
CHANGED
@@ -18,6 +18,39 @@ The codebase for APUS-xDAN-4.0-MOE is integrated into the latest Hugging Face tr
|
|
18 |
|
19 |
Copy code
|
20 |
Usage llama.cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
License
|
22 |
|
23 |
APUS-xDAN-4.0-MOE is distributed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
|
|
|
18 |
|
19 |
Copy code
|
20 |
Usage llama.cpp
|
21 |
+
|
22 |
+
Usage
|
23 |
+
|
24 |
+
"""
|
25 |
+
import torch
|
26 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
27 |
+
|
28 |
+
torch.set_default_dtype(torch.bfloat16)
|
29 |
+
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained("hpcai-tech/grok-1", trust_remote_code=True)
|
31 |
+
|
32 |
+
model = AutoModelForCausalLM.from_pretrained(
|
33 |
+
"hpcai-tech/grok-1",
|
34 |
+
trust_remote_code=True,
|
35 |
+
device_map="auto",
|
36 |
+
torch_dtype=torch.bfloat16,
|
37 |
+
)
|
38 |
+
model.eval()
|
39 |
+
|
40 |
+
text = "Replace this with your text"
|
41 |
+
input_ids = tokenizer(text, return_tensors="pt").input_ids
|
42 |
+
input_ids = input_ids.cuda()
|
43 |
+
attention_mask = torch.ones_like(input_ids)
|
44 |
+
generate_kwargs = {} # Add any additional args if you want
|
45 |
+
inputs = {
|
46 |
+
"input_ids": input_ids,
|
47 |
+
"attention_mask": attention_mask,
|
48 |
+
**generate_kwargs,
|
49 |
+
}
|
50 |
+
outputs = model.generate(**inputs)
|
51 |
+
print(outputs)
|
52 |
+
"""
|
53 |
+
|
54 |
License
|
55 |
|
56 |
APUS-xDAN-4.0-MOE is distributed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
|