Views
No views yet
1# Load model directly
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("Sourabh2/Chemical_compund", trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained("Sourabh2/Chemical_compund", trust_remote_code=True)
6# Set up the device (GPU if available, otherwise CPU)
7device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8model = model.to(device)
9
10
11
12input_str = "Nobelium".lower()
13input_ids = tokenizer.encode(input_str, return_tensors='pt').to(device)
14
15output = model.generate(
16 input_ids,
17 max_length=200,
18 num_return_sequences=1,
19 do_sample=True,
20 top_k=8,
21 top_p=0.95,
22 temperature=0.1,
23 repetition_penalty=1.2
24)
25
26decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
27print(decoded_output)