Views
No views yet

Qwen3-Max generated image
The following sections are either copied as they were from the onieth/chemAI2025 page or slightly modified. I didn't want to make it seem like I just ripped them off.
enable_thinking=True is no longer required.<think>. Therefore, it is normal for the model's output to contain only </think> without an explicit opening <think> tag.transformers and we advise you to use the latest version of transformers.transformers<4.51.0, you will encounter the following error:KeyError: 'qwen3'1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "onieth/chemAI2025"
4
5# load the tokenizer and the model
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype="auto",
10 device_map="auto"
11)
12
13# prepare the model input
14prompt = "Give me a short introduction to large language model."
15messages = [
16 {"role": "user", "content": prompt}
17]
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22)
23model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
24
25# conduct text completion
26generated_ids = model.generate(
27 **model_inputs,
28 max_new_tokens=32768
29)
30output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
31
32# parsing thinking content
33try:
34 # rindex finding 151668 (</think>)
35 index = len(output_ids) - output_ids[::-1].index(151668)
36except ValueError:
37 index = 0
38
39thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
40content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
41
42print("thinking content:", thinking_content) # no opening <think> tag
43print("content:", content)
44sglang>=0.4.6.post1 or vllm>=0.8.5 or to create an OpenAI-compatible API endpoint:python -m sglang.launch_server --model-path onieth/chemAI2025 --context-length 262144 --reasoning-parser deepseek-r1vllm serve onieth/chemAI2025 --max-model-len 262144 --enable-reasoning --reasoning-parser deepseek_r11from qwen_agent.agents import Assistant
2
3# Define LLM
4# Using OpenAI-compatible API endpoint. It is recommended to disable the reasoning and the tool call parsing
5# functionality of the deployment frameworks and let Qwen-Agent automate the related operations. For example,
6# `VLLM_USE_MODELSCOPE=true vllm serve onieth/chemAI2025 --served-model-name onieth/chemAI2025 --max-model-len 262144`.
7llm_cfg = {
8 'model': 'onieth/chemAI2025',
9
10 # Use a custom endpoint compatible with OpenAI API:
11 'model_server': 'http://localhost:8000/v1', # api_base without reasoning and tool call parsing
12 'api_key': 'EMPTY',
13 'generate_cfg': {
14 'thought_in_content': True,
15 },
16}
17
18# Define Tools
19tools = [
20 {'mcpServers': { # You can specify the MCP configuration file
21 'time': {
22 'command': 'uvx',
23 'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai']
24 },
25 "fetch": {
26 "command": "uvx",
27 "args": ["mcp-server-fetch"]
28 }
29 }
30 },
31 'code_interpreter', # Built-in tools
32]
33
34# Define Agent
35bot = Assistant(llm=llm_cfg, function_list=tools)
36
37# Streaming generation
38messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}]
39for responses in bot.run(messages=messages):
40 pass
41print(responses)Temperature=0.6, TopP=0.95, TopK=20, and MinP=0.presence_penalty parameter between 0 and 2 to reduce endless repetitions. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.answer field with only the choice letter, e.g., "answer": "C"."1@misc{qwen3technicalreport,
2 title={Qwen3 Technical Report},
3 author={Qwen Team},
4 year={2025},
5 eprint={2505.09388},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2505.09388},
9}