Views
No views yet
c_attn) and projection (c_proj) modules
| Dataset | Pre-trained GPT-2 | Fine-tuned GPT-2 | Improvement (%) |
|---|---|---|---|
| Medical Texts | 45.73 | 35.36 | 22.7 |
| Speech Transcriptions | 103.21 | 67.67 | 34.4 |
| Combined (All Data) | 53.15 | 39.86 | 25.0 |
| Epoch | Training Loss | Validation Loss | Perplexity |
|---|---|---|---|
| 1 | 3.95 | 4.20 | 44.99 |
| 5 | 3.89 | 4.11 | 42.03 |
| 10 | 3.81 | 4.05 | 40.22 |
| 15 | 3.83 | 4.03 | 39.29 |
| 20 | 3.77 | 4.01 | 38.70 |
| 25 | 3.77 | 4.00 | 38.33 |
| 30 | 3.78 | 3.99 | 38.22 |
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7# Load tokenizer
8lm_tokenizer = AutoTokenizer.from_pretrained("Vardis/Medical_Speech_Greek_GPT2")
9
10# Load base model
11base_model = AutoModelForCausalLM.from_pretrained(
12 "lighteternal/gpt2-finetuned-greek",
13 torch_dtype=torch.float16,
14 device_map="auto"
15)
16
17# Load LoRA weights
18lm_model = PeftModel.from_pretrained(base_model, "Vardis/Medical_Speech_Greek_GPT2").to(device)
19
20# Example inference
21input_text = "Ο ασθενής παρουσιάζει συμπτώματα"
22inputs = lm_tokenizer(input_text, return_tensors="pt").to(device)
23outputs = lm_model.generate(**inputs, max_length=50)
24print(lm_tokenizer.decode(outputs[0], skip_special_tokens=True))