Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!pip install -qU transformers accelerate
|
2 |
+
|
3 |
+
from transformers import AutoTokenizer
|
4 |
+
import transformers
|
5 |
+
import torch
|
6 |
+
|
7 |
+
model = "K00B404/DeepQwenScalerPlus"
|
8 |
+
messages = [{"role": "system", "content": "You are a reasoning coder and specialize in generating Python scripts"},
|
9 |
+
{"role": "user", "content": "What is a large language model?"}]
|
10 |
+
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
12 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
13 |
+
pipeline = transformers.pipeline(
|
14 |
+
"text-generation",
|
15 |
+
model=model,
|
16 |
+
torch_dtype=torch.float16,
|
17 |
+
device_map="auto",
|
18 |
+
)
|
19 |
+
|
20 |
+
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
21 |
+
print(outputs[0]["generated_text"])
|