Instructions to use Skywork/Skywork-13B-Math with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Skywork/Skywork-13B-Math with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Skywork/Skywork-13B-Math", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Skywork/Skywork-13B-Math", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Skywork/Skywork-13B-Math with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Skywork/Skywork-13B-Math" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Skywork/Skywork-13B-Math", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Skywork/Skywork-13B-Math
- SGLang
How to use Skywork/Skywork-13B-Math with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Skywork/Skywork-13B-Math" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Skywork/Skywork-13B-Math", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Skywork/Skywork-13B-Math" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Skywork/Skywork-13B-Math", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Skywork/Skywork-13B-Math with Docker Model Runner:
docker model run hf.co/Skywork/Skywork-13B-Math
Update README.md
Browse files
README.md
CHANGED
|
@@ -99,14 +99,32 @@ def special_encode(input, tokenizer):
|
|
| 99 |
res_id.append(sep_id)
|
| 100 |
|
| 101 |
return res_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
if __name__ == '__main__':
|
| 103 |
text = "ๅฐ็่ฆๅฐ150ๅๅ
ๅซ่ฏ้20%็ๅ่ฏ็จ้ๆๅซ่ฏ้5%็่ฏๆฐด๏ผ้่ฆๅ ๆฐดๅคๅฐๅๅ
๏ผ"
|
| 104 |
text_token_ids = torch.tensor(special_encode(
|
| 105 |
text, tokenizer)).to(model.device).reshape(1, -1)
|
| 106 |
response = model.generate(text_token_ids, do_sample=False, max_length=512)
|
| 107 |
-
response_text = tokenizer.decode(response.cpu()[0], skip_special_tokens=True)
|
| 108 |
-
|
| 109 |
-
|
|
|
|
| 110 |
"""่พๅบ็ปๆ๏ผ
|
| 111 |
้ฆๅ
๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ150ๅๅ
ๅซ่ฏ้20%็ๅ่ฏไธญๅซๆๅคๅฐๅๅ
็่ฏใ\n\n150ๅๅ
* 20% = 30ๅๅ
\n\n็ถๅ๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ่ฆๅพๅฐๅซ่ฏ้5%็่ฏๆฐด๏ผ้่ฆๅคๅฐๅๅ
็่ฏๆฐดใ\n\n30ๅๅ
/ 5% = 600ๅๅ
\n\nๆๅ๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ้่ฆๅ ๅคๅฐๅๅ
็ๆฐดใ\n\n600ๅๅ
- 150ๅๅ
= 450ๅๅ
\n\nๆไปฅ็ญๆกๆฏ๏ผๅฐ็้่ฆๅ 450ๅๅ
็ๆฐดใ
|
| 112 |
"""
|
|
@@ -141,13 +159,25 @@ def special_encode(input, tokenizer):
|
|
| 141 |
res_id.append(sep_id)
|
| 142 |
|
| 143 |
return res_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
if __name__ == '__main__':
|
| 145 |
text="Janetโs ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?"
|
| 146 |
text_token_ids = torch.tensor(special_encode(
|
| 147 |
text, tokenizer)).to(model.device).reshape(1, -1)
|
| 148 |
response = model.generate(text_token_ids, do_sample=False, max_length=512)
|
| 149 |
-
response_text = tokenizer.decode(response.cpu()[0], skip_special_tokens=True)
|
| 150 |
-
|
| 151 |
print(response_text)
|
| 152 |
"""Skywork-13B-Math Response:
|
| 153 |
First, we need to find out how many eggs Janet has left after eating for breakfast and baking for her friends. \n\nShe has 16 eggs per day, eats 3 for breakfast and uses 4 for baking. So, 16 - 3 - 4 = 9 eggs are left for selling at the farmers' market.\n\nSince she sells each egg for $2, she makes 9 * 2 = $<<9*2=18>>18 every day at the farmers' market.\n\nSo, the answer is $18.
|
|
|
|
| 99 |
res_id.append(sep_id)
|
| 100 |
|
| 101 |
return res_id
|
| 102 |
+
|
| 103 |
+
def special_encode(input, tokenizer):
|
| 104 |
+
raw_str = "[USER]%s[SEP][BOT]" % input.strip().replace("\r", "")
|
| 105 |
+
eos_id = tokenizer.eos_token_id
|
| 106 |
+
bos_id = tokenizer.bos_token_id
|
| 107 |
+
sep_id = tokenizer.encode("[SEP]")[-1]
|
| 108 |
+
res_id = [eos_id, bos_id]
|
| 109 |
+
arr = raw_str.split("[SEP]")
|
| 110 |
+
for elem_idx in range(len(arr)):
|
| 111 |
+
elem = arr[elem_idx]
|
| 112 |
+
elem_id = tokenizer.encode(elem)[1:]
|
| 113 |
+
res_id += elem_id
|
| 114 |
+
if elem_idx < len(arr) - 1:
|
| 115 |
+
res_id.append(sep_id)
|
| 116 |
+
|
| 117 |
+
return res_id
|
| 118 |
+
|
| 119 |
if __name__ == '__main__':
|
| 120 |
text = "ๅฐ็่ฆๅฐ150ๅๅ
ๅซ่ฏ้20%็ๅ่ฏ็จ้ๆๅซ่ฏ้5%็่ฏๆฐด๏ผ้่ฆๅ ๆฐดๅคๅฐๅๅ
๏ผ"
|
| 121 |
text_token_ids = torch.tensor(special_encode(
|
| 122 |
text, tokenizer)).to(model.device).reshape(1, -1)
|
| 123 |
response = model.generate(text_token_ids, do_sample=False, max_length=512)
|
| 124 |
+
response_text = tokenizer.decode(response.cpu()[0], skip_special_tokens=True)
|
| 125 |
+
|
| 126 |
+
response_text = extract_res(response_text)
|
| 127 |
+
print(response_text)
|
| 128 |
"""่พๅบ็ปๆ๏ผ
|
| 129 |
้ฆๅ
๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ150ๅๅ
ๅซ่ฏ้20%็ๅ่ฏไธญๅซๆๅคๅฐๅๅ
็่ฏใ\n\n150ๅๅ
* 20% = 30ๅๅ
\n\n็ถๅ๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ่ฆๅพๅฐๅซ่ฏ้5%็่ฏๆฐด๏ผ้่ฆๅคๅฐๅๅ
็่ฏๆฐดใ\n\n30ๅๅ
/ 5% = 600ๅๅ
\n\nๆๅ๏ผๆไปฌ้่ฆ่ฎก็ฎๅบ้่ฆๅ ๅคๅฐๅๅ
็ๆฐดใ\n\n600ๅๅ
- 150ๅๅ
= 450ๅๅ
\n\nๆไปฅ็ญๆกๆฏ๏ผๅฐ็้่ฆๅ 450ๅๅ
็ๆฐดใ
|
| 130 |
"""
|
|
|
|
| 159 |
res_id.append(sep_id)
|
| 160 |
|
| 161 |
return res_id
|
| 162 |
+
|
| 163 |
+
def extract_res(response):
|
| 164 |
+
if "[BOT]" in response:
|
| 165 |
+
response = response.split("[BOT]")[1]
|
| 166 |
+
if "<s>" in response:
|
| 167 |
+
response = response.split("<s>")[-1]
|
| 168 |
+
if "</s>" in response:
|
| 169 |
+
response = response.split("</s>")[0]
|
| 170 |
+
if "[SEP]" in response:
|
| 171 |
+
response = response.split("[SEP]")[0]
|
| 172 |
+
return response
|
| 173 |
+
|
| 174 |
if __name__ == '__main__':
|
| 175 |
text="Janetโs ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?"
|
| 176 |
text_token_ids = torch.tensor(special_encode(
|
| 177 |
text, tokenizer)).to(model.device).reshape(1, -1)
|
| 178 |
response = model.generate(text_token_ids, do_sample=False, max_length=512)
|
| 179 |
+
response_text = tokenizer.decode(response.cpu()[0], skip_special_tokens=True)
|
| 180 |
+
response_text = extract_res(response_text)
|
| 181 |
print(response_text)
|
| 182 |
"""Skywork-13B-Math Response:
|
| 183 |
First, we need to find out how many eggs Janet has left after eating for breakfast and baking for her friends. \n\nShe has 16 eggs per day, eats 3 for breakfast and uses 4 for baking. So, 16 - 3 - 4 = 9 eggs are left for selling at the farmers' market.\n\nSince she sells each egg for $2, she makes 9 * 2 = $<<9*2=18>>18 every day at the farmers' market.\n\nSo, the answer is $18.
|