Spaces:
Sleeping
Sleeping
Download models/lora_model.py from jaothan/GenAI_project: direct link, hf CLI and curl.
- Browser
- Download file 387 Bytes
-
https://huggingface.co/spaces/jaothan/GenAI_project/resolve/main/models/lora_model.py
- Command line
-
hf download hf://spaces/jaothan/GenAI_project/models/lora_model.py
-
curl -L -o lora_model.py https://huggingface.co/spaces/jaothan/GenAI_project/resolve/main/models/lora_model.py
387 Bytes
| from transformers import BertForSequenceClassification, LoRAConfig | |
| def get_lora_model(config): | |
| model = BertForSequenceClassification.from_pretrained('bert-base-uncased') | |
| lora_config = LoRAConfig(r=config['model']['lora']['r'], alpha=config['model']['lora']['alpha']) | |
| model.add_lora('imdb_lora', config=lora_config) | |
| model.train_lora('imdb_lora') | |
| return model | |