im-sangwoon/protein-sft-uniprot
Viewer • Updated • 1.55M • 19
How to use im-sangwoon/chatprot-qwen2.5-32b-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-32B-Instruct")
model = PeftModel.from_pretrained(base_model, "im-sangwoon/chatprot-qwen2.5-32b-lora")How to use im-sangwoon/chatprot-qwen2.5-32b-lora with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="im-sangwoon/chatprot-qwen2.5-32b-lora")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("im-sangwoon/chatprot-qwen2.5-32b-lora", dtype="auto")How to use im-sangwoon/chatprot-qwen2.5-32b-lora with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "im-sangwoon/chatprot-qwen2.5-32b-lora"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "im-sangwoon/chatprot-qwen2.5-32b-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/im-sangwoon/chatprot-qwen2.5-32b-lora
How to use im-sangwoon/chatprot-qwen2.5-32b-lora with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "im-sangwoon/chatprot-qwen2.5-32b-lora" \
--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": "im-sangwoon/chatprot-qwen2.5-32b-lora",
"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 "im-sangwoon/chatprot-qwen2.5-32b-lora" \
--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": "im-sangwoon/chatprot-qwen2.5-32b-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use im-sangwoon/chatprot-qwen2.5-32b-lora with Docker Model Runner:
docker model run hf.co/im-sangwoon/chatprot-qwen2.5-32b-lora
Qwen2.5-32B-Instruct 기반의 단백질 연구 특화 LoRA 어댑터입니다.
UniProt 데이터베이스에서 구축한 약 155만 건의 단백질 Q&A 데이터로 SFT(Supervised Fine-Tuning)하여, 단백질의 이름, 기능, 패밀리, 세포 내 위치 등에 대한 전문적인 질의응답이 가능합니다.
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
base_model_id = "Qwen/Qwen2.5-32B-Instruct"
adapter_id = "im-sangwoon/chatprot-qwen2.5-32b-lora"
# Load base model
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, adapter_id)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
# Inference
messages = [
{"role": "system", "content": "You are a helpful assistant for protein analysis."},
{"role": "user", "content": "What is the function of Hemoglobin subunit alpha?"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen2.5-32B-Instruct \
--enable-lora \
--lora-modules chatprot=im-sangwoon/chatprot-qwen2.5-32b-lora \
--dtype bfloat16 \
--trust-remote-code \
--max-model-len 8192 \
--max-lora-rank 64
im-sangwoon/protein-sft-uniprot - UniProt 데이터베이스에서 추출한 단백질 Q&A 데이터셋 (약 1,551,711건)
질문 유형:
| Parameter | Value |
|---|---|
| Rank (r) | 64 |
| Alpha | 16 |
| Dropout | 0.1 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Task Type | CAUSAL_LM |
| Parameter | Value |
|---|---|
| Epochs | 3 |
| Batch size (per device) | 1 |
| Gradient accumulation steps | 8 |
| Effective batch size | 8 |
| Learning rate | 2e-4 |
| LR scheduler | Cosine |
| Warmup ratio | 0.03 |
| Weight decay | 0.001 |
| Max grad norm | 0.3 |
| Optimizer | AdamW (fused) |
| Precision | bf16 |
| Gradient checkpointing | Enabled |