nfsrulesFR commited on
Commit
860fac4
·
verified ·
1 Parent(s): ffc9727

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +121 -121
README.md CHANGED
@@ -1,121 +1,121 @@
1
- ---
2
- base_model: meta-llama/Meta-Llama-3-8B
3
- tags:
4
- - molecular-optimization
5
- - chemistry
6
- - llama-3
7
- - grpo
8
- - rlhf
9
- license: apache-2.0
10
- language:
11
- - en
12
- pipeline_tag: text-generation
13
- ---
14
-
15
- # MEGA-GRPO
16
-
17
- Post-trained molecular optimization model using Tanimoto-aware GRPO (Group Relative Policy Optimization). Based on **Llama 3 8B**.
18
-
19
- **Paper**: [MEGA: A Large-Scale Molecular Editing Dataset for Guided-Action Optimization](https://openreview.net/pdf?id=wzou4rm3Tt)
20
- **Official Repository**: [https://github.com/nfsrules/MEGA.git](https://github.com/nfsrules/MEGA.git)
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install unsloth torch
26
- ```
27
-
28
- ## Usage
29
-
30
- ```python
31
- from unsloth import FastLanguageModel
32
- from unsloth.chat_templates import get_chat_template
33
-
34
- # Configuration
35
- max_seq_length = 1024
36
- lora_rank = 32
37
-
38
- # Load model
39
- model, tokenizer = FastLanguageModel.from_pretrained(
40
- model_name = "nfsrulesFR/mega-grpo",
41
- max_seq_length = max_seq_length,
42
- load_in_4bit = True,
43
- fast_inference = True,
44
- max_lora_rank = lora_rank,
45
- gpu_memory_utilization = 0.6,
46
- )
47
-
48
- # Configure tokenizer
49
- tokenizer.padding_side = 'left'
50
- if tokenizer.pad_token is None:
51
- tokenizer.pad_token = tokenizer.eos_token
52
-
53
- tokenizer = get_chat_template(
54
- tokenizer,
55
- chat_template="llama-3",
56
- mapping={"role": "from", "content": "value", "user": "human", "assistant": "gpt"},
57
- )
58
-
59
- # Generate
60
- input_smiles = "CCO"
61
- task = "Can you make molecule CCO more soluble in water? The output molecule should be similar to the input molecule."
62
-
63
- messages = [{"from": "human", "value": task}]
64
-
65
- encoded = tokenizer.apply_chat_template(
66
- messages,
67
- tokenize=True,
68
- add_generation_prompt=True,
69
- return_tensors="pt",
70
- padding=True,
71
- )
72
-
73
- outputs = model.generate(
74
- input_ids=encoded["input_ids"].cuda(),
75
- attention_mask=encoded["attention_mask"].cuda(),
76
- max_new_tokens=64,
77
- use_cache=True,
78
- pad_token_id=tokenizer.pad_token_id,
79
- )
80
-
81
- response = tokenizer.decode(outputs[0][encoded["input_ids"].shape[1]:], skip_special_tokens=True)
82
- print(response)
83
- ```
84
-
85
- ## Supported Tasks
86
-
87
- | Task ID | Description |
88
- |---------|-------------|
89
- | 101 | Increase water solubility |
90
- | 102 | Decrease water solubility |
91
- | 103 | Increase drug-likeness |
92
- | 104 | Decrease drug-likeness |
93
- | 105 | Increase permeability |
94
- | 106 | Decrease permeability |
95
- | 107 | Increase hydrogen bond acceptors |
96
- | 108 | Increase hydrogen bond donors |
97
- | 201 | Increase solubility + HBA |
98
- | 202 | Decrease solubility + increase HBA |
99
- | 203 | Increase solubility + HBD |
100
- | 204 | Decrease solubility + increase HBD |
101
- | 205 | Increase solubility + permeability |
102
- | 206 | Increase solubility + decrease permeability |
103
-
104
- ## Model Details
105
-
106
- - **Base Model**: Meta-Llama-3-8B
107
- - **Training**: Tanimoto-aware GRPO on 500K molecular transformations
108
- - **Input**: SMILES string + task description
109
- - **Output**: Modified SMILES string
110
-
111
- ## Citation
112
-
113
- ```bibtex
114
- @article{mega2025,
115
- title={MEGA: A Large-Scale Molecular Editing Dataset for Guided-Action Optimization},
116
- author={Fernandez, Nelson and Illouz, Maxime and Pinto, Luis and Yang, Entao and Amadou Boubacar, Habiboulaye},
117
- journal={Under review at International Conference on Learning Representations},
118
- year={2025},
119
- url={https://openreview.net/forum?id=wzou4rm3Tt}
120
- }
121
- ```
 
1
+ ---
2
+ base_model: meta-llama/Meta-Llama-3-8B
3
+ tags:
4
+ - molecular-optimization
5
+ - chemistry
6
+ - llama-3
7
+ - grpo
8
+ - rlhf
9
+ license: apache-2.0
10
+ language:
11
+ - en
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # MEGA-GRPO
16
+
17
+ Fine-tuned molecular optimization model using Tanimoto-aware GRPO (Group Relative Policy Optimization) on 500K molecular transformations. Based on **Llama 3 8B**.
18
+
19
+ **Paper**: [MEGA: A Large-Scale Molecular Editing Dataset for Guided-Action Optimization](https://openreview.net/pdf?id=wzou4rm3Tt)
20
+ **Official Repository**: [https://github.com/nfsrules/MEGA-moledit](https://github.com/nfsrules/MEGA-moledit)
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install unsloth torch
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ from unsloth import FastLanguageModel
32
+ from unsloth.chat_templates import get_chat_template
33
+
34
+ # Configuration
35
+ max_seq_length = 1024
36
+ lora_rank = 32
37
+
38
+ # Load model
39
+ model, tokenizer = FastLanguageModel.from_pretrained(
40
+ model_name = "nfsrulesFR/mega-grpo",
41
+ max_seq_length = max_seq_length,
42
+ load_in_4bit = True,
43
+ fast_inference = True,
44
+ max_lora_rank = lora_rank,
45
+ gpu_memory_utilization = 0.6,
46
+ )
47
+
48
+ # Configure tokenizer
49
+ tokenizer.padding_side = 'left'
50
+ if tokenizer.pad_token is None:
51
+ tokenizer.pad_token = tokenizer.eos_token
52
+
53
+ tokenizer = get_chat_template(
54
+ tokenizer,
55
+ chat_template="llama-3",
56
+ mapping={"role": "from", "content": "value", "user": "human", "assistant": "gpt"},
57
+ )
58
+
59
+ # Generate
60
+ input_smiles = "CCO"
61
+ task = "Can you make molecule CCO more soluble in water? The output molecule should be similar to the input molecule."
62
+
63
+ messages = [{"from": "human", "value": task}]
64
+
65
+ encoded = tokenizer.apply_chat_template(
66
+ messages,
67
+ tokenize=True,
68
+ add_generation_prompt=True,
69
+ return_tensors="pt",
70
+ padding=True,
71
+ )
72
+
73
+ outputs = model.generate(
74
+ input_ids=encoded["input_ids"].cuda(),
75
+ attention_mask=encoded["attention_mask"].cuda(),
76
+ max_new_tokens=64,
77
+ use_cache=True,
78
+ pad_token_id=tokenizer.pad_token_id,
79
+ )
80
+
81
+ response = tokenizer.decode(outputs[0][encoded["input_ids"].shape[1]:], skip_special_tokens=True)
82
+ print(response)
83
+ ```
84
+
85
+ ## Supported Tasks
86
+
87
+ | Task ID | Description |
88
+ |---------|-------------|
89
+ | 101 | Increase water solubility |
90
+ | 102 | Decrease water solubility |
91
+ | 103 | Increase drug-likeness |
92
+ | 104 | Decrease drug-likeness |
93
+ | 105 | Increase permeability |
94
+ | 106 | Decrease permeability |
95
+ | 107 | Increase hydrogen bond acceptors |
96
+ | 108 | Increase hydrogen bond donors |
97
+ | 201 | Increase solubility + HBA |
98
+ | 202 | Decrease solubility + increase HBA |
99
+ | 203 | Increase solubility + HBD |
100
+ | 204 | Decrease solubility + increase HBD |
101
+ | 205 | Increase solubility + permeability |
102
+ | 206 | Increase solubility + decrease permeability |
103
+
104
+ ## Model Details
105
+
106
+ - **Base Model**: Meta-Llama-3-8B
107
+ - **Training**: Tanimoto-aware GRPO on 500K molecular transformations
108
+ - **Input**: SMILES string + task description
109
+ - **Output**: Modified SMILES string
110
+
111
+ ## Citation
112
+
113
+ ```bibtex
114
+ @article{mega2025,
115
+ title={MEGA: A Large-Scale Molecular Editing Dataset for Guided-Action Optimization},
116
+ author={Fernandez, Nelson and Illouz, Maxime and Pinto, Luis and Yang, Entao and Amadou Boubacar, Habiboulaye},
117
+ journal={Under review at International Conference on Learning Representations},
118
+ year={2025},
119
+ url={https://openreview.net/forum?id=wzou4rm3Tt}
120
+ }
121
+ ```