Mxode commited on
Commit
f29ee9b
1 Parent(s): fbe21cd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -0
README.md CHANGED
@@ -1,3 +1,85 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - tiny
7
+ - small
8
+ - synonym
9
+ - tool
10
+ - converter
11
  ---
12
+ ## What's this?
13
+
14
+ A **tiny** model that can perform **paraphrasing** or **synonym substitution**.
15
+
16
+ The base model is [pythia-70m](https://huggingface.co/EleutherAI/pythia-70m). This model was fine-tuned with 10 epochs using [Q-Lora](https://github.com/artidoro/qlora) method on my own training set.
17
+
18
+
19
+
20
+ ## How to use
21
+
22
+ ### quick start
23
+
24
+ First import the model from hf:
25
+
26
+ ```python
27
+ from transformers import GPTNeoXForCausalLM, AutoTokenizer
28
+
29
+
30
+ model_name_or_path = 'Mxode/Pythia-70m-C-Language-KnowledgeExtract'
31
+ device = 'cuda'
32
+
33
+ model = GPTNeoXForCausalLM.from_pretrained(model_name_or_path).to(device)
34
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
35
+
36
+ # prompt template
37
+ prompt = '<|prompt|>Convert the following passage into synonymous sentences.<|prompt|>\n'
38
+ # any text you wish to convert, preferably in complete single sentences.
39
+ content = 'The theories and methods of systems science are extensively employed in various domains, including biology, economics, and sociology.'
40
+
41
+ text = prompt + content
42
+ ```
43
+
44
+ Then generate:
45
+
46
+ ```python
47
+ inputs = tokenizer(text, return_tensors="pt").to(device)
48
+ input_ids = inputs.input_ids
49
+
50
+ tokens = model.generate(
51
+ **inputs,
52
+ pad_token_id=tokenizer.eos_token_id,
53
+ max_new_tokens=100,
54
+ do_sample=True,
55
+ )
56
+ # strip the input
57
+ response = tokenizer.decode(tokens[0]).replace(text, "").strip('<|endoftext|>')
58
+
59
+ # I call it 'Synonymizer' :)
60
+ print(f'Synonymizer: {response}')
61
+ ### output:
62
+ ### The disciplines of systems science are extensively employed in various domains, including biology, economics, and sociology.
63
+ ```
64
+
65
+ Or maybe we'll try some more impossibly trained news? Hmm, get some sports news from espn and try:
66
+
67
+ ```python
68
+ ### ...
69
+ content = 'As both teams exited the court for halftime, Baynes and Mayen were shoulder to shoulder.'
70
+
71
+ ### ...
72
+ print(f'Synonymizer: {response}')
73
+ ### output:
74
+ ### As the team neets around the court to ease their shifts, Baynes and Middets were partnerly paryyneen.
75
+
76
+ ### sometimes:
77
+ ### Begantly mastitatively, Baynes and Mayen staged their team rested the Tywindes rested the Tywindes rested the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid the Tywindes laid
78
+ ```
79
+
80
+ WELL, as you can see, this is after all only an **experimental tiny model** and with that in mind I can give it a 7.5 out of 10 for performance.
81
+
82
+ I didn't adjust the hyperparameters, could try [low temperature] + [a bit higher repetition_penalty], the performance might be better.
83
+
84
+ I'll follow up by training more data on a slightly larger model and hopefully supporting multiple languages. While we all know that bigger models have better generalization capabilities - but smaller models are indeed cool :)
85
+