Instructions to use meituan-longcat/LongCat-Flash-Lite-Sparse with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use meituan-longcat/LongCat-Flash-Lite-Sparse with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="meituan-longcat/LongCat-Flash-Lite-Sparse") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import LongcatCausalLM model = LongcatCausalLM.from_pretrained("meituan-longcat/LongCat-Flash-Lite-Sparse", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use meituan-longcat/LongCat-Flash-Lite-Sparse with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "meituan-longcat/LongCat-Flash-Lite-Sparse" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "meituan-longcat/LongCat-Flash-Lite-Sparse", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/meituan-longcat/LongCat-Flash-Lite-Sparse
- SGLang
How to use meituan-longcat/LongCat-Flash-Lite-Sparse 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 "meituan-longcat/LongCat-Flash-Lite-Sparse" \ --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": "meituan-longcat/LongCat-Flash-Lite-Sparse", "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 "meituan-longcat/LongCat-Flash-Lite-Sparse" \ --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": "meituan-longcat/LongCat-Flash-Lite-Sparse", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use meituan-longcat/LongCat-Flash-Lite-Sparse with Docker Model Runner:
docker model run hf.co/meituan-longcat/LongCat-Flash-Lite-Sparse
| { | |
| "add_bos_token": false, | |
| "add_eos_token": true, | |
| "add_prefix_space": false, | |
| "bos_token": { | |
| "__type": "AddedToken", | |
| "content": "<longcat_s>", | |
| "lstrip": false, | |
| "normalized": true, | |
| "rstrip": false, | |
| "single_word": false | |
| }, | |
| "clean_up_tokenization_spaces": false, | |
| "eos_token": { | |
| "__type": "AddedToken", | |
| "content": "</longcat_s>", | |
| "lstrip": false, | |
| "normalized": true, | |
| "rstrip": false, | |
| "single_word": false | |
| }, | |
| "model_max_length": 131072, | |
| "pad_token": { | |
| "__type": "AddedToken", | |
| "content": "<longcat_pad>", | |
| "lstrip": false, | |
| "normalized": true, | |
| "rstrip": false, | |
| "single_word": false | |
| }, | |
| "sp_model_kwargs": {}, | |
| "tokenizer_class": "BloomTokenizer", | |
| "unk_token": { | |
| "__type": "AddedToken", | |
| "content": "<longcat_unk>", | |
| "lstrip": false, | |
| "normalized": true, | |
| "rstrip": false, | |
| "single_word": false | |
| }, | |
| "chat_template": "{%- set tool_choice = tool_choice | default('auto') -%}\n{%- set enable_thinking = enable_thinking | default(none) -%}\n{%- set save_history_reasoning_content = save_history_reasoning_content | default(false) -%}\n{%- set ns = namespace(final_messages = [], tool_types = [], last_query_index = -1) -%}\n{%- for message in messages -%}\n {%- set role = message.get('role') -%}\n {%- set c = message.get('content') -%}\n {%- if c is string -%}\n {%- set ns.final_messages = ns.final_messages + [message] -%}\n {%- elif c is iterable and c is not mapping -%}\n {%- set parts = namespace(text=[], thinking=[], tool_calls=[], tool_results=[]) -%}\n {%- for item in c -%}\n {%- if item['type'] == 'text' -%}\n {%- set parts.text = parts.text + [item['text']] -%}\n {%- elif item['type'] == 'thinking' -%}\n {%- if item['thinking'] -%}\n {%- set parts.thinking = parts.thinking + [item['thinking']] -%}\n {%- endif -%}\n {%- elif item['type'] == 'tool_use' -%}\n {%- set parts.tool_calls = parts.tool_calls + [{\n 'id': item['id'],\n 'type': 'function',\n 'function': {\n 'name': item['name'],\n 'arguments': item['input']\n }\n }] -%}\n {%- elif item['type'] == 'tool_result' -%}\n {%- set parts.tool_results = parts.tool_results + [{\n 'role': 'tool',\n 'name': item.get('name', ''),\n 'tool_call_id': item['tool_use_id'],\n 'content': item['content']\n }] -%}\n {%- endif -%}\n {%- endfor -%}\n {%- set ns.final_messages = ns.final_messages + parts.tool_results -%}\n {%- if not (parts.tool_results | length > 0 and parts.text | length == 0 and role == 'user') -%}\n {%- set ns.final_messages = ns.final_messages + [{\n 'role': role,\n 'content': parts.text | join(''),\n 'reasoning_content': parts.thinking | join(''),\n 'tool_calls': parts.tool_calls\n }] -%}\n {%- endif -%}\n {%- else -%}\n {%- set ns.final_messages = ns.final_messages + [message] -%}\n {%- endif -%}\n{%- endfor -%}\n{%- set messages = ns.final_messages -%}\n\n{%- for idx in range(messages|length) -%}\n {%- set msg = messages[idx] -%}\n {%- if msg.role == 'user' -%}\n {%- set ns.last_query_index = idx -%}\n {%- endif -%}\n{%- endfor -%}\n\n{%- if tools and tool_choice != 'none' -%}\n {{- \"<longcat_tool_declare>\\n\" -}}\n {{- \"# Tools\\n\" -}}\n {{- \"You have access to the following tools:\\n\\n\" -}}\n {%- for tool in tools -%}\n {%- if tool.type not in ns.tool_types -%}\n {%- set ns.tool_types = ns.tool_types + [tool.type] -%}\n {{- \"## Tool namespace: \" ~ tool.type ~ \"\\n\\n\" -}}\n {%- endif -%}\n {%- if tool.type == 'code_interpreter' -%}\n {%- set tool = {\"type\":\"code_interpreter\",\"function\":{\"name\":\"code_interpreter_preview\",\"description\":\"The code will be executed in a stateful Jupyter notebook sandbox environment, only supports local computation, data processing, and file operations.\\nCode sandbox environment (network isolated) Any external network requests or online API calls are prohibited.\\nIf online functionality is needed, please use other permitted tools.\\nCode will respond with the output of the execution or time out after 60.0 seconds. \",\"parameters\":{\"type\":\"object\",\"properties\":{\"language\":{\"type\":\"string\",\"description\":\"The programming language of the code to be executed. Available values: python (Default), java, go, js, ts, c, c++.\"},\"code\":{\"type\":\"string\",\"description\":\"Python code to be executed must not include the following:\\n- Importing network libraries such as requests, httplib, etc.\\n- Any form of HTTP requests.\\n- External API calls.\\n- Network port operations. Example: ```python\\nimport pandas as pd\\npd.DataFrame({'A':[1,2]})\\n```\"},\"timeout\":{\"type\":\"number\",\"description\":\"The maximum execution time of the code, in seconds. Default is 60.0.\"}}},\"required\":[\"code\"]}} -%}\n {%- endif -%}\n {{- \"### Tool name: \" + tool.function.name + \"\\n\" -}}\n {{- \"Description: \" + tool.function.description + \"\\n\\n\" -}}\n {{- \"InputSchema: \" + tool.function.parameters | tojson(ensure_ascii=False) + \"\\n\\n\" -}}\n {%- endfor -%}\n {{- '**Note**: For each function call, output the function name and arguments within the following XML format:\\n<longcat_tool_call>{function-name}\\n<longcat_arg_key>{arg-key-1}</longcat_arg_key>\\n<longcat_arg_value>{arg-value-1}</longcat_arg_value>\\n<longcat_arg_key>{arg-key-2}</longcat_arg_key>\\n<longcat_arg_value>{arg-value-2}</longcat_arg_value>\\n...\\n</longcat_tool_call>\\n' -}}\n {{- \"</longcat_tool_declare>\"-}}\n{%- endif -%}\n\n{%- for msg in messages -%}\n {%- if msg.role == \"system\" -%}\n {{- \"<longcat_system>\" + msg.content -}}\n {%- elif msg.role == \"user\" -%}\n {{- \"<longcat_user>\" -}}\n {%- if msg[\"files\"] -%}\n {{- '<longcat_files>\\n' ~ msg.files | tojson(indent=2) ~ '\\n</longcat_files>' -}}\n {%- endif -%}\n {{- msg.content -}}\n {%- if save_history_reasoning_content and enable_thinking is not none -%}\n {%- if loop.last or messages[loop.index0 + 1].role != 'assistant' -%}\n {# pass #}\n {%- else -%}\n {%- if enable_thinking == true -%}\n {{- \" /think_on\" -}}\n {%- if thinking_budget -%}\n {%- if thinking_budget < 1024 -%}\n {%- set thinking_budget = 1024 -%}\n {%- endif -%}\n {{- \"\\nthinking_budget: < \" ~ thinking_budget ~ \".\" -}}\n {%- endif -%}\n {{- \" \" -}}\n {%- elif enable_thinking == false -%}\n {{- \" /think_off \" -}}\n {%- endif -%}\n {%- endif -%}\n {%- elif loop.index0 >= ns.last_query_index and enable_thinking is not none -%}\n {%- if loop.last or messages[loop.index0 + 1].role != 'assistant' -%}\n {# pass #}\n {%- else -%}\n {%- if enable_thinking == true -%}\n {{- \" /think_on\" -}}\n {%- if thinking_budget -%}\n {%- if thinking_budget < 1024 -%}\n {%- set thinking_budget = 1024 -%}\n {%- endif -%}\n {{- \"\\nthinking_budget: < \" ~ thinking_budget ~ \".\" -}}\n {%- endif -%}\n {{- \" \" -}}\n {%- elif enable_thinking == false -%}\n {{- \" /think_off \" -}}\n {%- endif -%}\n {%- endif -%}\n {%- endif -%}\n {%- elif msg.role == \"assistant\" -%}\n {{- \"<longcat_assistant>\" -}}\n {%- if save_history_reasoning_content == true or loop.index0 > ns.last_query_index -%}\n {%- if enable_thinking == true -%}\n {%- if msg.reasoning_content -%}\n {%- set reasoning_content = msg.reasoning_content | trim -%}\n {{- \"<longcat_think>\\n\" ~ reasoning_content ~ \"\\n</longcat_think>\\n\" -}}\n {%- else -%}\n {{- \"<longcat_think>\\n\\n</longcat_think>\\n\" -}}\n {%- endif -%}\n {%- elif enable_thinking == false -%}\n {{- \"<longcat_think>\\n\\n</longcat_think>\\n\" -}}\n {%- endif -%}\n {%- endif -%}\n {%- if msg.content -%}\n {{- msg.content -}}\n {%- endif -%}\n {%- if msg.tool_calls -%}\n {%- for tool_call in msg.tool_calls -%}\n {{- \"<longcat_tool_call>\" ~ tool_call.function.name ~ \"\\n\" -}}\n {%- set _args = tool_call.function.arguments -%}\n {%- for k, v in _args.items() -%}\n {{- \"<longcat_arg_key>\" ~ k ~ \"</longcat_arg_key>\\n\" -}}\n {{- \"<longcat_arg_value>\" ~ (v if v is string else v | tojson(ensure_ascii=False)) ~ \"</longcat_arg_value>\\n\" -}}\n {% endfor -%}\n {{- \"</longcat_tool_call>\\n\" -}}\n {%- endfor -%}\n {%- endif -%}\n {{- \"</longcat_s>\" -}}\n {%- elif msg.role == \"tool\" -%}\n {%- if messages[loop.index0 - 1].role != \"tool\" -%}\n {{- \"<longcat_observation>\" -}}\n {%- endif -%}\n {{- \"<longcat_tool_response>\" ~ msg.name ~ \"\\n\" ~ msg.content ~ \"</longcat_tool_response>\" -}}\n {%- if loop.index0 == messages|length - 1 -%}\n {# pass #}\n {%- elif (save_history_reasoning_content or loop.index0 > ns.last_query_index) and messages[loop.index0 + 1].role != \"tool\" -%}\n {%- if enable_thinking == true -%}\n {{- \" /think_on\" -}}\n {%- if thinking_budget -%}\n {%- if thinking_budget < 1024 -%}\n {%- set thinking_budget = 1024 -%}\n {%- endif -%}\n {{- \"\\nthinking_budget: < \" ~ thinking_budget ~ \".\" -}}\n {%- endif -%}\n {{- \" \" -}}\n {%- elif enable_thinking == false -%}\n {{- \" /think_off \" -}}\n {%- endif -%}\n {%- endif -%}\n {%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {%- if enable_thinking == true -%}\n {{- \" /think_on\" -}}\n {%- if thinking_budget -%}\n {%- if thinking_budget < 1024 -%}\n {%- set thinking_budget = 1024 -%}\n {%- endif -%}\n {{- \"\\nthinking_budget: < \" ~ thinking_budget ~ \".\" -}}\n {%- endif -%}\n {{- \" <longcat_assistant><longcat_think>\\n\" -}}\n {%- elif enable_thinking == false -%}\n {{- \" /think_off <longcat_assistant><longcat_think>\\n\\n</longcat_think>\\n\" -}}\n {%- else -%}\n {{- \"<longcat_assistant>\" -}}\n {%- endif -%}\n{%- endif -%}" | |
| } |