add cobra

This commit is contained in:
2024-05-05 19:56:00 +08:00
parent 7352c07d59
commit b7054cba4d
7 changed files with 163 additions and 70 deletions

9
.gitmodules vendored
View File

@@ -1,6 +1,9 @@
[submodule "molscribe"] [submodule "molscribe"]
path = molscribe path = molscribe
url = https://github.com/thomas0809/MolScribe url = https://github.com/thomas0809/MolScribe
[submodule "vary"] [submodule "vary-toy"]
path = vary path = vary-toy
url = https://github.com/Ucas-HaoranWei/Vary url = https://github.com/Ucas-HaoranWei/Vary-toy
[submodule "cobra"]
path = cobra
url = https://github.com/h-zhao1997/cobra

171
README.md
View File

@@ -1,93 +1,132 @@
# ChemStructLM # ChemStructLM
ChemStructLM是一个旨在整合MolScribe和Vary库让大语言模型能够理解、设计和改造化学结构、分子和蛋白质的项目。该项目通过在大语言模型中融合这两个强大的化学信息处理库旨在推动化学和生物信息学领域的研究和应用。
## 特性
## Getting started 整合了MolScribe和Vary库的功能。
提供了一个示例环境,用于同时使用这两个库。
包含了示例代码,展示如何将这两个库融合使用。
开源,鼓励社区贡献。
快速开始
先决条件
确保你有一个可用的Conda环境。如果没有可以访问Miniconda或Anaconda官方网站了解如何安装。推荐使用micromamba作为包管理器。
To make it easy for you to get started with GitLab, here's a list of recommended next steps. ## 安装
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! 克隆ChemStructLM仓库到你的本地机器
## Add your files ```shell
git clone https://github.com/hotwa/ChemStructLM.git
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files cd ChemStructLM
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://gitlab.dockless.eu.org/lingyuzeng/chemstructlm.git
git branch -M main
git push -uf origin main
``` ```
## Integrate with your tools 初始化子模块MolScribe和Vary
- [ ] [Set up project integrations](http://gitlab.dockless.eu.org/lingyuzeng/chemstructlm/-/settings/integrations) ```shell
git submodule update --init --recursive
```
## Collaborate with your team 检出MolScribe和Vary的特定版本
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) ```shell
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) git submodule add https://github.com/thomas0809/MolScribe molscribe
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) git submodule add https://github.com/Ucas-HaoranWei/Vary-toy vary-toy
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) git submodule add https://github.com/h-zhao1997/cobra cobra
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) cd molscribe
git rev-parse HEAD
git checkout 97acee57d10bd719f4dc1cfd30d09f142b7dc65f
cd ../vary-toy
git rev-parse HEAD
git checkout e94e50f4b10c7b0f2a29e4d8b3804a35024b0565
cd ..
cd cobra
git rev-parse HEAD
git checkout 365a24d360f9c0d1ed4db96acc3a76b12782d138
```
## Test and Deploy 创建并激活Conda环境
Use the built-in continuous integration in GitLab. ```shell
micromamba env create -f environment.yml
micromamba run -n ChemStructLM python -m pip install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple/
# install flash-attention
micromamba run -n ChemStructLM python -m pip install flash-attn --no-build-isolation
# install vary
cd vary/Vary-master
# change pth path in source code
# `vary/Vary-master/vary/demo/run_qwen_vary.py` and `vary/Vary-master/vary/model/vary_qwen_vary.py` in line `/cache/vit-large-patch14/`
# download from https://huggingface.co/openai/clip-vit-large-patch14/tree/main
sed -i 's|/cache/vit-large-patch14/|/media/lingyuzeng/c617029b-8496-684d-b402-a18f08e75ef13/project/Vary-toy/clip-vit-large-patch14/|g' vary/Vary-master/vary/demo/run_qwen_vary.py
sed -i 's|/cache/vit-large-patch14/|/media/lingyuzeng/c617029b-8496-684d-b402-a18f08e75ef13/project/Vary-toy/clip-vit-large-patch14/|g' vary/Vary-master/vary/model/vary_qwen_vary.py
sed -i 's/self.seq_length = config.seq_length/self.seq_length = config.max_length/' vary-toy/Vary-master/vary/model/llm/qwen/modeling_qwen.py
micromamba run -n ChemStructLM python -m pip install e .
# install molscribe
cd ../../molscribe
micromamba run -n ChemStructLM python -m pip install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple/
sed -i 's/timm==0.4.12/timm==0.6.13/' setup.py
micromamba run -n ChemStructLM python setup.py install
cd ..
micromamba activate ChemStructLM
# test
python vary/Vary-master/vary/demo/run_qwen_vary.py --model-name /media/lingyuzeng/c617029b-8496-684d-b402-a18f08e75ef13/project/Vary-toy/clip-vit-large-patch14/ --image-file /mnt/wtrr1/deepinproject/chemstructlm/vary/assets/vary.png
```
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) test:
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
*** ```shell
micromamba create -n test python=3.10 -y
cd vary-toy/Vary-master
micromamba run -n test python -m pip install e . -i https://pypi.mirrors.ustc.edu.cn/simple/
cd ../../molscribe
micromamba run -n test python setup.py install
cd ..
micromamba activate test
```
# Editing this README MolScribe test:
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. ```shell
import torch
from molscribe import MolScribe
# from huggingface_hub import hf_hub_download
## Suggestions for a good README # ckpt_path = hf_hub_download('yujieq/MolScribe', 'swin_base_char_aux_1m.pth')
ckpt_path = '/mnt/wtrr1/deepinproject/MolScribe/ckpts/swin_base_char_aux_1m680k.pth'
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. model = MolScribe(ckpt_path, device=torch.device('cpu'))
output = model.predict_image_file('molscribe/assets/example.png', return_atoms_bonds=True, return_confidence=True)
```
## Name [Cobra: Extending Mamba to Multi-modal Large Language Model for Efficient Inference](https://github.com/h-zhao1997/cobra)
Choose a self-explaining name for your project.
## Description 安装:
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges ```shell
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. cd cobra
pip install -e .
## Visuals # install mamba and other packages
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. pip install packaging ninja
pip install mamba-ssm
pip install causal-conv1d
## Installation # Verify Ninja --> should return exit code "0"
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. ninja --version; echo $?
```
## Usage ## 目录结构
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support ```shell
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. YourProjectName/
## Roadmap ├── src/ # 项目源代码
If you have ideas for releases in the future, it is a good idea to list them in the README. │ ├── integration/ # 融合MolScribe和Vary的代码
│ └── utils/ # 工具和辅助功能
## Contributing ├── tests/ # 测试脚本
State if you are open to contributions and what your requirements are for accepting them. ├── vary/ # Vary项目作为子模块
├── molscribe/ # MolScribe项目作为子模块
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. ├── environments/ # 环境配置文件如conda环境文件
├── README.md # 项目说明文件
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. └── .gitmodules # git子模块配置文件
```
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

1
cobra Submodule

Submodule cobra added at 365a24d360

19
environment.yml Normal file
View File

@@ -0,0 +1,19 @@
name: ChemStructLM
channels:
- conda-forge
- fastai
dependencies:
- python=3.10 # 或其他版本根据vary和molscribe共同兼容的版本
- pymol-open-source
- biopandas
- biopython
- ipython
- jupyter
- ipykernel
- ipython
- seaborn
- jupyterlab
- notebook
- jupyterhub
- nbclassic
- requests

31
requirements.txt Normal file
View File

@@ -0,0 +1,31 @@
einops==0.6.1
einops-exts==0.0.4
gradio_client==0.2.9
OpenNMT-py==2.2.0
deepspeed==0.12.3
peft==0.4.0
ninja
torchaudio
rdkit-pypi>=2021.03.2
accelerate==0.24.1
transformers==4.32.1
bitsandbytes==0.41.0
scikit-learn==1.2.2
httpx==0.24.0
tokenizers>=0.12.1
markdown2[all]
wandb
shortuuid
tiktoken
sentencepiece==0.1.99
torch
torchvision
numpy>=1.19.5
pandas>=1.2.4
matplotlib>=3.5.3
opencv-python==4.5.5.64
huggingface-hub>=0.11.0
tensorboardX
SmilesPE==0.0.3
albumentations @ git+https://github.com/albumentations-team/albumentations@37e714fd2e326f6f88778e425f98c2de8c8d5372
timm @ git+https://github.com/rwightman/pytorch-image-models.git@54a6cca27a9a3e092a07457f5d56709da56e3cf5

1
vary

Submodule vary deleted from 9727432512

1
vary-toy Submodule

Submodule vary-toy added at e94e50f4b1