Text Generation
Transformers
Safetensors
Chinese
qwen3
traditional-chinese-medicine
lingdan-v2
r1
conversational
text-generation-inference
Instructions to use TCMLLM/Lingdan-4B-R1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TCMLLM/Lingdan-4B-R1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TCMLLM/Lingdan-4B-R1") 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("TCMLLM/Lingdan-4B-R1") model = AutoModelForCausalLM.from_pretrained("TCMLLM/Lingdan-4B-R1", 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 TCMLLM/Lingdan-4B-R1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TCMLLM/Lingdan-4B-R1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TCMLLM/Lingdan-4B-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TCMLLM/Lingdan-4B-R1
- SGLang
How to use TCMLLM/Lingdan-4B-R1 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 "TCMLLM/Lingdan-4B-R1" \ --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": "TCMLLM/Lingdan-4B-R1", "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 "TCMLLM/Lingdan-4B-R1" \ --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": "TCMLLM/Lingdan-4B-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use TCMLLM/Lingdan-4B-R1 with Docker Model Runner:
docker model run hf.co/TCMLLM/Lingdan-4B-R1
Improve model card navigation and result placement
Browse files
README.md
CHANGED
|
@@ -28,24 +28,14 @@ tags:
|
|
| 28 |
</p>
|
| 29 |
|
| 30 |
<p align="center">
|
|
|
|
| 31 |
<a href="https://modelscope.cn/collections/TCMAIBJTU/Lingdan-V2"><img src="https://img.shields.io/badge/Models-ModelScope-624AFF" alt="ModelScope models" /></a>
|
| 32 |
<a href="https://github.com/TCMAI-BJTU/LingLan"><img src="https://img.shields.io/badge/Benchmark-LingLan-2A8F5B" alt="LingLan benchmark" /></a>
|
| 33 |
<img src="https://img.shields.io/badge/Model_scales-4B_%7C_8B_%7C_14B-0B5394" alt="Model scales: 4B, 8B, and 14B" />
|
| 34 |
<a href="https://github.com/TCMAI-BJTU/Lingdan-V2/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache--2.0-D22128" alt="Apache License 2.0" /></a>
|
| 35 |
</p>
|
| 36 |
|
| 37 |
-
##
|
| 38 |
-
|
| 39 |
-
1. [Model Details](#model-details)
|
| 40 |
-
2. [Quickstart](#quickstart)
|
| 41 |
-
3. [Thinking Mode](#thinking-mode)
|
| 42 |
-
4. [vLLM Deployment](#vllm-deployment)
|
| 43 |
-
5. [Checkpoint Evaluation](#checkpoint-evaluation)
|
| 44 |
-
6. [Task Prompts](#task-prompts)
|
| 45 |
-
7. [Data Privacy and Responsible Use](#data-privacy-and-responsible-use)
|
| 46 |
-
8. [License](#license)
|
| 47 |
-
9. [Citation](#citation)
|
| 48 |
-
10. [Related Links](#related-links)
|
| 49 |
|
| 50 |
## Model Details
|
| 51 |
|
|
@@ -60,6 +50,33 @@ tags:
|
|
| 60 |
| Intended use | Structured TCM clinical reasoning and prescription-generation research |
|
| 61 |
| Platform model ID | `TCMLLM/Lingdan-4B-R1` |
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
## Quickstart
|
| 64 |
|
| 65 |
Use Transformers ≥4.51.0; see the [Qwen3 quickstart](https://qwen.readthedocs.io/en/stable/getting_started/quickstart.html).
|
|
@@ -185,33 +202,6 @@ print("Finish reason:", response.choices[0].finish_reason)
|
|
| 185 |
|
| 186 |
`EMPTY` is a placeholder for the local server started without API-key authentication.
|
| 187 |
|
| 188 |
-
## Checkpoint Evaluation
|
| 189 |
-
|
| 190 |
-
Paper-reported results for **Lingdan-4B-R1**. Full: LingLan (25,620 items); Hard: LingLan-Hard (5,200 items). Overall Score averages 16 primary metrics, excluding dose MAE. All scores use a 0–100 scale except MAE (lower is better). The paper uses zero-shot Chinese prompts, temperature 0.6, and at most 8,192 generated tokens; reproduction also requires the same data and scoring pipeline.
|
| 191 |
-
|
| 192 |
-
| Metric | LingLan Full | LingLan-Hard |
|
| 193 |
-
| --- | ---: | ---: |
|
| 194 |
-
| Overall Score ↑ | 63.4 | 40.4 |
|
| 195 |
-
| Prescription generation F1 ↑ | 36.2 | 24.8 |
|
| 196 |
-
| Clinical-record entity extraction F1 ↑ | 70.5 | 58.4 |
|
| 197 |
-
| Classical-text entity extraction F1 ↑ | 58.5 | 42.5 |
|
| 198 |
-
| Syndrome generation F1 ↑ | 9.5 | 1.6 |
|
| 199 |
-
| Treatment-principle generation F1 ↑ | 13.9 | 2.4 |
|
| 200 |
-
| Prescription dose cosine ↑ | 34.2 | 23.4 |
|
| 201 |
-
| Prescription dose MAE ↓ | 4.6 | 4.7 |
|
| 202 |
-
|
| 203 |
-
Task-level scores follow the appendix’s primary DTR metrics, not the character-level DTR-F1 variant.
|
| 204 |
-
|
| 205 |
-
| Private prescription evaluation (4,348 cases) | Score |
|
| 206 |
-
| --- | ---: |
|
| 207 |
-
| Herb F1 ↑ | 52.7 |
|
| 208 |
-
| Herb precision ↑ | 52.5 |
|
| 209 |
-
| Herb recall ↑ | 54.1 |
|
| 210 |
-
| Dose cosine ↑ | 49.5 |
|
| 211 |
-
| Dose MAE ↓ | 5.062 |
|
| 212 |
-
|
| 213 |
-
The private set contains 4,348 de-identified spleen/stomach disorder cases. See the [full comparison](https://github.com/TCMAI-BJTU/Lingdan-V2#main-results) for other checkpoints.
|
| 214 |
-
|
| 215 |
## Task Prompts
|
| 216 |
|
| 217 |
For SFT/R1 models, fill the placeholders in these LingLan evaluation templates and pass the text as the user message.
|
|
|
|
| 28 |
</p>
|
| 29 |
|
| 30 |
<p align="center">
|
| 31 |
+
<a href="https://huggingface.co/collections/TCMLLM/lingdan-v2"><img src="https://img.shields.io/badge/Models-Hugging_Face-FFD21E?logo=huggingface&logoColor=black" alt="Hugging Face models" /></a>
|
| 32 |
<a href="https://modelscope.cn/collections/TCMAIBJTU/Lingdan-V2"><img src="https://img.shields.io/badge/Models-ModelScope-624AFF" alt="ModelScope models" /></a>
|
| 33 |
<a href="https://github.com/TCMAI-BJTU/LingLan"><img src="https://img.shields.io/badge/Benchmark-LingLan-2A8F5B" alt="LingLan benchmark" /></a>
|
| 34 |
<img src="https://img.shields.io/badge/Model_scales-4B_%7C_8B_%7C_14B-0B5394" alt="Model scales: 4B, 8B, and 14B" />
|
| 35 |
<a href="https://github.com/TCMAI-BJTU/Lingdan-V2/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache--2.0-D22128" alt="Apache License 2.0" /></a>
|
| 36 |
</p>
|
| 37 |
|
| 38 |
+
[Model](#model-details) · [Results](#checkpoint-evaluation) · [Quickstart](#quickstart) · [vLLM](#vllm-deployment) · [Prompts](#task-prompts) · [Citation](#citation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
## Model Details
|
| 41 |
|
|
|
|
| 50 |
| Intended use | Structured TCM clinical reasoning and prescription-generation research |
|
| 51 |
| Platform model ID | `TCMLLM/Lingdan-4B-R1` |
|
| 52 |
|
| 53 |
+
## Checkpoint Evaluation
|
| 54 |
+
|
| 55 |
+
Paper-reported results for **Lingdan-4B-R1**. Full: LingLan (25,620 items); Hard: LingLan-Hard (5,200 items). Overall Score averages 16 primary metrics, excluding dose MAE. All scores use a 0–100 scale except MAE (lower is better). The paper uses zero-shot Chinese prompts, temperature 0.6, and at most 8,192 generated tokens; reproduction also requires the same data and scoring pipeline.
|
| 56 |
+
|
| 57 |
+
| Metric | LingLan Full | LingLan-Hard |
|
| 58 |
+
| --- | ---: | ---: |
|
| 59 |
+
| Overall Score ↑ | 63.4 | 40.4 |
|
| 60 |
+
| Prescription generation F1 ↑ | 36.2 | 24.8 |
|
| 61 |
+
| Clinical-record entity extraction F1 ↑ | 70.5 | 58.4 |
|
| 62 |
+
| Classical-text entity extraction F1 ↑ | 58.5 | 42.5 |
|
| 63 |
+
| Syndrome generation F1 ↑ | 9.5 | 1.6 |
|
| 64 |
+
| Treatment-principle generation F1 ↑ | 13.9 | 2.4 |
|
| 65 |
+
| Prescription dose cosine ↑ | 34.2 | 23.4 |
|
| 66 |
+
| Prescription dose MAE ↓ | 4.6 | 4.7 |
|
| 67 |
+
|
| 68 |
+
Task-level scores follow the appendix’s primary DTR metrics, not the character-level DTR-F1 variant.
|
| 69 |
+
|
| 70 |
+
| Private prescription evaluation (4,348 cases) | Score |
|
| 71 |
+
| --- | ---: |
|
| 72 |
+
| Herb F1 ↑ | 52.7 |
|
| 73 |
+
| Herb precision ↑ | 52.5 |
|
| 74 |
+
| Herb recall ↑ | 54.1 |
|
| 75 |
+
| Dose cosine ↑ | 49.5 |
|
| 76 |
+
| Dose MAE ↓ | 5.062 |
|
| 77 |
+
|
| 78 |
+
The private set contains 4,348 de-identified spleen/stomach disorder cases. See the [full comparison](https://github.com/TCMAI-BJTU/Lingdan-V2#main-results) for other checkpoints.
|
| 79 |
+
|
| 80 |
## Quickstart
|
| 81 |
|
| 82 |
Use Transformers ≥4.51.0; see the [Qwen3 quickstart](https://qwen.readthedocs.io/en/stable/getting_started/quickstart.html).
|
|
|
|
| 202 |
|
| 203 |
`EMPTY` is a placeholder for the local server started without API-key authentication.
|
| 204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
## Task Prompts
|
| 206 |
|
| 207 |
For SFT/R1 models, fill the placeholders in these LingLan evaluation templates and pass the text as the user message.
|