Skip to content

Commit e5a2a66

Browse files
authored
Add files via upload
1 parent 3d64503 commit e5a2a66

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

run_experiment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# from sentence_transformers import SentenceTransformer, util
55
import json
66
import re
7-
from utils_xqc import standardize, standardize_category, change_name, set_seed, load_json, save_json
7+
from utils import set_seed, load_json, save_json
88
import random
99
import numpy as np
1010
import json

utils.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import json
2+
import re
3+
import torch
4+
import transformers
5+
import transformers.models.llama.modeling_llama
6+
from functools import partial
7+
import numpy as np
8+
import random
9+
10+
def set_seed(seed):
11+
torch.manual_seed(seed)
12+
torch.cuda.manual_seed_all(seed)
13+
np.random.seed(seed)
14+
random.seed(seed)
15+
# torch.backends.cudnn.deterministic = True
16+
17+
18+
def load_json(file_name, file_path=""):
19+
file = []
20+
with open(file_path + file_name, "r") as f:
21+
file = json.load(f)
22+
return file
23+
24+
def save_json(data, file_name, file_path=""):
25+
with open(file_path + file_name, "w") as f:
26+
json.dump(data, f)

0 commit comments

Comments
 (0)