Views
No views yet

| HuggingFace Model | ModelScope Model | Wisemodel Model | |
|---|---|---|---|
| Skywork-MoE-Base | 🤗 Skywork-MoE-Base | 🤖Skywork-MoE-Base | 👾Skywork-MoE-Base |
| Skywork-MoE-Base-FP8 | 🤗 Skywork-MoE-Base-FP8 | 🤖Skywork-MoE-Base-FP8 | 👾Skywork-MoE-Base-FP8 |
| Skywork-MoE-Chat | 😊 Coming Soon | 🤖 | 👾 |

1
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model = AutoModelForCausalLM.from_pretrained("Skywork/Skywork-MoE-Base", trust_remote_code=True, device_map='auto')
5tokenizer = AutoTokenizer.from_pretrained("Skywork/Skywork-MoE-Base", trust_remote_code=True)
6
7inputs = tokenizer('陕西的省会是西安', return_tensors='pt').to(model.device)
8response = model.generate(inputs.input_ids, max_length=128)
9print(tokenizer.decode(response.cpu()[0], skip_special_tokens=True))
10"""
11陕西的省会是西安。
12西安,古称长安、镐京,是陕西省会、副省级市、关中平原城市群核心城市、丝绸之路起点城市、“一带一路”核心区、中国西部地区重要的中心城市,国家重要的科研、教育、工业基地。
13西安是中国四大古都之一,联合国科教文组织于1981年确定的“世界历史名城”,美媒评选的世界十大古都之一。地处关中平原中部,北濒渭河,南依秦岭,八水润长安。下辖11区2县并代管西
14"""
15
16inputs = tokenizer('陕西的省会是西安,甘肃的省会是兰州,河南的省会是郑州', return_tensors='pt').to(model.device)
17response = model.generate(inputs.input_ids, max_length=128)
18print(tokenizer.decode(response.cpu()[0], skip_special_tokens=True))
19"""
20陕西的省会是西安,甘肃的省会是兰州,河南的省会是郑州,湖北的省会是武汉,湖南的省会是长沙,安徽的省会是合肥,江西的省会是南昌,江苏的省会是南京,浙江的省会是杭州,福建的省会是福州,广东的省会是广州,广西的省会是南宁,四川的省会是成都,贵州的省会是贵阳,云南的省会是昆明,山西的省会是太原,山东的省会是济南,河北的省会是石家庄,辽宁的省会是沈阳,吉林的省会是长春,黑龙江的
21"""
22vllmSkywork-MoE-Base-FP81# for cuda12.1
2pip3 install --pre torch pytorch-triton --index-url https://download.pytorch.org/whl/nightly/cu121
3# for cuda12.4
4pip3 install --pre torch pytorch-triton --index-url https://download.pytorch.org/whl/nightly/cu1241MAX_JOBS=8 pip3 install git+https://github.com/facebookresearch/xformers.git # need to wait for a long time
2pip3 install vllm-flash-attn --no-depsvllm provided by skywork:1git clone https://github.com/SkyworkAI/vllm.git
2cd vllm1pip3 install -r requirements-build.txt
2pip3 install -r requirements-cuda.txt
3MAX_JOBS=8 python3 setup.py installdocker pull registry.cn-wulanchabu.aliyuncs.com/triple-mu/skywork-moe-vllm:v11model_path="Skywork/Skywork-MoE-Base-FP8"
2workspace=${PWD}
3
4docker run \
5 --runtime nvidia \
6 --gpus all \
7 -it \
8 --rm \
9 --shm-size=1t \
10 --ulimit memlock=-1 \
11 --privileged=true \
12 --ulimit stack=67108864 \
13 --ipc=host \
14 -v ${model_path}:/Skywork-MoE-Base-FP8 \
15 -v ${workspace}:/workspace \
16 registry.cn-wulanchabu.aliyuncs.com/triple-mu/skywork-moe-vllm:v11from vllm import LLM, SamplingParams
2
3model_path = 'Skywork/Skywork-MoE-Base-FP8'
4prompts = [
5 "The president of the United States is",
6 "The capital of France is",
7]
8
9sampling_params = SamplingParams(temperature=0.3, max_tokens=256)
10
11llm = LLM(
12 model=model_path,
13 kv_cache_dtype='auto',
14 tensor_parallel_size=8,
15 gpu_memory_utilization=0.95,
16 enforce_eager=True,
17 trust_remote_code=True,
18)
19
20outputs = llm.generate(prompts, sampling_params)
21
22for output in outputs:
23 prompt = output.prompt
24 generated_text = output.outputs[0].text
25 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")@misc{wei2024skywork,
title={Skywork-MoE: A Deep Dive into Training Techniques for Mixture-of-Experts Language Models},
author={Tianwen Wei, Bo Zhu, Liang Zhao, Cheng Cheng, Biye Li, Weiwei Lü, Peng Cheng, Jianhao Zhang, Xiaoyu Zhang, Liang Zeng, Xiaokun Wang, Yutuan Ma, Rui Hu, Shuicheng Yan, Han Fang, Yahui Zhou},
url={https://arxiv.org/pdf/2406.06563},
year={2024},
archivePrefix={arXiv},
primaryClass={cs.CL}
}@article{zhao2024longskywork,
title={LongSkywork: A Training Recipe for Efficiently Extending Context Length in Large Language Models},
author={Zhao, Liang and Wei, Tianwen and Zeng, Liang and Cheng, Cheng and Yang, Liu and Cheng, Peng and Wang, Lijie and Li, Chenxia and Wu, Xuejie and Zhu, Bo and others},
journal={arXiv preprint arXiv:2406.00605},
url={https://arxiv.org/abs/2406.00605},
year={2024}
}