This is a
QLoRA (Quantized LoRA) adapter trained on top of
Codemaster67/Olmo-7b-spe for chemistry
SMILES language modelling using the
Codemaster67/Causal_lm_chemistry_1M_rows dataset.
The base model's tokenizer was pre-extended with ~300 SPE (SMILES Pair
Encoding) chemistry tokens plus <|start_of_smiles|> / <|end_of_smiles|>
special tokens. The embed_tokens and lm_head layers are saved as
full (non-LoRA) trainable copies via modules_to_save because they were
resized during tokenizer extension.
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5bnb_config = BitsAndBytesConfig(
6 load_in_4bit=True,
7 bnb_4bit_use_double_quant=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=torch.bfloat16,
10)
11base_model = AutoModelForCausalLM.from_pretrained(
12 "Codemaster67/Olmo-7b-spe", quantization_config=bnb_config, trust_remote_code=True
13)
14model = PeftModel.from_pretrained(base_model, "Codemaster67/Olmo-7b_250KQlora")
15tokenizer = AutoTokenizer.from_pretrained("Codemaster67/Olmo-7b_250KQlora", trust_remote_code=True)
16
17smiles_input = "<|start_of_smiles|>CC(=O)Oc1ccccc1C(=O)O<|end_of_smiles|>"
18inputs = tokenizer(smiles_input, return_tensors="pt")
19outputs = model.generate(**inputs, max_new_tokens=128)
20print(tokenizer.decode(outputs[0], skip_special_tokens=False))
Chemistry-domain language modelling, SMILES generation and completion,
and downstream molecular property prediction via fine-tuning.