--- license: Apache License 2.0 tasks: - text-generation base_model: - iic/QwenLong-L1-32B --- ## Intro The AWQ version is quantized using [ms-swift](https://github.com/modelscope/ms-swift). Note that the AWQ version for QwenLong-L1-32B models are verified to be working on Transformers/vLLM. We have not have the chance to tested them on other engines. ## Inference ```python from modelscope import AutoModelForCausalLM, AutoTokenizer model_name = "swift/QwenLong-L1-32B-AWQ" # load the tokenizer and the model tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto" ) # prepare the model input template = """Please read the following text and answer the question below. $DOC$ $Q$ Format your response as follows: "Therefore, the answer is (insert answer here)".""" context = "" question = "" prompt = template.replace('$DOC$', context.strip()).replace('$Q$', question.strip()) messages = [ {"role": "user", "content": prompt} ] text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True ) model_inputs = tokenizer([text], return_tensors="pt").to(model.device) # conduct text completion generated_ids = model.generate( **model_inputs, max_new_tokens=10000, temperature=0.7, top_p=0.95 ) output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking content try: # rindex finding 151649 () index = len(output_ids) - output_ids[::-1].index(151649) except ValueError: index = 0 thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n") content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n") print("thinking content:", thinking_content) print("content:", content) ``` ## Quantization The model has undergone AWQ int4 quantization using the [ms-swift](https://github.com/modelscope/ms-swift) framework. If you have fine-tuned the model and wish to quantize the fine-tuned version, you can refer to the following quantization scripts: - Dense Model Quantization Script: [View Here](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/awq.sh) - MoE Model Quantization Script: [View Here](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/moe/awq.sh) With these scripts, you can easily complete the quantization process for the model.