Views
No views yet
| Name | Quant method | Size |
|---|---|---|
| Ko-Qwen2-7B-Instruct.Q2_K.gguf | Q2_K | 2.81GB |
| Ko-Qwen2-7B-Instruct.IQ3_XS.gguf | IQ3_XS | 3.11GB |
| Ko-Qwen2-7B-Instruct.IQ3_S.gguf | IQ3_S | 3.26GB |
| Ko-Qwen2-7B-Instruct.Q3_K_S.gguf | Q3_K_S | 3.25GB |
| Ko-Qwen2-7B-Instruct.IQ3_M.gguf | IQ3_M | 3.33GB |
| Ko-Qwen2-7B-Instruct.Q3_K.gguf | Q3_K | 3.55GB |
| Ko-Qwen2-7B-Instruct.Q3_K_M.gguf | Q3_K_M | 3.55GB |
| Ko-Qwen2-7B-Instruct.Q3_K_L.gguf | Q3_K_L | 3.81GB |
| Ko-Qwen2-7B-Instruct.IQ4_XS.gguf | IQ4_XS | 3.96GB |
| Ko-Qwen2-7B-Instruct.Q4_0.gguf | Q4_0 | 4.13GB |
| Ko-Qwen2-7B-Instruct.IQ4_NL.gguf | IQ4_NL | 4.15GB |
| Ko-Qwen2-7B-Instruct.Q4_K_S.gguf | Q4_K_S | 4.15GB |
| Ko-Qwen2-7B-Instruct.Q4_K.gguf | Q4_K | 4.36GB |
| Ko-Qwen2-7B-Instruct.Q4_K_M.gguf | Q4_K_M | 4.36GB |
| Ko-Qwen2-7B-Instruct.Q4_1.gguf | Q4_1 | 4.54GB |
| Ko-Qwen2-7B-Instruct.Q5_0.gguf | Q5_0 | 4.95GB |
| Ko-Qwen2-7B-Instruct.Q5_K_S.gguf | Q5_K_S | 4.95GB |
| Ko-Qwen2-7B-Instruct.Q5_K.gguf | Q5_K | 5.07GB |
| Ko-Qwen2-7B-Instruct.Q5_K_M.gguf | Q5_K_M | 5.07GB |
| Ko-Qwen2-7B-Instruct.Q5_1.gguf | Q5_1 | 5.36GB |
| Ko-Qwen2-7B-Instruct.Q6_K.gguf | Q6_K | 5.82GB |
| Ko-Qwen2-7B-Instruct.Q8_0.gguf | Q8_0 | 7.54GB |
1from transformers import TextStreamer, pipeline, AutoTokenizer, AutoModelForCausalLM
2
3model_id = 'spow12/Ko-Qwen2-7B-Instruct'
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5# %%
6model = AutoModelForCausalLM.from_pretrained(
7 model_id,
8 torch_dtype=torch.bfloat16,
9 attn_implementation="flash_attention_2",
10 device_map='auto',
11)
12model.eval()
13
14pipe = pipeline("conversational", model=model, tokenizer=tokenizer, device_map='auto')
15
16streamer = TextStreamer(tokenizer)
17
18generation_configs = dict(
19 max_new_tokens=2048,
20 num_return_sequences=1,
21 temperature=0.1,
22 # early_stopping=True,
23 repetition_penalty=1.2,
24 num_beams=1,
25 do_sample=True,
26 top_k=20,
27 top_p=0.9,
28 eos_token_id=tokenizer.eos_token_id,
29 pad_token_id=tokenizer.eos_token_id,
30 streamer=streamer
31)
32
33sys_message = """당신은 친절한 챗봇으로서 상대방의 요청에 최대한 자세하고 친절하게 답해야합니다.
34사용자가 제공하는 정보를 세심하게 분석하여 사용자의 의도를 신속하게 파악하고 그에 따라 답변을 생성해야합니다.
35
36항상 매우 자연스러운 한국어로 응답하세요."""
37
38message = [
39 {
40 'role': "system",
41 'content': sys_message
42 },
43 {
44 'role': 'user',
45 'content': "현재의 경제상황에 대해 어떻게 생각해?."
46 }
47]
48conversation = pipe(message, **generation_configs)
49conversation[-1]<|im_start|>system
당신은 친절한 챗봇으로서 상대방의 요청에 최대한 자세하고 친절하게 답해야합니다.
사용자가 제공하는 정보를 세심하게 분석하여 사용자의 의도를 신속하게 파악하고 그에 따라 답변을 생성해야합니다.
항상 매우 자연스러운 한국어로 응답하세요.<|im_end|>
<|im_start|>user
현재의 경제상황에 대해 어떻게 생각해?<|im_end|>
<|im_start|>assistant
저는 인공지능이기 때문에 현재의 경제 상황이나 개인적인 의견을 가지고 있지 않습니다. 하지만, 최근에는 전 세계적으로 경기가 어려워지고 있는 추세입니다. 많은 나라들이 대처하기 위한 다양한 정책과 조치들을 시행하고 있습니다. 이러한 상황에서 각자 자신의 역량을 발휘하며 살아가시길 바랍니다.<|im_end|>transformers>=4.37.0, or you might encounter the following error:KeyError: 'qwen2'apply_chat_template to show you how to load the tokenizer and model and how to generate contents.1from transformers import AutoModelForCausalLM, AutoTokenizer
2device = "cuda" # the device to load the model onto
3
4model = AutoModelForCausalLM.from_pretrained(
5 "Qwen/Qwen2-7B-Instruct",
6 torch_dtype="auto",
7 device_map="auto"
8)
9tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-7B-Instruct")
10
11prompt = "Give me a short introduction to large language model."
12messages = [
13 {"role": "system", "content": "You are a helpful assistant."},
14 {"role": "user", "content": prompt}
15]
16text = tokenizer.apply_chat_template(
17 messages,
18 tokenize=False,
19 add_generation_prompt=True
20)
21model_inputs = tokenizer([text], return_tensors="pt").to(device)
22
23generated_ids = model.generate(
24 model_inputs.input_ids,
25 max_new_tokens=512
26)
27generated_ids = [
28 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
29]
30
31response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]pip install "vllm>=0.4.3"config.json file by including the below snippet:1 {
2 "architectures": [
3 "Qwen2ForCausalLM"
4 ],
5 // ...
6 "vocab_size": 152064,
7
8 // adding the following snippets
9 "rope_scaling": {
10 "factor": 4.0,
11 "original_max_position_embeddings": 32768,
12 "type": "yarn"
13 }
14 }python -m vllm.entrypoints.openai.api_server --served-model-name Qwen2-7B-Instruct --model path/to/weights1curl http://localhost:8000/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "Qwen2-7B-Instruct",
5 "messages": [
6 {"role": "system", "content": "You are a helpful assistant."},
7 {"role": "user", "content": "Your Long Input Here."}
8 ]
9 }'rope_scaling configuration only when processing long contexts is required.| Datasets | Llama-3-8B-Instruct | Yi-1.5-9B-Chat | GLM-4-9B-Chat | Qwen1.5-7B-Chat | Qwen2-7B-Instruct |
|---|---|---|---|---|---|
| English | |||||
| MMLU | 68.4 | 69.5 | 72.4 | 59.5 | 70.5 |
| MMLU-Pro | 41.0 | - | - | 29.1 | 44.1 |
| GPQA | 34.2 | - | - | 27.8 | 25.3 |
| TheroemQA | 23.0 | - | - | 14.1 | 25.3 |
| MT-Bench | 8.05 | 8.20 | 8.35 | 7.60 | 8.41 |
| Coding | |||||
| Humaneval | 62.2 | 66.5 | 71.8 | 46.3 | 79.9 |
| MBPP | 67.9 | - | - | 48.9 | 67.2 |
| MultiPL-E | 48.5 | - | - | 27.2 | 59.1 |
| Evalplus | 60.9 | - | - | 44.8 | 70.3 |
| LiveCodeBench | 17.3 | - | - | 6.0 | 26.6 |
| Mathematics | |||||
| GSM8K | 79.6 | 84.8 | 79.6 | 60.3 | 82.3 |
| MATH | 30.0 | 47.7 | 50.6 | 23.2 | 49.6 |
| Chinese | |||||
| C-Eval | 45.9 | - | 75.6 | 67.3 | 77.2 |
| AlignBench | 6.20 | 6.90 | 7.01 | 6.20 | 7.21 |
@article{qwen2,
title={Qwen2 Technical Report},
year={2024}
}