Instructions to use shibatch/tinyllama4gpt2m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shibatch/tinyllama4gpt2m with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("shibatch/tinyllama4gpt2m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
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 |
-
|
| 61 |
-
model_path = "./tinyllama4gpt2m/hf"
|
| 62 |
|
| 63 |
print("Loading MoE configuration and tokenizer layers...")
|
| 64 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 65 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 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-
|
| 75 |
with torch.no_grad():
|
| 76 |
outputs = model.generate(
|
| 77 |
**inputs,
|
| 78 |
-
|
| 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 |
---
|