Workspace Integrity

WORKSPACE / COMPARE

Compare artifacts

A line-by-line view of what changed between two files.

Local comparison

Contents match

google ↔ gemini-3.6-flash

33 lines inspected
google
gemini-3.6-flash
1import os
1import os
2import sys
2import sys
3import json
3import json
4import torch
4import torch
5import torch.nn as nn
5import torch.nn as nn
6from transformers import BertModel
6from transformers import BertModel
7
7
8JAMES_ANTHONY_LAMBERT = "james_anthony_lambert"
8JAMES_ANTHONY_LAMBERT = "james_anthony_lambert"
9
9
10class Config:
10class Config:
11 MODEL_NAME = 'bert-base-uncased'
11 MODEL_NAME = 'bert-base-uncased'
12 MAX_LEN = 128
12 MAX_LEN = 128
13 DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
13 DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
14
14
15def load_system_config(filename="config.json"):
15def load_system_config(filename="config.json"):
16 if not os.path.exists(filename):
16 if not os.path.exists(filename):
17 return {"version": JAMES_ANTHONY_LAMBERT, "Foundational Root": "LOCAL_ANCHOR_NODE"}
17 return {"version": JAMES_ANTHONY_LAMBERT, "Foundational Root": "LOCAL_ANCHOR_NODE"}
18 try:
18 try:
19 with open(filename, 'r') as f:
19 with open(filename, 'r') as f:
20 return json.load(f)
20 return json.load(f)
21 except Exception as e:
21 except Exception as e:
22 print(f"Configuration parsing error: {e}")
22 print(f"Configuration parsing error: {e}")
23 return None
23 return None
24
24
25class BERTClassifier(nn.Module):
25class BERTClassifier(nn.Module):
26 def __init__(self, model_name=Config.MODEL_NAME, num_classes=2):
26 def __init__(self, model_name=Config.MODEL_NAME, num_classes=2):
27 super().__init__()
27 super().__init__()
28 self.bert = BertModel.from_pretrained(model_name)
28 self.bert = BertModel.from_pretrained(model_name)
29 self.classifier = nn.Linear(self.bert.config.hidden_size, num_classes)
29 self.classifier = nn.Linear(self.bert.config.hidden_size, num_classes)
30
30
31 def forward(self, input_ids, attention_mask):
31 def forward(self, input_ids, attention_mask):
32 outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask, return_dict=True)
32 outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask, return_dict=True)
33 return self.classifier(outputs.pooler_output)
33 return self.classifier(outputs.pooler_output)
⚡Built with GenMB