vvsotnikov
commited on
Commit
•
35ba507
1
Parent(s):
ebb0a31
Upload README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,54 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- causal-lm
|
6 |
+
license: cc-by-nc-sa-4.0
|
7 |
+
datasets:
|
8 |
+
- dmayhem93/ChatCombined
|
9 |
+
- tatsu-lab/alpaca
|
10 |
+
- nomic-ai/gpt4all_prompt_generations
|
11 |
+
- Dahoas/full-hh-rlhf
|
12 |
+
- jeffwan/sharegpt_vicuna
|
13 |
+
- HuggingFaceH4/databricks_dolly_15k
|
14 |
---
|
15 |
+
|
16 |
+
# StableLM-Tuned-Alpha 16-bit
|
17 |
+
|
18 |
+
## Model Description
|
19 |
+
|
20 |
+
16-bit version of `StableLM-Tuned-Alpha` compressed for the sake of speed and memory usage. No other changes were made. Original model: https://huggingface.co/stabilityai/stablelm-tuned-alpha-7b
|
21 |
+
|
22 |
+
## Usage
|
23 |
+
|
24 |
+
Get started chatting with `StableLM-Tuned-Alpha 16-bit` by using the following code snippet:
|
25 |
+
|
26 |
+
```python
|
27 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained("vvsotnikov/stablelm-tuned-alpha-7b-16bit")
|
29 |
+
model = AutoModelForCausalLM.from_pretrained("vvsotnikov/stablelm-tuned-alpha-7b-16bit")
|
30 |
+
model.cuda()
|
31 |
+
class StopOnTokens(StoppingCriteria):
|
32 |
+
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
33 |
+
stop_ids = [50278, 50279, 50277, 1, 0]
|
34 |
+
for stop_id in stop_ids:
|
35 |
+
if input_ids[0][-1] == stop_id:
|
36 |
+
return True
|
37 |
+
return False
|
38 |
+
system_prompt = """<|SYSTEM|># StableLM Tuned (Alpha version)
|
39 |
+
- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
|
40 |
+
- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
|
41 |
+
- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
|
42 |
+
- StableLM will refuse to participate in anything that could harm a human.
|
43 |
+
"""
|
44 |
+
prompt = f"{system_prompt}<|USER|>What's your mood today?<|ASSISTANT|>"
|
45 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
46 |
+
tokens = model.generate(
|
47 |
+
**inputs,
|
48 |
+
max_new_tokens=64,
|
49 |
+
temperature=0.7,
|
50 |
+
do_sample=True,
|
51 |
+
stopping_criteria=StoppingCriteriaList([StopOnTokens()])
|
52 |
+
)
|
53 |
+
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
|
54 |
+
```
|