Download scripts/chains/pb_chain.sh from SocrAIte-Mosaic/patientphex-task1: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/SocrAIte-Mosaic/patientphex-task1/resolve/main/scripts/chains/pb_chain.sh
- Command line
-
hf download hf://SocrAIte-Mosaic/patientphex-task1/scripts/chains/pb_chain.sh
-
curl -L -o pb_chain.sh https://huggingface.co/SocrAIte-Mosaic/patientphex-task1/resolve/main/scripts/chains/pb_chain.sh
2.6 kB
| # pb 全链: 等 dl_pb_mirror 完成 -> 冒烟 -> B 全量 -> convert -> count gate | |
| set -x | |
| export PYTHONPATH=/root/patientphex/retrain_t1/code | |
| export NLTK_DATA=/root/patientphex/retrain_t1/third_party/PhenoTagger-Plus/nltk_data | |
| PY=/opt/anaconda3/envs/pt_env310/bin/python | |
| C=/root/patientphex/retrain_t1/code | |
| PB=/root/patientphex/retrain_t1/third_party/PhenoBERT | |
| O=/root/patientphex/pb_runtime | |
| R=$C/artifacts/b_retrain | |
| B=/root/patientphex/PatientPheX-V1-B/PatientPheX-V1-B.jsonl | |
| # 等待权重下载进程结束 | |
| for i in $(seq 1 240); do | |
| pgrep -f dl_pb_mirror.sh > /dev/null || break | |
| sleep 30 | |
| done | |
| pgrep -f dl_pb_mirror.sh > /dev/null && { echo PB_DL_STILL_RUNNING; exit 1; } | |
| # 等 stanza 资源就位 | |
| for i in $(seq 1 120); do | |
| grep -q STANZA_TAR_DONE /root/patientphex/dl_stanza4.out 2>/dev/null && break | |
| sleep 30 | |
| done | |
| grep -q STANZA_TAR_DONE /root/patientphex/dl_stanza4.out || { echo STANZA_NOT_READY; exit 1; } | |
| ls /root/stanza_resources/en/ | head -4 | |
| ls -la $PB/phenobert/models/ $PB/phenobert/embeddings/ | head -50 | |
| [ -f $PB/phenobert/models/HPOModel_H/model_layer1.pkl ] || { echo PB_LAYER1_MISSING; exit 2; } | |
| [ -f $PB/phenobert/models/bert_model_max_triple.pkl ] || { echo PB_BERTPKL_MISSING; exit 2; } | |
| [ -f $PB/phenobert/embeddings/fasttext_pubmed.bin ] || { echo PB_FASTTEXT_MISSING; exit 2; } | |
| du -sb $PB/phenobert/embeddings/fasttext_pubmed.bin | |
| echo PB_WEIGHTS_READY | |
| # 冒烟: 单篇文档 | |
| mkdir -p $O/smoke_in $O/smoke_out | |
| head -c 100000 $O/corpus/$(ls $O/corpus | head -1) > /dev/null | |
| cp $(ls -d $O/corpus/* | head -1) $O/smoke_in/ | |
| CUDA_VISIBLE_DEVICES=4 $PY $C/scripts/run_phenobert_official_compat.py \ | |
| --phenobert $PB --input-dir $O/smoke_in --output-dir $O/smoke_out \ | |
| --threads 16 || { echo PB_SMOKE_FAIL; exit 3; } | |
| ls $O/smoke_out/ | |
| cat $O/smoke_out/*.json 2>/dev/null | head -c 600 | |
| echo PB_SMOKE_DONE | |
| # B 全量 | |
| mkdir -p $O/out | |
| CUDA_VISIBLE_DEVICES=4 $PY $C/scripts/run_phenobert_official_compat.py \ | |
| --phenobert $PB --input-dir $O/corpus --output-dir $O/out \ | |
| --threads 32 || { echo PB_FULL_FAIL; exit 4; } | |
| ls $O/out | wc -l | |
| echo PB_FULL_DONE | |
| # convert + 2026 过滤 | |
| $PY $C/scripts/prepare_phenobert_official.py convert \ | |
| --input $B \ | |
| --annotations $O/out \ | |
| --ontology /root/patientphex/PatientPheX-V1-A/hp.obo \ | |
| --raw-output $R/B-phenobert-raw.jsonl \ | |
| --compatible-output $R/B-phenobert-official-hpo2026.jsonl \ | |
| --report $R/B-phenobert-conversion-report.json || { echo PB_CONVERT_FAIL; exit 5; } | |
| /root/patientphex/judge_venv/bin/python /root/patientphex/count_ents.py $R/B-phenobert-official-hpo2026.jsonl 8110 | |
| echo PB_CHAIN_DONE | |