Text Generation
Transformers
Safetensors
English
Chinese
Russian
yue2
music-generation
orbitquant
quantization
4-bit precision
custom-code
8-bit precision
Instructions to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WaveCut/YuE2-3B-OrbitQuant-W4A4")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("WaveCut/YuE2-3B-OrbitQuant-W4A4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WaveCut/YuE2-3B-OrbitQuant-W4A4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/WaveCut/YuE2-3B-OrbitQuant-W4A4
- SGLang
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 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 "WaveCut/YuE2-3B-OrbitQuant-W4A4" \ --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": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "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 "WaveCut/YuE2-3B-OrbitQuant-W4A4" \ --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": "WaveCut/YuE2-3B-OrbitQuant-W4A4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use WaveCut/YuE2-3B-OrbitQuant-W4A4 with Docker Model Runner:
docker model run hf.co/WaveCut/YuE2-3B-OrbitQuant-W4A4
Download src/runtime/yue2/compact_sampling.py from WaveCut/YuE2-3B-OrbitQuant-W4A4: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/WaveCut/YuE2-3B-OrbitQuant-W4A4/resolve/main/src/runtime/yue2/compact_sampling.py
- Command line
-
hf download hf://WaveCut/YuE2-3B-OrbitQuant-W4A4/src/runtime/yue2/compact_sampling.py
-
curl -L -o compact_sampling.py https://huggingface.co/WaveCut/YuE2-3B-OrbitQuant-W4A4/resolve/main/src/runtime/yue2/compact_sampling.py
1.44 kB
| """Experimental top-k sampling: tied boundary logits may select a different support.""" | |
| import torch | |
| from .protocol import EOD, ABC_END, MUSIC_END, CODEC_OFFSET, CODEC_SIZE | |
| from .sampling import window_penalty, distribution | |
| def sample_topk(logits, sampling, history, step, phase, legacy_off, generator): | |
| if legacy_off or sampling.temperature==0: | |
| scores=distribution(logits,sampling,history,step,phase,legacy_off) | |
| return scores.argmax(-1,keepdim=True) if sampling.temperature==0 else torch.multinomial(scores.softmax(-1),1,generator=generator) | |
| scores=logits.float().clone() | |
| end=ABC_END if phase=='abc' else MUSIC_END | |
| mask=torch.full_like(scores,float('-inf')) | |
| if phase=='abc':mask[...,:EOD]=0 | |
| else:mask[...,CODEC_OFFSET:CODEC_OFFSET+CODEC_SIZE]=0 | |
| mask[...,end]=0 | |
| scores+=mask | |
| if step<sampling.min_tokens:scores[...,end]=-torch.inf | |
| scores=window_penalty(scores,history[-sampling.penalty_window:],sampling.repetition_penalty) | |
| if sampling.temperature!=1:scores/=sampling.temperature | |
| values,indices=scores.topk(min(sampling.top_k,scores.shape[-1])) | |
| if sampling.top_p<1: | |
| probabilities=values.softmax(-1) | |
| removed=probabilities.cumsum(-1)-probabilities>sampling.top_p | |
| removed[...,:1]=False | |
| values=values.masked_fill(removed,-torch.inf) | |
| choice=torch.multinomial(values.softmax(-1),1,generator=generator) | |
| return indices.gather(-1,choice) | |