Spaces:
Runtime error
Runtime error
stakelovelace
commited on
Commit
•
1de88e7
1
Parent(s):
227e573
test2
Browse files- app.py +10 -5
- results/config.json +28 -0
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
@@ -74,14 +74,19 @@ def train_model(model, tokenizer, data, device):
|
|
74 |
def main(api_name, base_url):
|
75 |
device = get_device() # Get the appropriate device
|
76 |
data = load_data_and_config("train2.csv")
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
78 |
# Load the configuration for a specific model
|
79 |
-
config = AutoConfig.from_pretrained('google/codegemma-2b')
|
80 |
# Update the activation function
|
81 |
# config.hidden_act = '' # Set to use approximate GeLU gelu_pytorch_tanh
|
82 |
-
config.hidden_activation = 'gelu_pytorch_tanh' # Set to use GeLU
|
83 |
|
84 |
-
model = AutoModelForCausalLM.from_pretrained('google/codegemma-2b', is_decoder=True)
|
85 |
#model = BertLMHeadModel.from_pretrained('google/codegemma-2b', is_decoder=True)
|
86 |
# Example assuming you have a prepared dataset for classification
|
87 |
#model = BertForSequenceClassification.from_pretrained('thenlper/gte-small', num_labels=2, is_decoder=True) # binary classification
|
|
|
1 |
import torch
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GemmaTokenizer, AutoConfig, TrainingArguments, Trainer, BertLMHeadModel, BertForSequenceClassification
|
3 |
from datasets import Dataset
|
4 |
import pandas as pd
|
5 |
import csv
|
|
|
74 |
def main(api_name, base_url):
|
75 |
device = get_device() # Get the appropriate device
|
76 |
data = load_data_and_config("train2.csv")
|
77 |
+
|
78 |
+
model_id = "google/codegemma-2b"
|
79 |
+
tokenizer = GemmaTokenizer.from_pretrained(model_id)
|
80 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
81 |
+
|
82 |
+
#tokenizer = AutoTokenizer.from_pretrained("google/codegemma-2b")
|
83 |
# Load the configuration for a specific model
|
84 |
+
# config = AutoConfig.from_pretrained('google/codegemma-2b')
|
85 |
# Update the activation function
|
86 |
# config.hidden_act = '' # Set to use approximate GeLU gelu_pytorch_tanh
|
87 |
+
# config.hidden_activation = 'gelu_pytorch_tanh' # Set to use GeLU
|
88 |
|
89 |
+
# model = AutoModelForCausalLM.from_pretrained('google/codegemma-2b', is_decoder=True)
|
90 |
#model = BertLMHeadModel.from_pretrained('google/codegemma-2b', is_decoder=True)
|
91 |
# Example assuming you have a prepared dataset for classification
|
92 |
#model = BertForSequenceClassification.from_pretrained('thenlper/gte-small', num_labels=2, is_decoder=True) # binary classification
|
results/config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "google/codegemma-2b",
|
3 |
+
"architectures": [
|
4 |
+
"GemmaForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"bos_token_id": 2,
|
9 |
+
"eos_token_id": 1,
|
10 |
+
"head_dim": 256,
|
11 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
12 |
+
"hidden_size": 2048,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"intermediate_size": 16384,
|
15 |
+
"is_decoder": true,
|
16 |
+
"max_position_embeddings": 8192,
|
17 |
+
"model_type": "gemma",
|
18 |
+
"num_attention_heads": 8,
|
19 |
+
"num_hidden_layers": 18,
|
20 |
+
"num_key_value_heads": 1,
|
21 |
+
"pad_token_id": 0,
|
22 |
+
"rms_norm_eps": 1e-06,
|
23 |
+
"rope_theta": 10000.0,
|
24 |
+
"torch_dtype": "float32",
|
25 |
+
"transformers_version": "4.40.1",
|
26 |
+
"use_cache": true,
|
27 |
+
"vocab_size": 256000
|
28 |
+
}
|