-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathqwen-transcript-hack.py
More file actions
39 lines (32 loc) · 991 Bytes
/
Copy pathqwen-transcript-hack.py
File metadata and controls
39 lines (32 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
def main():
model_name = "Qwen/Qwen3-0.6B-Base"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
dtype="auto",
device_map="auto",
)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto",
)
input_text = (
"This is a transcript of a conversation between a helpful bot, 'Bot', "
"and a human, 'User'. The bot is very intelligent and always answers "
"the human's questions with a useful reply.\n\n"
"User: Provide a synonym for 'bright'\n\n"
"Bot: "
)
out = pipe(
input_text,
max_new_tokens=80,
do_sample=True, # set False for greedy
temperature=0.7,
top_p=0.9
)
print(out[0]["generated_text"])
if __name__ == "__main__":
main()