shibatch commited on
Commit
1b738d5
·
verified ·
1 Parent(s): e8873cc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +5 -7
README.md CHANGED
@@ -57,12 +57,11 @@ Because the configuration parameters are seamlessly matched with the standard Tr
57
  import torch
58
  from transformers import AutoTokenizer, AutoModelForCausalLM
59
 
60
- # Path to the local directory containing your 'hf' folder
61
- model_path = "./tinyllama4gpt2m/hf"
62
 
63
  print("Loading MoE configuration and tokenizer layers...")
64
- tokenizer = AutoTokenizer.from_pretrained(model_path)
65
- model = AutoModelForCausalLM.from_pretrained(model_path)
66
 
67
  device = "cuda" if torch.cuda.is_available() else "cpu"
68
  model = model.to(device)
@@ -71,11 +70,11 @@ model.eval()
71
  prompt = "Once upon"
72
  inputs = tokenizer(prompt, return_tensors="pt").to(device)
73
 
74
- print("Running inference loop (Validating Top-3 sparse routing matrices)...")
75
  with torch.no_grad():
76
  outputs = model.generate(
77
  **inputs,
78
- max_new_tokens=20,
79
  do_sample=False
80
  )
81
 
@@ -84,7 +83,6 @@ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
84
  print("\n--- Inference Test Result ---")
85
  print("Prompt :", prompt)
86
  print("Generated:", generated_text)
87
-
88
  ```
89
 
90
  ---
 
57
  import torch
58
  from transformers import AutoTokenizer, AutoModelForCausalLM
59
 
60
+ repo_id = "shibatch/tinyllama4gpt2m"
 
61
 
62
  print("Loading MoE configuration and tokenizer layers...")
63
+ tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="hf")
64
+ model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="hf")
65
 
66
  device = "cuda" if torch.cuda.is_available() else "cpu"
67
  model = model.to(device)
 
70
  prompt = "Once upon"
71
  inputs = tokenizer(prompt, return_tensors="pt").to(device)
72
 
73
+ print("Running inference loop (Validating Top-2 sparse routing matrices)...")
74
  with torch.no_grad():
75
  outputs = model.generate(
76
  **inputs,
77
+ max_length=64,
78
  do_sample=False
79
  )
80
 
 
83
  print("\n--- Inference Test Result ---")
84
  print("Prompt :", prompt)
85
  print("Generated:", generated_text)
 
86
  ```
87
 
88
  ---