File size: 1,711 Bytes
1b8e737 77cf934 1b8e737 77cf934 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
---
library_name: transformers
tags:
- medical
datasets:
- stefan-m-lenz/ICDOPS-QA-2024
language:
- de
base_model:
- meta-llama/Llama-3.1-8B-Instruct
---
# Model Card for Model stefan-m-lenz/Llama-3.1-8B-ICDOPS-QA-2024
This model is a PEFT adapter (e.g., LoRA) fine-tuned using the dataset [ICDOPS-QA-2024](https://huggingface.co/datasets/stefan-m-lenz/ICDOPS-QA-2024) based on [meta-llama/Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct).
For more information about the training, see the [dataset card](https://huggingface.co/datasets/stefan-m-lenz/ICDOPS-QA-2024).
# Usage
Package prerequisites:
```
pip install transformers accelerate peft
```
Load the model.
```{python}
repo_id = "stefan-m-lenz/Llama-3.1-8B-ICDOPS-QA-2024"
config = PeftConfig.from_pretrained(repo_id, device_map="auto")
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, device_map="auto")
model = PeftModel.from_pretrained(model, repo_id, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, device_map="auto")
```
```{python}
# Test input
test_input = """Was ist der ICD-10-Code für die Tumordiagnose „Bronchialkarzinom, Hauptbronchus“? Antworte nur kurz mit dem ICD-10 Code."""
# Generate response
inputs = tokenizer(test_input, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=7,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
temperature=None,
top_p=None,
top_k=None,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
response = response[len(test_input):].strip()
print("Test Input:", test_input)
print("Model Response:", response)
``` |