Text Generation
Transformers
Safetensors
English
code
qwen3_moe
security
code-repair
oss-bench
Mixture of Experts
chain-of-thought
nlp
c
cpp
php
conversational
Run this model with HF Jobs
Run NxcodeOfficial/NxCode-SafeCoder-30B 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/NxcodeOfficial/NxCode-SafeCoder-30B. 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/NxcodeOfficial/NxCode-SafeCoder-30B 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/NxcodeOfficial/NxCode-SafeCoder-30B. 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.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/NxcodeOfficial/NxCode-SafeCoder-30B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use NxcodeOfficial/NxCode-SafeCoder-30B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NxcodeOfficial/NxCode-SafeCoder-30B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NxcodeOfficial/NxCode-SafeCoder-30B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NxcodeOfficial/NxCode-SafeCoder-30B") model = AutoModelForCausalLM.from_pretrained("NxcodeOfficial/NxCode-SafeCoder-30B", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NxcodeOfficial/NxCode-SafeCoder-30B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NxcodeOfficial/NxCode-SafeCoder-30B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NxcodeOfficial/NxCode-SafeCoder-30B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NxcodeOfficial/NxCode-SafeCoder-30B
- SGLang
How to use NxcodeOfficial/NxCode-SafeCoder-30B 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 "NxcodeOfficial/NxCode-SafeCoder-30B" \ --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": "NxcodeOfficial/NxCode-SafeCoder-30B", "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 "NxcodeOfficial/NxCode-SafeCoder-30B" \ --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": "NxcodeOfficial/NxCode-SafeCoder-30B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NxcodeOfficial/NxCode-SafeCoder-30B with Docker Model Runner:
docker model run hf.co/NxcodeOfficial/NxCode-SafeCoder-30B
Upload folder using huggingface_hub
Browse filesFiles changed (24)
- .gitattributes+1
- added_tokens.jsonAdded+28
- chat_template.jinjaAdded+117
- config.jsonAdded+38
- generation_config.jsonAdded+13
- merges.txtAdded
- model-00001-of-00013.safetensorsAdded+3
- model-00002-of-00013.safetensorsAdded+3
- model-00003-of-00013.safetensorsAdded+3
- model-00004-of-00013.safetensorsAdded+3
- model-00005-of-00013.safetensorsAdded+3
- model-00006-of-00013.safetensorsAdded+3
- model-00007-of-00013.safetensorsAdded+3
- model-00008-of-00013.safetensorsAdded+3
- model-00009-of-00013.safetensorsAdded+3
- model-00010-of-00013.safetensorsAdded+3
- model-00011-of-00013.safetensorsAdded+3
- model-00012-of-00013.safetensorsAdded+3
- model-00013-of-00013.safetensorsAdded+3
- model.safetensors.index.jsonAdded
- special_tokens_map.jsonAdded+31
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+239
- vocab.jsonAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text
12345678910111213141516171819202122232425262728{ "</think>": 151668, "</tool_call>": 151658, "</tool_response>": 151666, "<think>": 151667, "<tool_call>": 151657, "<tool_response>": 151665, "<|box_end|>": 151649, "<|box_start|>": 151648, "<|endoftext|>": 151643, "<|file_sep|>": 151664, "<|fim_middle|>": 151660, "<|fim_pad|>": 151662, "<|fim_prefix|>": 151659, "<|fim_suffix|>": 151661, "<|im_end|>": 151645, "<|im_start|>": 151644, "<|image_pad|>": 151655, "<|object_ref_end|>": 151647, "<|object_ref_start|>": 151646, "<|quad_end|>": 151651, "<|quad_start|>": 151650, "<|repo_name|>": 151663, "<|video_pad|>": 151656, "<|vision_end|>": 151653, "<|vision_pad|>": 151654, "<|vision_start|>": 151652}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117{% macro render_extra_keys(json_dict, handled_keys) %} {%- if json_dict is mapping %} {%- for json_key in json_dict if json_key not in handled_keys %} {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %} {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }} {%- else %} {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }} {%- endif %} {%- endfor %} {%- endif %}{% endmacro %}
{%- if messages[0]["role"] == "system" %} {%- set system_message = messages[0]["content"] %} {%- set loop_messages = messages[1:] %}{%- else %} {%- set loop_messages = messages %}{%- endif %}
{%- if not tools is defined %} {%- set tools = [] %}{%- endif %}
{%- if system_message is defined %} {{- "<|im_start|>system\n" + system_message }}{%- else %} {%- if tools is iterable and tools | length > 0 %} {{- "<|im_start|>system\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks." }} {%- endif %}{%- endif %}{%- if tools is iterable and tools | length > 0 %} {{- "\n\n# Tools\n\nYou have access to the following functions:\n\n" }} {{- "<tools>" }} {%- for tool in tools %} {%- if tool.function is defined %} {%- set tool = tool.function %} {%- endif %} {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }} {%- if tool.description is defined %} {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }} {%- endif %} {{- '\n<parameters>' }} {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %} {%- for param_name, param_fields in tool.parameters.properties|items %} {{- '\n<parameter>' }} {{- '\n<name>' ~ param_name ~ '</name>' }} {%- if param_fields.type is defined %} {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }} {%- endif %} {%- if param_fields.description is defined %} {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }} {%- endif %} {%- set handled_keys = ['name', 'type', 'description'] %} {{- render_extra_keys(param_fields, handled_keys) }} {{- '\n</parameter>' }} {%- endfor %} {%- endif %} {% set handled_keys = ['type', 'properties'] %} {{- render_extra_keys(tool.parameters, handled_keys) }} {{- '\n</parameters>' }} {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %} {{- render_extra_keys(tool, handled_keys) }} {{- '\n</function>' }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}{%- endif %}{%- if system_message is defined %} {{- '<|im_end|>\n' }}{%- else %} {%- if tools is iterable and tools | length > 0 %} {{- '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- for message in loop_messages %} {%- if message.role == "assistant" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %} {{- '<|im_start|>' + message.role }} {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %} {{- '\n' + message.content | trim + '\n' }} {%- endif %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {{- '<|im_end|>\n' }} {%- elif message.role == "user" or message.role == "system" or message.role == "assistant" %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user\n' }} {%- endif %} {{- '<tool_response>\n' }} {{- message.content }} {{- '\n</tool_response>\n' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }}{%- endif %}1234567891011121314151617181920212223242526272829303132333435363738{ "architectures": [ "Qwen3MoeForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "bos_token_id": 151643, "decoder_sparse_step": 1, "dtype": "float16", "eos_token_id": 151645, "head_dim": 128, "hidden_act": "silu", "hidden_size": 2048, "initializer_range": 0.02, "intermediate_size": 6144, "max_position_embeddings": 262144, "max_window_layers": 48, "mlp_only_layers": [], "model_type": "qwen3_moe", "moe_intermediate_size": 768, "norm_topk_prob": true, "num_attention_heads": 32, "num_experts": 128, "num_experts_per_tok": 8, "num_hidden_layers": 48, "num_key_value_heads": 4, "output_router_logits": false, "rms_norm_eps": 1e-06, "rope_scaling": null, "rope_theta": 10000000, "router_aux_loss_coef": 0.001, "sliding_window": null, "tie_word_embeddings": false, "transformers_version": "4.57.3", "use_cache": true, "use_sliding_window": false, "vocab_size": 151936}12345678910111213{ "do_sample": true, "eos_token_id": [ 151645, 151643 ], "pad_token_id": 151643, "repetition_penalty": 1.05, "temperature": 0.7, "top_k": 20, "top_p": 0.8, "transformers_version": "4.57.3"}123version https://git-lfs.github.com/spec/v1oid sha256:246953ac6c1672d3ab63a3169547546642d7ce5de363259eff106a0bd479f163size 4997183592123version https://git-lfs.github.com/spec/v1oid sha256:31833878b96d784cae41e7a54ed9d746b3ced9799a8afbea3036f751e67b94b1size 4997740032123version https://git-lfs.github.com/spec/v1oid sha256:d04d01e3da996682ce11d1b33756db0b9dbf2c60ad108794d268627db6db7736size 4997740632123version https://git-lfs.github.com/spec/v1oid sha256:6d9ec6d23174aac98dbec136e7f628315c221295ba9c7e1753c96a8e2f754d50size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:735a08a0621195fad75cf18c2cf448ee069d4d60a4616da04749f3999c6754f1size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:4095eeadf41261fa5be69377e99a2b74ce813b59b5dbe3002e0d2bda5e0bb85fsize 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:e0552cec3c766ec4313894d5125752e7ba2419e4c86cbc6e96ad06e11cd135b9size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:ea25c9982e4adc248a9c57a53bb568241b4821151e3df73396f93379ce581d63size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:b1b8e55db93f9736392a7be4ba599c4ad8a15bb3ee08b4d031fe5c7a03c58069size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:7e29e86b174e654c06f9c8af8efaba2deab79fab72a8235abbc891ec5405913bsize 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:9a7fe8c35fbb6f53f92cfdd463c57100b1c0848df58d7873e596c6e5a7b8d48fsize 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:fa2dda619cca33fca4408537ec7819b42722a287f1054cf6837939d78bb53426size 4997741608123version https://git-lfs.github.com/spec/v1oid sha256:289946c48b5fb00e1af0d5d0bfda8b76af1afa15acf2913d115c25f424ccef57size 109422013612345678910111213141516171819202122232425262728293031{ "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>" ], "eos_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123version https://git-lfs.github.com/spec/v1oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4size 11422654123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239{ "add_bos_token": false, "add_prefix_space": false, "added_tokens_decoder": { "151643": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151644": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151645": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151646": { "content": "<|object_ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151647": { "content": "<|object_ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151648": { "content": "<|box_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151649": { "content": "<|box_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151650": { "content": "<|quad_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151651": { "content": "<|quad_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151652": { "content": "<|vision_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151653": { "content": "<|vision_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151654": { "content": "<|vision_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151655": { "content": "<|image_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151656": { "content": "<|video_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151657": { "content": "<tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151658": { "content": "</tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151659": { "content": "<|fim_prefix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151660": { "content": "<|fim_middle|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151661": { "content": "<|fim_suffix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151662": { "content": "<|fim_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151663": { "content": "<|repo_name|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151664": { "content": "<|file_sep|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151665": { "content": "<tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151666": { "content": "</tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151667": { "content": "<think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151668": { "content": "</think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>" ], "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "extra_special_tokens": {}, "model_max_length": 1048576, "pad_token": "<|endoftext|>", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}.gitattributes+1
added_tokens.jsonAdded+28
chat_template.jinjaAdded+117
config.jsonAdded+38
generation_config.jsonAdded+13
merges.txtAdded
model-00001-of-00013.safetensorsAdded+3
model-00002-of-00013.safetensorsAdded+3
model-00003-of-00013.safetensorsAdded+3
model-00004-of-00013.safetensorsAdded+3
model-00005-of-00013.safetensorsAdded+3
model-00006-of-00013.safetensorsAdded+3
model-00007-of-00013.safetensorsAdded+3
model-00008-of-00013.safetensorsAdded+3
model-00009-of-00013.safetensorsAdded+3
model-00010-of-00013.safetensorsAdded+3
model-00011-of-00013.safetensorsAdded+3
model-00012-of-00013.safetensorsAdded+3
model-00013-of-00013.safetensorsAdded+3
model.safetensors.index.jsonAdded
special_tokens_map.jsonAdded+31
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+239
vocab.jsonAdded