maayanorner
commited on
Commit
โข
490b24e
1
Parent(s):
2bf7e5b
Update README.md
Browse files
README.md
CHANGED
@@ -1,9 +1,80 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
## Training procedure
|
5 |
|
6 |
-
|
|
|
|
|
7 |
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Model
|
2 |
+
NOT production-ready.
|
3 |
+
Based on DictaLM2.0; fine-tuned for text summarization.
|
|
|
4 |
|
5 |
+
Known Issues:
|
6 |
+
- The model is bloated (disk size).
|
7 |
+
- While the results look pretty good, the model was not evaluated.
|
8 |
|
9 |
|
10 |
+
# Data:
|
11 |
+
https://github.com/IAHLT/summarization_he
|
12 |
+
|
13 |
+
|
14 |
+
```# !pip install bitsandbytes>=0.41.3 to quantize
|
15 |
+
import torch
|
16 |
+
from transformers import (
|
17 |
+
AutoModelForCausalLM,
|
18 |
+
AutoTokenizer,
|
19 |
+
BitsAndBytesConfig
|
20 |
+
)
|
21 |
+
|
22 |
+
|
23 |
+
def predict_text(text, tokenizer, model, num_beams=4, temperature=1, max_new_tokens=512):
|
24 |
+
inputs = tokenizer(f'{text}\n### ืกืืืื:', return_tensors="pt")
|
25 |
+
in_data = inputs.input_ids.to('cuda')
|
26 |
+
output_ids = model.generate(input_ids=in_data, num_beams=num_beams, max_new_tokens = max_new_tokens, do_sample=True, early_stopping=True, use_cache = True, temperature=temperature, eos_token_id=tokenizer.eos_token_id)
|
27 |
+
generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=False)
|
28 |
+
|
29 |
+
return generated_text
|
30 |
+
|
31 |
+
|
32 |
+
# optional
|
33 |
+
use_4bit = True
|
34 |
+
bnb_4bit_compute_dtype = "float16"
|
35 |
+
bnb_4bit_quant_type = "nf4"
|
36 |
+
use_nested_quant = False
|
37 |
+
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
38 |
+
|
39 |
+
|
40 |
+
# optional
|
41 |
+
bnb_config = BitsAndBytesConfig(
|
42 |
+
load_in_4bit=use_4bit,
|
43 |
+
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
44 |
+
bnb_4bit_compute_dtype=compute_dtype,
|
45 |
+
bnb_4bit_use_double_quant=use_nested_quant,
|
46 |
+
)
|
47 |
+
|
48 |
+
model_path = 'maayanorner/hebrew-summarization-llm'
|
49 |
+
|
50 |
+
model = AutoModelForCausalLM.from_pretrained(
|
51 |
+
model_path,
|
52 |
+
trust_remote_code=True,
|
53 |
+
quantization_config=bnb_config # optional
|
54 |
+
)
|
55 |
+
model.to('cuda')
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
57 |
+
|
58 |
+
text = '...'
|
59 |
+
|
60 |
+
predict_text(text, max_new_tokens=512, tokenizer=tokenizer, model=model)
|
61 |
+
```
|
62 |
+
|
63 |
+
# Short Example:
|
64 |
+
### Random Linkedin Post (out-of-distribution):
|
65 |
+
|
66 |
+
ืืืจื ืฉืืืฉ ืฉื ืื ืืืชืืจืืช ืืืจืืฉืืช, ืื ื ืืื ืืฉืชืฃ ืฉืกืืืืชื ืชืืืจ ืจืืฉืื ืืืืขื ืืืืฉื! ๐
|
67 |
+
|
68 |
+
ืชืืื ืืืืื ืืืืืื ืืืงืืืืช ืชื ืืืื-ืืคื ืขื ืืืืข ืืืืืื, ืืืจืฆืื ืื ืคืืืื, ืืืฉืคืื ืืืืืจืื ืฉืชืืื ืืขืืจื ืื ืืืืืข ืืืืืื ืืืฉืื (ืชืจืชื ืืฉืืข โ ืจืื ืชืืื ื ๐).
|
69 |
+
|
70 |
+
ืืืืื ืืืืืืืื ืืืคืจืืืงืืื ืืฉืื ืื ืฉืืืฆืขืชื ืฆืืจืชื ืืืข ืื ืืกืืื ืืืืื ืืืื ืืืืืืืช ืืืืื ืื:
|
71 |
+
โข ืฉืคืืช ืชืื ืืช: C, C++, C#, Python, JavaScript, TypeScript
|
72 |
+
โข ืืืื ืืกืืืืืช ืขืืืื: Docker, Jenkins, SQL, Gatling, Selenium
|
73 |
+
โข ืชืื ืืช ืืขืจืืืช ืืฉืืืฆืืช (Embedded): Arduino, Raspberry Pi
|
74 |
+
|
75 |
+
ืืขืช ืื ื ืืืคืฉ ืืช ืืืืืื ืืช ืฉืื ืืืฉืชืื ืืชืขืฉืืื, ืขื ืขืืืคืืช ืืชืคืงืืื ืคืืชืื Full-Stack/Back-End ืื ืคืชืื ืื ืืืฆืขืืช ื ืืกืคืืช!
|
76 |
+
|
77 |
+
ืื ื ืืืืข ืขื ืชืฉืืงื ืืืื ืืืืืื, ืืืืืืฆืื ืืืืื ืืืฉืืื ืืฆืืจืชืืช. ืื ืื ืืชื ืืืืจืื ืืืจื ืฉืืืคืฉืช ืืคืชื ืฆืขืืจ ืื ืืื, ืืฉืื ืืฉืืื ืงืืจืืช ืืืื. ืืื ืื - ืื ืืืืง ืื ืฉืืชืืฃ ืืขืืจื ืื ืืืื! ๐
|
78 |
+
|
79 |
+
### Summary:
|
80 |
+
ืืคืืกื ืืชืืจ ืืช ืกืืื ืืืืืืื ืฉื ืืืืชื ืืชืืืจ ืจืืฉืื ืืืืขื ืืืืฉื ืืืืืื ืืืงืืืืช ืชื ืืืื-ืืคื. ืืืืื ืืืืืืืื ืฆืืจ ืืืืชื ืืืข ืื ืืกืืื ืืืืื ืืืื ืืืืืืืช ืืืืื ืืช, ืืืื ืฉืคืืช ืชืื ืืช, ืืืื ืืกืืืืืช ืขืืืื, ืืชืื ืืช ืืขืจืืืช ืืฉืืืฆืืช. ืืขืช ืืื ืืืคืฉ ืขืืืื ืืชืืื ืืคืืชืื.
|