Text Generation
Transformers
Safetensors
Chinese
English
yunmo_next
traditional-chinese
kimi-delta-attention
research
torchao
int8
conversational
custom_code
8-bit precision
Run this model with HF Jobs
Run yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yuhuanstudio/Yunmo-Next-1B-Instruct-INT8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("yuhuanstudio/Yunmo-Next-1B-Instruct-INT8", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8
- SGLang
How to use yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 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 "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8" \ --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": "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8", "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 "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8" \ --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": "yuhuanstudio/Yunmo-Next-1B-Instruct-INT8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yuhuanstudio/Yunmo-Next-1B-Instruct-INT8 with Docker Model Runner:
docker model run hf.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8
Download code/yunmo_next/packed.py from yuhuanstudio/Yunmo-Next-1B-Instruct-INT8: direct link, hf CLI and curl.
- Browser
- Download file 2.95 kB
-
https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8/resolve/main/code/yunmo_next/packed.py
- Command line
-
hf download hf://yuhuanstudio/Yunmo-Next-1B-Instruct-INT8/code/yunmo_next/packed.py
-
curl -L -o packed.py https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct-INT8/resolve/main/code/yunmo_next/packed.py
2.95 kB
| from __future__ import annotations | |
| import torch | |
| def validate_cu_seqlens(cu_seqlens: torch.Tensor, sequence_length: int) -> None: | |
| if cu_seqlens.ndim != 1 or cu_seqlens.numel() < 2: | |
| raise ValueError("cu_seqlens must contain at least one start/end pair") | |
| if cu_seqlens.dtype != torch.long: | |
| raise ValueError("cu_seqlens must use torch.long") | |
| if int(cu_seqlens[0]) != 0 or int(cu_seqlens[-1]) != sequence_length: | |
| raise ValueError("cu_seqlens must span the complete flattened sequence") | |
| if not bool(torch.all(cu_seqlens[1:] > cu_seqlens[:-1])): | |
| raise ValueError("cu_seqlens must be strictly increasing") | |
| def document_starts( | |
| cu_seqlens: torch.Tensor, sequence_length: int | |
| ) -> torch.Tensor: | |
| validate_cu_seqlens(cu_seqlens, sequence_length) | |
| starts = torch.zeros(sequence_length, dtype=torch.bool, device=cu_seqlens.device) | |
| starts[cu_seqlens[:-1]] = True | |
| return starts.unsqueeze(0) | |
| def document_position_ids( | |
| cu_seqlens: torch.Tensor, sequence_length: int | |
| ) -> torch.Tensor: | |
| validate_cu_seqlens(cu_seqlens, sequence_length) | |
| lengths = cu_seqlens[1:] - cu_seqlens[:-1] | |
| offsets = torch.repeat_interleave(cu_seqlens[:-1], lengths) | |
| return (torch.arange(sequence_length, device=cu_seqlens.device) - offsets).unsqueeze(0) | |
| def document_causal_mask( | |
| cu_seqlens: torch.Tensor, | |
| sequence_length: int, | |
| *, | |
| window: int | None = None, | |
| ) -> torch.Tensor: | |
| validate_cu_seqlens(cu_seqlens, sequence_length) | |
| identifiers = document_identifiers(cu_seqlens, sequence_length) | |
| positions = torch.arange(sequence_length, device=cu_seqlens.device) | |
| distance = positions[:, None] - positions[None, :] | |
| mask = (identifiers[:, None] == identifiers[None, :]) & (distance >= 0) | |
| if window is not None: | |
| if window <= 0: | |
| raise ValueError("attention window must be positive") | |
| mask &= distance < window | |
| return mask | |
| def document_identifiers( | |
| cu_seqlens: torch.Tensor, sequence_length: int | |
| ) -> torch.Tensor: | |
| validate_cu_seqlens(cu_seqlens, sequence_length) | |
| lengths = cu_seqlens[1:] - cu_seqlens[:-1] | |
| return torch.repeat_interleave( | |
| torch.arange(lengths.numel(), device=cu_seqlens.device), lengths | |
| ) | |
| def segment_ranges(cu_seqlens: torch.Tensor, sequence_length: int) -> list[tuple[int, int]]: | |
| validate_cu_seqlens(cu_seqlens, sequence_length) | |
| boundaries = cu_seqlens.detach().cpu().tolist() | |
| return list(zip(boundaries[:-1], boundaries[1:], strict=True)) | |
| def mask_cross_document_labels( | |
| labels: torch.Tensor, cu_seqlens: torch.Tensor, *, ignore_index: int = -100 | |
| ) -> torch.Tensor: | |
| if labels.ndim != 2 or labels.shape[0] != 1: | |
| raise ValueError("packed labels must have shape [1, sequence]") | |
| validate_cu_seqlens(cu_seqlens, labels.shape[1]) | |
| result = labels.clone() | |
| boundaries = cu_seqlens[1:-1] - 1 | |
| result[0, boundaries] = ignore_index | |
| return result | |