L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Productivité · SKILL.md

python-pipeline

python-pipeline

Guides high-level Python LTP pipeline workflows for model loading, sentence splitting, task outputs, custom words, and integration helpers.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: python-pipeline description: "Guides high-level Python LTP pipeline workflows for model loading, sentence splitting, task outputs, custom words, and integration helpers." disable-model-invocation: true metadata: disco-role: operating license: CC BY-NC 4.0

Python Pipeline

Use this sub-skill when the user wants to use from ltp import LTP, StnSplit for Chinese NLP inference, output conversion, or service integration.

Choose this route when

  • The task names LTP(...), pipeline, LTPOutput, StnSplit, LTP/tiny, LTP/small, LTP/base, LTP/legacy, or local LTP model directories.
  • The user asks for CWS, POS, NER, SRL, dependency parsing, SDP, SDPG, custom words, or GPU movement from Python.
  • The user needs to interpret output structures or convert LTP output into a tabular/CoNLL-U-like format.
  • The user wants to wrap LTP behind a Python service or batch-processing script.

Route low-level perceptron model/trainer APIs to ../legacy-extension/SKILL.md, deep-training/config tasks to ../training-and-data/SKILL.md, and Rust/C bindings to ../rust-bindings/SKILL.md.

Minimal safe workflow

  1. Confirm the package imports and optional CUDA state from the root skill:

    python ../../scripts/check_ltp_install.py --json
    
  2. For no-network diagnostics, run the pipeline smoke script without loading a model:

    python scripts/ltp_pipeline_smoke.py --skip-model-load
    
  3. If the user has a local or cached model, load it explicitly:

    python scripts/ltp_pipeline_smoke.py --model-path /path/to/ltp-model --local-files-only --tasks cws,pos,ner
    
  4. For real application code, use a model id or local path and choose tasks deliberately:

    from ltp import LTP
    
    ltp = LTP("LTP/small")
    output = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner"])
    print(output.cws, output.pos, output.ner)
    

Read these references

Bundled helpers

Important boundaries

  • Do not run remote model downloads unless the user has accepted network/model-cache side effects.
  • Do not claim legacy LTP("LTP/legacy") supports SRL/DEP/SDP/SDPG. It supports CWS/POS/NER only.
  • Do not pass raw strings when cws is omitted from tasks; pass pretokenized List[List[str]].
  • Do not hide private Hugging Face tokens, proxies, or model paths in scripts or committed configs.
Skills enregistrées