Commit 8c2d07de authored by Мазур Грета Евгеньевна's avatar Мазур Грета Евгеньевна
Browse files

obuch with cross and graphic SAVING LORA

parent dd810160
No related merge requests found
Showing with 42 additions and 8 deletions
+42 -8
from peft import PeftConfig
from transformers import BertModel, BertTokenizer
from peft import PeftModel
import torch
config = PeftConfig.from_pretrained("./fine-tuned-bert-lora")
print("Базовая модель:", config.base_model_name_or_path)
print("LoRA config:", config)
\ No newline at end of file
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Загружаем базовую модель
base_model = BertModel.from_pretrained("bert-base-uncased").to(device)
# Загружаем адаптер LoRA
model = PeftModel.from_pretrained(base_model, "./fine-tuned-bert-lora_new").to(device)
# Загружаем токенизатор
tokenizer = BertTokenizer.from_pretrained("./fine-tuned-bert-lora_new")
# Пример инференса
text = "This is a test prompt."
inputs = tokenizer(text, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model(**inputs)
print("LoRA адаптер загружен, выходы модели:", outputs)
\ No newline at end of file
from peft import PeftConfig
from transformers import BertModel, BertTokenizer
from peft import PeftModel
import torch
config = PeftConfig.from_pretrained("./fine-tuned-bert-lora")
print("Базовая модель:", config.base_model_name_or_path)
print("LoRA config:", config)
\ No newline at end of file
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Загружаем базовую модель
base_model = BertModel.from_pretrained("bert-base-uncased").to(device)
# Загружаем адаптер LoRA
model = PeftModel.from_pretrained(base_model, "./fine-tuned-bert-lora_new").to(device)
# Загружаем токенизатор
tokenizer = BertTokenizer.from_pretrained("./fine-tuned-bert-lora_new")
# Пример инференса
text = "This is a test prompt."
inputs = tokenizer(text, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model(**inputs)
print("LoRA адаптер загружен, выходы модели:", outputs)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment