Views
No views yet

{prompt}
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|---|---|---|---|---|---|
| main | 4 | 128 | Evol Instruct Code | 8192 | 3.89 GB |
TheBloke/deepseek-coder-6.7B-base-AWQ.deepseek-coder-6.7B-base-AWQ--quantization awq parameter.python3 python -m vllm.entrypoints.api_server --model TheBloke/deepseek-coder-6.7B-base-AWQ --quantization awqquantization=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/deepseek-coder-6.7B-base-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/deepseek-coder-6.7B-base-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 autoawq1pip3 uninstall -y autoawq
2git clone https://github.com/casper-hansen/AutoAWQ
3cd AutoAWQ
4pip3 install .1from awq import AutoAWQForCausalLM
2from transformers import AutoTokenizer
3
4model_name_or_path = "TheBloke/deepseek-coder-6.7B-base-AWQ"
5
6# Load tokenizer
7tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
8# Load model
9model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
10 trust_remote_code=False, safetensors=True)
11
12prompt = "Tell me about AI"
13prompt_template=f'''{prompt}
14'''
15
16print("*** Running model.generate:")
17
18token_input = tokenizer(
19 prompt_template,
20 return_tensors='pt'
21).input_ids.cuda()
22
23# Generate output
24generation_output = model.generate(
25 token_input,
26 do_sample=True,
27 temperature=0.7,
28 top_p=0.95,
29 top_k=40,
30 max_new_tokens=512
31)
32
33# Get the tokens from the output, decode them, print them
34token_output = generation_output[0]
35text_output = tokenizer.decode(token_output)
36print("LLM output: ", text_output)
37
38"""
39# Inference should be possible with transformers pipeline as well in future
40# But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
41from transformers import pipeline
42
43print("*** Pipeline:")
44pipe = pipeline(
45 "text-generation",
46 model=model,
47 tokenizer=tokenizer,
48 max_new_tokens=512,
49 do_sample=True,
50 temperature=0.7,
51 top_p=0.95,
52 top_k=40,
53 repetition_penalty=1.1
54)
55
56print(pipe(prompt_template)[0]['generated_text'])
57"""Loader: AutoAWQ.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
4model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
5input_text = "#write a quick sort algorithm"
6inputs = tokenizer(input_text, return_tensors="pt").cuda()
7outputs = model.generate(**inputs, max_length=128)
8print(tokenizer.decode(outputs[0], skip_special_tokens=True))1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
4model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
5input_text = """<|fim▁begin|>def quick_sort(arr):
6 if len(arr) <= 1:
7 return arr
8 pivot = arr[0]
9 left = []
10 right = []
11<|fim▁hole|>
12 if arr[i] < pivot:
13 left.append(arr[i])
14 else:
15 right.append(arr[i])
16 return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
17inputs = tokenizer(input_text, return_tensors="pt").cuda()
18outputs = model.generate(**inputs, max_length=128)
19print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])1from transformers import AutoTokenizer, AutoModelForCausalLM
2tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
3model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
4
5input_text = """#utils.py
6import torch
7from sklearn import datasets
8from sklearn.model_selection import train_test_split
9from sklearn.preprocessing import StandardScaler
10from sklearn.metrics import accuracy_score
11
12def load_data():
13 iris = datasets.load_iris()
14 X = iris.data
15 y = iris.target
16
17 # Standardize the data
18 scaler = StandardScaler()
19 X = scaler.fit_transform(X)
20
21 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
22
23 # Convert numpy data to PyTorch tensors
24 X_train = torch.tensor(X_train, dtype=torch.float32)
25 X_test = torch.tensor(X_test, dtype=torch.float32)
26 y_train = torch.tensor(y_train, dtype=torch.int64)
27 y_test = torch.tensor(y_test, dtype=torch.int64)
28
29 return X_train, X_test, y_train, y_test
30
31def evaluate_predictions(y_test, y_pred):
32 return accuracy_score(y_test, y_pred)
33#model.py
34import torch
35import torch.nn as nn
36import torch.optim as optim
37from torch.utils.data import DataLoader, TensorDataset
38
39class IrisClassifier(nn.Module):
40 def __init__(self):
41 super(IrisClassifier, self).__init__()
42 self.fc = nn.Sequential(
43 nn.Linear(4, 16),
44 nn.ReLU(),
45 nn.Linear(16, 3)
46 )
47
48 def forward(self, x):
49 return self.fc(x)
50
51 def train_model(self, X_train, y_train, epochs, lr, batch_size):
52 criterion = nn.CrossEntropyLoss()
53 optimizer = optim.Adam(self.parameters(), lr=lr)
54
55 # Create DataLoader for batches
56 dataset = TensorDataset(X_train, y_train)
57 dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
58
59 for epoch in range(epochs):
60 for batch_X, batch_y in dataloader:
61 optimizer.zero_grad()
62 outputs = self(batch_X)
63 loss = criterion(outputs, batch_y)
64 loss.backward()
65 optimizer.step()
66
67 def predict(self, X_test):
68 with torch.no_grad():
69 outputs = self(X_test)
70 _, predicted = outputs.max(1)
71 return predicted.numpy()
72#main.py
73from utils import load_data, evaluate_predictions
74from model import IrisClassifier as Classifier
75
76def main():
77 # Model training and evaluation
78"""
79inputs = tokenizer(input_text, return_tensors="pt").cuda()
80outputs = model.generate(**inputs, max_new_tokens=140)
81print(tokenizer.decode(outputs[0]))