Text Generation
Transformers
Safetensors
Chinese
English
yunmo_next
chat
traditional-chinese
hybrid-attention
kimi-delta-attention
linear-attention
research
custom_code
Instructions to use yuhuanstudio/Yunmo-Next-1B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yuhuanstudio/Yunmo-Next-1B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yuhuanstudio/Yunmo-Next-1B-Instruct", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("yuhuanstudio/Yunmo-Next-1B-Instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yuhuanstudio/Yunmo-Next-1B-Instruct 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" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuhuanstudio/Yunmo-Next-1B-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yuhuanstudio/Yunmo-Next-1B-Instruct
- SGLang
How to use yuhuanstudio/Yunmo-Next-1B-Instruct 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" \ --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": "yuhuanstudio/Yunmo-Next-1B-Instruct", "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 "yuhuanstudio/Yunmo-Next-1B-Instruct" \ --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": "yuhuanstudio/Yunmo-Next-1B-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yuhuanstudio/Yunmo-Next-1B-Instruct with Docker Model Runner:
docker model run hf.co/yuhuanstudio/Yunmo-Next-1B-Instruct
Download code/yunmo_next/kda_runtime.py from yuhuanstudio/Yunmo-Next-1B-Instruct: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct/resolve/main/code/yunmo_next/kda_runtime.py
- Command line
-
hf download hf://yuhuanstudio/Yunmo-Next-1B-Instruct/code/yunmo_next/kda_runtime.py
-
curl -L -o kda_runtime.py https://huggingface.co/yuhuanstudio/Yunmo-Next-1B-Instruct/resolve/main/code/yunmo_next/kda_runtime.py
2.53 kB
| """Instance-scoped dispatch for the long-context KDA training engine.""" | |
| from __future__ import annotations | |
| from functools import partial, wraps | |
| from threading import RLock | |
| from .training_engine import TrainingEngineConfig | |
| _KDA_DISPATCH_LOCK = RLock() | |
| def configure_kda_mixer_runtime(mixer, engine: TrainingEngineConfig): | |
| """Attach the configured KDA call to one mixer without global leakage. | |
| FLA's ``KimiDeltaAttention.forward`` resolves ``chunk_kda`` from its module | |
| global at call time. The research trainer replaced that global once per | |
| process, which works for a one-model executable but leaks when a process holds | |
| models with different engines. This wrapper swaps it only for this bound | |
| forward and restores it in ``finally``; the custom autograd function owns its | |
| backward, so the global is not needed after forward returns. | |
| """ | |
| if not isinstance(engine, TrainingEngineConfig): | |
| raise TypeError("KDA runtime requires TrainingEngineConfig") | |
| segment_size = int(engine.recurrent_segment_tokens) | |
| metadata = { | |
| "format": "yunmo-next-kda-training-engine-v1", | |
| "installed": False, | |
| "segment_size": segment_size, | |
| "allow_packed_documents": bool(engine.recurrent_packed_documents), | |
| "official_forward_serial_backward": bool( | |
| engine.recurrent_official_forward_serial_backward | |
| ), | |
| } | |
| if segment_size == 0: | |
| mixer._yunmo_kda_training_engine = metadata | |
| return mixer | |
| if not ( | |
| engine.recurrent_packed_documents | |
| and engine.recurrent_official_forward_serial_backward | |
| ): | |
| raise RuntimeError("invalid serial recurrent execution configuration") | |
| import fla.layers.kda as fla_kda_layer | |
| from .kda_serial import serial_chunk_kda | |
| engine = partial( | |
| serial_chunk_kda, | |
| segment_size=segment_size, | |
| chunk_size=64, | |
| allow_packed_documents=True, | |
| official_forward_serial_backward=True, | |
| ) | |
| original_forward = mixer.forward | |
| def forward(*args, **kwargs): | |
| with _KDA_DISPATCH_LOCK: | |
| previous = fla_kda_layer.chunk_kda | |
| fla_kda_layer.chunk_kda = engine | |
| try: | |
| return original_forward(*args, **kwargs) | |
| finally: | |
| fla_kda_layer.chunk_kda = previous | |
| mixer.forward = forward | |
| metadata = {**metadata, "installed": True, "dispatch": "instance_scoped"} | |
| mixer._yunmo_kda_training_engine = metadata | |
| return mixer | |