Implement LLaMA (#9)

Co-authored-by: Zhuohan Li <zhuohan123@gmail.com>
This commit is contained in:
Woosuk Kwon
2023-03-30 12:25:32 +08:00
committed by GitHub
co-authored by Zhuohan Li
parent a1b3de86cd
commit 80a2f812f1
7 changed files with 500 additions and 35 deletions
+2 -5
View File
@@ -299,7 +299,7 @@ class OPTForCausalLM(nn.Module):
param.data.copy_(loaded_weight)
@staticmethod
def download_weights(model_name: str, path: str):
def get_weights(model_name: str, path: str):
path = os.path.join(path, f"{model_name}-np")
path = os.path.abspath(os.path.expanduser(path))
os.makedirs(path, exist_ok=True)
@@ -316,11 +316,8 @@ class OPTForCausalLM(nn.Module):
cache_dir=os.path.join(path, "cache"))
bin_files = glob.glob(os.path.join(folder, "*.bin"))
if "/" in model_name:
model_name = model_name.split("/")[1].lower()
for bin_file in tqdm(bin_files, desc="Convert format"):
state = torch.load(bin_file)
state = torch.load(bin_file, map_location="cpu")
for name, param in tqdm(state.items(), leave=False):
if name.startswith("decoder."):
name = "model." + name