Views
No views yet
pip install -r requirements.txt1pip install huggingface_hub
2python - <<'PY'
3from huggingface_hub import snapshot_download
4snapshot_download(
5 repo_id="<USER_OR_ORG>/<REPO_NAME>",
6 repo_type="model",
7 local_dir="judgment_partition_infer_bundle",
8 local_dir_use_symlinks=False,
9)
10print("Downloaded -> judgment_partition_infer_bundle")
11PYtext (or full_text).{"sample_id":"demo_1","text":"...全文..."}case_no and case_name are passed through to outputs.python infer_cli.py --input examples/input.jsonloutput/<YYYYMMDD_HHMMSS>/ by default:predictions.jsonlrun_meta.json1python infer_cli.py \
2 --input examples/input.jsonl \
3 --output examples/output.example.jsonl \
4 --device cpu--anchor autoanchor_status accordingly.1from judgment_partition_infer import Predictor
2
3pred = Predictor() # loads ./assets/best_model.pt + ./assets/vocab.json (or env override)
4out = pred.predict_text("...全文/片段...")
5print(out["boundaries"])assets/best_model.pt.b64.part-* (text shards).
Predictor() will automatically reassemble/decode and load the model.pip install only the code (without assets), pass explicit paths:1from judgment_partition_infer import Predictor
2pred = Predictor(
3 model_path="path/to/best_model.pt",
4 vocab_path="path/to/vocab.json",
5 device="cpu",
6)pip install -r requirements-publish.txthuggingface-cli loginexport HF_TOKEN=... / export HUGGINGFACE_HUB_TOKEN=...python publish_to_hf.py --repo-id <USER_OR_ORG>/<REPO_NAME> --publicpython publish_to_hf.py --repo-id <USER_OR_ORG>/<REPO_NAME> --skip-createhf.co) instead:1chmod +x push_to_hf_ssh.sh
2./push_to_hf_ssh.sh <USER_OR_ORG>/<REPO_NAME>pip install -r requirements.txt1pip install huggingface_hub
2python - <<'PY'
3from huggingface_hub import snapshot_download
4snapshot_download(
5 repo_id="<USER_OR_ORG>/<REPO_NAME>",
6 repo_type="model",
7 local_dir="judgment_partition_infer_bundle",
8 local_dir_use_symlinks=False,
9)
10print("Downloaded -> judgment_partition_infer_bundle")
11PYtext(系统也兼容读取 full_text 字段)。{"sample_id":"demo_1","text":"...全文..."}注:可选的元数据字段如case_no(案号)和case_name(案名)在处理过程中不会被修改,并会原样透传到输出结果中。
1python infer_cli.py --input examples/input.jsonl
2output/<YYYYMMDD_HHMMSS>/ 目录下,包含以下两个文件:predictions.jsonl:包含边界坐标、各个分区文本等最终预测结果。run_meta.json:本次推理任务的运行元数据及统计信息。1python infer_cli.py \
2 --input examples/input.jsonl \
3 --output examples/output.example.jsonl \
4 --device cpu--anchor autoboundary[0](第 1 条边界)强制对齐至 Z1 锚点(即正文前 100 个字符内出现的最后一个“号”字)。boundary[3](第 4 条边界)强制对齐至 Z4 锚点(匹配“判决如下”或“如下判决”)。anchor_status 字段(标明锚点缺失)。1from judgment_partition_infer import Predictor
2
3# 初始化预测器(默认加载 ./assets/best_model.pt 和 ./assets/vocab.json,或用环境变量覆盖)
4pred = Predictor()
5
6# 传入文书全文或片段进行推理
7out = pred.predict_text("...全文/片段...")
8
9# 打印预测出的 6 个边界位置
10print(out["boundaries"])assets/best_model.pt.b64.part-* 文本分片形式存储;
Predictor() 会自动拼接、解码并加载,不需要手动处理。1from judgment_partition_infer import Predictor
2pred = Predictor(
3 model_path="path/to/best_model.pt",
4 vocab_path="path/to/vocab.json",
5 device="cpu",
6)pip install -r requirements-publish.txthuggingface-cli loginexport HF_TOKEN=... / export HUGGINGFACE_HUB_TOKEN=...python publish_to_hf.py --repo-id <USER_OR_ORG>/<REPO_NAME> --publicpython publish_to_hf.py --repo-id <USER_OR_ORG>/<REPO_NAME> --skip-createhf.co)推送:1chmod +x push_to_hf_ssh.sh
2./push_to_hf_ssh.sh <USER_OR_ORG>/<REPO_NAME>