Instructions to use sunzeyeah/pangu-350M-reward with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sunzeyeah/pangu-350M-reward with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sunzeyeah/pangu-350M-reward", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("sunzeyeah/pangu-350M-reward", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sunzeyeah/pangu-350M-reward with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sunzeyeah/pangu-350M-reward" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sunzeyeah/pangu-350M-reward", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sunzeyeah/pangu-350M-reward
- SGLang
How to use sunzeyeah/pangu-350M-reward 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 "sunzeyeah/pangu-350M-reward" \ --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": "sunzeyeah/pangu-350M-reward", "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 "sunzeyeah/pangu-350M-reward" \ --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": "sunzeyeah/pangu-350M-reward", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sunzeyeah/pangu-350M-reward with Docker Model Runner:
docker model run hf.co/sunzeyeah/pangu-350M-reward
update modeling
Browse files- modeling_gptpangu.py +1 -1
modeling_gptpangu.py
CHANGED
|
@@ -460,7 +460,7 @@ class GPTPanguForCausalLM(GPTPanguPreTrainedModel):
|
|
| 460 |
|
| 461 |
if attention_mask is not None and position_ids is None:
|
| 462 |
# create position_ids on the fly for batch generation
|
| 463 |
-
position_ids = attention_mask.
|
| 464 |
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 465 |
if past:
|
| 466 |
position_ids = position_ids[:, -1].unsqueeze(-1)
|
|
|
|
| 460 |
|
| 461 |
if attention_mask is not None and position_ids is None:
|
| 462 |
# create position_ids on the fly for batch generation
|
| 463 |
+
position_ids = attention_mask.int().cumsum(-1).long() - 1
|
| 464 |
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 465 |
if past:
|
| 466 |
position_ids = position_ids[:, -1].unsqueeze(-1)
|