phenixace commited on
Commit
8d9caa8
1 Parent(s): 378b789

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -1
README.md CHANGED
@@ -6,6 +6,38 @@ license: apache-2.0
6
 
7
  #### Notice: The input should contain 2 context examples and the cutoff length should be set to 2048 to ensure best performance.
8
 
9
- More usage will be released later
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  Paper Link: https://arxiv.org/abs/2403.04197
 
6
 
7
  #### Notice: The input should contain 2 context examples and the cutoff length should be set to 2048 to ensure best performance.
8
 
9
+ A simple inference example:
10
+ ```
11
+ from transformers import AutoModelForCausalLM
12
+
13
+ model = AutoModelForCausalLM.from_pretrained("phenixace/ICMA-Galactica-125M-M2C")
14
+
15
+ from transformers import AutoTokenizer
16
+ tk = AutoTokenizer.from_pretrained("phenixace/ICMA-Galactica-125M-M2C")
17
+
18
+ from transformers import GenerationConfig
19
+ text = """Generate a caption for the molecule: C[C@]12CCC(=O)C=C1CC[C@@H]3[C@@H]2C(=O)C[C@]4([C@H]3CCC4=O)C
20
+ Caption: The molecule is a 3-oxo Delta(4)-steroid that is androst-4-ene carrying three oxo-substituents at positions 3, 11 and 17. It has a role as an androgen, a human urinary metabolite, a marine metabolite and an EC 1.1.1.146 (11beta-hydroxysteroid dehydrogenase) inhibitor. It is a 3-oxo-Delta(4) steroid, a 17-oxo steroid, an androstanoid and an 11-oxo steroid. It derives from a hydride of an androstane.
21
+
22
+ Generate a caption for the molecule: C[C@]12CCC(=O)C=C1CC[C@@H]3[C@@H]2C(=O)C[C@]4([C@H]3CC[C@@H]4C(=O)CO)C
23
+ Caption: The molecule is an 11-oxo steroid that is corticosterone in which the hydroxy substituent at the 11beta position has been oxidised to give the corresponding ketone. It has a role as a human metabolite and a mouse metabolite. It is a 21-hydroxy steroid, a 3-oxo-Delta(4) steroid, a 20-oxo steroid, an 11-oxo steroid, a corticosteroid and a primary alpha-hydroxy ketone. It derives from a corticosterone.
24
+
25
+ Based on the above examples, analyse the similarities and differences between the examples and finally generate a caption for the molecule: C[C@]12CCC(=O)C=C1CC[C@@H]3[C@@H]2C(=O)C[C@]\\4([C@H]3CC/C4=C/C(=O)OC)C."""
26
+ generation_config = GenerationConfig(
27
+ do_sample=True,
28
+ temperature=0.7,
29
+ top_p=0.85,
30
+ top_k=40,
31
+ num_beams=1,
32
+ repetition_penalty=1.0,
33
+ pad_token_id=0,
34
+ )
35
+ inputs = tk(text, return_tensors="pt", return_token_type_ids=False)
36
+ outputs = model.generate(**inputs, return_dict_in_generate=True, output_scores=True, num_return_sequences=1, max_new_tokens=256, generation_config=generation_config)
37
+
38
+ # decode
39
+ decoded = tk.decode(outputs.sequences[0], skip_special_tokens=True)
40
+ print(decoded)
41
+ ```
42
 
43
  Paper Link: https://arxiv.org/abs/2403.04197