Text Generation
Transformers
Safetensors
English
qwen3
Generated from Trainer
open-r1
Text2SQL
Reasoning
conversational
text-generation-inference
Instructions to use anonymous-2321/Think2SQL-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use anonymous-2321/Think2SQL-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="anonymous-2321/Think2SQL-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("anonymous-2321/Think2SQL-4B") model = AutoModelForCausalLM.from_pretrained("anonymous-2321/Think2SQL-4B") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use anonymous-2321/Think2SQL-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "anonymous-2321/Think2SQL-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": "anonymous-2321/Think2SQL-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/anonymous-2321/Think2SQL-4B
- SGLang
How to use anonymous-2321/Think2SQL-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 "anonymous-2321/Think2SQL-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": "anonymous-2321/Think2SQL-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 "anonymous-2321/Think2SQL-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": "anonymous-2321/Think2SQL-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use anonymous-2321/Think2SQL-4B with Docker Model Runner:
docker model run hf.co/anonymous-2321/Think2SQL-4B
Update chat_template.jinja
Browse filesInclude Reasoning tokens by default when starting decoding.
- chat_template.jinja +5 -8
chat_template.jinja
CHANGED
|
@@ -35,14 +35,14 @@
|
|
| 35 |
{%- if message.reasoning_content is string %}
|
| 36 |
{%- set reasoning_content = message.reasoning_content %}
|
| 37 |
{%- else %}
|
| 38 |
-
{%- if '</
|
| 39 |
-
{%- set reasoning_content = content.split('</
|
| 40 |
-
{%- set content = content.split('</
|
| 41 |
{%- endif %}
|
| 42 |
{%- endif %}
|
| 43 |
{%- if loop.index0 > ns.last_query_index %}
|
| 44 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 45 |
-
{{- '<|im_start|>' + message.role + '\n<
|
| 46 |
{%- else %}
|
| 47 |
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 48 |
{%- endif %}
|
|
@@ -82,8 +82,5 @@
|
|
| 82 |
{%- endif %}
|
| 83 |
{%- endfor %}
|
| 84 |
{%- if add_generation_prompt %}
|
| 85 |
-
{{- '<|im_start|>assistant\n'
|
| 86 |
-
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 87 |
-
{{- '<think>\n\n</think>\n\n' }}
|
| 88 |
-
{%- endif %}
|
| 89 |
{%- endif %}
|
|
|
|
| 35 |
{%- if message.reasoning_content is string %}
|
| 36 |
{%- set reasoning_content = message.reasoning_content %}
|
| 37 |
{%- else %}
|
| 38 |
+
{%- if '</reasoning>' in content %}
|
| 39 |
+
{%- set reasoning_content = content.split('</reasoning>')[0].rstrip('\n').split('<reasoning>')[-1].lstrip('\n') %}
|
| 40 |
+
{%- set content = content.split('</reasoning>')[-1].lstrip('\n') %}
|
| 41 |
{%- endif %}
|
| 42 |
{%- endif %}
|
| 43 |
{%- if loop.index0 > ns.last_query_index %}
|
| 44 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 45 |
+
{{- '<|im_start|>' + message.role + '\n<reasoning>\n' + reasoning_content.strip('\n') + '\n</reasoning>\n\n' + content.lstrip('\n') }}
|
| 46 |
{%- else %}
|
| 47 |
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 48 |
{%- endif %}
|
|
|
|
| 82 |
{%- endif %}
|
| 83 |
{%- endfor %}
|
| 84 |
{%- if add_generation_prompt %}
|
| 85 |
+
{{- '<|im_start|>assistant\n<think>\n\n</think>\n\n<reasoning>\n'}}
|
|
|
|
|
|
|
|
|
|
| 86 |
{%- endif %}
|