Instructions to use tiny-random/longcat-flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/longcat-flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/longcat-flash", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/longcat-flash", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("tiny-random/longcat-flash", trust_remote_code=True) 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
- vLLM
How to use tiny-random/longcat-flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/longcat-flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/longcat-flash", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/longcat-flash
- SGLang
How to use tiny-random/longcat-flash 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 "tiny-random/longcat-flash" \ --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": "tiny-random/longcat-flash", "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 "tiny-random/longcat-flash" \ --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": "tiny-random/longcat-flash", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/longcat-flash with Docker Model Runner:
docker model run hf.co/tiny-random/longcat-flash
| { | |
| "architectures": [ | |
| "LongcatFlashForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "attention_method": "MLA", | |
| "auto_map": { | |
| "AutoConfig": "configuration_longcat_flash.LongcatFlashConfig", | |
| "AutoModel": "modeling_longcat_flash.LongcatFlashModel", | |
| "AutoModelForCausalLM": "modeling_longcat_flash.LongcatFlashForCausalLM" | |
| }, | |
| "bos_token_id": 1, | |
| "eos_token_id": 2, | |
| "expert_ffn_hidden_size": 64, | |
| "ffn_hidden_size": 64, | |
| "head_dim": 192, | |
| "hidden_act": "silu", | |
| "hidden_size": 8, | |
| "initializer_range": 0.006, | |
| "kv_lora_rank": 384, | |
| "max_position_embeddings": 131072, | |
| "mla_scale_kv_lora": true, | |
| "mla_scale_q_lora": true, | |
| "model_type": "longcat_flash", | |
| "moe_topk": 12, | |
| "n_routed_experts": 32, | |
| "norm_topk_prob": false, | |
| "num_attention_heads": 4, | |
| "num_key_value_heads": 4, | |
| "num_layers": 2, | |
| "q_lora_rank": 32, | |
| "qk_head_dim": 256, | |
| "qk_nope_head_dim": 64, | |
| "qk_rope_head_dim": 192, | |
| "rms_norm_eps": 1e-05, | |
| "rope_theta": 10000000.0, | |
| "routed_scaling_factor": 6.0, | |
| "router_bias": false, | |
| "tie_word_embeddings": false, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.56.0.dev0", | |
| "use_cache": true, | |
| "v_head_dim": 64, | |
| "vocab_size": 131072, | |
| "zero_expert_num": 16, | |
| "zero_expert_type": "identity" | |
| } |