Shishir1807
commited on
Commit
•
bd1ba98
1
Parent(s):
2bef6dd
Upload model card
Browse files
README.md
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- gpt
|
7 |
+
- llm
|
8 |
+
- large language model
|
9 |
+
- h2o-llmstudio
|
10 |
+
inference: false
|
11 |
+
thumbnail: https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
|
12 |
+
---
|
13 |
+
# Model Card
|
14 |
+
## Summary
|
15 |
+
|
16 |
+
This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
|
17 |
+
- Base model: [EleutherAI/pythia-2.8b-deduped](https://huggingface.co/EleutherAI/pythia-2.8b-deduped)
|
18 |
+
|
19 |
+
|
20 |
+
## Usage
|
21 |
+
|
22 |
+
To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers`, `accelerate` and `torch` libraries installed.
|
23 |
+
|
24 |
+
```bash
|
25 |
+
pip install transformers==4.29.2
|
26 |
+
pip install einops==0.6.1
|
27 |
+
pip install accelerate==0.19.0
|
28 |
+
pip install torch==2.0.0
|
29 |
+
```
|
30 |
+
|
31 |
+
```python
|
32 |
+
import torch
|
33 |
+
from transformers import pipeline
|
34 |
+
|
35 |
+
generate_text = pipeline(
|
36 |
+
model="Shishir1807/Moas_Explicit_PYT_v2",
|
37 |
+
torch_dtype="auto",
|
38 |
+
trust_remote_code=True,
|
39 |
+
use_fast=True,
|
40 |
+
device_map={"": "cuda:0"},
|
41 |
+
)
|
42 |
+
|
43 |
+
res = generate_text(
|
44 |
+
"Why is drinking water so healthy?",
|
45 |
+
min_new_tokens=2,
|
46 |
+
max_new_tokens=256,
|
47 |
+
do_sample=False,
|
48 |
+
num_beams=1,
|
49 |
+
temperature=float(0.0),
|
50 |
+
repetition_penalty=float(1.2),
|
51 |
+
renormalize_logits=True
|
52 |
+
)
|
53 |
+
print(res[0]["generated_text"])
|
54 |
+
```
|
55 |
+
|
56 |
+
You can print a sample prompt after the preprocessing step to see how it is feed to the tokenizer:
|
57 |
+
|
58 |
+
```python
|
59 |
+
print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
|
60 |
+
```
|
61 |
+
|
62 |
+
```bash
|
63 |
+
<|prompt|>Why is drinking water so healthy?<|endoftext|><|answer|>
|
64 |
+
```
|
65 |
+
|
66 |
+
Alternatively, you can download [h2oai_pipeline.py](h2oai_pipeline.py), store it alongside your notebook, and construct the pipeline yourself from the loaded model and tokenizer. If the model and the tokenizer are fully supported in the `transformers` package, this will allow you to set `trust_remote_code=False`.
|
67 |
+
|
68 |
+
```python
|
69 |
+
import torch
|
70 |
+
from h2oai_pipeline import H2OTextGenerationPipeline
|
71 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
72 |
+
|
73 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
74 |
+
"Shishir1807/Moas_Explicit_PYT_v2",
|
75 |
+
use_fast=True,
|
76 |
+
padding_side="left",
|
77 |
+
trust_remote_code=True,
|
78 |
+
)
|
79 |
+
model = AutoModelForCausalLM.from_pretrained(
|
80 |
+
"Shishir1807/Moas_Explicit_PYT_v2",
|
81 |
+
torch_dtype="auto",
|
82 |
+
device_map={"": "cuda:0"},
|
83 |
+
trust_remote_code=True,
|
84 |
+
)
|
85 |
+
generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
|
86 |
+
|
87 |
+
res = generate_text(
|
88 |
+
"Why is drinking water so healthy?",
|
89 |
+
min_new_tokens=2,
|
90 |
+
max_new_tokens=256,
|
91 |
+
do_sample=False,
|
92 |
+
num_beams=1,
|
93 |
+
temperature=float(0.0),
|
94 |
+
repetition_penalty=float(1.2),
|
95 |
+
renormalize_logits=True
|
96 |
+
)
|
97 |
+
print(res[0]["generated_text"])
|
98 |
+
```
|
99 |
+
|
100 |
+
|
101 |
+
You may also construct the pipeline from the loaded model and tokenizer yourself and consider the preprocessing steps:
|
102 |
+
|
103 |
+
```python
|
104 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
105 |
+
|
106 |
+
model_name = "Shishir1807/Moas_Explicit_PYT_v2" # either local folder or huggingface model name
|
107 |
+
# Important: The prompt needs to be in the same format the model was trained with.
|
108 |
+
# You can find an example prompt in the experiment logs.
|
109 |
+
prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
|
110 |
+
|
111 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
112 |
+
model_name,
|
113 |
+
use_fast=True,
|
114 |
+
trust_remote_code=True,
|
115 |
+
)
|
116 |
+
model = AutoModelForCausalLM.from_pretrained(
|
117 |
+
model_name,
|
118 |
+
torch_dtype="auto",
|
119 |
+
device_map={"": "cuda:0"},
|
120 |
+
trust_remote_code=True,
|
121 |
+
)
|
122 |
+
model.cuda().eval()
|
123 |
+
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
|
124 |
+
|
125 |
+
# generate configuration can be modified to your needs
|
126 |
+
tokens = model.generate(
|
127 |
+
input_ids=inputs["input_ids"],
|
128 |
+
attention_mask=inputs["attention_mask"],
|
129 |
+
min_new_tokens=2,
|
130 |
+
max_new_tokens=256,
|
131 |
+
do_sample=False,
|
132 |
+
num_beams=1,
|
133 |
+
temperature=float(0.0),
|
134 |
+
repetition_penalty=float(1.2),
|
135 |
+
renormalize_logits=True
|
136 |
+
)[0]
|
137 |
+
|
138 |
+
tokens = tokens[inputs["input_ids"].shape[1]:]
|
139 |
+
answer = tokenizer.decode(tokens, skip_special_tokens=True)
|
140 |
+
print(answer)
|
141 |
+
```
|
142 |
+
|
143 |
+
## Quantization and sharding
|
144 |
+
|
145 |
+
You can load the models using quantization by specifying ```load_in_8bit=True``` or ```load_in_4bit=True```. Also, sharding on multiple GPUs is possible by setting ```device_map=auto```.
|
146 |
+
|
147 |
+
## Model Architecture
|
148 |
+
|
149 |
+
```
|
150 |
+
GPTNeoXForCausalLM(
|
151 |
+
(gpt_neox): GPTNeoXModel(
|
152 |
+
(embed_in): Embedding(50304, 2560)
|
153 |
+
(layers): ModuleList(
|
154 |
+
(0-31): 32 x GPTNeoXLayer(
|
155 |
+
(input_layernorm): LayerNorm((2560,), eps=1e-05, elementwise_affine=True)
|
156 |
+
(post_attention_layernorm): LayerNorm((2560,), eps=1e-05, elementwise_affine=True)
|
157 |
+
(attention): GPTNeoXAttention(
|
158 |
+
(rotary_emb): RotaryEmbedding()
|
159 |
+
(query_key_value): Linear(in_features=2560, out_features=7680, bias=True)
|
160 |
+
(dense): Linear(in_features=2560, out_features=2560, bias=True)
|
161 |
+
)
|
162 |
+
(mlp): GPTNeoXMLP(
|
163 |
+
(dense_h_to_4h): Linear(in_features=2560, out_features=10240, bias=True)
|
164 |
+
(dense_4h_to_h): Linear(in_features=10240, out_features=2560, bias=True)
|
165 |
+
(act): GELUActivation()
|
166 |
+
)
|
167 |
+
)
|
168 |
+
)
|
169 |
+
(final_layer_norm): LayerNorm((2560,), eps=1e-05, elementwise_affine=True)
|
170 |
+
)
|
171 |
+
(embed_out): Linear(in_features=2560, out_features=50304, bias=False)
|
172 |
+
)
|
173 |
+
```
|
174 |
+
|
175 |
+
## Model Configuration
|
176 |
+
|
177 |
+
This model was trained using H2O LLM Studio and with the configuration in [cfg.yaml](cfg.yaml). Visit [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio) to learn how to train your own large language models.
|
178 |
+
|
179 |
+
|
180 |
+
## Disclaimer
|
181 |
+
|
182 |
+
Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
|
183 |
+
|
184 |
+
- Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
|
185 |
+
- Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
|
186 |
+
- Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
|
187 |
+
- Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
|
188 |
+
- Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
|
189 |
+
- Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
|
190 |
+
|
191 |
+
By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.
|