Spaces:
Runtime error
Runtime error
stakelovelace
commited on
Commit
•
457f3a4
1
Parent(s):
acc7015
commit from tesla
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import torch
|
2 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, Trainer, BertLMHeadModel, BertForSequenceClassification
|
3 |
from datasets import Dataset
|
4 |
import pandas as pd
|
5 |
import csv
|
@@ -67,6 +67,11 @@ def main(api_name, base_url):
|
|
67 |
device = get_device() # Get the appropriate device
|
68 |
data = load_data_and_config("train2.csv")
|
69 |
tokenizer = AutoTokenizer.from_pretrained("google/codegemma-2b")
|
|
|
|
|
|
|
|
|
|
|
70 |
model = AutoModelForCausalLM.from_pretrained('google/codegemma-2b', is_decoder=True)
|
71 |
#model = BertLMHeadModel.from_pretrained('google/codegemma-2b', is_decoder=True)
|
72 |
# Example assuming you have a prepared dataset for classification
|
@@ -74,7 +79,8 @@ def main(api_name, base_url):
|
|
74 |
model.to(device) # Move model to the appropriate device
|
75 |
|
76 |
train_model(model, tokenizer, data, device)
|
77 |
-
|
|
|
78 |
model.save_pretrained("./fine_tuned_model")
|
79 |
tokenizer.save_pretrained("./fine_tuned_model")
|
80 |
|
|
|
1 |
import torch
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, TrainingArguments, Trainer, BertLMHeadModel, BertForSequenceClassification
|
3 |
from datasets import Dataset
|
4 |
import pandas as pd
|
5 |
import csv
|
|
|
67 |
device = get_device() # Get the appropriate device
|
68 |
data = load_data_and_config("train2.csv")
|
69 |
tokenizer = AutoTokenizer.from_pretrained("google/codegemma-2b")
|
70 |
+
# Load the configuration for a specific model
|
71 |
+
config = AutoConfig.from_pretrained('google/codegemma-2b')
|
72 |
+
# Update the activation function
|
73 |
+
config.hidden_act = 'gelu_pytorch_tanh' # Set to use approximate GeLU
|
74 |
+
|
75 |
model = AutoModelForCausalLM.from_pretrained('google/codegemma-2b', is_decoder=True)
|
76 |
#model = BertLMHeadModel.from_pretrained('google/codegemma-2b', is_decoder=True)
|
77 |
# Example assuming you have a prepared dataset for classification
|
|
|
79 |
model.to(device) # Move model to the appropriate device
|
80 |
|
81 |
train_model(model, tokenizer, data, device)
|
82 |
+
|
83 |
+
|
84 |
model.save_pretrained("./fine_tuned_model")
|
85 |
tokenizer.save_pretrained("./fine_tuned_model")
|
86 |
|