Instructions to use spidyun/kmoshi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use spidyun/kmoshi with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="spidyun/kmoshi") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("spidyun/kmoshi", device_map="auto") - Moshi
How to use spidyun/kmoshi with Moshi:
# pip install moshi # Run the interactive web server python -m moshi.server --hf-repo "spidyun/kmoshi" # Then open https://localhost:8998 in your browser
# pip install moshi import torch from moshi.models import loaders # Load checkpoint info from HuggingFace checkpoint = loaders.CheckpointInfo.from_hf_repo("spidyun/kmoshi") # Load the Mimi audio codec mimi = checkpoint.get_mimi(device="cuda") mimi.set_num_codebooks(8) # Encode audio (24kHz, mono) wav = torch.randn(1, 1, 24000 * 10) # [batch, channels, samples] with torch.no_grad(): codes = mimi.encode(wav.cuda()) decoded = mimi.decode(codes) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use spidyun/kmoshi with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "spidyun/kmoshi" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "spidyun/kmoshi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/spidyun/kmoshi
- SGLang
How to use spidyun/kmoshi 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 "spidyun/kmoshi" \ --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": "spidyun/kmoshi", "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 "spidyun/kmoshi" \ --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": "spidyun/kmoshi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use spidyun/kmoshi with Docker Model Runner:
docker model run hf.co/spidyun/kmoshi
| { | |
| "architectures": [ | |
| "KmoshiForConditionalGeneration" | |
| ], | |
| "attention_dropout": 0.0, | |
| "audio_encoder_config": { | |
| "_frame_rate": null, | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "audio_channels": 1, | |
| "codebook_dim": 256, | |
| "codebook_size": 2048, | |
| "compress": 2, | |
| "dilation_growth_rate": 2, | |
| "dtype": "bfloat16", | |
| "head_dim": 64, | |
| "hidden_act": "gelu", | |
| "hidden_size": 512, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 2048, | |
| "kernel_size": 7, | |
| "last_kernel_size": 3, | |
| "layer_scale_initial_scale": 0.01, | |
| "max_position_embeddings": 8000, | |
| "model_type": "mimi", | |
| "norm_eps": 1e-05, | |
| "num_attention_heads": 8, | |
| "num_filters": 64, | |
| "num_hidden_layers": 8, | |
| "num_key_value_heads": 8, | |
| "num_quantizers": 32, | |
| "num_residual_layers": 1, | |
| "num_semantic_quantizers": 1, | |
| "pad_mode": "constant", | |
| "residual_kernel_size": 3, | |
| "rope_parameters": { | |
| "rope_theta": 10000.0, | |
| "rope_type": "default" | |
| }, | |
| "sampling_rate": 24000, | |
| "sliding_window": 250, | |
| "tie_word_embeddings": true, | |
| "trim_right_ratio": 1.0, | |
| "upsample_groups": 512, | |
| "upsampling_ratios": [ | |
| 8, | |
| 6, | |
| 5, | |
| 4 | |
| ], | |
| "use_cache": false, | |
| "use_causal_conv": true, | |
| "use_conv_shortcut": false, | |
| "use_streaming": false, | |
| "vector_quantization_hidden_dimension": 256 | |
| }, | |
| "audio_vocab_size": 2048, | |
| "bos_token_id": null, | |
| "depth_decoder_config": { | |
| "attention_dropout": 0.0, | |
| "audio_vocab_size": 2048, | |
| "bos_token_id": null, | |
| "dtype": "bfloat16", | |
| "eos_token_id": null, | |
| "ffn_dim": 5632, | |
| "head_dim": 64, | |
| "hidden_act": "silu", | |
| "hidden_size": 1024, | |
| "initializer_range": 0.02, | |
| "input_size": 4096, | |
| "max_position_embeddings": 17, | |
| "model_type": "kmoshi_depth", | |
| "num_attention_heads": 16, | |
| "num_codebooks": 16, | |
| "num_hidden_layers": 6, | |
| "num_key_value_heads": 16, | |
| "pad_token_id": null, | |
| "rms_norm_eps": 1e-08, | |
| "sliding_window": 8, | |
| "tie_word_embeddings": false, | |
| "use_cache": true, | |
| "vocab_size": 151936 | |
| }, | |
| "dtype": "bfloat16", | |
| "eos_token_id": null, | |
| "ffn_dim": 24576, | |
| "head_dim": 128, | |
| "hidden_act": "silu", | |
| "hidden_size": 4096, | |
| "initializer_range": 0.02, | |
| "max_position_embeddings": 3000, | |
| "model_type": "kmoshi", | |
| "num_attention_heads": 32, | |
| "num_codebooks": 8, | |
| "num_hidden_layers": 36, | |
| "num_key_value_heads": 8, | |
| "pad_token_id": null, | |
| "rms_norm_eps": 1e-06, | |
| "rope_parameters": { | |
| "rope_theta": 1000000.0, | |
| "rope_type": "default" | |
| }, | |
| "sliding_window": 3000, | |
| "tie_word_embeddings": false, | |
| "transformers_version": "5.14.0.dev0", | |
| "use_cache": true, | |
| "vocab_size": 151936 | |
| } | |