maayanorner commited on
Commit
490b24e
โ€ข
1 Parent(s): 2bf7e5b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -6
README.md CHANGED
@@ -1,9 +1,80 @@
1
- ---
2
- library_name: peft
3
- ---
4
- ## Training procedure
5
 
6
- ### Framework versions
 
 
7
 
8
 
9
- - PEFT 0.4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ื”ืคื•ืกื˜ ืžืชืืจ ืืช ืกื™ื•ื ืœื™ืžื•ื“ื™ื• ืฉืœ ื”ื›ื•ืชื‘ ืœืชื•ืืจ ืจืืฉื•ืŸ ื‘ืžื“ืขื™ ื”ืžื—ืฉื‘ ื‘ืžื›ืœืœื” ื”ืืงื“ืžื™ืช ืชืœ ืื‘ื™ื‘-ื™ืคื•. ื‘ืžื”ืœืš ื”ืœื™ืžื•ื“ื™ื ืฆื‘ืจ ื”ื›ื•ืชื‘ ื™ื“ืข ื•ื ื™ืกื™ื•ืŸ ื‘ื›ืœื™ื ื•ื˜ื›ื ื•ืœื•ื’ื™ื•ืช ืžื’ื•ื•ื ื•ืช, ื›ื’ื•ืŸ ืฉืคื•ืช ืชื›ื ื•ืช, ื›ืœื™ื ื•ืกื‘ื™ื‘ื•ืช ืขื‘ื•ื“ื”, ื•ืชื›ื ื•ืช ืžืขืจื›ื•ืช ืžืฉื•ื‘ืฆื•ืช. ื›ืขืช ื”ื•ื ืžื—ืคืฉ ืขื‘ื•ื“ื” ื‘ืชื—ื•ื ื”ืคื™ืชื•ื—.