Text Generation
Transformers
Safetensors
English
spark2_5
browser-agent
betterwright
playwright
tool-use
agent
long-context
conversational
custom_code
Instructions to use ProCreations/BetterWright-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProCreations/BetterWright-4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ProCreations/BetterWright-4b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ProCreations/BetterWright-4b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ProCreations/BetterWright-4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ProCreations/BetterWright-4b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ProCreations/BetterWright-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ProCreations/BetterWright-4b
- SGLang
How to use ProCreations/BetterWright-4b 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 "ProCreations/BetterWright-4b" \ --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": "ProCreations/BetterWright-4b", "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 "ProCreations/BetterWright-4b" \ --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": "ProCreations/BetterWright-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ProCreations/BetterWright-4b with Docker Model Runner:
docker model run hf.co/ProCreations/BetterWright-4b
| { | |
| "backend": "tokenizers", | |
| "bos_token": "<|start▁of▁sentence|>", | |
| "clean_up_tokenization_spaces": false, | |
| "eos_token": "<|end▁of▁sentence|>", | |
| "is_local": true, | |
| "legacy": true, | |
| "local_files_only": false, | |
| "model_max_length": 262144, | |
| "pad_token": "<|▁pad▁|>", | |
| "sp_model_kwargs": {}, | |
| "tokenizer_class": "TokenizersBackend", | |
| "unk_token": "<unk>", | |
| "chat_template": "{#- 0826版本 -#}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set enable_thinking = enable_thinking | default(true) %}\n\n{#- Render a string or a list of text blocks. -#}\n{%- macro render_content(content, context_name) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- elif content is iterable and content is not mapping %}\n {%- for block in content %}\n {%- if block.type == 'text' %}\n {{- block.text }}\n {%- else %}\n {{- raise_exception('Unsupported ' ~ context_name ~ ' content block type: ' ~ (block.type | string)) }}\n {%- endif %}\n {%- endfor %}\n {%- else %}\n {{- raise_exception(context_name ~ ' content must be a string or a list of text blocks') }}\n {%- endif %}\n{%- endmacro %}\n\n{#- Default system prompt -#}\n{%- set default_system = \"you are a helpful assistant.\" %}\n\n{#- The first message-level system is placed in the initial system block. -#}\n{%- set ns = namespace(initial_system='') %}\n{%- if messages[0].role == \"system\" %}\n {%- set ns.initial_system = render_content(messages[0].content, 'system') %}\n{%- endif %}\n\n{#- System block -#}\n{{- '<|start▁of▁sentence|><|System|>' + '\\n' + default_system }}\n{%- if tools %}\n {{- '## Tools' + '\\n' + 'You have access to the following functions:' + '\\n' + '<tools>' }}\n {%- for tool in tools %}\n {{- '\\n' + tool.function | tojson}}\n {%- endfor %}\n {{- '\\n' + '</tools>' }}\n{%- endif %}\n{%- if ns.initial_system %}\n {{- '\\n\\n' + ns.initial_system }}\n{%- endif %}\n{{- '<|end▁of▁sentence|>'}}\n\n{#- Conversation turns -#}\n{%- for message in messages %}\n {%- if message.role == \"system\" %}\n {#- The first system message was consumed by the initial block. -#}\n {%- if not loop.first %}\n {{- '<|start▁of▁sentence|><|System|>\\n' + render_content(message.content, 'system') + '<|end▁of▁sentence|>' }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|start▁of▁sentence|><|User|>' + render_content(message.content, 'user') + '<|end▁of▁sentence|>' }}\n {%- elif message.role == \"assistant\" %}\n {%- set assistant_content = render_content(message.content, 'assistant') %}\n {%- if message.reasoning_content is defined and message.reasoning_content %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- set reasoning_content = '' %}\n {%- endif %}\n {{- '<|start▁of▁sentence|><|Bot|>'}}\n {%- if reasoning_content %}\n {{- '<think>' + reasoning_content + '</think>'}}\n {%- else %}\n {{- '</think>' }}\n {%- endif %}\n {%- if assistant_content %}\n {{- assistant_content }}\n {%- endif %}\n {%- if message.tool_calls is defined and message.tool_calls is not none %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function.arguments is not mapping %}\n {{- raise_exception('tool_call.function.arguments must be a dictionary; normalize JSON strings before apply_chat_template') }}\n {%- endif %}\n {%- set args = tool_call.function.arguments %}\n {{- '<tool_call>' + tool_call.function.name }}\n {%- for k, v in args.items() %}\n {{- '<arg_key>' ~ k ~ '</arg_key><arg_value>' ~ (v if v is string else v | tojson) ~ '</arg_value>' }}\n {%- endfor %}\n {{- '</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|end▁of▁sentence|>' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem is undefined or loop.previtem.role != \"tool\" %}\n {{- '<|start▁of▁sentence|><|Tool|>' }}\n {%- endif %}\n {{- '<tool_response>' ~ message.content ~ '</tool_response>' }}\n {%- if loop.nextitem is undefined or loop.nextitem.role != \"tool\" %}\n {{- '<|end▁of▁sentence|>' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unsupported message role: ' ~ message.role) }}\n {%- endif %}\n{%- endfor %}\n\n{#- Generation prompt -#}\n{%- if add_generation_prompt %}\n {{- '<|start▁of▁sentence|><|Bot|>' }}\n {%- if enable_thinking is defined and enable_thinking %}\n {{- '<think>' }}\n {%- endif %}\n {%- if enable_thinking is defined and not enable_thinking %}\n {{- '</think>' }}\n {%- endif %}\n{%- endif %}\n" | |
| } |