Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: Qwen/Qwen3-4b
|
| 8 |
+
tags:
|
| 9 |
+
- chat
|
| 10 |
+
- function-calling
|
| 11 |
+
- tool-use
|
| 12 |
+
- star-method
|
| 13 |
+
- sota
|
| 14 |
+
library_name: transformers
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# STAR-4b
|
| 18 |
+
|
| 19 |
+
## Introduction
|
| 20 |
+
|
| 21 |
+
**STAR-4b** is a highly capable 4b parameter language model specialized in function calling, achieving excellent performances on the [Berkeley Function Calling Leaderboard (BFCL)](https://huggingface.co/spaces/gorilla-llm/berkeley-function-calling-leaderboard) for models in its size class.
|
| 22 |
+
|
| 23 |
+
This model is the result of fine-tuning the `Qwen/Qwen3-4b` base model using the novel **STAR (Similarity-guided Teacher-Assisted Refinement)** framework. STAR is a holistic training curriculum designed to effectively transfer the advanced capabilities of large language models (LLMs) into "super-tiny" models, making them powerful, accessible, and efficient for real-world agentic applications.
|
| 24 |
+
|
| 25 |
+
The key innovations of the STAR framework include:
|
| 26 |
+
- **Similarity-guided RL (Sim-RL)**: A reinforcement learning mechanism that uses a fine-grained, similarity-based reward signal. This provides a more robust and continuous signal for policy optimization compared to simple binary rewards, which is crucial for complex, multi-solution tasks like function calling.
|
| 27 |
+
- **Constrained Knowledge Distillation (CKD)**: An advanced training objective that augments top-k forward KL divergence to suppress confidently incorrect predictions. This ensures training stability while preserving the model's exploration capacity, creating a strong foundation for the subsequent RL phase.
|
| 28 |
+
|
| 29 |
+
Our STAR-4b model significantly outperforms other open models under 1B parameters and even surpasses several larger models, demonstrating the effectiveness of the STAR methodology.
|
| 30 |
+
|
| 31 |
+
## Model Details
|
| 32 |
+
|
| 33 |
+
- **Model Type**: Causal Language Model, fine-tuned for function calling.
|
| 34 |
+
- **Base Model**: `Qwen/Qwen3-4b`
|
| 35 |
+
- **Training Framework**: STAR (CKD + Sim-RL)
|
| 36 |
+
- **Architecture**: Transformer with RoPE, SwiGLU, RMSNorm, and Attention QKV bias.
|
| 37 |
+
- **Number of Parameters**: ~4b
|
| 38 |
+
- **Context Length**: Supports up to 32,768 tokens.
|
| 39 |
+
|
| 40 |
+
## Requirements
|
| 41 |
+
|
| 42 |
+
The code of Qwen3 has been in the latest Hugging Face `transformers` and we advise you to use the latest version of `transformers`.
|
| 43 |
+
With `transformers<4.51.0`, you will encounter the following error:
|
| 44 |
+
```
|
| 45 |
+
KeyError: 'qwen3'
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Quickstart
|
| 49 |
+
|
| 50 |
+
Here is a code snippet showing how to load STAR-4b and use it for a chat-based task.
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 54 |
+
|
| 55 |
+
model_name = "star-lab/STAR-4b"
|
| 56 |
+
|
| 57 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 58 |
+
model_name,
|
| 59 |
+
torch_dtype="auto",
|
| 60 |
+
device_map="auto"
|
| 61 |
+
)
|
| 62 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 63 |
+
|
| 64 |
+
# Example prompt that could trigger a function call
|
| 65 |
+
prompt = "What is the current weather in San Francisco?"
|
| 66 |
+
messages = [
|
| 67 |
+
{"role": "system", "content": "You are a helpful assistant with access to external tools."},
|
| 68 |
+
{"role": "user", "content": prompt}
|
| 69 |
+
]
|
| 70 |
+
text = tokenizer.apply_chat_template(
|
| 71 |
+
messages,
|
| 72 |
+
tokenize=False,
|
| 73 |
+
add_generation_prompt=True
|
| 74 |
+
)
|
| 75 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 76 |
+
|
| 77 |
+
generated_ids = model.generate(
|
| 78 |
+
**model_inputs,
|
| 79 |
+
max_new_tokens=32768
|
| 80 |
+
)
|
| 81 |
+
generated_ids = [
|
| 82 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 83 |
+
]
|
| 84 |
+
|
| 85 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 86 |
+
print(response)
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
For deployment, you can use `sglang>=0.4.6.post1` or `vllm>=0.8.5` or to create an OpenAI-compatible API endpoint:
|
| 90 |
+
- SGLang:
|
| 91 |
+
```shell
|
| 92 |
+
python -m sglang.launch_server --model-path star-lab/STAR-4b --reasoning-parser qwen3
|
| 93 |
+
```
|
| 94 |
+
- vLLM:
|
| 95 |
+
```shell
|
| 96 |
+
vllm serve star-lab/STAR-4b --enable-reasoning --reasoning-parser deepseek_r1
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
For local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported STAR-4b.
|
| 100 |
+
|
| 101 |
+
## Evaluation & Performance
|
| 102 |
+
|
| 103 |
+
STAR-4b has achieved outstanding performance for models of its size on renowned function calling benchmarks.
|
| 104 |
+
|
| 105 |
+
- BFCLv3: Achieved 65.24% overall accuracy.
|
| 106 |
+
- ACEBench: Achieved 74.10% summary score, demonstrating superior generalization and robustness.
|