How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="Willlzh/COFOS")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("Willlzh/COFOS")
model = AutoModelForCausalLM.from_pretrained("Willlzh/COFOS", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

COFOS

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.

How It Was Trained

COFOS was trained as a student model from COF/ROS chemistry data:

  • Teacher data: a 35B Qwen teacher generated and normalized COF/ROS QA and mechanism answers from structured records and retrieved evidence.
  • Student training: QLoRA/SFT on a Qwen-style student model, followed by LoRA adapter merge into a standalone Transformers checkpoint.
  • Training mixture: Willlzh/COFOS_data, including teacher-distilled COF/ROS QA, RAG-style samples, chemistry/redox QA, and answer-style correction data.
  • Deployment model: The default COFOS 9B weights include the domain fine-tuning and the subsequent direct-QA LoRA. Load the checkpoint directly with Transformers. The M4 evaluation used these weights with BM25 and knowledge-graph retrieval enabled in the COFOS runtime.

What It Can Do

COFOS is intended for research and literature-review assistance, especially:

  • answer COF photocatalysis and ROS questions in natural QA style
  • distinguish dominant ROS/product, secondary species, and intermediates
  • handle common species such as O2ยท-, 1O2, H2O2, ยทOH, SO4ยท-, SO5ยท-, HO2ยท, *O2, *OOH, and *HOOH
  • avoid describing H2O2 as a radical ROS
  • explain condition-dependent ROS assignments involving light, O2, water, sacrificial reagents, PMS/PDS, or related redox environments
  • work with external KG/BM25/PDF-RAG evidence when used through the COFOS CLI or local project runtime

Usage

Python / Transformers

This checkpoint was exported with Transformers 5.14.1.

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "Willlzh/COFOS"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)

messages = [
    {
        "role": "system",
        "content": (
            "You are COFOS, a natural QA assistant for covalent organic "
            "frameworks and reactive oxygen species. Answer directly and do "
            "not call H2O2 a radical ROS."
        ),
    },
    {
        "role": "user",
        "content": "What ROS does TT-T-COF generate under visible-light photocatalysis?",
    },
]

prompt = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=256,
        do_sample=False,
    )

print(tokenizer.decode(outputs[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))

npm / npx CLI

The npm CLI loads the model and can add KG/BM25 and local PDF evidence:

npx @lzhzzzzwill/cofos
npx @lzhzzzzwill/cofos --pdf-dir ./new_pdfs
npx @lzhzzzzwill/cofos --model /path/to/merged_model
npx @lzhzzzzwill/cofos --no-rag

Or install it globally:

npm install -g @lzhzzzzwill/cofos
cofos --pdf-dir ./new_pdfs

By default, the CLI stores model/runtime artifacts under ./.cofos/ in the launch directory. PDFs passed with --pdf-dir are parsed locally and are not uploaded.

Limitations

  • COFOS can hallucinate material-specific facts if the answer is not represented in the model or retrieval evidence.
  • Direct Transformers usage is no-RAG; use the CLI or project runtime for evidence-augmented answers.
  • It is not guaranteed to cite sources correctly unless connected to an external retrieval system.
  • Mechanistic explanations are research assistance, not experimental proof.
  • Do not use COFOS for high-stakes chemical safety, medical, legal, or regulatory decisions.

Links

Downloads last month
91
Safetensors
Model size
9B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train Willlzh/COFOS

Space using Willlzh/COFOS 1