FreedomIntelligence/huatuo_encyclopedia_qa
Viewer • Updated • 364k • 1.99k • 88
How to use wubingheng/Doge-20M-Medical-SFT with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="wubingheng/Doge-20M-Medical-SFT", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("wubingheng/Doge-20M-Medical-SFT", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("wubingheng/Doge-20M-Medical-SFT", trust_remote_code=True)
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]:]))How to use wubingheng/Doge-20M-Medical-SFT with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "wubingheng/Doge-20M-Medical-SFT"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "wubingheng/Doge-20M-Medical-SFT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/wubingheng/Doge-20M-Medical-SFT
How to use wubingheng/Doge-20M-Medical-SFT with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "wubingheng/Doge-20M-Medical-SFT" \
--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": "wubingheng/Doge-20M-Medical-SFT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "wubingheng/Doge-20M-Medical-SFT" \
--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": "wubingheng/Doge-20M-Medical-SFT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use wubingheng/Doge-20M-Medical-SFT with Docker Model Runner:
docker model run hf.co/wubingheng/Doge-20M-Medical-SFT
This model is a fine-tuned version of wubingheng/Doge-20M-Chinese. It has been trained using TRL.
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, TextStreamer
tokenizer = AutoTokenizer.from_pretrained("wubingheng/Doge-20M-Medical-SFT")
model = AutoModelForCausalLM.from_pretrained("wubingheng/Doge-20M-Medical-SFT", trust_remote_code=True)
generation_config = GenerationConfig(
max_new_tokens=40,
min_new_tokens=1,
num_beams=1,
eos_token_id=[tokenizer.eos_token_id],
stop_strings=[tokenizer.eos_token],
early_stopping=False,
use_cache=True,
do_sample=True,
temperature=0.95,
repetition_penalty=1.0,
)
steamer = TextStreamer(tokenizer=tokenizer, skip_prompt=True)
system_prompt = """
你是一个医学助手,能够回答用户提出的医学问题。请根据用户的问题,给出准确的医学建议和解答。
""".strip()
prompt = "肝癌术后饮食注意事项有哪些"
conversation = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": prompt},
]
inputs = tokenizer.apply_chat_template(
conversation=conversation,
tokenize=True,
return_tensors="pt",
)
print(prompt)
output = model.generate(
inputs,
tokenizer=tokenizer,
generation_config=generation_config,
streamer=steamer
)
This model was trained with SFT.
@misc{smalldoges,
title={SmallDoges: A Family of Dynamic UltraFast Small Language Models},
author={Jingze, Shi and Yifan, Wu and Bingheng, Wu and Yuyu, Luo},
year={2025},
month={March},
url={https://github.com/SmallDoges/small-doge}
}
Base model
wubingheng/Doge-20M-Chinese