COFOS is a domain-adapted causal language model for covalent organic frameworks
(COFs), reactive oxygen species (ROS), oxygen-derived products, and photocatalytic
or redox mechanism QA.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "Willlzh/COFOS"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 trust_remote_code=True,
12)
13
14messages = [
15 {
16 "role": "system",
17 "content": (
18 "You are COFOS, a natural QA assistant for covalent organic "
19 "frameworks and reactive oxygen species. Answer directly and do "
20 "not call H2O2 a radical ROS."
21 ),
22 },
23 {
24 "role": "user",
25 "content": "What ROS does TT-T-COF generate under visible-light photocatalysis?",
26 },
27]
28
29prompt = tokenizer.apply_chat_template(
30 messages,
31 tokenize=False,
32 add_generation_prompt=True,
33)
34inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
35
36with torch.no_grad():
37 outputs = model.generate(
38 **inputs,
39 max_new_tokens=256,
40 do_sample=False,
41 )
42
43print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1npx @lzhzzzzwill/cofos
2npx @lzhzzzzwill/cofos --pdf-dir ./new_pdfs
3npx @lzhzzzzwill/cofos --model /path/to/merged_model
4npx @lzhzzzzwill/cofos --no-rag
1npm install -g @lzhzzzzwill/cofos
2cofos --pdf-dir ./new_pdfs