Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Intel/Qwen3-235B-A22B-Instruct-2507-int4-asym-AutoRound"
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=16384
29)
30output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
31
32content = tokenizer.decode(output_ids, skip_special_tokens=True)
33
34print("content:", content)
35
36"""
37content: A Large Language Model (LLM) is a type of artificial intelligence designed to understand, generate, and manipulate human language. Built using deep learning techniques—especially transformer architectures—LLMs are trained on vast amounts of text data from books, websites, and other sources. This training enables them to recognize patterns in language, answer questions, write essays, translate languages, and even generate creative content like stories or code. Due to their scale—often with billions of parameters—LLMs can capture nuanced linguistic features and produce remarkably human-like text. Examples include models like GPT, Llama, and PaLM. LLMs are transforming fields such as education, customer service, and content creation by enabling more natural and intelligent interactions between humans and machines.
38
39"""auto-round --model Qwen/Qwen3-235B-A22B-Instruct-2507 --output_dir ./Qwen3-235B-A22B-Instruct-2507-int4 --enable_torch_compile --format auto_round:auto_awq --asym