hkqiu commited on
Commit
e323b5f
·
verified ·
1 Parent(s): bfd28ae

Add PolyOpus model card and usage example

Browse files
Files changed (1) hide show
  1. README.md +74 -1
README.md CHANGED
@@ -1,3 +1,76 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ - zh
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: deepseek-ai/deepseek-llm-7b-chat
8
+ tags:
9
+ - chemistry
10
+ - polymers
11
+ - materials-science
12
+ - text-generation
13
  ---
14
+
15
+ # PolyOpus
16
+
17
+ PolyOpus is a polymer-specialized language model built by supervised fine-tuning of [DeepSeek-LLM-7B-Chat](https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat). It serves as the specialist model in the [PolySea framework](https://github.com/hkqiu/PolySea).
18
+
19
+ PolyOpus 是面向聚合物科学的专用语言模型,支持性质预测、指定带隙的结构生成和聚合物知识问答。
20
+
21
+ ## Supported tasks
22
+
23
+ - Predict glass-transition temperature, crystalline band gap and atomization energy.
24
+ - Classify polyimide heat resistance using Tg-derived categories.
25
+ - Generate polymer structures for a specified band-gap target.
26
+ - Answer polymer-science questions in English or Chinese.
27
+
28
+ For property prediction, provide the requested property and a polymer repeat-unit SMILES. The `*` symbols indicate polymerization attachment points.
29
+
30
+ ## Model details
31
+
32
+ - Approximately 7B parameters; `LlamaForCausalLM` architecture.
33
+ - A complete merged FP16 checkpoint in three Safetensors shards. No separate LoRA adapter is required for inference.
34
+ - A 4,096-token context window, with the tokenizer and chat template included.
35
+
36
+ ## Quick start
37
+
38
+ Install `torch`, `transformers` and `accelerate`, then run:
39
+
40
+ ```python
41
+ import torch
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer
43
+
44
+ model_id = "hkqiu/PolyOpus"
45
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
46
+ model = AutoModelForCausalLM.from_pretrained(
47
+ model_id, torch_dtype=torch.float16, device_map="auto"
48
+ )
49
+
50
+ messages = [{
51
+ "role": "user",
52
+ "content": "Predict the Tg of the following SMILES: *CC*"
53
+ }]
54
+ prompt = tokenizer.apply_chat_template(
55
+ messages, tokenize=False, add_generation_prompt=True
56
+ )
57
+ inputs = tokenizer(
58
+ prompt, add_special_tokens=False, return_tensors="pt"
59
+ ).to(model.device)
60
+
61
+ with torch.inference_mode():
62
+ outputs = model.generate(
63
+ **inputs, max_new_tokens=128, do_sample=True,
64
+ temperature=0.7, top_p=0.95,
65
+ pad_token_id=tokenizer.eos_token_id,
66
+ )
67
+ answer = outputs[0, inputs["input_ids"].shape[1]:]
68
+ print(tokenizer.decode(answer, skip_special_tokens=True))
69
+ ```
70
+
71
+ Predictions and generated structures require independent validation before use in experiments or materials selection.
72
+
73
+ ## Links
74
+
75
+ - [PolySea source code](https://github.com/hkqiu/PolySea)
76
+ - [Base model](https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat)