Instructions to use Hanlard/Pangu_alpha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hanlard/Pangu_alpha with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Hanlard/Pangu_alpha", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Hanlard/Pangu_alpha", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Hanlard/Pangu_alpha with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Hanlard/Pangu_alpha" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hanlard/Pangu_alpha", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Hanlard/Pangu_alpha
- SGLang
How to use Hanlard/Pangu_alpha 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 "Hanlard/Pangu_alpha" \ --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": "Hanlard/Pangu_alpha", "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 "Hanlard/Pangu_alpha" \ --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": "Hanlard/Pangu_alpha", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Hanlard/Pangu_alpha with Docker Model Runner:
docker model run hf.co/Hanlard/Pangu_alpha
Upload 6 files
Browse files- TokenConvert.py +30 -0
- special_tokens_map.json +1 -0
- spiece.model +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- vocab.vocab +0 -0
TokenConvert.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from tokenization_gptpangu import GPTPanguTokenizer
|
| 2 |
+
# import json
|
| 3 |
+
#
|
| 4 |
+
# tokenizer = GPTPanguTokenizer.from_pretrained(".")
|
| 5 |
+
# with open("tokenizer.json",encoding="utf-8") as f:
|
| 6 |
+
# cofig = json.load(f)
|
| 7 |
+
#
|
| 8 |
+
#
|
| 9 |
+
# vocab_file = "vocab.vocab"
|
| 10 |
+
#
|
| 11 |
+
# f = open(vocab_file, 'r', encoding="utf-8")
|
| 12 |
+
# lines = f.readlines()
|
| 13 |
+
# vocab = []
|
| 14 |
+
# for line in enumerate(lines):
|
| 15 |
+
# key = line[1].split('\t')[0]
|
| 16 |
+
# pair = [key,line[0]]
|
| 17 |
+
# vocab.append(pair)
|
| 18 |
+
#
|
| 19 |
+
# cofig['model']['vocab'] = vocab
|
| 20 |
+
#
|
| 21 |
+
# with open("new_tokenizer.json","w",encoding="utf-8") as w:
|
| 22 |
+
# d = json.dumps(cofig)
|
| 23 |
+
# w.write(d)
|
| 24 |
+
#
|
| 25 |
+
# print("ok")
|
| 26 |
+
|
| 27 |
+
from transformers import AutoTokenizer
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained(".")
|
| 29 |
+
|
| 30 |
+
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "<sep>", "pad_token": "<pad>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}, "additional_special_tokens": [ "<eod>"]}
|
spiece.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:18857e86783e50cfcaa0bc3c043fb4e9b5f240b885d2870ea593ee69b44f7a3a
|
| 3 |
+
size 879697
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"do_lower_case": false, "remove_space": true, "keep_accents": false, "bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "<sep>", "pad_token": "<pad>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "additional_special_tokens": [ "<eod>"], "special_tokens_map_file": null, "name_or_path": "TsinghuaAI/CPM-Generate", "tokenizer_class": "CpmTokenizer"}
|
vocab.vocab
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|