nqzfaizal77ai
commited on
Commit
•
0fb4ef1
1
Parent(s):
b1d306c
Update README.md
Browse files
README.md
CHANGED
@@ -29,4 +29,46 @@ The dataset is structured hierarchically, with each level representing an increa
|
|
29 |
4. **Sub-Unit:** Combination of two or more fragments.
|
30 |
5. **Unit:** Combination of two or more sub-units.
|
31 |
6. **Super-Unit:** Combination of two or more units.
|
32 |
-
7. **Mega-Unit:** Combination of two or more super-units.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
4. **Sub-Unit:** Combination of two or more fragments.
|
30 |
5. **Unit:** Combination of two or more sub-units.
|
31 |
6. **Super-Unit:** Combination of two or more units.
|
32 |
+
7. **Mega-Unit:** Combination of two or more super-units.
|
33 |
+
|
34 |
+
**How to Use**
|
35 |
+
|
36 |
+
```python
|
37 |
+
import torch
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
39 |
+
from IPython.display import display, HTML
|
40 |
+
|
41 |
+
# prompt: load model and generate example
|
42 |
+
model_name = "nqzfaizal77ai/sa-145m-en-wikipedia-culture-part1-1bc"
|
43 |
+
|
44 |
+
model = AutoModelForCausalLM.from_pretrained(model_name,trust_remote_code=True)
|
45 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name,trust_remote_code=True)
|
46 |
+
|
47 |
+
torch.manual_seed(3077)
|
48 |
+
|
49 |
+
# Example usage stochastic decode
|
50 |
+
input_text = "The cultural impact of the internet is"
|
51 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
52 |
+
output = model.generate(**inputs,
|
53 |
+
do_sample=True,
|
54 |
+
top_k=50,
|
55 |
+
top_p=0.95,
|
56 |
+
repetition_penalty=1.2,
|
57 |
+
max_length=100)
|
58 |
+
def print_with_border(text):
|
59 |
+
"""Prints the given text with a border around it."""
|
60 |
+
display(HTML(f"<div style='border: 1px solid black; padding: 10px;'>{text}</div>"))
|
61 |
+
|
62 |
+
# Example usage greedy decode
|
63 |
+
print_with_border(tokenizer.decode(output[0], skip_special_tokens=True))
|
64 |
+
|
65 |
+
output = merged_model.generate(**inputs,
|
66 |
+
do_sample=False,
|
67 |
+
max_length=100)
|
68 |
+
def print_with_border(text):
|
69 |
+
"""Prints the given text with a border around it."""
|
70 |
+
display(HTML(f"<div style='border: 1px solid black; padding: 10px;'>{text}</div>"))
|
71 |
+
|
72 |
+
# Example usage
|
73 |
+
print_with_border(tokenizer.decode(output[0], skip_special_tokens=True))
|
74 |
+
```
|