PKU-ML/GRASP-4B
031
1---2license: apache-2.03language:4- en5base_model:6- Qwen/Qwen3-4B-Thinking-25077library_name: transformers8---9 10 11 12 13<p align="center">14 <img src="https://raw.githubusercontent.com/PKU-ML/GRASP/main/logo-new.png" width="15%"/>15<p>16 17# PKU-ML/GRASP-4B18 19## 📊 Overview20 21Integrating graph knowledge into Large Language Models (LLMs) via passive representation faces critical bottlenecks: limited context windows, unreliable numerical computation, and structural hallucinations. 22To solve this, we propose **GRASP** (Graph Reasoning via Agentic Solving and Probing), shifting the paradigm from passive ingestion to proactive agentic exploration. 23By interleaving **Neighbor Retrieval** for on-demand probing with **Code Interpreter** as a deterministic solver, GRASP enables LLMs to autonomously navigate and compute over complex topologies. 24We employ a staged reinforcement learning strategy (GRPO) that transitions from visible tuning to a structure-blind environment, forcing the agent to develop genuine topological awareness. 25Evaluated on multi-domain graph reasoning benchmarks, our 4B model achieves a 53.06% average performance boost, surpassing SOTA baselines like DeepSeek-V3.2 and successfully generalizing to unseen tasks, 26with high potential for tackling sampling on million-node graphs and solving Hard-level LeetCode graph problems.27 28 29 30## 📌 Key Takeaways31 321️⃣ **Agentic Probing over Passive Ingestion**.33We propose GRASP (Graph Reasoning via AgenticSolving and Probing), shifting the paradigm from passive ingestion to proactive agentic exploration. By interleaving Neighbor Retrieval (Eyes 👀) for on-demand probing with Code Interpreter (Hands 🙌) as a deterministic solver, GRASP enables LLMs to autonomously navigate and compute over complex topologies.34 352️⃣ **Structure-Blind RL Training**.36We employ a staged reinforcement learning strategy (GRPO) that transitions from visible tuning to a structure-blind environment, forcing the agent to develop genuine topological awareness.37 383️⃣ **From Million-Node Graphs to Hard LeetCode**.39Evaluated on multi-domain graph reasoning benchmarks, our 4B model achieves a 53.06% average performance boost, surpassing SOTA baselines like DeepSeek-V3.2 and successfully generalizing to unseen tasks, with high potential for tackling sampling on million-node graphs and solving Hard-level LeetCode graph problems.40 41 42 43 44## 🌊 Evaluation on Graph Reasoning Benchmarks45 46 47| Model | Arxiv |PubMed |Products | WikiCS | fb15k237 |wn18rr |TSG-Bench |ExplaGraphs |Erdős |RealErdős |Average |48|------------------|-----------|-----------|-----------|-----------|------------|-----------|------------|------------|------------|------------|------------|49| Qwen3-4B-Thinking|51.00 |25.00 |21.00 |29.00 |16.00 |13.00 |62.00 |45.00 |38.80 |7.11 |30.79 |50| GPT-4o |52.00 |43.00 |72.00 |24.00 |52.00 |24.00 |72.00 |77.00 |40.60 |18.07 |47.46 |51| DeepsSeek-V3.2 |65.00 |47.00 |70.00 |79.00 |65.00 |26.00 |**88.00** |**99.00** |83.60 |66.44 |68.90 |52| GRASP-4B |**73.00** |**90.00** |**77.00** |**88.00** |**82.00** |**67.00** |85.00 |97.00 |**91.00** |**88.57** |**83.85** |53 54 55 56 57 58 59## Quickstart60 61The code of Qwen3 has been in the latest Hugging Face `transformers` and we advise you to use the latest version of `transformers`.62 63With `transformers<4.51.0`, you will encounter the following error:64```65KeyError: 'qwen3'66```67 68The following contains a code snippet illustrating how to use the model generate content based on given inputs. 69```python70from transformers import AutoModelForCausalLM, AutoTokenizer71 72model_name = "PKU-ML/GRASP-4B"73 74# load the tokenizer and the model75tokenizer = AutoTokenizer.from_pretrained(model_name)76model = AutoModelForCausalLM.from_pretrained(77 model_name,78 torch_dtype="auto",79 device_map="auto"80)81 82# prepare the model input83prompt = "Give me a short introduction to large language model."84messages = [85 {"role": "user", "content": prompt}86]87text = tokenizer.apply_chat_template(88 messages,89 tokenize=False,90 add_generation_prompt=True,91)92model_inputs = tokenizer([text], return_tensors="pt").to(model.device)93 94# conduct text completion95generated_ids = model.generate(96 **model_inputs,97 max_new_tokens=819298)99output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() 100 101# parsing thinking content102try:103 # rindex finding 151668 (</think>)104 index = len(output_ids) - output_ids[::-1].index(151668)105except ValueError:106 index = 0107 108thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")109content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")110 111print("thinking content:", thinking_content) # no opening <think> tag112print("content:", content)113 114```115 116## Agentic Use117 118For the specific tool configuration and agentic usages of GRASP, please refer to our [example](https://github.com/PKU-ML/GRASP/blob/main/evaluation/example.py) on Github.119 120 121 122## Citation123 124If you find our work helpful, feel free to give us a cite.125 126```127 128```