Views
No views yet

{prompt}
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|---|---|---|---|---|---|
| main | 4 | 128 | Alpaca Japanese | 4096 | 36.98 GB |
TheBloke/Swallow-70B-AWQ.Swallow-70B-AWQ--quantization awq parameter.python3 -m vllm.entrypoints.api_server --model TheBloke/Swallow-70B-AWQ --quantization awq --dtype autoquantization=awq.1from vllm import LLM, SamplingParams
2
3prompts = [
4 "Tell me about AI",
5 "Write a story about llamas",
6 "What is 291 - 150?",
7 "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
8]
9prompt_template=f'''{prompt}
10'''
11
12prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
13
14sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
15
16llm = LLM(model="TheBloke/Swallow-70B-AWQ", quantization="awq", dtype="auto")
17
18outputs = llm.generate(prompts, sampling_params)
19
20# Print the outputs.
21for output in outputs:
22 prompt = output.prompt
23 generated_text = output.outputs[0].text
24 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")ghcr.io/huggingface/text-generation-inference:1.1.0--model-id TheBloke/Swallow-70B-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096pip3 install huggingface-hub1from huggingface_hub import InferenceClient
2
3endpoint_url = "https://your-endpoint-url-here"
4
5prompt = "Tell me about AI"
6prompt_template=f'''{prompt}
7'''
8
9client = InferenceClient(endpoint_url)
10response = client.text_generation(prompt,
11 max_new_tokens=128,
12 do_sample=True,
13 temperature=0.7,
14 top_p=0.95,
15 top_k=40,
16 repetition_penalty=1.1)
17
18print(f"Model output: ", response)pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl1pip3 uninstall -y autoawq
2git clone https://github.com/casper-hansen/AutoAWQ
3cd AutoAWQ
4pip3 install .1from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
2
3model_name_or_path = "TheBloke/Swallow-70B-AWQ"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name_or_path,
8 low_cpu_mem_usage=True,
9 device_map="cuda:0"
10)
11
12# Using the text streamer to stream output one token at a time
13streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
14
15prompt = "Tell me about AI"
16prompt_template=f'''{prompt}
17'''
18
19# Convert prompt to tokens
20tokens = tokenizer(
21 prompt_template,
22 return_tensors='pt'
23).input_ids.cuda()
24
25generation_params = {
26 "do_sample": True,
27 "temperature": 0.7,
28 "top_p": 0.95,
29 "top_k": 40,
30 "max_new_tokens": 512,
31 "repetition_penalty": 1.1
32}
33
34# Generate streamed output, visible one token at a time
35generation_output = model.generate(
36 tokens,
37 streamer=streamer,
38 **generation_params
39)
40
41# Generation without a streamer, which will include the prompt in the output
42generation_output = model.generate(
43 tokens,
44 **generation_params
45)
46
47# Get the tokens from the output, decode them, print them
48token_output = generation_output[0]
49text_output = tokenizer.decode(token_output)
50print("model.generate output: ", text_output)
51
52# Inference is also possible via Transformers' pipeline
53from transformers import pipeline
54
55pipe = pipeline(
56 "text-generation",
57 model=model,
58 tokenizer=tokenizer,
59 **generation_params
60)
61
62pipe_output = pipe(prompt_template)[0]['generated_text']
63print("pipeline output: ", pipe_output)
64Loader: AutoAWQ.
| Model | Size | JCommonsenseQA | JEMHopQA | NIILC | JSQuAD | XL-Sum | MGSM | WMT20-en-ja | WMT20-ja-en |
|---|---|---|---|---|---|---|---|---|---|
| 4-shot | 4-shot | 4-shot | 4-shot | 1-shot | 4-shot | 4-shot | 4-shot | ||
| Llama 2 | 7B | 0.3852 | 0.4240 | 0.3410 | 0.7917 | 0.1905 | 0.0760 | 0.1783 | 0.1738 |
| Swallow | 7B | 0.4808 | 0.5078 | 0.5968 | 0.8573 | 0.1830 | 0.1240 | 0.2510 | 0.1511 |
| Llama 2 | 13B | 0.6997 | 0.4415 | 0.4170 | 0.8533 | 0.2139 | 0.1320 | 0.2146 | 0.1982 |
| Swallow | 13B | 0.7837 | 0.5063 | 0.6398 | 0.9005 | 0.2168 | 0.2040 | 0.2720 | 0.1771 |
| Llama 2 | 70B | 0.8686 | 0.4656 | 0.5256 | 0.9080 | 0.2361 | 0.3560 | 0.2643 | 0.2398 |
| Swallow | 70B | 0.9348 | 0.6290 | 0.6960 | 0.9176 | 0.2266 | 0.4840 | 0.3043 | 0.2298 |
pip install -r requirements.txt1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_name = "tokyotech-llm/Swallow-7b-instruct-hf"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, device_map="auto")
8
9
10PROMPT_DICT = {
11 "prompt_input": (
12 "以下に、あるタスクを説明する指示があり、それに付随する入力が更なる文脈を提供しています。"
13 "リクエストを適切に完了するための回答を記述してください。\n\n"
14 "### 指示:\n{instruction}\n\n### 入力:\n{input}\n\n### 応答:"
15
16 ),
17 "prompt_no_input": (
18 "以下に、あるタスクを説明する指示があります。"
19 "リクエストを適切に完了するための回答を記述してください。\n\n"
20 "### 指示:\n{instruction}\n\n### 応答:"
21 ),
22}
23
24def create_prompt(instruction, input=None):
25 """
26 Generates a prompt based on the given instruction and an optional input.
27 If input is provided, it uses the 'prompt_input' template from PROMPT_DICT.
28 If no input is provided, it uses the 'prompt_no_input' template.
29
30 Args:
31 instruction (str): The instruction describing the task.
32 input (str, optional): Additional input providing context for the task. Default is None.
33
34 Returns:
35 str: The generated prompt.
36 """
37 if input:
38 # Use the 'prompt_input' template when additional input is provided
39 return PROMPT_DICT["prompt_input"].format(instruction=instruction, input=input)
40 else:
41 # Use the 'prompt_no_input' template when no additional input is provided
42 return PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
43
44# Example usage
45instruction_example = "以下のトピックに関する詳細な情報を提供してください。"
46input_example = "東京工業大学の主なキャンパスについて教えてください"
47prompt = create_prompt(instruction_example, input_example)
48
49input_ids = tokenizer.encode(
50 prompt,
51 add_special_tokens=False,
52 return_tensors="pt"
53)
54
55tokens = model.generate(
56 input_ids.to(device=model.device),
57 max_new_tokens=128,
58 temperature=0.99,
59 top_p=0.95,
60 do_sample=True,
61)
62
63out = tokenizer.decode(tokens[0], skip_special_tokens=True)
64print(out)
651import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_name = "tokyotech-llm/Swallow-7b-hf"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
8
9prompt = "東京工業大学の主なキャンパスは、"
10input_ids = tokenizer.encode(
11 prompt,
12 add_special_tokens=False,
13 return_tensors="pt"
14)
15tokens = model.generate(
16 input_ids.to(device=model.device),
17 max_new_tokens=128,
18 temperature=0.99,
19 top_p=0.95,
20 do_sample=True,
21)
22
23out = tokenizer.decode(tokens[0], skip_special_tokens=True)
24print(out)