48 lines
1.5 KiB
Markdown
48 lines
1.5 KiB
Markdown
|
|
---
|
|||
|
|
license: apache-2.0
|
|||
|
|
language:
|
|||
|
|
- zh
|
|||
|
|
base_model:
|
|||
|
|
- THUDM/glm-4-9b
|
|||
|
|
pipeline_tag: text-generation
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# AnesGLM is a large language model designed for anesthesiology question answering tasks in Chinese.
|
|||
|
|
|
|||
|
|
We develop AnesGLM, a Chinese large language model specialized for anesthesiology knowledge understanding and question answering. It is built upon THUDM/glm-4-9b and further adapted with domain-specific data from anesthesiology question answering and examination-style tasks. The model is designed to provide more accurate and professional responses for clinical anesthesiology education and knowledge-intensive QA scenarios.
|
|||
|
|
|
|||
|
|
## How to use
|
|||
|
|
|
|||
|
|
```python
|
|||
|
|
import torch
|
|||
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|||
|
|
|
|||
|
|
device = "cuda"
|
|||
|
|
|
|||
|
|
tokenizer = AutoTokenizer.from_pretrained("QiHongzhi/AnesGLM", trust_remote_code=True)
|
|||
|
|
|
|||
|
|
query = "什么是肺泡最小有效浓度(MAC)?"
|
|||
|
|
|
|||
|
|
inputs = tokenizer.apply_chat_template(
|
|||
|
|
[{"role": "user", "content": query}],
|
|||
|
|
add_generation_prompt=True,
|
|||
|
|
tokenize=True,
|
|||
|
|
return_tensors="pt",
|
|||
|
|
return_dict=True
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
inputs = inputs.to(device)
|
|||
|
|
|
|||
|
|
model = AutoModelForCausalLM.from_pretrained(
|
|||
|
|
"QiHongzhi/AnesGLM",
|
|||
|
|
torch_dtype=torch.bfloat16,
|
|||
|
|
low_cpu_mem_usage=True,
|
|||
|
|
trust_remote_code=True
|
|||
|
|
).to(device).eval()
|
|||
|
|
|
|||
|
|
gen_kwargs = {"max_length": 512, "do_sample": True, "top_k": 1}
|
|||
|
|
|
|||
|
|
with torch.no_grad():
|
|||
|
|
outputs = model.generate(**inputs, **gen_kwargs)
|
|||
|
|
outputs = outputs[:, inputs["input_ids"].shape[1]:]
|
|||
|
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|