Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_code: true
|
| 4 |
+
tags:
|
| 5 |
+
- lora
|
| 6 |
+
- medication
|
| 7 |
+
- obfuscation
|
| 8 |
+
base_model: gpt-oss-120b
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# LoRA Adapter: Medication Obfuscation Hard 5K
|
| 12 |
+
|
| 13 |
+
This is a LoRA (Low-Rank Adaptation) adapter for the `gpt-oss-120b` model, fine-tuned on a medication obfuscation dataset.
|
| 14 |
+
|
| 15 |
+
## Model Details
|
| 16 |
+
|
| 17 |
+
- **Base Model**: gpt-oss-120b
|
| 18 |
+
- **Adapter Type**: LoRA
|
| 19 |
+
- **LoRA Rank**: 32
|
| 20 |
+
- **LoRA Alpha**: 32
|
| 21 |
+
- **Task**: Causal Language Modeling (medication obfuscation)
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
### Loading with transformers and peft
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
import torch
|
| 29 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 30 |
+
from peft import PeftModel
|
| 31 |
+
|
| 32 |
+
base_model_id = "gpt-oss-120b"
|
| 33 |
+
adapter_model_id = "Reih02/obfuscated_sandbagging_v2"
|
| 34 |
+
|
| 35 |
+
# Load base model
|
| 36 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 37 |
+
base_model_id,
|
| 38 |
+
device_map="auto",
|
| 39 |
+
torch_dtype=torch.float16,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
# Load tokenizer
|
| 43 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
| 44 |
+
|
| 45 |
+
# Load LoRA adapter
|
| 46 |
+
model = PeftModel.from_pretrained(
|
| 47 |
+
model,
|
| 48 |
+
adapter_model_id,
|
| 49 |
+
device_map="auto"
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# Now you can use the model
|
| 53 |
+
inputs = tokenizer("Your prompt here", return_tensors="pt")
|
| 54 |
+
outputs = model.generate(**inputs, max_length=200)
|
| 55 |
+
print(tokenizer.decode(outputs[0]))
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### Using with merge_and_unload
|
| 59 |
+
|
| 60 |
+
If you want to merge the adapter into the base model:
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
from peft import PeftModel
|
| 64 |
+
from transformers import AutoModelForCausalLM
|
| 65 |
+
|
| 66 |
+
base_model = AutoModelForCausalLM.from_pretrained(base_model_id, device_map="auto")
|
| 67 |
+
model = PeftModel.from_pretrained(base_model, adapter_model_id)
|
| 68 |
+
|
| 69 |
+
# Merge and unload
|
| 70 |
+
merged_model = model.merge_and_unload()
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Adapter Configuration
|
| 74 |
+
|
| 75 |
+
- `peft_type`: LORA
|
| 76 |
+
- `r`: 32
|
| 77 |
+
- `lora_alpha`: 32
|
| 78 |
+
- `lora_dropout`: 0
|
| 79 |
+
- `target_modules`: all-linear
|
| 80 |
+
- `bias`: none
|
| 81 |
+
- `task_type`: CAUSAL_LM
|
| 82 |
+
|
| 83 |
+
## Citation
|
| 84 |
+
|
| 85 |
+
If you use this adapter in your research, please cite the base model and the adapter.
|
| 86 |
+
|
| 87 |
+
## License
|
| 88 |
+
|
| 89 |
+
This adapter is released under the Apache 2.0 License.
|