oweller2
commited on
Commit
•
f051168
1
Parent(s):
47fa45e
added reamdme
Browse files
README.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
|
6 |
+
import torch
|
7 |
+
|
8 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
+
print(f"Using device: {device}")
|
10 |
+
|
11 |
+
model = AutoModelForCausalLM.from_pretrained("orionweller/test-flex-gpt", trust_remote_code=True)
|
12 |
+
model = model.to(device)
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained("orionweller/test-flex-gpt", trust_remote_code=True)
|
14 |
+
|
15 |
+
# test it out and encode some text
|
16 |
+
prompt = "The capital of France is"
|
17 |
+
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
18 |
+
# put the input ids on the right device
|
19 |
+
inputs = inputs.to(device)
|
20 |
+
outputs = model.generate(inputs, max_new_tokens=5, do_sample=True, top_p=0.95)
|
21 |
+
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|