Views
No views yet

1from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig
2
3model_name = "RTP-LLM/Qwen3-Coder-30B-A3B-Instruct-RTPurbo"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 config=config,
10 trust_remote_code=True,
11 torch_dtype="auto",
12 device_map="auto"
13)
14
15# prepare the model input
16prompt = "Write a quick sort algorithm."
17messages = [
18 {"role": "user", "content": prompt}
19]
20text = tokenizer.apply_chat_template(
21 messages,
22 tokenize=False,
23 add_generation_prompt=True,
24)
25model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
26
27# conduct text completion
28generated_ids = model.generate(
29 **model_inputs,
30 max_new_tokens=128
31)
32output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
33
34content = tokenizer.decode(output_ids, skip_special_tokens=True)
35
36print("content:", content)| Longbench | lcc | repo-p | samsum | trec | lsht | 2wikim | hotpot | multi-en | multi-zh | musique | qasper | vcsum | qmsum | PR-en | PR-zh | Avg. (%) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Qwen3-Coder-30B-A3B | ||||||||||||||||
| Full Attn | 34.34 | 27.14 | 45.80 | 81.00 | 47.50 | 42.08 | 57.64 | 52.89 | 65.99 | 38.30 | 39.25 | 13.55 | 23.77 | 99.00 | 99.75 | 51.20 |
| RTPurbo | 35.96 | 35.21 | 46.49 | 81.00 | 49.00 | 47.39 | 55.44 | 52.93 | 65.23 | 35.58 | 39.78 | 13.80 | 23.68 | 99.00 | 99.75 | 52.02 |