Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -26,15 +26,16 @@ python nanogpt_slm_instruct_inference.py
|
|
| 26 |
# Import loads the model automatically (one-time download from HuggingFace)
|
| 27 |
from nanogpt_slm_instruct_inference import ask
|
| 28 |
|
|
|
|
| 29 |
# Simple question
|
| 30 |
print(ask("What is the capital of France?"))
|
| 31 |
-
|
| 32 |
# With input context
|
| 33 |
print(ask(
|
| 34 |
instruction="Summarize the following text.",
|
| 35 |
input_text="Machine learning enables systems to learn from data rather than being explicitly programmed."
|
| 36 |
))
|
| 37 |
-
|
| 38 |
# Control generation
|
| 39 |
print(ask(
|
| 40 |
"Write a short poem about the ocean.",
|
|
@@ -42,6 +43,7 @@ print(ask(
|
|
| 42 |
top_k=100, # wider sampling pool
|
| 43 |
max_tokens=150 # longer output
|
| 44 |
))
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
### Option 3: Load weights manually
|
|
@@ -49,7 +51,10 @@ print(ask(
|
|
| 49 |
from huggingface_hub import hf_hub_download
|
| 50 |
import torch, tiktoken
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Build model (full architecture in nanogpt_slm_instruct_inference.py)
|
| 55 |
from nanogpt_slm_instruct_inference import GPT, GPTConfig, generate, format_input
|
|
|
|
| 26 |
# Import loads the model automatically (one-time download from HuggingFace)
|
| 27 |
from nanogpt_slm_instruct_inference import ask
|
| 28 |
|
| 29 |
+
## First time execution will O/P prefed 5 examples with model responses
|
| 30 |
# Simple question
|
| 31 |
print(ask("What is the capital of France?"))
|
| 32 |
+
print()
|
| 33 |
# With input context
|
| 34 |
print(ask(
|
| 35 |
instruction="Summarize the following text.",
|
| 36 |
input_text="Machine learning enables systems to learn from data rather than being explicitly programmed."
|
| 37 |
))
|
| 38 |
+
print()
|
| 39 |
# Control generation
|
| 40 |
print(ask(
|
| 41 |
"Write a short poem about the ocean.",
|
|
|
|
| 43 |
top_k=100, # wider sampling pool
|
| 44 |
max_tokens=150 # longer output
|
| 45 |
))
|
| 46 |
+
print()
|
| 47 |
```
|
| 48 |
|
| 49 |
### Option 3: Load weights manually
|
|
|
|
| 51 |
from huggingface_hub import hf_hub_download
|
| 52 |
import torch, tiktoken
|
| 53 |
|
| 54 |
+
repo_id= "nishantup/nanogpt-slm-instruct"
|
| 55 |
+
filename = "nanogpt_slm_instruct.pth"
|
| 56 |
+
|
| 57 |
+
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 58 |
|
| 59 |
# Build model (full architecture in nanogpt_slm_instruct_inference.py)
|
| 60 |
from nanogpt_slm_instruct_inference import GPT, GPTConfig, generate, format_input
|