Downloads · 30 days
13
10% of all-time downloads
iopwsy/MatGPT-synthesis
MatGPT-synthesis is a text generation model from iopwsy. Use it when you need the model to write or continue text. It is set up for transformers.
predicted the synthesis path in inorganic chemistry
Downloads · 30 days
13
10% of all-time downloads
All-time downloads
134
Public
Parameters
137M
510 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors510 MB · 99%
How the weights are stored.
F32124M · 91%
From the Hugging Face model README
predicted the synthesis path in inorganic chemistry
from transformers import GPT2Tokenizer, GPT2LMHeadModel, StoppingCriteria, StoppingCriteriaList
import torch
model_path = "iopwsy/MatGPT-synthesis"
tokenizer = GPT2Tokenizer.from_pretrained(model_path, pad_token = '<|endoftext|>')
model = GPT2LMHeadModel.from_pretrained(model_path)
model.config.pad_token_id = model.config.eos_token_id
model.eval()
class StopforGPT2(StoppingCriteria):
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
return input_ids[0,-1].detach().cpu().numpy() == 50256
def get_path(text):
with torch.no_grad():
res = model.generate(input_ids = tokenizer.encode_plus(text, return_tensors = 'pt'),
do_sample=True,
top_k = 10,
top_p = 0.95,
temperature = 0.1,
max_new_tokens = 300,
stopping_criteria=StoppingCriteriaList([StopforGPT2()]))
print(tokenizer.decode(res[0],skip_special_tokens=True))
### example
get_path("How to synthesis Li7La3Zr2O12?\n")