Update README.md
Browse files
README.md
CHANGED
@@ -23,84 +23,31 @@ this model uses Task classification and the conversation is between USER and Ans
|
|
23 |
# NOTE β οΈ
|
24 |
|
25 |
|
26 |
-
THE JAX/FLAX version of model is available both for training and usage
|
27 |
|
|
|
28 |
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
```
|
37 |
|
38 |
-
|
39 |
-
```python
|
40 |
-
# It's recommended to use PipeLine
|
41 |
-
# Make Sure that you have sentence piece,bits and bytes and accelerate installed
|
42 |
-
from transformers import LlamaTokenizer, LlamaForCausalLM, pipeline, GenerationConfig
|
43 |
-
import torch
|
44 |
-
from IPython.display import clear_output
|
45 |
-
import textwrap
|
46 |
-
from typing import List, Optional
|
47 |
-
import re
|
48 |
-
import base64
|
49 |
-
|
50 |
-
tokenizer = LlamaTokenizer.from_pretrained("erfanzar/LGeM-7B-MT")
|
51 |
-
model = LlamaForCausalLM.from_pretrained(
|
52 |
-
'erfanzar/LGeM-7B-MT',
|
53 |
-
load_in_8bit=True,
|
54 |
-
device_map='auto',
|
55 |
-
torch_dtype=torch.float16
|
56 |
-
)
|
57 |
-
|
58 |
-
def generator(input_text,pipe_line,max_number=256,do_print=False ,args_a=False):
|
59 |
-
verify_text = lambda txt : '\n'.join([textwrap.fill(txt, width=140) for txt in txt.split('\n')])
|
60 |
-
|
61 |
-
orginal_text = input_text
|
62 |
-
if not input_text.startswith(f'<|prompter|>') and args_a:
|
63 |
-
input_text = f'<\s><|prompter|> {input_text}<\s><|ai|>'
|
64 |
-
for i in range(max_number):
|
65 |
-
exac = input_text
|
66 |
-
with torch.no_grad():
|
67 |
-
output = pipe_line(input_text)
|
68 |
-
input_text = output[0]['generated_text']
|
69 |
-
if do_print:
|
70 |
-
clear_output(wait=True)
|
71 |
-
print(verify_text(input_text))
|
72 |
-
|
73 |
-
if input_text.endswith('<\s>') and i>6 or exac == input_text or input_text.endswith('<|prompter|>') and i>6:
|
74 |
-
break
|
75 |
-
yield verify_text(input_text)
|
76 |
|
|
|
|
|
77 |
```
|
78 |
|
79 |
-
|
80 |
-
And Use just like
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
```python
|
85 |
-
|
86 |
-
pipe_line = pipeline(
|
87 |
-
"text-generation",
|
88 |
-
model=model,
|
89 |
-
tokenizer=tokenizer,
|
90 |
-
temperature=0.8,
|
91 |
-
top_p=0.95,
|
92 |
-
max_new_tokens=4,
|
93 |
-
output_scores=True
|
94 |
-
|
95 |
-
)
|
96 |
-
```
|
97 |
or Just Simply Open [GOOGLE COLAB ππ](https://colab.research.google.com/drive/1nWS_FhWIDH3-g56F3FbWCIYi0ngVdWHx?usp=sharing)
|
98 |
|
99 |
### Generate Method to get res Text by Text
|
100 |
|
101 |
```python
|
102 |
|
103 |
-
def generate(model_,input_ids_,tokeinzer_,max_length:int=
|
104 |
with torch.no_grad():
|
105 |
before_start = len(input_ids_[0])+1
|
106 |
for _ in range(max_length):
|
@@ -160,8 +107,8 @@ from modules import FlaxLGeMForCausalLM
|
|
160 |
|
161 |
- and Training code is available at jax_train.py (check source)
|
162 |
- training parameters
|
163 |
-
- - learning rate
|
164 |
-
- - Optimizer
|
165 |
- - batch 32
|
166 |
- - TPU POD
|
167 |
- - Train Time 50 hours
|
|
|
23 |
# NOTE β οΈ
|
24 |
|
25 |
|
|
|
26 |
|
27 |
+
THE JAX/FLAX version of model is available both for training and usage And This model support context length of 3300
|
28 |
|
29 |
|
30 |
+
this model support run with OST_UI so heres how to run it with just one command
|
31 |
|
32 |
+
```shell
|
33 |
+
git clone https://github.com/erfanzar/OST-OpenSourceTransformers
|
34 |
+
cd OST-OpenSourceTransformers/
|
35 |
+
python3 OST_UI/app.py --model_id='erfanzar/chatLGeM' --
|
36 |
```
|
37 |
|
38 |
+
## Examples π
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
```text
|
41 |
+
</s><|prompter|> TEXT </s><|assistant|>
|
42 |
```
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
or Just Simply Open [GOOGLE COLAB ππ](https://colab.research.google.com/drive/1nWS_FhWIDH3-g56F3FbWCIYi0ngVdWHx?usp=sharing)
|
45 |
|
46 |
### Generate Method to get res Text by Text
|
47 |
|
48 |
```python
|
49 |
|
50 |
+
def generate(model_,input_ids_,tokeinzer_,max_length:int=3300,temperature :float= 0.2,eos_token_id:int=2):
|
51 |
with torch.no_grad():
|
52 |
before_start = len(input_ids_[0])+1
|
53 |
for _ in range(max_length):
|
|
|
107 |
|
108 |
- and Training code is available at jax_train.py (check source)
|
109 |
- training parameters
|
110 |
+
- - learning rate 2e-5
|
111 |
+
- - Optimizer AdamW
|
112 |
- - batch 32
|
113 |
- - TPU POD
|
114 |
- - Train Time 50 hours
|