Instructions to use Willlzh/COFOS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Willlzh/COFOS with Transformers:
# 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Willlzh/COFOS with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Willlzh/COFOS" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Willlzh/COFOS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Willlzh/COFOS
- SGLang
How to use Willlzh/COFOS with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Willlzh/COFOS" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Willlzh/COFOS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Willlzh/COFOS" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Willlzh/COFOS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Willlzh/COFOS with Docker Model Runner:
docker model run hf.co/Willlzh/COFOS
# 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]:]))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
H2O2as 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
- Model:
Willlzh/COFOS - Dataset:
Willlzh/COFOS_data - npm CLI:
@lzhzzzzwill/cofos
- Downloads last month
- 91
# 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)