alimosavian
commited on
Commit
•
99ce23b
1
Parent(s):
25e1d06
Update README.md
Browse files
README.md
CHANGED
@@ -60,9 +60,49 @@ Users (both direct and downstream) should be made aware of the risks, biases and
|
|
60 |
|
61 |
## How to Get Started with the Model
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
[More Information Needed]
|
66 |
|
67 |
## Training Details
|
68 |
|
|
|
60 |
|
61 |
## How to Get Started with the Model
|
62 |
|
63 |
+
´´´python
|
64 |
+
import torch
|
65 |
+
from transformers import pipeline
|
66 |
+
from transformers import TextStreamer
|
67 |
+
from transformers import AutoTokenizer
|
68 |
+
from transformers import AutoModelForCausalLM
|
69 |
+
|
70 |
+
|
71 |
+
model_name = 'four-two-labs/lynx-micro'
|
72 |
+
|
73 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
74 |
+
model = AutoModelForCausalLM.from_pretrained(
|
75 |
+
model_name,
|
76 |
+
device_map='cuda',
|
77 |
+
torch_dtype=torch.bfloat16,
|
78 |
+
use_flash_attention_2=True, # Remove if flash attention isn't available
|
79 |
+
)
|
80 |
+
|
81 |
+
pipe = pipeline(
|
82 |
+
'text-generation',
|
83 |
+
model=model,
|
84 |
+
tokenizer=tokenizer,
|
85 |
+
streamer=TextStreamer(tokenizer=tokenizer)
|
86 |
+
)
|
87 |
+
|
88 |
+
messages = [
|
89 |
+
#{'role': 'user', 'content': 'Lös ekvationen 2x^2-5 = 9'},
|
90 |
+
#{'role': 'user', 'content': 'Vad är fel med denna mening: "Hej! Jag idag bra mår."'},
|
91 |
+
#{'role': 'user', 'content': """Översätt till svenska: Hayashi, the Japanese government spokesperson, said Monday that Tokyo is answering the Chinese presence around the islands with vessels of its own.\n\n“We ensure a comprehensive security system for territorial waters by deploying Coast Guard patrol vessels that are consistently superior to other party’s capacity,” Hayashi said.\n\nAny Japanese-Chinese incident in the Senkakus raises the risk of a wider conflict, analysts note, due to Japan’s mutual defense treaty with the United States.\n\nWashington has made clear on numerous occasions that it considers the Senkakus to be covered by the mutual defense pact."""},
|
92 |
+
#{'role': 'user', 'content': """Vad handlar texten om?\n\nHayashi, the Japanese government spokesperson, said Monday that Tokyo is answering the Chinese presence around the islands with vessels of its own.\n\n“We ensure a comprehensive security system for territorial waters by deploying Coast Guard patrol vessels that are consistently superior to other party’s capacity,” Hayashi said.\n\nAny Japanese-Chinese incident in the Senkakus raises the risk of a wider conflict, analysts note, due to Japan’s mutual defense treaty with the United States.\n\nWashington has made clear on numerous occasions that it considers the Senkakus to be covered by the mutual defense pact."""},
|
93 |
+
#{'role': 'user', 'content': """Skriv en sci-fi novell som utspelar sig över millenium på en planet runt ett binärt stjärnsystem."""},
|
94 |
+
{'role': 'user', 'content': 'Hur många helikoptrar kan en människa äta på en gång?'},
|
95 |
+
]
|
96 |
+
|
97 |
+
r = pipe(
|
98 |
+
messages,
|
99 |
+
max_length=4096,
|
100 |
+
do_sample=False,
|
101 |
+
eos_token_id=tokenizer.vocab['<end_of_turn>']
|
102 |
+
)
|
103 |
+
```
|
104 |
+
|
105 |
|
|
|
106 |
|
107 |
## Training Details
|
108 |
|