Text Generation
Transformers
Safetensors
hy_v4
hunyuan
hy4
Mixture of Experts
conversational
Eval Results
Instructions to use tencent/Hy4-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tencent/Hy4-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tencent/Hy4-preview") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tencent/Hy4-preview") model = AutoModelForCausalLM.from_pretrained("tencent/Hy4-preview", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tencent/Hy4-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tencent/Hy4-preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/Hy4-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tencent/Hy4-preview
- SGLang
How to use tencent/Hy4-preview 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 "tencent/Hy4-preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/Hy4-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "tencent/Hy4-preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/Hy4-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tencent/Hy4-preview with Docker Model Runner:
docker model run hf.co/tencent/Hy4-preview
update
Browse files- finetune/README.md +0 -1
- finetune/README_CN.md +2 -2
finetune/README.md
CHANGED
|
@@ -143,7 +143,6 @@ The key parameters in the script are as follows:
|
|
| 143 |
- `--max_steps`: Total number of training steps.
|
| 144 |
- `--save_steps`: Number of steps between saving checkpoints.
|
| 145 |
- `--use_lora`: Whether to use LoRA training. Also accepts `--lora_rank`, `--lora_alpha`, and `--lora_dropout` parameters. By default, LoRA is applied to "q_proj", "k_proj", "v_proj", and "o_proj". To change this, modify the code. Note: **When using LoRA training, only the LoRA weights are saved, not the base model weights.**
|
| 146 |
-
- `--make_moe_param_leaf_module`: When using ZeRO-3 with MoE training, treat the MoE module as a leaf module, i.e., its parameters are not partitioned by ZeRO-3. This option is expected to significantly increase memory usage.
|
| 147 |
- `--gradient_checkpointing`: Enable gradient checkpointing.
|
| 148 |
- `--learning_rate`: Maximum learning rate during training.
|
| 149 |
- `--min_lr`: Minimum learning rate during training.
|
|
|
|
| 143 |
- `--max_steps`: Total number of training steps.
|
| 144 |
- `--save_steps`: Number of steps between saving checkpoints.
|
| 145 |
- `--use_lora`: Whether to use LoRA training. Also accepts `--lora_rank`, `--lora_alpha`, and `--lora_dropout` parameters. By default, LoRA is applied to "q_proj", "k_proj", "v_proj", and "o_proj". To change this, modify the code. Note: **When using LoRA training, only the LoRA weights are saved, not the base model weights.**
|
|
|
|
| 146 |
- `--gradient_checkpointing`: Enable gradient checkpointing.
|
| 147 |
- `--learning_rate`: Maximum learning rate during training.
|
| 148 |
- `--min_lr`: Minimum learning rate during training.
|
finetune/README_CN.md
CHANGED
|
@@ -143,8 +143,8 @@ Are you sure you want to continue connecting (yes/no)?
|
|
| 143 |
- `--max_steps`: 训练的总步数
|
| 144 |
- `--save_steps`: 每多少个 step 存储一个 checkpoint
|
| 145 |
- `--use_lora`: 是否用 lora 训练,同时接收`--lora_rank`,`--lora_alpha`和`--lora_dropout`参数。lora 默认应用于 MLA(Multi-head Latent Attention)投影层:"q_a_proj", "q_b_proj", "kv_a_proj_with_mqa", "kv_b_proj", "o_proj",如果需要改变的话在代码中修改即可。注意:**使用 lora 训练时,只会保存 lora 的权重,而不会保存 base 模型的权重**
|
| 146 |
-
- `--
|
| 147 |
-
- `--
|
| 148 |
- `--min_lr`: 训练时的最小学习率
|
| 149 |
- `--use_flash_attn`: 开启 flash-attention 进行训练加速
|
| 150 |
|
|
|
|
| 143 |
- `--max_steps`: 训练的总步数
|
| 144 |
- `--save_steps`: 每多少个 step 存储一个 checkpoint
|
| 145 |
- `--use_lora`: 是否用 lora 训练,同时接收`--lora_rank`,`--lora_alpha`和`--lora_dropout`参数。lora 默认应用于 MLA(Multi-head Latent Attention)投影层:"q_a_proj", "q_b_proj", "kv_a_proj_with_mqa", "kv_b_proj", "o_proj",如果需要改变的话在代码中修改即可。注意:**使用 lora 训练时,只会保存 lora 的权重,而不会保存 base 模型的权重**
|
| 146 |
+
- `--gradient_checkpointing`:开启梯度检查点
|
| 147 |
+
- `--learning_rate`: 训练时的最大学习率
|
| 148 |
- `--min_lr`: 训练时的最小学习率
|
| 149 |
- `--use_flash_attn`: 开启 flash-attention 进行训练加速
|
| 150 |
|