From 75f44ef747f569a8fbd015162898bbde22cdb854 Mon Sep 17 00:00:00 2001
From: wawltor
Date: Fri, 25 Oct 2024 10:52:59 +0800
Subject: [PATCH] change the directory legacy to slm (#9311)
---
.github/workflows/pipelines.yml | 8 +-
.pre-commit-config.yaml | 2 +-
README.md | 4 +-
README_en.md | 4 +-
docs/FAQ.md | 176 ++--
docs/advanced_guide/prompt.md | 14 +-
docs/compression.md | 36 +-
docs/model_zoo/model_list_multy_device.md | 8 +-
docs/model_zoo/taskflow.md | 288 +++---
docs/server.md | 30 +-
docs/trainer.md | 4 +-
.../cross_encoder/deploy/cpp/start_server.sh | 1 -
.../cross_encoder/deploy/python/deploy.sh | 3 -
.../cross_encoder/scripts/evaluate_ce.sh | 3 -
.../cross_encoder/scripts/export_model.sh | 4 -
.../scripts/export_to_serving.sh | 7 -
.../cross_encoder/scripts/predict_ce.sh | 11 -
.../ranking/cross_encoder/scripts/train_ce.sh | 18 -
.../ernie_matching/deploy/cpp/start_server.sh | 1 -
.../ernie_matching/deploy/python/deploy.sh | 3 -
.../ernie_matching/scripts/evaluate.sh | 16 -
.../ernie_matching/scripts/export_model.sh | 3 -
.../scripts/export_to_serving.sh | 7 -
.../scripts/predict_pairwise.sh | 15 -
.../deploy/cpp/start_server.sh | 1 -
.../in_batch_negative/deploy/python/deploy.sh | 1 -
.../in_batch_negative/scripts/evaluate.sh | 4 -
.../in_batch_negative/scripts/export_model.sh | 3 -
.../scripts/export_to_serving.sh | 7 -
.../recall/milvus/scripts/feature_extract.sh | 6 -
.../recall/milvus/scripts/search.sh | 6 -
.../recall/simcse/deploy/python/deploy.sh | 1 -
.../recall/simcse/scripts/evaluate.sh | 4 -
.../recall/simcse/scripts/export_model.sh | 3 -
.../retrieval_based/deploy/python/deploy.sh | 1 -
.../retrieval_based/scripts/evaluate.sh | 4 -
.../retrieval_based/scripts/export_model.sh | 1 -
.../scripts/export_to_serving.sh | 7 -
.../retrieval_based/scripts/run.sh | 8 -
.../scripts/run_build_index.sh | 16 -
.../retrieval_based/deploy/python/deploy.sh | 1 -
legacy/examples/benchmark/ceval/README.md | 84 --
.../information_extraction/DuIE/README.md | 142 ---
.../information_extraction/DuIE/predict.sh | 14 -
.../transformer/tls/distributed_utils.py | 19 -
.../examples/model_interpretation/download.sh | 10 -
.../task/senti/LIME/exceptions.py | 2 -
.../task/senti/rnn/lstm_train.sh | 20 -
.../task/similarity/LIME/exceptions.py | 2 -
.../task/similarity/simnet/lstm_train.sh | 21 -
.../multimodal/layoutlm/train_funsd.sh | 17 -
.../deploy/paddle_inference/README.md | 54 -
legacy/examples/text_classification/README.md | 8 -
.../text_generation/vae-seq2seq/README.md | 30 -
legacy/examples/text_matching/simcse/train.sh | 15 -
.../text_summarization/bart/README.md | 10 -
.../deploy/paddle_inference/README.md | 31 -
.../text_to_knowledge/ernie-ctm/README.md | 167 ----
.../docs/ThesisReproduction_NLP.md | 928 ------------------
legacy/model_zoo/electra/README.md | 7 -
.../model_zoo/ernie-3.0-tiny/deploy/README.md | 43 -
.../models/ernie_tokencls_model/1/README.md | 1 -
legacy/model_zoo/ernie-doc/README.md | 6 -
legacy/model_zoo/luke/README.md | 91 --
legacy/model_zoo/xlnet/README.md | 7 -
llm/README.md | 2 +-
llm/auto_parallel/llama/README.md | 2 +-
llm/docs/pretrain.rst | 4 +-
llm/experimental/ernie-3.5-se/README.md | 2 +-
llm/gcu/llama/predict_llama_gcu.sh | 2 +-
llm/tools/preprocess/README.md | 2 +-
scripts/distribute/ci_case_auto.sh | 2 +-
scripts/distribute/ci_case_dy.sh | 6 +-
scripts/distribute/run_ci.sh | 4 +-
scripts/regression/ci_case.sh | 42 +-
scripts/regression/get_model_list.py | 6 +-
{legacy => slm}/applications/README.md | 20 +-
.../information_extraction/README.md | 42 +-
.../information_extraction/README_en.md | 0
.../information_extraction/document/README.md | 46 +-
.../document/README_en.md | 0
.../document/deploy/simple_serving/README.md | 16 +-
.../deploy/simple_serving/README_en.md | 0
.../document/deploy/simple_serving/client.py | 0
.../document/deploy/simple_serving/server.py | 0
.../document/evaluate.py | 0
.../document/finetune.py | 0
.../information_extraction/document/utils.py | 0
.../information_extraction/label_studio.py | 0
.../label_studio_doc.md | 42 +-
.../label_studio_doc_en.md | 0
.../label_studio_text.md | 48 +-
.../label_studio_text_en.md | 0
.../information_extraction/taskflow_doc.md | 32 +-
.../information_extraction/taskflow_doc_en.md | 0
.../information_extraction/taskflow_text.md | 40 +-
.../taskflow_text_en.md | 0
.../information_extraction/text/README.md | 40 +-
.../information_extraction/text/README_en.md | 0
.../text/data_distill/README.md | 40 +-
.../text/data_distill/README_en.md | 0
.../text/data_distill/criterion.py | 0
.../text/data_distill/data_collator.py | 0
.../text/data_distill/data_distill.py | 0
.../deploy/simple_serving/README.md | 16 +-
.../deploy/simple_serving/README_en.md | 0
.../deploy/simple_serving/client.py | 0
.../deploy/simple_serving/server.py | 0
.../text/data_distill/evaluate.py | 0
.../text/data_distill/evaluate_teacher.py | 0
.../text/data_distill/metric.py | 0
.../text/data_distill/train.py | 0
.../text/data_distill/utils.py | 0
.../text/deploy/simple_serving/README.md | 16 +-
.../text/deploy/simple_serving/README_en.md | 0
.../text/deploy/simple_serving/client.py | 0
.../text/deploy/simple_serving/server.py | 0
.../information_extraction/text/evaluate.py | 0
.../information_extraction/text/finetune.py | 0
.../information_extraction/text/utils.py | 0
.../applications/neural_search/README.md | 54 +-
.../applications/neural_search/img/attu.png | Bin
.../neural_search/img/system_pipeline.png | Bin
.../ranking/cross_encoder/README.md | 34 +-
.../ranking/cross_encoder/data.py | 0
.../cross_encoder/deploy/cpp/http_client.py | 0
.../cross_encoder/deploy/cpp/rpc_client.py | 0
.../cross_encoder/deploy/cpp/start_server.sh | 15 +
.../deploy/python/config_nlp.yml | 0
.../cross_encoder/deploy/python/deploy.sh | 17 +
.../cross_encoder/deploy/python/predict.py | 0
.../cross_encoder/deploy/python/rpc_client.py | 2 +-
.../deploy/python/web_service.py | 0
.../ranking/cross_encoder/evaluate.py | 0
.../ranking/cross_encoder/export_model.py | 0
.../cross_encoder/export_to_serving.py | 1 +
.../ranking/cross_encoder/predict.py | 0
.../cross_encoder/scripts/evaluate_ce.sh | 17 +
.../cross_encoder/scripts/export_model.sh | 18 +
.../scripts/export_to_serving.sh | 21 +
.../cross_encoder/scripts/predict_ce.sh | 26 +
.../ranking/cross_encoder/scripts/train_ce.sh | 33 +
.../ranking/cross_encoder/train_ce.py | 0
.../ranking/ernie_matching/README.md | 38 +-
.../ranking/ernie_matching/data.py | 2 +-
.../ernie_matching/deploy/cpp/http_client.py | 0
.../ernie_matching/deploy/cpp/rpc_client.py | 0
.../ernie_matching/deploy/cpp/start_server.sh | 15 +
.../deploy/python/config_nlp.yml | 0
.../ernie_matching/deploy/python/deploy.sh | 17 +
.../ernie_matching/deploy/python/predict.py | 0
.../deploy/python/rpc_client.py | 2 +-
.../deploy/python/web_service.py | 0
.../ranking/ernie_matching/evaluate.py | 0
.../ranking/ernie_matching/export_model.py | 0
.../ernie_matching}/export_to_serving.py | 0
.../ranking/ernie_matching/model.py | 0
.../ernie_matching/predict_pairwise.py | 0
.../ernie_matching/scripts/evaluate.sh | 30 +
.../ernie_matching/scripts/export_model.sh | 17 +
.../scripts/export_to_serving.sh | 21 +
.../scripts/predict_pairwise.sh | 29 +
.../ernie_matching/scripts/train_pairwise.sh | 14 +
.../ranking/ernie_matching/train_pairwise.py | 0
.../recall/in_batch_negative/README.md | 76 +-
.../recall/in_batch_negative/ann_util.py | 3 +-
.../recall/in_batch_negative/base_model.py | 0
.../in_batch_negative/batch_negative/model.py | 0
.../recall/in_batch_negative}/data.py | 0
.../deploy/cpp/http_client.py | 0
.../deploy/cpp/rpc_client.py | 0
.../deploy/cpp/start_server.sh | 15 +
.../deploy/python/config_nlp.yml | 0
.../in_batch_negative/deploy/python/deploy.sh | 15 +
.../deploy/python/predict.py | 0
.../deploy/python/rpc_client.py | 2 +-
.../deploy/python/web_service.py | 0
.../recall/in_batch_negative/evaluate.py | 0
.../recall/in_batch_negative/export_model.py | 0
.../in_batch_negative/export_to_serving.py | 1 +
.../recall/in_batch_negative/inference.py | 10 +-
.../recall/in_batch_negative/predict.py | 0
.../recall/in_batch_negative/recall.py | 0
.../in_batch_negative/scripts/evaluate.sh | 18 +
.../in_batch_negative/scripts/export_model.sh | 17 +
.../scripts/export_to_serving.sh | 21 +
.../in_batch_negative/scripts/predict.sh | 14 +
.../scripts/run_build_index.sh | 0
.../in_batch_negative/train_batch_neg.py | 0
.../neural_search/recall/milvus/README.md | 20 +-
.../neural_search/recall/milvus/base_model.py | 0
.../neural_search/recall/milvus/config.py | 0
.../neural_search/recall/milvus}/data.py | 2 +
.../recall/milvus/feature_extract.py | 0
.../neural_search/recall/milvus/inference.py | 0
.../recall/milvus/milvus_ann_search.py | 0
.../recall/milvus/milvus_util.py | 0
.../recall/milvus/scripts/feature_extract.sh | 20 +
.../recall/milvus/scripts/search.sh | 20 +
.../neural_search/recall/simcse/README.md | 56 +-
.../neural_search/recall/simcse}/ann_util.py | 0
.../neural_search/recall/simcse/data.py | 0
.../recall/simcse/deploy/python/deploy.sh | 15 +
.../recall/simcse/deploy/python/predict.py | 0
.../neural_search/recall/simcse/evaluate.py | 0
.../recall/simcse/export_model.py | 0
.../neural_search/recall/simcse/inference.py | 0
.../neural_search/recall/simcse/model.py | 0
.../neural_search/recall/simcse/predict.py | 0
.../neural_search/recall/simcse/recall.py | 0
.../recall/simcse/scripts/evaluate.sh | 18 +
.../recall/simcse/scripts/export_model.sh | 17 +
.../recall/simcse/scripts/predict.sh | 14 +
.../recall/simcse/scripts/run_build_index.sh | 14 +
.../recall/simcse/scripts/train.sh | 14 +
.../neural_search/recall/simcse/train.py | 0
.../neural_search/requirements.txt | 0
.../applications/neural_search/run_system.py | 0
.../applications/question_answering/README.md | 4 +-
.../unsupervised_qa/README.md | 122 +--
.../evaluate.py | 0
.../finetune.py | 0
.../span.py | 0
.../utils.py | 0
.../finetune/question_generation/gen_utils.py | 0
.../finetune/question_generation/predict.py | 0
.../finetune/question_generation/train.py | 0
.../unsupervised_qa/run_corpus_preparation.py | 0
.../unsupervised_qa/run_data_preprocess.py | 0
.../unsupervised_qa/run_pipelines_example.py | 0
.../run_qa_pairs_generation.py | 0
.../tools/create_synthetic_answer.py | 0
.../tools/create_synthetic_question.py | 0
.../tools/dev_qq_pair_creation.py | 0
.../tools/json_format_indent.py | 0
.../tools/question_coverage.py | 0
.../text_classification/README.md | 78 +-
.../text_classification/doccano.md | 36 +-
.../text_classification/doccano.py | 0
.../hierarchical/README.md | 102 +-
.../hierarchical/analysis/README.md | 74 +-
.../hierarchical/analysis/aug.py | 0
.../hierarchical/analysis/dirty.py | 0
.../hierarchical/analysis/evaluate.py | 0
.../hierarchical/analysis/sent_interpret.py | 0
.../hierarchical/analysis/sparse.py | 0
.../analysis/word_interpret.ipynb | 0
.../deploy/paddle_serving/README.md | 40 +-
.../deploy/paddle_serving/config.yml | 0
.../deploy/paddle_serving/http_client.py | 0
.../deploy/paddle_serving/rpc_client.py | 0
.../deploy/paddle_serving/service.py | 0
.../hierarchical/deploy/predictor/README.md | 56 +-
.../hierarchical/deploy/predictor/infer.py | 0
.../deploy/predictor/predictor.py | 0
.../deploy/simple_serving/README.md | 12 +-
.../deploy/simple_serving/client.py | 3 +-
.../deploy/simple_serving/ernie_m_server.py | 0
.../deploy/simple_serving/server.py | 0
.../deploy/triton_serving/README.md | 44 +-
.../triton_serving/models/seqcls/config.pbtxt | 0
.../models/seqcls_model/config.pbtxt | 0
.../models/seqcls_postprocess/1/model.py | 0
.../models/seqcls_postprocess/config.pbtxt | 0
.../models/tokenizer/1/model.py | 0
.../models/tokenizer/config.pbtxt | 0
.../triton_serving/seqcls_grpc_client.py | 0
.../hierarchical/export_model.py | 1 +
.../hierarchical/few-shot/README.md | 44 +-
.../hierarchical/few-shot/infer.py | 0
.../hierarchical/few-shot/metric.py | 0
.../few-shot/requirements_cpu.txt | 0
.../few-shot/requirements_gpu.txt | 0
.../hierarchical/few-shot/train.py | 0
.../hierarchical/few-shot/utils.py | 0
.../hierarchical/metric.py | 4 +-
.../hierarchical/predict.py | 0
.../text_classification/hierarchical/prune.py | 16 +-
.../hierarchical/retrieval_based/README.md | 62 +-
.../retrieval_based/base_model.py | 0
.../hierarchical/retrieval_based/data.py | 1 +
.../deploy/python/config_nlp.yml | 0
.../retrieval_based/deploy/python/deploy.sh | 15 +
.../retrieval_based/deploy/python/predict.py | 0
.../deploy/python/rpc_client.py | 2 +-
.../deploy/python/web_service.py | 0
.../hierarchical/retrieval_based/evaluate.py | 0
.../retrieval_based/export_model.py | 0
.../retrieval_based}/export_to_serving.py | 1 +
.../hierarchical/retrieval_based/model.py | 0
.../hierarchical/retrieval_based/predict.py | 0
.../hierarchical/retrieval_based/recall.py | 0
.../retrieval_based/requirements.txt | 0
.../retrieval_based/run_system.py | 0
.../retrieval_based/scripts/evaluate.sh | 18 +
.../retrieval_based/scripts/export_model.sh | 15 +
.../scripts/export_to_serving.sh | 21 +
.../retrieval_based/scripts/predict.sh | 14 +
.../retrieval_based/scripts/run.sh | 22 +
.../scripts/run_build_index.sh | 30 +
.../retrieval_based/scripts/train.sh | 0
.../hierarchical/retrieval_based/train.py | 0
.../retrieval_based/utils/__init__.py | 0
.../retrieval_based/utils/config.py | 0
.../retrieval_based/utils/feature_extract.py | 0
.../retrieval_based/utils/milvus_util.py | 0
.../retrieval_based/utils/vector_insert.py | 0
.../text_classification/hierarchical/train.py | 0
.../hierarchical}/utils.py | 2 +-
.../text_classification/multi_class/README.md | 70 +-
.../multi_class/analysis/README.md | 70 +-
.../multi_class/analysis/aug.py | 0
.../multi_class/analysis/dirty.py | 0
.../multi_class/analysis/sent_interpret.py | 0
.../multi_class/analysis/sparse.py | 0
.../multi_class/analysis/word_interpret.ipynb | 0
.../deploy/simple_serving/README.md | 8 +-
.../deploy/simple_serving/client.py | 0
.../deploy/simple_serving/server.py | 0
.../deploy/triton_serving/README.md | 42 +-
.../triton_serving/models/seqcls/config.pbtxt | 0
.../models/seqcls_model/config.pbtxt | 0
.../models/seqcls_postprocess/1/model.py | 0
.../models/seqcls_postprocess/config.pbtxt | 0
.../models/tokenizer/1/model.py | 0
.../models/tokenizer/config.pbtxt | 0
.../triton_serving/seqcls_grpc_client.py | 0
.../multi_class/few-shot/README.md | 46 +-
.../multi_class/few-shot/infer.py | 0
.../multi_class/few-shot/requirements_cpu.txt | 0
.../multi_class/few-shot/requirements_gpu.txt | 0
.../multi_class/few-shot/train.py | 0
.../multi_class/few-shot/utils.py | 0
.../multi_class/retrieval_based/README.md | 54 +-
.../multi_class/retrieval_based/base_model.py | 0
.../multi_class/retrieval_based/data.py | 1 +
.../deploy/python/config_nlp.yml | 0
.../retrieval_based/deploy/python/deploy.sh | 15 +
.../retrieval_based/deploy/python/predict.py | 0
.../deploy/python/rpc_client.py | 0
.../deploy/python/web_service.py | 0
.../multi_class/retrieval_based/evaluate.py | 0
.../retrieval_based/export_model.py | 0
.../retrieval_based/export_to_serving.py | 1 +
.../multi_class/retrieval_based/model.py | 0
.../multi_class/retrieval_based/predict.py | 0
.../multi_class/retrieval_based/recall.py | 0
.../retrieval_based/requirements.txt | 0
.../multi_class/retrieval_based/run_system.py | 0
.../retrieval_based/scripts/evaluate.sh | 0
.../retrieval_based/scripts/export_model.sh | 0
.../scripts/export_to_serving.sh | 0
.../retrieval_based/scripts/predict.sh | 0
.../retrieval_based/scripts/run.sh | 0
.../scripts/run_build_index.sh | 0
.../retrieval_based/scripts/train.sh | 0
.../multi_class/retrieval_based/train.py | 0
.../retrieval_based/utils/__init__.py | 0
.../retrieval_based/utils/config.py | 0
.../retrieval_based/utils/feature_extract.py | 0
.../retrieval_based/utils/milvus_util.py | 0
.../retrieval_based/utils/vector_insert.py | 0
.../text_classification/multi_class/train.py | 0
.../text_classification/multi_class/utils.py | 0
.../text_classification/multi_label/README.md | 98 +-
.../multi_label/analysis/README.md | 82 +-
.../multi_label/analysis/aug.py | 0
.../multi_label/analysis/dirty.py | 0
.../multi_label/analysis/evaluate.py | 0
.../multi_label/analysis/sent_interpret.py | 0
.../multi_label/analysis/sparse.py | 0
.../multi_label/analysis/word_interpret.ipynb | 0
.../deploy/paddle_serving/README.md | 40 +-
.../deploy/paddle_serving/config.yml | 0
.../deploy/paddle_serving/http_client.py | 0
.../deploy/paddle_serving/rpc_client.py | 0
.../deploy/paddle_serving/service.py | 0
.../multi_label/deploy/predictor/README.md | 54 +-
.../multi_label/deploy/predictor/infer.py | 0
.../multi_label/deploy/predictor/predictor.py | 0
.../deploy/simple_serving/README.md | 12 +-
.../deploy/simple_serving/client.py | 3 +-
.../deploy/simple_serving/ernie_m_server.py | 0
.../deploy/simple_serving/server.py | 0
.../deploy/triton_serving/README.md | 48 +-
.../triton_serving/models/seqcls/config.pbtxt | 0
.../models/seqcls_model/config.pbtxt | 0
.../models/seqcls_postprocess/1/model.py | 0
.../models/seqcls_postprocess/config.pbtxt | 0
.../models/tokenizer/1/model.py | 0
.../models/tokenizer/config.pbtxt | 0
.../triton_serving/seqcls_grpc_client.py | 0
.../multi_label/export_model.py | 1 +
.../multi_label/few-shot/README.md | 48 +-
.../multi_label/few-shot/infer.py | 0
.../multi_label/few-shot/metric.py | 0
.../multi_label/few-shot/requirements_cpu.txt | 0
.../multi_label/few-shot/requirements_gpu.txt | 0
.../multi_label/few-shot/train.py | 0
.../multi_label/few-shot/utils.py | 0
.../text_classification/multi_label/metric.py | 4 +-
.../multi_label/predict.py | 0
.../text_classification/multi_label/prune.py | 0
.../multi_label/retrieval_based/README.md | 62 +-
.../multi_label/retrieval_based/base_model.py | 0
.../multi_label/retrieval_based/data.py | 1 +
.../deploy/python/config_nlp.yml | 0
.../retrieval_based/deploy/python/deploy.sh | 0
.../retrieval_based/deploy/python/predict.py | 0
.../deploy/python/rpc_client.py | 2 +-
.../deploy/python/web_service.py | 0
.../multi_label/retrieval_based/evaluate.py | 0
.../retrieval_based/export_model.py | 0
.../retrieval_based/export_to_serving.py | 1 +
.../multi_label/retrieval_based/metric.py | 3 +-
.../multi_label/retrieval_based/model.py | 0
.../multi_label/retrieval_based/predict.py | 0
.../multi_label/retrieval_based/recall.py | 0
.../retrieval_based/requirements.txt | 0
.../multi_label/retrieval_based/run_system.py | 0
.../retrieval_based/scripts/evaluate.sh | 0
.../retrieval_based/scripts/export_model.sh | 0
.../scripts/export_to_serving.sh | 0
.../retrieval_based/scripts/predict.sh | 0
.../retrieval_based/scripts/run.sh | 0
.../scripts/run_build_index.sh | 0
.../retrieval_based/scripts/train.sh | 0
.../multi_label/retrieval_based/train.py | 0
.../retrieval_based/utils/__init__.py | 0
.../retrieval_based/utils/config.py | 2 +-
.../retrieval_based/utils/feature_extract.py | 0
.../retrieval_based/utils/milvus_util.py | 0
.../retrieval_based/utils/vector_insert.py | 0
.../text_classification/multi_label/train.py | 0
.../text_classification/multi_label}/utils.py | 2 +-
{legacy => slm}/examples/README.md | 2 +-
{legacy => slm}/examples/RLHF/README.md | 10 +-
{legacy => slm}/examples/RLHF/comm_utils.py | 0
.../examples/RLHF/data/__init__.py | 0
{legacy => slm}/examples/RLHF/data/alpaca.py | 0
{legacy => slm}/examples/RLHF/data/base.py | 2 +-
.../examples/RLHF/data/preference.py | 0
.../examples/RLHF/data/prompt_only.py | 0
.../examples/RLHF/data/safe_rlhf.py | 0
.../examples/RLHF/data/supervised.py | 0
{legacy => slm}/examples/RLHF/infer_utils.py | 0
.../examples/RLHF/models/__init__.py | 0
.../examples/RLHF/models/infer_model_utils.py | 0
.../examples/RLHF/models/model_pp.py | 0
.../examples/RLHF/models/pp_model_utils.py | 0
.../examples/RLHF/models/ppo_model.py | 0
.../examples/RLHF/models/ppo_model_utils.py | 0
.../examples/RLHF/models/score_model.py | 0
.../examples/RLHF/models/score_model_utils.py | 0
{legacy => slm}/examples/RLHF/ppo_config.json | 0
{legacy => slm}/examples/RLHF/ppo_main.py | 0
{legacy => slm}/examples/RLHF/ppo_trainer.py | 0
.../examples/RLHF/reward_config.json | 0
{legacy => slm}/examples/RLHF/reward_main.py | 0
.../examples/RLHF/reward_trainer.py | 0
{legacy => slm}/examples/RLHF/run.sh | 0
.../examples/RLHF/tests/run_model.py | 0
.../examples/RLHF/tests/test_export.py | 0
.../examples/RLHF/trainer_utils.py | 0
slm/examples/benchmark/ceval/README.md | 84 ++
.../examples/benchmark/ceval/eval.py | 0
.../examples/benchmark/ceval/evaluator.py | 0
.../benchmark/ceval/model_evaluator.py | 0
.../benchmark/ceval/subject_mapping.json | 0
.../examples/benchmark/clue/README.md | 44 +-
.../classification/run_clue_classifier.py | 0
.../run_clue_classifier_trainer.py | 0
.../clue/grid_search_tools/draw_pic.py | 0
.../clue/grid_search_tools/extract_result.sh | 0
.../clue/grid_search_tools/grid_search.py | 0
.../clue/grid_search_tools/run_cls.sh | 0
.../clue/grid_search_tools/run_mrc.sh | 0
.../warmup_dataset_and_model.py | 0
.../examples/benchmark/clue/mrc/run_c3.py | 0
.../examples/benchmark/clue/mrc/run_chid.py | 0
.../benchmark/clue/mrc/run_cmrc2018.py | 0
.../examples/benchmark/glue/README.md | 32 +-
.../examples/benchmark/glue/run_glue.py | 0
.../benchmark/glue/run_glue_trainer.py | 0
.../llm/llama_single_gpu/benchmark.py | 0
.../llm/llama_single_gpu/benchmark_utils.py | 0
.../examples/benchmark/peft/README.md | 8 +-
.../benchmark/peft/paddle/benchmark.py | 0
.../peft/paddle/inference_benchmark.py | 0
.../examples/benchmark/peft/paddle/utils.py | 0
.../benchmark/peft/torch/benchmark.py | 0
.../peft/torch/ds_config_stage2.json | 0
.../peft/torch/ds_config_stage3.json | 0
.../peft/torch/inference_benchmark.py | 0
.../benchmark/peft/torch/requirements.txt | 0
.../examples/benchmark/peft/torch/utils.py | 0
.../examples/benchmark/wiki_lambada/README.md | 4 +-
.../examples/benchmark/wiki_lambada/eval.py | 0
.../code_generation/codegen/README.md | 88 +-
.../code_generation/codegen/codegen_server.py | 0
.../code_generation/codegen/requirements.txt | 0
.../code_generation/codegen/run_clm.py | 0
.../code_generation/codegen/run_clm.sh | 0
.../examples/dialogue/README_DGU.md | 18 +-
.../examples/dialogue/README_LIC2021.md | 36 +-
.../examples/dialogue/README_PLATO-2.md | 10 +-
.../examples/dialogue/README_PLATO-XL.md | 16 +-
.../dialogue/README_UnifiedTransformer.md | 50 +-
.../examples/dialogue/dgu/README.md | 16 +-
{legacy => slm}/examples/dialogue/dgu/args.py | 0
{legacy => slm}/examples/dialogue/dgu/data.py | 2 +-
{legacy => slm}/examples/dialogue/dgu/main.py | 25 +-
.../examples/dialogue/dgu/metric.py | 1 -
.../dialogue/lic2021_baseline/README.md | 34 +-
.../dialogue/lic2021_baseline/args.py | 0
.../dialogue/lic2021_baseline/data.py | 0
.../dialogue/lic2021_baseline/finetune.py | 0
.../dialogue/lic2021_baseline/infer.py | 0
.../examples/dialogue/plato-2/README.md | 8 +-
.../examples/dialogue/plato-2/imgs/case.jpg | Bin
.../dialogue/plato-2/imgs/network.png | Bin
.../examples/dialogue/plato-2/interaction.py | 0
.../examples/dialogue/plato-2/model.py | 0
.../dialogue/plato-2/readers/dialog_reader.py | 0
.../dialogue/plato-2/readers/nsp_reader.py | 0
.../dialogue/plato-2/readers/plato_reader.py | 1 -
.../dialogue/plato-2/utils/__init__.py | 0
.../examples/dialogue/plato-2/utils/args.py | 0
.../dialogue/plato-2/utils/masking.py | 0
.../dialogue/plato-2/utils/tokenization.py | 2 +-
{legacy => slm}/examples/dialogue/plato-xl | 0
.../dialogue/unified_transformer/README.md | 48 +-
.../dialogue/unified_transformer/finetune.py | 0
.../dialogue/unified_transformer/infer.py | 0
.../unified_transformer/interaction.py | 0
.../dialogue/unified_transformer/utils.py | 4 +-
{legacy => slm}/examples/few_shot/README.md | 0
.../examples/few_shot/RGL/README.md | 0
{legacy => slm}/examples/few_shot/RGL/data.py | 0
{legacy => slm}/examples/few_shot/RGL/rgl.py | 0
.../examples/few_shot/RGL/scripts/run_pet.sh | 14 +
.../examples/few_shot/RGL/scripts/run_rgl.sh | 14 +
.../examples/few_shot/RGL/template.py | 0
.../examples/few_shot/RGL/tokenizer.py | 0
.../examples/few_shot/RGL/utils.py | 0
.../examples/few_shot/RGL/verbalizer.py | 0
.../examples/few_shot/efl/README.md | 0
{legacy => slm}/examples/few_shot/efl/data.py | 0
.../examples/few_shot/efl/prompt/bustm.json | 0
.../examples/few_shot/efl/prompt/chid.json | 0
.../examples/few_shot/efl/prompt/cluewsc.json | 0
.../examples/few_shot/efl/prompt/csl.json | 0
.../examples/few_shot/efl/prompt/csldcp.json | 0
.../examples/few_shot/efl/prompt/eprstmt.json | 0
.../examples/few_shot/efl/prompt/iflytek.json | 0
.../examples/few_shot/efl/prompt/ocnli.json | 0
.../examples/few_shot/efl/prompt/tnews.json | 0
.../examples/few_shot/efl/run_train.py | 0
.../examples/few_shot/efl/utils.py | 0
.../examples/few_shot/p-tuning/README.md | 0
.../examples/few_shot/p-tuning/data.py | 2 +-
.../few_shot/p-tuning/prompt/bustm.json | 0
.../few_shot/p-tuning/prompt/chid.json | 0
.../few_shot/p-tuning/prompt/cluewsc.json | 0
.../few_shot/p-tuning/prompt/csl.json | 0
.../few_shot/p-tuning/prompt/csldcp.json | 0
.../few_shot/p-tuning/prompt/eprstmt.json | 0
.../few_shot/p-tuning/prompt/iflytek.json | 0
.../few_shot/p-tuning/prompt/ocnli.json | 0
.../few_shot/p-tuning/prompt/tnews.json | 0
.../examples/few_shot/p-tuning/run_train.py | 0
.../examples/few_shot/p-tuning/utils.py | 0
.../examples/few_shot/pet/README.md | 0
{legacy => slm}/examples/few_shot/pet/data.py | 0
.../examples/few_shot/pet/prompt/bustm.json | 0
.../examples/few_shot/pet/prompt/chid.json | 0
.../examples/few_shot/pet/prompt/cluewsc.json | 0
.../examples/few_shot/pet/prompt/csl.json | 0
.../examples/few_shot/pet/prompt/csldcp.json | 0
.../examples/few_shot/pet/prompt/eprstmt.json | 0
.../examples/few_shot/pet/prompt/iflytek.json | 0
.../examples/few_shot/pet/prompt/ocnli.json | 0
.../examples/few_shot/pet/prompt/tnews.json | 0
.../examples/few_shot/pet/run_train.py | 0
.../examples/few_shot/pet/utils.py | 0
.../information_extraction/DuEE/README.md | 58 +-
.../information_extraction/DuEE/classifier.py | 0
.../DuEE/duee_1_data_prepare.py | 0
.../DuEE/duee_1_postprocess.py | 0
.../DuEE/duee_fin_data_prepare.py | 0
.../DuEE/duee_fin_postprocess.py | 0
.../DuEE/pictures/DuEE-Fin/ee.png | Bin
.../DuEE/pictures/DuEE-Fin/enum_model.png | Bin
.../DuEE/pictures/DuEE-Fin/role_model.png | Bin
.../DuEE/pictures/DuEE-Fin/trigger_model.png | Bin
.../DuEE/run_classifier.sh | 0
.../information_extraction/DuEE/run_duee_1.sh | 0
.../DuEE/run_duee_fin.sh | 0
.../DuEE/run_sequence_labeling.sh | 0
.../DuEE/sequence_labeling.py | 0
.../information_extraction/DuEE/utils.py | 0
.../information_extraction/DuIE/README.md | 142 +++
.../DuIE/data/id2spo.json | 0
.../DuIE/data/predicate2id.json | 0
.../DuIE/data_loader.py | 0
.../DuIE/extract_chinese_and_punct.py | 0
.../DuIE/images/tagging_strategy.png | Bin
.../information_extraction/DuIE/predict.sh | 28 +
.../DuIE/re_official_evaluation.py | 0
.../information_extraction/DuIE/run_duie.py | 0
.../information_extraction/DuIE/train.sh | 0
.../information_extraction/DuIE/utils.py | 0
.../information_extraction/DuUIE/README.md | 12 +-
.../DuUIE/config/multi-task-duuie.yaml | 0
.../information_extraction/DuUIE/inference.py | 0
.../DuUIE/process_data.py | 0
.../DuUIE/requirements.txt | 0
.../DuUIE/run_seq2struct.py | 0
.../DuUIE/uie/__init__.py | 0
.../DuUIE/uie/evaluation/__init__.py | 0
.../DuUIE/uie/evaluation/constants.py | 0
.../DuUIE/uie/evaluation/scorer.py | 0
.../DuUIE/uie/evaluation/sel2record.py | 0
.../DuUIE/uie/seq2struct/__init__.py | 0
.../DuUIE/uie/seq2struct/data_collator.py | 0
.../DuUIE/uie/seq2struct/t5_bert_tokenizer.py | 0
.../DuUIE/uie/seq2struct/utils.py | 0
.../information_extraction/msra_ner/README.md | 18 +-
.../information_extraction/msra_ner/eval.py | 0
.../msra_ner/predict.py | 0
.../information_extraction/msra_ner/train.py | 0
.../waybill_ie/README.md | 18 +-
.../information_extraction/waybill_ie/data.py | 0
.../deploy/python/predict_bigru_crf.py | 0
.../waybill_ie/deploy/python/predict_ernie.py | 0
.../deploy/python/predict_ernie_crf.py | 0
.../waybill_ie/download.py | 0
.../waybill_ie/export_bigru_crf_model.py | 0
.../waybill_ie/export_ernie_crf_model.py | 0
.../waybill_ie/export_ernie_model.py | 0
.../waybill_ie/model.py | 0
.../waybill_ie/run_bigru_crf.py | 0
.../waybill_ie/run_ernie.py | 0
.../waybill_ie/run_ernie_crf.py | 0
.../examples/lexical_analysis/README.md | 22 +-
.../examples/lexical_analysis/data.py | 0
.../lexical_analysis/deploy/predict.py | 0
.../examples/lexical_analysis/download.py | 0
.../examples/lexical_analysis/eval.py | 0
.../examples/lexical_analysis/export_model.py | 0
.../examples/lexical_analysis/model.py | 0
.../examples/lexical_analysis/predict.py | 0
.../examples/lexical_analysis/train.py | 0
.../DuReader-robust/README.md | 18 +-
.../DuReader-robust/args.py | 0
.../DuReader-robust/run_du.py | 0
.../DuReader-yesno/README.md | 12 +-
.../DuReader-yesno/args.py | 0
.../DuReader-yesno/run_du.py | 0
.../SQuAD/README.md | 28 +-
.../SQuAD/args.py | 0
.../SQuAD/deploy/python/predict.py | 0
.../SQuAD/export_model.py | 0
.../SQuAD/run_squad.py | 0
.../examples/machine_translation/README.md | 0
.../preprocessor/prepare-iwslt14.sh | 0
.../preprocessor/prepare-wmt14en2de.sh | 0
.../preprocessor/prepare-wmt14en2fr.sh | 0
.../preprocessor/preprocessor.py | 0
.../machine_translation/requirements.txt | 0
.../machine_translation/seq2seq/README.md | 18 +-
.../machine_translation/seq2seq/args.py | 0
.../machine_translation/seq2seq/data.py | 0
.../seq2seq/deploy/python/infer.py | 0
.../seq2seq/export_model.py | 0
.../machine_translation/seq2seq/predict.py | 0
.../seq2seq/seq2seq_attn.py | 0
.../machine_translation/seq2seq/train.py | 0
.../machine_translation/transformer/README.md | 2 +-
.../transformer/configs/transformer.base.yaml | 0
.../transformer/configs/transformer.big.yaml | 0
.../transformer/deploy/cpp/CMakeLists.txt | 0
.../transformer/deploy/cpp/README.md | 0
.../transformer/deploy/cpp/helper.h | 0
.../transformer/deploy/cpp/run.sh | 0
.../transformer/deploy/cpp/run_impl.sh | 0
.../transformer/deploy/cpp/transformer_e2e.cc | 0
.../transformer/deploy/python/README.md | 0
.../transformer/deploy/python/benchmark.sh | 0
.../transformer/deploy/python/inference.py | 0
.../deploy/python/tls/benchmark_utils.py | 0
.../transformer/deploy/python/tls/recorder.py | 0
.../transformer/deploy/serving/README.md | 0
.../transformer/deploy/serving/benchmark.py | 0
.../deploy/serving/benchmark_serving.sh | 0
.../deploy/serving/export_serving_model.py | 0
.../deploy/serving/transformer_reader.py | 0
.../deploy/serving/transformer_web_client.py | 0
.../deploy/serving/transformer_web_server.py | 0
.../deploy/serving/utils/recorder.py | 0
.../transformer/export_model.py | 0
.../images/multi_head_attention.png | Bin
.../images/transformer_network.png | Bin
.../transformer/predict.py | 0
.../machine_translation/transformer/reader.py | 0
.../transformer/static/predict.py | 0
.../transformer/static/train.py | 0
.../transformer/tls/distributed_utils.py | 33 +
.../transformer/tls/record.py | 0
.../transformer/tls/to_static.py | 0
.../machine_translation/transformer/train.py | 0
.../model_compression/distill_lstm/README.md | 36 +-
.../model_compression/distill_lstm/args.py | 2 +-
.../distill_lstm/bert_distill.py | 0
.../model_compression/distill_lstm/data.py | 0
.../model_compression/distill_lstm/small.py | 0
.../model_compression/distill_lstm/utils.py | 1 -
.../model_compression/minilmv2/README.md | 22 +-
.../minilmv2/general_distill.py | 0
.../model_compression/minilmv2/run_clue.py | 0
.../examples/model_compression/ofa/README.md | 54 +-
.../model_compression/ofa/export_model.py | 0
.../model_compression/ofa/imgs/ofa_bert.jpg | Bin
.../model_compression/ofa/run_glue_ofa.py | 0
.../ofa/run_glue_ofa_depth.py | 0
.../model_compression/pp-minilm/README.md | 22 +-
.../model_compression/pp-minilm/data.py | 0
.../pp-minilm/deploy/python/infer.py | 0
.../pp-minilm/deploy/python/infer_all.sh | 0
.../pp-minilm/deploy/python/infer_perf.sh | 0
.../pp-minilm/deploy/serving/README.md | 6 +-
.../pp-minilm/deploy/serving/config_nlp.yml | 0
.../deploy/serving/export_to_serving.py | 0
.../pp-minilm/deploy/serving/rpc_client.py | 0
.../pp-minilm/deploy/serving/web_service.py | 0
.../pp-minilm/finetuning/export_model.py | 0
.../pp-minilm/finetuning/run_all_search.sh | 0
.../pp-minilm/finetuning/run_clue.py | 0
.../pp-minilm/finetuning/run_clue.sh | 0
.../pp-minilm/finetuning/run_one_search.sh | 0
.../pp-minilm/general_distill/README.md | 8 +-
.../general_distill/general_distill.py | 0
.../pp-minilm/general_distill/run.sh | 0
.../model_compression/pp-minilm/pp-minilm.png | Bin
.../pp-minilm/pruning/export.sh | 0
.../pp-minilm/pruning/export_all.sh | 0
.../pp-minilm/pruning/export_model.py | 0
.../pp-minilm/pruning/prune.py | 0
.../pp-minilm/pruning/prune.sh | 0
.../pp-minilm/quantization/quant_all.sh | 0
.../pp-minilm/quantization/quant_post.py | 0
.../examples/model_interpretation/README.md | 66 +-
.../examples/model_interpretation/data/mrc_ch | 0
.../examples/model_interpretation/data/mrc_en | 0
.../model_interpretation/data/senti_ch | 0
.../model_interpretation/data/senti_en | 0
.../model_interpretation/data/similarity_ch | 0
.../model_interpretation/data/similarity_en | 0
slm/examples/model_interpretation/download.sh | 24 +
.../evaluation/accuracy/cal_acc.py | 0
.../evaluation/accuracy/mrc_f1_evaluate.py | 0
.../evaluation/accuracy/run_acc.sh | 14 +
.../evaluation/accuracy/run_mrc_f1.sh | 14 +
.../evaluation/consistency/cal_map.py | 0
.../evaluation/consistency/run_map.sh | 14 +
.../evaluation/faithfulness/newp_analysis.py | 0
.../evaluation/faithfulness/run_newp.sh | 14 +
.../evaluation/plausibility/eval_mrc.py | 0
.../evaluation/plausibility/eval_senti.py | 0
.../plausibility/eval_similarity.py | 0
.../evaluation/plausibility/run_f1.sh | 14 +
.../model_interpretation/imgs/equation1.png | Bin
.../model_interpretation/imgs/equation2.png | Bin
.../model_interpretation/imgs/equation3.png | Bin
.../model_interpretation/imgs/equation4.png | Bin
.../model_interpretation/imgs/equation5.png | Bin
.../model_interpretation/imgs/example1.png | Bin
.../model_interpretation/imgs/structure.png | Bin
.../model_interpretation/punctuations | 0
.../rationale_extraction/available_gpu.py | 0
.../rationale_extraction/generate.sh | 14 +
.../generate_evaluation_data.py | 0
.../generate_evaluation_data.sh | 14 +
.../rationale_extraction/mrc_pred.py | 0
.../newp_text_generate.py | 0
.../run_2_pred_mrc_per.sh | 14 +
.../run_2_pred_senti_per.sh | 14 +
.../run_2_pred_similarity_per.sh | 14 +
.../rationale_extraction/sentiment_pred.py | 0
.../rationale_extraction/similarity_pred.py | 0
.../model_interpretation/requirements.txt | 0
.../model_interpretation/task/README.md | 0
.../task/mrc/roberta/modeling.py | 0
.../task/mrc/run_1_predict_rc.sh | 14 +
.../task/mrc/run_1_predict_rc_all.sh | 14 +
.../task/mrc/run_2_inter_rc.sh | 14 +
.../task/mrc/run_2_inter_rc_all.sh | 14 +
.../task/mrc/run_train_rc.sh | 14 +
.../task/mrc/saliency_map/rc_finetune.py | 0
.../task/mrc/saliency_map/rc_interpretable.py | 0
.../task/mrc/saliency_map/rc_prediction.py | 0
.../task/mrc/saliency_map/squad.py | 0
.../task/mrc/saliency_map/utils.py | 0
.../task/senti/LIME/exceptions.py | 17 +
.../task/senti/LIME/explanation.py | 8 +-
.../task/senti/LIME/lime_base.py | 0
.../task/senti/LIME/lime_text.py | 9 +-
.../task/senti/pretrained_models/run_train.sh | 14 +
.../task/senti/pretrained_models/train.py | 0
.../task/senti/pretrained_models/utils.py | 0
.../task/senti/rnn/lstm_train.sh | 34 +
.../task/senti/rnn/model.py | 0
.../task/senti/rnn/tokenizer_config.json | 0
.../task/senti/rnn/train.py | 0
.../task/senti/rnn/utils.py | 0
.../task/senti/roberta/modeling.py | 0
.../task/senti/run_inter.sh | 14 +
.../task/senti/run_inter_all.sh | 14 +
.../saliency_map/sentiment_interpretable.py | 0
.../task/senti/saliency_map/utils.py | 0
.../task/similarity/LIME/exceptions.py | 17 +
.../task/similarity/LIME/explanation.py | 11 +-
.../task/similarity/LIME/lime_base.py | 0
.../task/similarity/LIME/lime_text.py | 11 +-
.../task/similarity/pretrained_models/data.py | 2 +-
.../similarity/pretrained_models/model.py | 0
.../pretrained_models/predict_pointwise.py | 0
.../pretrained_models/run_train_pointwise.sh | 14 +
.../pretrained_models/train_pointwise.py | 0
.../task/similarity/roberta/modeling.py | 0
.../task/similarity/run_inter.sh | 14 +
.../task/similarity/run_inter_all.sh | 14 +
.../saliency_map/similarity_interpretable.py | 0
.../task/similarity/saliency_map/utils.py | 0
.../task/similarity/simnet/gen_vocab.py | 0
.../simnet/interpreter_attention.py | 0
.../similarity/simnet/interpreter_grad.py | 0
.../task/similarity/simnet/lstm_train.sh | 35 +
.../task/similarity/simnet/model.py | 0
.../task/similarity/simnet/predict.py | 0
.../task/similarity/simnet/train.py | 0
.../task/similarity/simnet/utils.py | 0
.../model_interpretation/task/transformer.py | 0
.../examples/model_interpretation/utils.py | 0
.../examples/multimodal/layoutlm/README.md | 12 +-
.../examples/multimodal/layoutlm/funsd.py | 0
.../multimodal/layoutlm/preprocess.py | 15 +
.../multimodal/layoutlm/preprocess.sh | 14 +
.../multimodal/layoutlm/train_funsd.py | 0
.../multimodal/layoutlm/train_funsd.sh | 31 +
.../examples/multimodal/layoutlm/utils.py | 0
.../examples/multimodal/layoutxlm/README.md | 10 +-
.../examples/multimodal/layoutxlm/compare.py | 0
.../multimodal/layoutxlm/run_xfun_re.py | 31 +-
.../multimodal/layoutxlm/run_xfun_re.sh | 14 +
.../multimodal/layoutxlm/run_xfun_ser.py | 0
.../multimodal/layoutxlm/run_xfun_ser.sh | 14 +
.../examples/multimodal/layoutxlm/xfun.py | 17 +-
.../examples/multimodal/minigpt4/README.md | 12 +-
.../multimodal/minigpt4/merge_weight.py | 0
.../minigpt4/paddle_minigpt4_instrction.md | 20 +-
.../multimodal/minigpt4/run_predict.py | 0
.../examples/question_generation/README.md | 6 +-
.../examples/question_generation/t5/README.md | 34 +-
.../question_generation/t5/predict.py | 0
.../question_generation/t5/requirements.txt | 0
.../examples/question_generation/t5/train.py | 0
.../examples/question_generation/t5/utils.py | 0
.../question_generation/unimo-text/README.md | 68 +-
.../deploy/paddle_inference/README.md | 54 +
.../deploy/paddle_inference/infer_utils.py | 0
.../deploy/paddle_inference/inference.py | 0
.../deploy/paddle_serving/README.md | 48 +-
.../deploy/paddle_serving/config.yml | 0
.../deploy/paddle_serving/infer_utils.py | 0
.../deploy/paddle_serving/pipeline_client.py | 0
.../deploy/paddle_serving/pipeline_service.py | 0
.../unimo-text/export_model.py | 0
.../unimo-text/gen_utils.py | 0
.../question_generation/unimo-text/predict.py | 0
.../unimo-text/requirements.txt | 0
.../question_generation/unimo-text/train.py | 0
.../examples/semantic_indexing/NQdataset.py | 0
.../examples/semantic_indexing/README.md | 6 +-
.../README_gradient_cache.md | 22 +-
.../examples/semantic_indexing/ance/model.py | 0
.../examples/semantic_indexing}/ann_util.py | 3 +-
.../examples/semantic_indexing/base_model.py | 0
.../semantic_indexing/batch_negative/model.py | 0
.../semantic_indexing/biencoder_base_model.py | 0
.../examples/semantic_indexing/data.py | 0
.../semantic_indexing/dense_retriever.py | 0
.../examples/semantic_indexing/evaluate.py | 0
.../semantic_indexing/faiss_indexer.py | 0
.../semantic_indexing/fast_predict.py | 0
.../generate_dense_embeddings.py | 0
.../semantic_indexing/gradient_cache/model.py | 0
.../hardest_negative/model.py | 0
.../examples/semantic_indexing/predict.py | 0
.../semantic_indexing/qa_validation.py | 0
.../examples/semantic_indexing/recall.py | 0
.../semantic_indexing/requirements.txt | 0
.../semantic_indexing/run_ann_data_gen.py | 0
.../examples/semantic_indexing/tokenizers.py | 0
.../examples/semantic_indexing/train_ance.py | 0
.../semantic_indexing/train_batch_neg.py | 0
.../semantic_indexing/train_gradient_cache.py | 0
.../train_gradient_cache_DPR.py | 0
.../semantic_indexing/train_hardest_neg.py | 0
.../sentiment_analysis/skep/README.md | 40 +-
.../skep/deploy/python/predict.py | 0
.../sentiment_analysis/skep/export_model.py | 0
.../sentiment_analysis/skep/predict_aspect.py | 0
.../skep/predict_opinion.py | 0
.../skep/predict_sentence.py | 0
.../sentiment_analysis/skep/train_aspect.py | 0
.../sentiment_analysis/skep/train_opinion.py | 0
.../sentiment_analysis/skep/train_sentence.py | 0
.../sentiment_analysis/textcnn/README.md | 30 +-
.../sentiment_analysis/textcnn/data.py | 0
.../textcnn/deploy/python/predict.py | 0
.../textcnn/export_model.py | 3 +-
.../sentiment_analysis/textcnn/model.py | 0
.../sentiment_analysis/textcnn/predict.py | 6 +-
.../sentiment_analysis/textcnn/train.py | 10 +-
.../simultaneous_translation/stacl/README.md | 58 +-
.../stacl/config/transformer.yaml | 0
.../stacl/demo/README.md | 30 +-
.../stacl/demo/README_ai.md | 6 +-
.../stacl/demo/const.py | 0
.../stacl/demo/demo.py | 0
.../stacl/demo/images/paddlenlp.png | Bin
.../stacl/demo/images/speech_demo_show.gif | Bin
.../stacl/demo/images/step1.png | Bin
.../stacl/demo/images/step2.png | Bin
.../stacl/demo/images/step3.png | Bin
.../stacl/demo/images/step4.png | Bin
.../stacl/demo/images/step5.png | Bin
.../stacl/demo/images/step6.png | Bin
.../stacl/demo/images/step7.png | Bin
.../stacl/demo/images/step8.png | Bin
.../stacl/demo/images/text_demo_show.gif | Bin
.../stacl/demo/model_demo.py | 0
.../stacl/demo/requirements.txt | 0
.../stacl/demo/transformer_demo.yaml | 0
.../stacl/images/STACL_architecture.png | Bin
.../stacl/images/example.png | Bin
.../simultaneous_translation/stacl/model.py | 0
.../simultaneous_translation/stacl/predict.py | 0
.../simultaneous_translation/stacl/reader.py | 0
.../stacl/requirements.txt | 0
.../simultaneous_translation/stacl/train.py | 0
.../stacl/utils/record.py | 0
.../stacl/utils/tokenizer.py | 0
slm/examples/text_classification/README.md | 7 +
.../pretrained_models/README.md | 0
.../text_correction/ernie-csc/README.md | 32 +-
.../ernie-csc/change_sgml_to_txt.py | 0
.../text_correction/ernie-csc/download.py | 0
.../text_correction/ernie-csc/export_model.py | 0
.../text_correction/ernie-csc/model.py | 0
.../ernie-csc/pinyin_vocab.txt | 0
.../text_correction/ernie-csc/predict.py | 0
.../ernie-csc/predict_sighan.py | 0
.../ernie-csc/requirements.txt | 0
.../ernie-csc/run_sighan_predict.sh | 14 +
.../ernie-csc/sighan_evaluate.py | 0
.../text_correction/ernie-csc/train.py | 0
.../text_correction/ernie-csc/utils.py | 2 +-
.../text_generation/couplet/README.md | 7 +-
.../examples/text_generation/ctrl/README.md | 2 +-
.../examples/text_generation/ernie-gen | 0
.../examples/text_generation/opt/README.md | 2 +-
.../examples/text_generation/opt/demo.py | 0
.../text_generation/reformer/README.md | 0
.../text_generation/unimo-text/README.md | 28 +-
.../text_generation/unimo-text/gen_utils.py | 18 +-
.../text_generation/unimo-text/run_gen.py | 0
.../unimo-text/scripts/lcsts_train.sh | 0
.../unimo-text/scripts/qg_train.sh | 0
.../unimo-text/scripts/table_train.sh | 0
.../text_generation/vae-seq2seq/README.md | 30 +
.../examples/text_graph/erniesage/README.md | 26 +-
.../config/erniesage_link_prediction.yaml | 0
.../text_graph/erniesage/data/__init__.py | 0
.../text_graph/erniesage/data/dataset.py | 0
.../text_graph/erniesage/data/graph_reader.py | 0
.../erniesage/example_data/graph_data.txt | 0
.../erniesage/example_data/train_data.txt | 0
.../text_graph/erniesage/link_prediction.py | 0
.../text_graph/erniesage/models/__init__.py | 0
.../text_graph/erniesage/models/conv.py | 0
.../text_graph/erniesage/models/encoder.py | 0
.../text_graph/erniesage/models/loss.py | 0
.../text_graph/erniesage/models/model.py | 0
.../erniesage/preprocessing/dump_graph.py | 0
.../examples/text_matching/README.md | 4 +-
.../text_matching/ernie_matching/README.md | 14 +-
.../text_matching/ernie_matching/data.py | 2 +-
.../ernie_matching/deploy/python/predict.py | 0
.../ernie_matching/export_model.py | 0
.../text_matching/ernie_matching/model.py | 0
.../ernie_matching/predict_pairwise.py | 0
.../ernie_matching/predict_pointwise.py | 0
.../ernie_matching/train_pairwise.py | 0
.../ernie_matching/train_pointwise.py | 0
.../text_matching/question_matching/README.md | 10 +-
.../text_matching/question_matching/data.py | 0
.../text_matching/question_matching/model.py | 0
.../question_matching/predict.py | 0
.../text_matching/question_matching/train.py | 0
.../sentence_transformers/README.md | 54 +-
.../deploy/simple_serving/README.md | 10 +-
.../deploy/simple_serving/client.py | 0
.../deploy/simple_serving/server.py | 0
.../sentence_transformers/export_model.py | 0
.../sentence_transformers/model.py | 0
.../sentence_transformers/predict.py | 0
.../sentence_transformers/train.py | 0
.../examples/text_matching/simbert/README.md | 10 +-
.../examples/text_matching/simbert/data.py | 0
.../examples/text_matching/simbert/predict.py | 0
.../examples/text_matching/simcse/README.md | 10 +-
.../examples/text_matching/simcse/data.py | 0
.../examples/text_matching/simcse/model.py | 0
.../examples/text_matching/simcse/predict.py | 0
.../examples/text_matching/simcse/train.py | 0
slm/examples/text_matching/simcse/train.sh | 29 +
.../examples/text_matching/simnet/README.md | 30 +-
.../examples/text_matching/simnet/model.py | 0
.../examples/text_matching/simnet/predict.py | 0
.../examples/text_matching/simnet/train.py | 0
.../examples/text_matching/simnet/utils.py | 0
.../text_summarization/bart/README.md | 9 +
.../pointer_summarizer/.gitignore | 0
.../pointer_summarizer/README.md | 0
.../text_summarization/prophetnet/README.md | 1 -
.../text_summarization/unimo-text/README.md | 38 +-
.../deploy/paddle_inference/README.md | 31 +
.../paddle_inference/inference_unimo_text.py | 0
.../deploy/paddle_serving/README.md | 46 +-
.../deploy/paddle_serving/config.yml | 0
.../deploy/paddle_serving/export_serving.sh | 0
.../deploy/paddle_serving/pipeline_client.py | 0
.../deploy/paddle_serving/pipeline_service.py | 0
.../unimo-text/export_model.py | 0
.../unimo-text/export_model.sh | 0
.../text_summarization/unimo-text/train.py | 0
.../text_summarization/unimo-text/train.sh | 0
.../text_summarization/unimo-text/utils.py | 0
.../examples/text_to_knowledge/README.md | 50 +-
.../doc/img/ernie_ctm_inputs.png | Bin
.../doc/img/ernie_ctm_model.png | Bin
.../doc/img/text_to_knowledge.png | Bin
.../doc/img/text_to_knowledge_example.png | Bin
.../doc/img/wordtag_example.png | Bin
.../doc/img/wordtag_model.png | Bin
.../text_to_knowledge/ernie-ctm/README.md | 167 ++++
.../ernie-ctm/data_process.py | 0
.../text_to_knowledge/ernie-ctm/metric.py | 0
.../text_to_knowledge/ernie-ctm/predict.py | 0
.../text_to_knowledge/ernie-ctm/train.py | 0
.../text_to_knowledge/ernie-ctm/utils.py | 0
.../text_to_knowledge/nptag/README.md | 42 +-
.../examples/text_to_knowledge/nptag/data.py | 0
.../nptag/deploy/python/predict.py | 2 +-
.../text_to_knowledge/nptag/export_model.py | 1 +
.../text_to_knowledge/nptag/metric.py | 0
.../text_to_knowledge/nptag/predict.py | 0
.../examples/text_to_knowledge/nptag/train.py | 0
.../examples/text_to_knowledge/nptag/utils.py | 0
.../text_to_knowledge/termtree/README.md | 116 +--
.../text_to_knowledge/termtree/termtree.py | 0
.../termtree/termtree_type.csv | 0
.../text_to_knowledge/wordtag-ie/README.md | 184 ++--
.../wordtag-ie/demo_config.json | 0
.../text_to_knowledge/wordtag/README.md | 70 +-
.../text_to_knowledge/wordtag/predict.py | 0
.../examples/torch_migration/README.md | 16 +-
.../docs/ThesisReproduction_NLP.md | 928 ++++++++++++++++++
.../torch_migration/pipeline/Step1/README.md | 6 +-
.../pipeline/Step1/check_step1.py | 0
.../pipeline/Step1/pd_forward_bert.py | 0
.../pipeline/Step1/pt_forward_bert.py | 0
.../pipeline/Step1/torch2paddle.py | 0
.../torch_migration/pipeline/Step2/README.md | 8 +-
.../pipeline/Step2/accuracy.py | 0
.../pipeline/Step2/check_step2.py | 0
.../Step2/demo_sst2_sentence/demo.tsv | 0
.../torch_migration/pipeline/Step2/predict.py | 0
.../pipeline/Step2/test_data.py | 0
.../pipeline/Step2/test_metric.py | 0
.../torch_migration/pipeline/Step3/README.md | 6 +-
.../pipeline/Step3/check_step3.py | 0
.../pipeline/Step3/paddle_loss.py | 0
.../pipeline/Step3/torch_loss.py | 0
.../torch_migration/pipeline/Step4/README.md | 8 +-
.../pipeline/Step4/check_step4.py | 0
.../torch_migration/pipeline/Step4/test_bp.py | 0
.../pipeline/Step4/test_lr_scheduler.py | 0
.../torch_migration/pipeline/Step5/README.md | 8 +-
.../pipeline/Step5/bert_paddle/train.py | 0
.../pipeline/Step5/bert_paddle/train.sh | 0
.../pipeline/Step5/bert_paddle/utils.py | 0
.../pipeline/Step5/bert_torch/accuracy.py | 0
.../pipeline/Step5/bert_torch/glue.py | 0
.../pipeline/Step5/bert_torch/train.py | 0
.../pipeline/Step5/bert_torch/train.sh | 0
.../pipeline/Step5/bert_torch/utils.py | 0
.../pipeline/Step5/check_step5.py | 0
.../generate_classifier_weights.py | 0
.../pipeline/fake_data/gen_fake_data.py | 0
.../pipeline/models/pd_bert.py | 0
.../pipeline/models/pt_bert.py | 0
.../reprod_log_demo/check_log_diff.py | 0
.../pipeline/reprod_log_demo/write_log.py | 0
.../pipeline/weights/torch2paddle.py | 0
.../pipeline/weights/torch_bert_weight.py | 0
.../examples/torch_migration/requirements.txt | 0
{legacy => slm}/model_zoo/README.md | 0
{legacy => slm}/model_zoo/bert/README.md | 118 +--
.../model_zoo/bert/create_pretraining_data.py | 0
.../model_zoo/bert/data/sample_text.txt | 0
.../model_zoo/bert/deploy/python/README.md | 8 +-
.../bert/deploy/python/seq_cls_infer.py | 0
.../model_zoo/bert/export_model.py | 0
.../model_zoo/bert/run_glue_trainer.py | 0
.../model_zoo/bert/run_pretrain.py | 0
.../model_zoo/bert/run_pretrain_trainer.py | 0
.../model_zoo/bert/static/README.md | 74 +-
.../bert/static/create_pretraining_data.py | 0
.../bert/static/data/sample_text.txt | 0
.../model_zoo/bert/static/dataset.py | 0
.../model_zoo/bert/static/predict_glue.py | 0
.../model_zoo/bert/static/run_glue.py | 0
.../bert/static/run_glue_with_sparaity.py | 0
.../model_zoo/bert/static/run_pretrain.py | 0
.../model_zoo/bert/static_ipu/README.md | 0
.../custom_ops/custom_checkpointoutput.cc | 0
.../static_ipu/custom_ops/custom_detach.cc | 0
.../static_ipu/custom_ops/custom_identity.cc | 0
.../static_ipu/custom_ops/custom_nll_loss.cc | 0
.../custom_ops/custom_shape_infer.cc | 0
.../disable_attn_dropout_bwd_pattern.cc | 0
.../bert/static_ipu/custom_ops/tied_gather.cc | 0
.../custom_ops/tied_gather_pattern.cc | 0
.../bert/static_ipu/custom_ops/utils.cc | 0
.../prevent_const_expr_folding_op.cc | 0
.../model_zoo/bert/static_ipu/dataset_ipu.py | 0
.../model_zoo/bert/static_ipu/load_tf_ckpt.py | 0
.../model_zoo/bert/static_ipu/modeling.py | 0
.../bert/static_ipu/requirements.txt | 0
.../model_zoo/bert/static_ipu/run_pretrain.py | 0
.../model_zoo/bert/static_ipu/run_squad.py | 0
.../static_ipu/scripts/pod16/run_pretrain.sh | 0
.../scripts/pod16/run_pretrain_phase2.sh | 0
.../static_ipu/scripts/pod16/run_squad.sh | 0
.../scripts/pod16/run_squad_infer.sh | 0
.../static_ipu/scripts/pod4/run_pretrain.sh | 0
.../scripts/pod4/run_pretrain_phase2.sh | 0
.../bert/static_ipu/scripts/pod4/run_squad.sh | 0
.../scripts/pod4/run_squad_infer.sh | 0
.../model_zoo/bert/static_ipu/utils.py | 0
{legacy => slm}/model_zoo/bigbird/README.md | 44 +-
{legacy => slm}/model_zoo/bigbird/args.py | 0
.../model_zoo/bigbird/data/data.txt | 0
.../model_zoo/bigbird/run_classifier.py | 0
{legacy => slm}/model_zoo/bigbird/run_glue.py | 0
.../model_zoo/bigbird/run_pretrain.py | 0
.../model_zoo/chinesebert/README.md | 58 +-
.../model_zoo/chinesebert/cmrc_eval.sh | 0
.../model_zoo/chinesebert/cmrc_evaluate.py | 0
.../model_zoo/chinesebert/dataset_cmrc2018.py | 0
.../model_zoo/chinesebert/eval_cmrc.py | 0
.../model_zoo/chinesebert/metric_cmrc.py | 0
.../model_zoo/chinesebert/run_chn.sh | 0
.../model_zoo/chinesebert/run_cmrc2018.sh | 0
.../model_zoo/chinesebert/run_xnli.sh | 0
.../model_zoo/chinesebert/train_chn.py | 0
.../model_zoo/chinesebert/train_cmrc2018.py | 0
.../model_zoo/chinesebert/train_xnli.py | 0
.../model_zoo/chinesebert/utils.py | 0
{legacy => slm}/model_zoo/convbert/README.md | 34 +-
{legacy => slm}/model_zoo/convbert/convert.py | 0
.../model_zoo/convbert/run_glue.py | 0
.../model_zoo/convbert/run_pretrain.py | 0
slm/model_zoo/electra/README.md | 7 +
{legacy => slm}/model_zoo/ernie-1.0/README.md | 2 +-
{legacy => slm}/model_zoo/ernie-1.0/args.py | 0
.../converter/params_static_to_dygraph.py | 0
.../model_zoo/ernie-1.0/data_tools/Makefile | 0
.../ernie-1.0/data_tools/dataset_utils.py | 0
.../ernie-1.0/data_tools/ernie_dataset.py | 0
.../ernie-1.0/data_tools/helpers.cpp | 0
.../model_zoo/ernie-1.0/finetune/README.md | 28 +-
.../model_zoo/ernie-1.0/finetune/config.yml | 0
.../ernie-1.0/finetune/deploy/README.md | 8 +-
.../finetune/deploy/seq_cls_infer.py | 0
.../ernie-1.0/finetune/question_answering.py | 0
.../model_zoo/ernie-1.0/finetune/run_ner.py | 0
.../model_zoo/ernie-1.0/finetune/run_qa.py | 0
.../ernie-1.0/finetune/run_seq_cls.py | 0
.../finetune/sequence_classification.py | 0
.../finetune/token_classification.py | 0
.../model_zoo/ernie-1.0/finetune/utils.py | 0
.../ernie-1.0/pretraining_introduction.md | 2 +-
.../model_zoo/ernie-1.0/run_gb512_s1m.sh | 0
.../ernie-1.0/run_gb512_s1m_trainer.sh | 0
.../ernie-1.0/run_npu_single_card.sh | 0
.../model_zoo/ernie-1.0/run_pretrain.py | 0
.../ernie-1.0/run_pretrain_trainer.py | 0
.../model_zoo/ernie-1.0/vocab/README.md | 46 +-
.../model_zoo/ernie-1.0/vocab/gen_char.py | 0
.../model_zoo/ernie-1.0/vocab/gen_vocab.py | 0
.../model_zoo/ernie-1.0/vocab/merge_vocab.py | 0
.../model_zoo/ernie-3.0-tiny/README.md | 8 +-
.../ernie-3.0-tiny/data/intent_label.txt | 0
.../ernie-3.0-tiny/data/slot_label.txt | 0
slm/model_zoo/ernie-3.0-tiny/deploy/README.md | 43 +
.../ernie-3.0-tiny/deploy/python/README.md | 32 +-
.../deploy/python/infer_demo.py | 0
.../model_zoo/ernie-3.0-tiny/model.py | 0
.../model_zoo/ernie-3.0-tiny/run_eval.py | 0
.../model_zoo/ernie-3.0-tiny/run_train.py | 0
.../model_zoo/ernie-3.0-tiny/utils.py | 0
{legacy => slm}/model_zoo/ernie-3.0/README.md | 38 +-
.../model_zoo/ernie-3.0/compress_qa.py | 0
.../model_zoo/ernie-3.0/compress_seq_cls.py | 0
.../model_zoo/ernie-3.0/compress_token_cls.py | 0
.../model_zoo/ernie-3.0/configs/default.yml | 0
.../model_zoo/ernie-3.0/deploy/README.md | 4 +-
.../ernie-3.0/deploy/python/README.md | 14 +-
.../ernie-3.0/deploy/python/requirements.txt | 0
.../ernie-3.0/deploy/python/seq_cls_infer.py | 0
.../deploy/python/token_cls_infer.py | 0
.../ernie-3.0/deploy/serving/README.md | 6 +-
.../serving/models/ernie_seqcls/1/README.md | 0
.../serving/models/ernie_seqcls/config.pbtxt | 0
.../models/ernie_seqcls_model/1/README.md | 0
.../models/ernie_seqcls_model/config.pbtxt | 0
.../ernie_seqcls_postprocess/1/model.py | 0
.../ernie_seqcls_postprocess/config.pbtxt | 0
.../models/ernie_seqcls_tokenizer/1/model.py | 0
.../ernie_seqcls_tokenizer/config.pbtxt | 0
.../serving/models/ernie_tokencls/1/README.md | 0
.../models/ernie_tokencls/config.pbtxt | 0
.../models/ernie_tokencls_model/1/README.md | 1 +
.../models/ernie_tokencls_model/config.pbtxt | 0
.../ernie_tokencls_postprocess/1/model.py | 0
.../ernie_tokencls_postprocess/config.pbtxt | 0
.../ernie_tokencls_tokenizer/1/model.py | 0
.../ernie_tokencls_tokenizer/config.pbtxt | 0
.../deploy/serving/seq_cls_grpc_client.py | 0
.../deploy/serving/token_cls_grpc_client.py | 0
.../ernie-3.0/deploy/simple_serving/README.md | 12 +-
.../deploy/simple_serving/client_qa.py | 0
.../deploy/simple_serving/client_seq_cls.py | 0
.../deploy/simple_serving/client_token_cls.py | 0
.../deploy/simple_serving/server_qa.py | 0
.../deploy/simple_serving/server_seq_cls.py | 0
.../deploy/simple_serving/server_token_cls.py | 0
{legacy => slm}/model_zoo/ernie-3.0/infer.py | 0
{legacy => slm}/model_zoo/ernie-3.0/run_qa.py | 0
.../model_zoo/ernie-3.0/run_seq_cls.py | 0
.../model_zoo/ernie-3.0/run_token_cls.py | 0
{legacy => slm}/model_zoo/ernie-3.0/utils.py | 0
.../model_zoo/ernie-code/README.md | 4 +-
slm/model_zoo/ernie-doc/README.md | 6 +
{legacy => slm}/model_zoo/ernie-gen/README.md | 0
.../model_zoo/ernie-health/README.md | 0
.../model_zoo/ernie-layout/README.md | 0
.../model_zoo/ernie-layout/README_ch.md | 52 +-
.../model_zoo/ernie-layout/data_collator.py | 0
.../ernie-layout/deploy/python/README.md | 0
.../ernie-layout/deploy/python/README_ch.md | 8 +-
.../ernie-layout/deploy/python/infer.py | 0
.../ernie-layout/deploy/python/predictor.py | 0
.../deploy/python/requirements.txt | 0
.../model_zoo/ernie-layout/export_model.py | 0
.../model_zoo/ernie-layout/finetune_args.py | 0
.../model_zoo/ernie-layout/layout_trainer.py | 0
.../model_zoo/ernie-layout/requirements.txt | 0
.../model_zoo/ernie-layout/run_cls.py | 0
.../model_zoo/ernie-layout/run_mrc.py | 0
.../model_zoo/ernie-layout/run_ner.py | 0
.../model_zoo/ernie-layout/utils.py | 0
{legacy => slm}/model_zoo/ernie-m/README.md | 2 +-
.../model_zoo/ernie-vil2.0/README.md | 34 +-
.../model_zoo/ernie-vil2.0/data_util.py | 0
.../ernie-vil2.0/deploy/python/infer.py | 0
.../model_zoo/ernie-vil2.0/export_model.py | 0
.../ernie-vil2.0/extract_features.py | 0
.../model_zoo/ernie-vil2.0/predict.py | 0
.../preprocess/create_arrow_dataset.py | 0
.../model_zoo/ernie-vil2.0/requirements.txt | 0
.../model_zoo/ernie-vil2.0/run_finetune.py | 0
.../model_zoo/ernie-vil2.0/trainer_util.py | 0
.../ernie-vil2.0/utils/evaluation.py | 0
.../ernie-vil2.0/utils/evaluation_tr.py | 0
.../utils/make_topk_predictions.py | 0
.../utils/make_topk_predictions_tr.py | 0
.../utils/transform_ir_annotation_to_tr.py | 0
.../model_zoo/gpt-3/.pre-commit-config.yaml | 0
{legacy => slm}/model_zoo/gpt-3/README.md | 0
.../model_zoo/gpt-3/benchmarks/README.md | 0
.../N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh | 0
.../gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh | 0
.../N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh | 0
.../data_parallel/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
...gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh | 0
...finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh | 0
..._finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh | 0
...gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh | 0
..._gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh | 0
...gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh | 0
...tune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh | 0
...une_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh | 0
...gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh | 0
.../finetune/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
.../N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh | 0
.../N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh | 0
.../N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh | 0
.../N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh | 0
.../N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh | 0
.../N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh | 0
.../N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh | 0
.../N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh | 0
.../N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh | 0
.../N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh | 0
.../N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh | 0
.../N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh | 0
.../gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh | 0
.../gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh | 0
.../N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh | 0
.../N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh | 0
.../N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh | 0
.../N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh | 0
.../N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh | 0
.../N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh | 0
.../benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
.../N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh | 0
.../N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh | 0
.../gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh | 0
.../gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh | 0
.../benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
..._stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh | 0
..._stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh | 0
..._stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh | 0
...tage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh | 0
.../sharding/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
.../gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh | 0
.../gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh | 0
.../gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh | 0
.../gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh | 0
.../gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh | 0
.../gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh | 0
.../gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh | 0
.../gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh | 0
.../gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh | 0
.../gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh | 0
.../auto_amp/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
...gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh | 0
.../auto_parallel/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
...auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh | 0
...auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh | 0
...auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh | 0
...auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh | 0
...auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh | 0
...auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh | 0
...auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh | 0
...auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh | 0
...auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh | 0
...auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh | 0
...auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh | 0
...auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh | 0
..._auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh | 0
..._auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh | 0
..._auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh | 0
..._auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh | 0
..._auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh | 0
..._auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh | 0
...t_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh | 0
...pt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh | 0
.../new_exec_pp/benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
..._pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh | 0
..._pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh | 0
..._pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh | 0
..._pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh | 0
..._pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh | 0
..._pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh | 0
..._pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh | 0
..._pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh | 0
..._pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh | 0
..._pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh | 0
..._pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh | 0
..._pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh | 0
...o_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh | 0
...o_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh | 0
...o_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh | 0
...o_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh | 0
...o_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh | 0
...o_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh | 0
...to_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh | 0
...uto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh | 0
.../benchmark_common/prepare.sh | 0
.../benchmark_common/run_benchmark.sh | 0
.../gpt-3/codestyle/clang_format.hook | 0
.../model_zoo/gpt-3/codestyle/copyright.hook | 0
.../gpt-3/codestyle/cpplint_pre_commit.hook | 0
.../gpt-3/codestyle/docstring_checker.py | 0
.../gpt-3/codestyle/pylint_pre_commit.hook | 0
.../gpt-3/codestyle/test_docstring_checker.py | 0
.../gpt-3/docs/cluster_deployment.md | 0
.../model_zoo/gpt-3/docs/compression.md | 0
.../model_zoo/gpt-3/docs/deployment_faq.md | 0
.../model_zoo/gpt-3/docs/docker_install.md | 0
.../gpt-3/docs/images/fleetx_arc.png | Bin
.../gpt-3/docs/images/throughput_compare.png | Bin
.../docs/images/throughput_compare_graph.png | Bin
.../model_zoo/gpt-3/docs/quick_start.md | 0
.../model_zoo/gpt-3/docs/standard.md | 0
.../model_zoo/gpt-3/external_ops/.gitignore | 0
.../model_zoo/gpt-3/external_ops/fast_ln/ln.h | 0
.../gpt-3/external_ops/fast_ln/ln_api.cpp | 0
.../external_ops/fast_ln/ln_bwd_kernels.h | 0
.../fast_ln/ln_bwd_semi_cuda_kernel.cu | 0
.../fast_ln/ln_fwd_cuda_kernel.cu | 0
.../external_ops/fast_ln/ln_fwd_kernels.h | 0
.../external_ops/fast_ln/ln_kernel_traits.h | 0
.../gpt-3/external_ops/fast_ln/ln_utils.h | 0
.../external_ops/fused_ln/layer_norm_cuda.cu | 0
.../external_ops/fused_ln/layer_norm_cuda.h | 0
.../model_zoo/gpt-3/external_ops/setup.py | 0
.../model_zoo/gpt-3/ppfleetx/__init__.py | 0
.../gpt/auto/export_gpt_fp16_single_card.yaml | 0
.../nlp/gpt/auto/generation_gpt_13B_mp8.yaml | 0
.../nlp/gpt/auto/generation_gpt_175B_mp8.yaml | 0
.../nlp/gpt/auto/generation_gpt_345M_mp2.yaml | 0
.../auto/generation_gpt_345M_single_card.yaml | 0
.../nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml | 0
.../nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml | 0
.../auto/pretrain_gpt_1.3B_dp8_tuning.yaml | 0
.../auto/pretrain_gpt_1.3B_single_card.yaml | 0
.../gpt/auto/pretrain_gpt_13B_sharding8.yaml | 0
.../auto/pretrain_gpt_345M_single_card.yaml | 0
...etrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml | 0
.../auto/pretrain_gpt_6.7B_sharding16.yaml | 0
.../nlp/gpt/auto/pretrain_gpt_base.yaml | 0
.../nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml | 0
.../gpt/auto/qat_generation_gpt_345M_mp2.yaml | 0
.../nlp/gpt/eval_gpt_345M_single_card.yaml | 0
.../gpt/eval_pruned_gpt_345M_single_card.yaml | 0
.../gpt/eval_qat_gpt_345M_single_card.yaml | 0
.../gpt/export_qat_gpt_345M_single_card.yaml | 0
.../finetune_gpt_345M_single_card_glue.yaml | 0
.../configs/nlp/gpt/finetune_gpt_base.yaml | 0
.../nlp/gpt/generation_gpt_345M_dp8.yaml | 0
.../nlp/gpt/generation_gpt_345M_mp1.yaml | 0
.../gpt/generation_gpt_345M_single_card.yaml | 0
.../gpt/generation_gpt_6.7B_single_mp1.yaml | 0
...eneration_pruned_gpt_345M_single_card.yaml | 0
.../generation_qat_gpt_345M_single_card.yaml | 0
.../generation_qat_gpt_6.7B_single_card.yaml | 0
.../nlp/gpt/inference_gpt_345M_dp8.yaml | 0
.../gpt/inference_gpt_345M_single_card.yaml | 0
.../nlp/gpt/pretrain_gpt_1.3B_dp8.yaml | 0
.../nlp/gpt/pretrain_gpt_1.3B_sep8.yaml | 0
.../gpt/pretrain_gpt_1.3B_single_card.yaml | 0
.../configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml | 0
.../nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml | 0
.../gpt/pretrain_gpt_345M_single_card.yaml | 0
.../nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml | 0
.../gpt/pretrain_gpt_6.7B_single_card.yaml | 0
.../configs/nlp/gpt/pretrain_gpt_base.yaml | 0
.../gpt/pretrain_gpt_cn_345M_single_card.yaml | 0
.../nlp/gpt/prune_gpt_345M_single_card.yaml | 0
.../configs/nlp/gpt/qat_gpt_345M_mp8.yaml | 0
.../nlp/gpt/qat_gpt_345M_single_card.yaml | 0
.../nlp/gpt/qat_gpt_6.7B_sharding16.yaml | 0
.../model_zoo/gpt-3/ppfleetx/core/__init__.py | 0
.../gpt-3/ppfleetx/core/engine/__init__.py | 0
.../gpt-3/ppfleetx/core/engine/auto_engine.py | 0
.../ppfleetx/core/engine/basic_engine.py | 0
.../ppfleetx/core/engine/eager_engine.py | 0
.../ppfleetx/core/engine/inference_engine.py | 0
.../gpt-3/ppfleetx/core/module/__init__.py | 0
.../ppfleetx/core/module/basic_module.py | 0
.../model_zoo/gpt-3/ppfleetx/data/__init__.py | 0
.../ppfleetx/data/data_tools/__init__.py | 0
.../ppfleetx/data/data_tools/cpp/Makefile | 0
.../ppfleetx/data/data_tools/cpp/__init__.py | 0
.../ppfleetx/data/data_tools/cpp/compile.py | 0
.../data_tools/cpp/fast_index_map_helpers.cpp | 0
.../ppfleetx/data/data_tools/gpt/README.md | 0
.../ppfleetx/data/data_tools/gpt/__init__.py | 0
.../data/data_tools/gpt/preprocess_data.py | 0
.../data/data_tools/gpt/raw_trans_to_json.py | 0
.../gpt-3/ppfleetx/data/dataset/__init__.py | 0
.../ppfleetx/data/dataset/glue_dataset.py | 0
.../ppfleetx/data/dataset/gpt_dataset.py | 0
.../gpt-3/ppfleetx/data/sampler/__init__.py | 0
.../ppfleetx/data/sampler/batch_sampler.py | 0
.../gpt-3/ppfleetx/data/sampler/collate.py | 0
.../ppfleetx/data/tokenizers/__init__.py | 0
.../ppfleetx/data/tokenizers/gpt_tokenizer.py | 0
.../tokenizers/tokenization_utils_base.py | 0
.../ppfleetx/data/transforms/__init__.py | 0
.../ppfleetx/data/transforms/preprocess.py | 0
.../gpt-3/ppfleetx/data/transforms/utils.py | 0
.../gpt-3/ppfleetx/data/utils/__init__.py | 0
.../ppfleetx/data/utils/batch_collate_fn.py | 0
.../gpt-3/ppfleetx/distributed/__init__.py | 0
.../ppfleetx/distributed/apis/__init__.py | 0
.../ppfleetx/distributed/apis/auto_env.py | 0
.../ppfleetx/distributed/apis/comm_groups.py | 0
.../gpt-3/ppfleetx/distributed/apis/env.py | 0
.../gpt-3/ppfleetx/distributed/apis/io.py | 0
.../ppfleetx/distributed/apis/strategy.py | 0
.../gpt-3/ppfleetx/models/__init__.py | 0
.../models/language_model/__init__.py | 0
.../models/language_model/auto_utils.py | 0
.../models/language_model/gpt/__init__.py | 0
.../language_model/gpt/auto/__init__.py | 0
.../language_model/gpt/auto/auto_model.py | 0
.../language_model/gpt/auto/auto_module.py | 0
.../language_model/gpt/dygraph/__init__.py | 0
.../gpt/dygraph/hybrid_model.py | 0
.../language_model/gpt/dygraph/processor.py | 0
.../gpt/dygraph/single_model.py | 0
.../models/language_model/language_module.py | 0
.../ppfleetx/models/language_model/metrics.py | 0
.../ppfleetx/models/language_model/utils.py | 0
.../gpt-3/ppfleetx/ops/fused_layers.py | 0
.../gpt-3/ppfleetx/ops/setup_cuda.py | 0
.../gpt-3/ppfleetx/ops/test_topp_sampling.py | 0
.../gpt-3/ppfleetx/ops/topp_sampling.cu | 0
.../gpt-3/ppfleetx/optims/__init__.py | 0
.../gpt-3/ppfleetx/optims/grad_clip.py | 0
.../gpt-3/ppfleetx/optims/lr_scheduler.py | 0
.../gpt-3/ppfleetx/optims/optimizer.py | 0
.../gpt-3/ppfleetx/tools/__init__.py | 0
.../gpt-3/ppfleetx/tools/multiprocess_tool.py | 0
.../gpt-3/ppfleetx/utils/__init__.py | 0
.../gpt-3/ppfleetx/utils/auto_config.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/check.py | 0
.../ppfleetx/utils/compression_helper.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/config.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/device.py | 0
.../gpt-3/ppfleetx/utils/download.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/export.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/file.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/log.py | 0
.../ppfleetx/utils/tensor_fusion_helper.py | 0
.../model_zoo/gpt-3/ppfleetx/utils/version.py | 0
.../projects/gpt/auto_export_gpt_13B_mp8.sh | 0
.../projects/gpt/auto_export_gpt_175B_mp8.sh | 0
.../projects/gpt/auto_export_gpt_345M_mp2.sh | 0
.../gpt/auto_export_gpt_345M_single_card.sh | 0
.../projects/gpt/auto_export_gpt_6.7B_mp1.sh | 0
.../gpt/auto_export_gpt_fp16_single_card.sh | 0
.../gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh | 0
.../projects/gpt/auto_gpt_1.3B_dp8_tuning.sh | 0
.../projects/gpt/auto_gpt_1.3B_single_card.sh | 0
.../projects/gpt/auto_gpt_13B_sharding8.sh | 0
.../projects/gpt/auto_gpt_345M_single_card.sh | 0
.../auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh | 0
.../projects/gpt/auto_gpt_6.7B_sharding16.sh | 0
.../gpt/auto_qat_export_gpt_345M_mp2.sh | 0
.../model_zoo/gpt-3/projects/gpt/benchmark.py | 0
.../gpt-3/projects/gpt/docs/README.md | 0
.../gpt-3/projects/gpt/docs/auto_parallel.md | 2 +-
.../projects/gpt/docs/hybrid_parallel.md | 0
.../projects/gpt/docs/hybrid_profiler.md | 0
.../gpt-3/projects/gpt/docs/inference.md | 0
.../gpt/docs/quantization_aware_training.md | 0
.../gpt-3/projects/gpt/docs/single_card.md | 0
.../projects/gpt/docs/single_finetune.md | 0
.../projects/gpt/docs/structured_pruning.md | 0
.../gpt/eval_prune_gpt_345M_single_card.sh | 0
.../gpt/eval_qat_gpt_345M_single_card.sh | 0
.../gpt/evaluate_gpt_345M_single_card.sh | 0
.../gpt/export_gpt_345M_single_card.sh | 0
.../gpt/export_prune_gpt_345M_single_card.sh | 0
.../gpt/export_qat_gpt_345M_single_card.sh | 0
.../gpt/finetune_gpt_345M_single_card.sh | 0
.../model_zoo/gpt-3/projects/gpt/inference.py | 0
.../gpt/inference_gpt_6.7B_single_card.sh | 0
.../projects/gpt/inference_gpt_multigpu.sh | 0
.../projects/gpt/inference_gpt_single_card.sh | 0
.../projects/gpt/pretrain_gpt_1.3B_dp8.sh | 0
.../projects/gpt/pretrain_gpt_1.3B_sep8.sh | 0
.../gpt/pretrain_gpt_1.3B_single_card.sh | 0
.../gpt/pretrain_gpt_175B_mp8_pp16.sh | 0
.../gpt/pretrain_gpt_345M_single_card.sh | 0
.../gpt/pretrain_gpt_6.7B_sharding16.sh | 0
.../gpt/prune_gpt_345M_single_card.sh | 0
.../gpt-3/projects/gpt/qat_gpt_345M_mp8.sh | 0
.../projects/gpt/qat_gpt_345M_single_card.sh | 0
.../projects/gpt/qat_gpt_6.7B_sharding16.sh | 0
.../gpt-3/projects/gpt/run_benchmark.sh | 0
.../model_zoo/gpt-3/requirements.txt | 0
{legacy => slm}/model_zoo/gpt-3/run_mp8.sh | 0
.../model_zoo/gpt-3/tasks/gpt/generation.py | 0
.../model_zoo/gpt-3/tasks/gpt/inference.py | 0
.../gpt-3/tasks/gpt/run_generation.sh | 0
.../model_zoo/gpt-3/tasks/gpt/train_pir.py | 0
{legacy => slm}/model_zoo/gpt-3/tools/auto.py | 0
.../model_zoo/gpt-3/tools/auto_export.py | 0
{legacy => slm}/model_zoo/gpt-3/tools/eval.py | 0
.../model_zoo/gpt-3/tools/export.py | 0
.../model_zoo/gpt-3/tools/inference.py | 0
.../model_zoo/gpt-3/tools/train.py | 0
slm/model_zoo/luke/README.md | 91 ++
{legacy => slm}/model_zoo/luke/args.py | 0
.../model_zoo/luke/open_entity_processor.py | 0
.../model_zoo/luke/run_open_entity.py | 0
{legacy => slm}/model_zoo/luke/run_squad.py | 0
.../model_zoo/megatronbert/README.md | 16 +-
.../model_zoo/megatronbert/args.py | 0
.../model_zoo/megatronbert/run_glue.py | 0
.../model_zoo/megatronbert/run_squad.py | 0
{legacy => slm}/model_zoo/moe/data_tools | 0
{legacy => slm}/model_zoo/moe/dygraph/args.py | 0
.../model_zoo/moe/dygraph/checkpointing.py | 0
.../model_zoo/moe/dygraph/dataset.py | 0
.../moe/dygraph/framework/__init__.py | 0
.../moe/dygraph/framework/group_sharded.py | 0
.../moe/dygraph/framework/storage_process.py | 0
.../model_zoo/moe/dygraph/modeling.py | 0
{legacy => slm}/model_zoo/moe/dygraph/run.sh | 0
.../model_zoo/moe/dygraph/run_moe_pretrain.py | 0
.../model_zoo/moe/dygraph/sync_files.sh | 0
.../model_zoo/moe/dygraph/utils.py | 0
{legacy => slm}/model_zoo/mpnet/README.md | 34 +-
{legacy => slm}/model_zoo/mpnet/convert.py | 0
.../model_zoo/mpnet/glue/predict.sh | 0
.../model_zoo/mpnet/glue/run_glue.py | 0
.../model_zoo/mpnet/glue/run_predict.py | 0
{legacy => slm}/model_zoo/mpnet/glue/train.sh | 0
.../model_zoo/mpnet/squad/run_squad.py | 0
{legacy => slm}/model_zoo/plato-xl/README.md | 2 +-
{legacy => slm}/model_zoo/rembert/README.md | 18 +-
.../model_zoo/rembert/data_processor.py | 0
{legacy => slm}/model_zoo/rembert/main.py | 0
{legacy => slm}/model_zoo/rembert/trainer.py | 0
{legacy => slm}/model_zoo/roberta/README.md | 38 +-
.../model_zoo/roberta/create_data.py | 0
.../model_zoo/roberta/run_pretrain.py | 0
{legacy => slm}/model_zoo/roberta/utils.py | 0
{legacy => slm}/model_zoo/roformer/README.md | 42 +-
{legacy => slm}/model_zoo/roformer/convert.py | 0
.../model_zoo/roformer/run_cail2019_scm.py | 0
.../model_zoo/roformer/run_thucnews.py | 0
.../model_zoo/roformer/test_mlm.py | 0
{legacy => slm}/model_zoo/rw/README.md | 2 +-
.../model_zoo/rw/predict_generation.py | 0
{legacy => slm}/model_zoo/t5/README.md | 74 +-
{legacy => slm}/model_zoo/t5/convert.py | 0
{legacy => slm}/model_zoo/t5/data.py | 0
{legacy => slm}/model_zoo/t5/dataset_utils.py | 0
{legacy => slm}/model_zoo/t5/glue_demo.py | 0
.../model_zoo/t5/run_clue_trainer.py | 0
{legacy => slm}/model_zoo/t5/run_glue.py | 0
.../model_zoo/t5/run_glue_trainer.py | 0
{legacy => slm}/model_zoo/t5/t5_dataset.py | 0
.../model_zoo/t5/t5_run_pretrain_trainer.py | 0
{legacy => slm}/model_zoo/t5/tests/t5_mp.py | 0
.../test_parallel_dygraph_dataparallel.py | 0
.../model_zoo/t5/tests/test_t5_mp.py | 0
{legacy => slm}/model_zoo/t5/utils.py | 0
.../model_zoo/t5/zero_shot_demo.py | 0
{legacy => slm}/model_zoo/tinybert/README.md | 52 +-
.../model_zoo/tinybert/data_augmentation.py | 0
.../model_zoo/tinybert/general_distill.py | 0
.../model_zoo/tinybert/imgs/tinybert.png | Bin
.../model_zoo/tinybert/task_distill.py | 0
.../model_zoo/transformer-xl/README.md | 0
{legacy => slm}/model_zoo/uie/README.md | 84 +-
.../model_zoo/uie/deploy/python/README.md | 8 +-
.../model_zoo/uie/deploy/python/infer.py | 0
.../deploy/serving/simple_serving/README.md | 16 +-
.../deploy/serving/simple_serving/client.py | 0
.../deploy/serving/simple_serving/server.py | 0
{legacy => slm}/model_zoo/uie/doccano.md | 80 +-
{legacy => slm}/model_zoo/uie/doccano.py | 0
{legacy => slm}/model_zoo/uie/evaluate.py | 0
{legacy => slm}/model_zoo/uie/finetune.py | 0
.../model_zoo/uie/labelstudio2doccano.py | 0
{legacy => slm}/model_zoo/uie/utils.py | 0
{legacy => slm}/model_zoo/xlm/README.md | 30 +-
{legacy => slm}/model_zoo/xlm/framework.jpg | Bin
{legacy => slm}/model_zoo/xlm/xnli_eval.py | 0
{legacy => slm}/model_zoo/xlm/xnli_train.py | 0
slm/model_zoo/xlnet/README.md | 7 +
{legacy => slm}/pipelines/.readthedocs.yaml | 0
{legacy => slm}/pipelines/API.md | 4 +-
{legacy => slm}/pipelines/FAQ.md | 60 +-
{legacy => slm}/pipelines/Makefile | 0
{legacy => slm}/pipelines/README.md | 56 +-
{legacy => slm}/pipelines/VERSION | 0
{legacy => slm}/pipelines/VERSION.txt | 0
.../pipelines/benchmarks/README.md | 10 +-
.../pipelines/benchmarks/requirements.txt | 0
.../benchmarks/retrieval_benchmarks.py | 0
{legacy => slm}/pipelines/docker/Dockerfile | 0
.../pipelines/docker/Dockerfile-GPU | 0
{legacy => slm}/pipelines/docker/README.md | 24 +-
.../pipelines/docker/create_index.sh | 0
.../pipelines/docker/dense_qa.yaml | 0
.../pipelines/docker/docker-compose-gpu.yml | 0
.../pipelines/docker/docker-compose.yml | 0
.../pipelines/docker/run_client.sh | 0
.../pipelines/docker/run_server.sh | 0
.../pipelines/docker/semantic_search.yaml | 0
{legacy => slm}/pipelines/docker/start.sh | 0
.../pipelines/docker/start_compose.sh | 0
{legacy => slm}/pipelines/docs/index.md | 56 +-
.../pipelines/docs/package/agents/agents.md | 0
.../pipelines/docs/package/agents/memory.md | 0
.../docs/package/docstore/elasticsearch.md | 0
.../pipelines/docs/package/docstore/faiss.md | 0
.../docs/package/docstore/milvus2.md | 0
.../docs/package/nodes/answer_extractor.md | 0
.../package/nodes/document_intelligence.md | 0
.../docs/package/nodes/file_converter.md | 0
.../pipelines/docs/package/nodes/llm.md | 0
.../pipelines/docs/package/nodes/other.md | 0
.../docs/package/nodes/preprocessor.md | 0
.../docs/package/nodes/question_generator.md | 0
.../pipelines/docs/package/nodes/ranker.md | 0
.../pipelines/docs/package/nodes/reader.md | 0
.../pipelines/docs/package/nodes/retriever.md | 0
.../docs/package/nodes/search_engine.md | 0
.../docs/package/nodes/sentiment_analysis.md | 0
.../package/pipelines/standard_pipelines.md | 0
.../docs/package/rest_api/application.md | 0
.../docs/package/rest_api/controller.md | 0
.../pipelines/docs/requirements.txt | 0
.../pipelines/examples/FAQ/Install_windows.md | 42 +-
.../pipelines/examples/FAQ/README.md | 56 +-
.../examples/FAQ/dense_faq_example.py | 0
.../pipelines/examples/FAQ/run_faq_server.sh | 0
.../pipelines/examples/FAQ/run_faq_web.sh | 0
.../examples/contrastive_training/README.md | 0
.../contrastive_training/arguments.py | 0
.../examples/contrastive_training/data.py | 0
.../data/toy_finetune_data.jsonl | 0
.../evaluation/__init__.py | 0
.../evaluation/benchmarks.py | 0
.../evaluation/mteb/eval_mteb.py | 4 +-
.../evaluation/mteb/mteb_models.py | 0
.../evaluation/mteb/mteb_models_nv.py | 55 +-
.../evaluation/prediction.py | 0
.../contrastive_training/models/__init__.py | 0
.../contrastive_training/models/modeling.py | 0
.../contrastive_training/requirements.txt | 0
.../examples/contrastive_training/train.py | 0
.../IMAGE_TO_TEXT_SEARCH.md | 24 +-
.../examples/image_text_retrieval/README.md | 26 +-
.../image_to_text_retrieval_example.py | 0
.../image_text_retrieval/run_search_server.sh | 0
.../image_text_retrieval/run_search_web.sh | 0
.../text_to_image_retrieval_example.py | 0
.../question-answering/Install_windows.md | 32 +-
.../examples/question-answering/README.md | 28 +-
.../question-answering/dense_qa_example.py | 0
.../question-answering/run_qa_server.sh | 0
.../examples/question-answering/run_qa_web.sh | 0
.../semantic-search/Install_windows.md | 36 +-
.../examples/semantic-search/Multi_Recall.md | 58 +-
.../examples/semantic-search/Neural_Search.md | 20 +-
.../examples/semantic-search/README.md | 36 +-
.../multi_recall_semantic_search_example.py | 0
.../run_neural_search_server.sh | 0
.../semantic-search/run_search_server.sh | 0
.../semantic-search/run_search_web.sh | 0
.../semantic_search_example.py | 0
.../examples/tree-of-thought/README.md | 6 +-
.../examples/tree-of-thought/demo.py | 0
.../examples/tree-of-thought/requirements.txt | 0
.../pipelines/examples/tree-of-thought/run.py | 0
.../tree-of-thought/src/llm/__init__.py | 0
.../src/llm/chat_template.json | 0
.../tree-of-thought/src/llm/ernie_bot.py | 0
.../examples/tree-of-thought/src/llm/llama.py | 0
.../tree-of-thought/src/tot/__init__.py | 0
.../tree-of-thought/src/tot/methods/bfs.py | 0
.../tree-of-thought/src/tot/models.py | 0
.../src/tot/prompts/crosswords.py | 0
.../tree-of-thought/src/tot/prompts/game24.py | 0
.../tree-of-thought/src/tot/prompts/text.py | 0
.../tree-of-thought/src/tot/tasks/__init__.py | 0
.../tree-of-thought/src/tot/tasks/base.py | 0
.../src/tot/tasks/crosswords.py | 0
.../tree-of-thought/src/tot/tasks/game24.py | 0
.../tree-of-thought/src/tot/tasks/text.py | 0
{legacy => slm}/pipelines/mkdocs.yml | 2 +-
.../pipelines/pipelines/__init__.py | 0
.../pipelines/pipelines/agents/__init__.py | 0
.../pipelines/pipelines/agents/agent_step.py | 0
.../pipelines/pipelines/agents/base.py | 0
.../pipelines/agents/memory/__init__.py | 0
.../pipelines/pipelines/agents/memory/base.py | 0
.../agents/memory/conversation_memory.py | 0
.../pipelines/agents/memory/no_memory.py | 0
.../pipelines/pipelines/agents/types.py | 0
.../pipelines/data_handler/__init__.py | 0
.../pipelines/data_handler/dataset.py | 0
.../pipelines/data_handler/inputs.py | 0
.../pipelines/data_handler/predictions.py | 0
.../pipelines/data_handler/processor.py | 0
.../pipelines/data_handler/samples.py | 0
.../pipelines/document_stores/__init__.py | 0
.../pipelines/document_stores/base.py | 0
.../document_stores/elasticsearch.py | 0
.../pipelines/document_stores/faiss.py | 0
.../pipelines/document_stores/filter_utils.py | 0
.../pipelines/document_stores/milvus2.py | 0
.../pipelines/document_stores/sql.py | 0
.../pipelines/document_stores/utils.py | 0
{legacy => slm}/pipelines/pipelines/errors.py | 0
.../pipelines/pipelines/nodes/__init__.py | 0
.../nodes/answer_extractor/__init__.py | 0
.../answer_extractor/answer_extractor.py | 0
.../answer_extractor_preprocessor.py | 0
.../nodes/answer_extractor/qa_filter.py | 0
.../qa_filter_postprocessor.py | 0
.../pipelines/pipelines/nodes/base.py | 0
.../nodes/combine_documents/__init__.py | 0
.../pipelines/nodes/combine_documents/base.py | 0
.../nodes/combine_documents/map_reduce.py | 0
.../nodes/combine_documents/reduce.py | 0
.../nodes/combine_documents/stuff.py | 0
.../pipelines/nodes/document/__init__.py | 0
.../nodes/document/document_intelligence.py | 0
.../nodes/document/document_preprocessor.py | 0
.../nodes/file_classifier/__init__.py | 0
.../nodes/file_classifier/file_type.py | 0
.../nodes/file_converter/__init__.py | 0
.../pipelines/nodes/file_converter/base.py | 0
.../pipelines/nodes/file_converter/docx.py | 0
.../pipelines/nodes/file_converter/image.py | 0
.../nodes/file_converter/markdown.py | 0
.../pipelines/nodes/file_converter/pdf.py | 0
.../pipelines/nodes/file_converter/txt.py | 0
.../pipelines/pipelines/nodes/llm/__init__.py | 0
.../pipelines/pipelines/nodes/llm/chatglm.py | 0
.../pipelines/nodes/llm/ernie_bot.py | 0
.../pipelines/pipelines/nodes/llm/history.py | 0
.../pipelines/nodes/llm/prompt_template.py | 0
.../pipelines/nodes/models/__init__.py | 0
.../nodes/models/neural_search_model.py | 0
.../pipelines/nodes/other/__init__.py | 0
.../pipelines/nodes/other/docs2answers.py | 0
.../pipelines/nodes/other/join_answers.py | 0
.../pipelines/nodes/other/join_docs.py | 0
.../pipelines/nodes/other/route_documents.py | 0
.../pipelines/nodes/preprocessor/__init__.py | 0
.../pipelines/nodes/preprocessor/base.py | 0
.../nodes/preprocessor/preprocessor.py | 0
.../nodes/preprocessor/text_splitter.py | 0
.../pipelines/nodes/prompt/__init__.py | 0
.../nodes/prompt/invocation_layer/__init__.py | 0
.../nodes/prompt/invocation_layer/base.py | 0
.../nodes/prompt/invocation_layer/chatglm.py | 0
.../nodes/prompt/invocation_layer/chatgpt.py | 0
.../prompt/invocation_layer/ernie_bot.py | 0
.../nodes/prompt/invocation_layer/handlers.py | 0
.../nodes/prompt/invocation_layer/open_ai.py | 0
.../pipelines/nodes/prompt/prompt_model.py | 0
.../pipelines/nodes/prompt/prompt_node.py | 0
.../pipelines/nodes/prompt/prompt_template.py | 0
.../pipelines/nodes/prompt/shapers.py | 0
.../nodes/question_generator/__init__.py | 0
.../question_generator/question_generator.py | 0
.../pipelines/nodes/ranker/__init__.py | 0
.../pipelines/pipelines/nodes/ranker/base.py | 0
.../pipelines/nodes/ranker/ernie_ranker.py | 0
.../pipelines/nodes/reader/__init__.py | 0
.../pipelines/pipelines/nodes/reader/base.py | 0
.../pipelines/nodes/reader/ernie_dureader.py | 0
.../pipelines/nodes/retriever/__init__.py | 0
.../pipelines/nodes/retriever/base.py | 0
.../nodes/retriever/base_embedding_encoder.py | 0
.../pipelines/nodes/retriever/dense.py | 0
.../pipelines/nodes/retriever/embedder.py | 0
.../nodes/retriever/ernie_encoder.py | 0
.../nodes/retriever/multimodal_retriever.py | 0
.../nodes/retriever/parallel_retriever.py | 0
.../pipelines/nodes/retriever/sparse.py | 0
.../pipelines/nodes/retriever/web.py | 0
.../pipelines/nodes/search_engine/__init__.py | 0
.../pipelines/nodes/search_engine/base.py | 0
.../nodes/search_engine/providers.py | 0
.../pipelines/nodes/search_engine/utils.py | 0
.../pipelines/nodes/search_engine/web.py | 0
.../nodes/sentiment_analysis/__init__.py | 0
.../nodes/sentiment_analysis/senta.py | 0
.../sentiment_analysis/senta_preprocessor.py | 0
.../sentiment_analysis/senta_visualization.py | 0
.../nodes/text_to_image_generator/__init__.py | 0
.../text_to_image_generator.py | 0
.../pipelines/pipelines/pipelines/__init__.py | 0
.../pipelines/pipelines/pipelines/base.py | 0
.../pipelines/pipelines/pipelines/config.py | 0
.../pipelines/pipelines/standard_pipelines.py | 0
.../pipelines/pipelines/pipelines/utils.py | 0
{legacy => slm}/pipelines/pipelines/schema.py | 0
.../pipelines/pipelines/utils/__init__.py | 0
.../pipelines/pipelines/utils/cleaning.py | 0
.../pipelines/pipelines/utils/common_utils.py | 0
.../pipelines/pipelines/utils/doc_store.py | 0
.../pipelines/pipelines/utils/export_utils.py | 0
.../pipelines/pipelines/utils/import_utils.py | 0
.../pipelines/pipelines/utils/logger.py | 0
.../pipelines/utils/preprocessing.py | 0
.../pipelines/pipelines/utils/tokenization.py | 0
.../pipelines/pipelines/version.py | 0
{legacy => slm}/pipelines/requirements.txt | 0
.../pipelines/rest_api/__init__.py | 0
.../pipelines/rest_api/application.py | 0
{legacy => slm}/pipelines/rest_api/config.py | 0
.../pipelines/rest_api/controller/__init__.py | 0
.../pipelines/rest_api/controller/document.py | 0
.../rest_api/controller/errors/__init__.py | 0
.../rest_api/controller/errors/http_error.py | 0
.../pipelines/rest_api/controller/feedback.py | 0
.../rest_api/controller/file_upload.py | 0
.../pipelines/rest_api/controller/router.py | 0
.../pipelines/rest_api/controller/search.py | 0
.../pipelines/rest_api/controller/utils.py | 0
.../pipelines/rest_api/pipeline/__init__.py | 0
.../pipelines/rest_api/pipeline/chatfile.yaml | 0
.../rest_api/pipeline/custom_component.py | 0
.../rest_api/pipeline/dense_faq.yaml | 0
.../pipelines/rest_api/pipeline/dense_qa.yaml | 0
.../rest_api/pipeline/docprompt.yaml | 0
.../pipeline/image_to_text_retrieval.yaml | 0
.../multi_recall_semantic_search.yaml | 0
.../rest_api/pipeline/pipelines.yaml | 0
.../pipeline/semantic_ernie_search_en.yaml | 0
.../rest_api/pipeline/semantic_search.yaml | 0
.../pipeline/semantic_search_custom.yaml | 0
.../rest_api/pipeline/semantic_search_en.yaml | 0
.../pipeline/semantic_search_milvus.yaml | 0
.../pipelines/rest_api/pipeline/senta.yaml | 0
.../rest_api/pipeline/text_to_image.yaml | 0
.../pipeline/text_to_image_retrieval.yaml | 0
.../rest_api/pipeline/unsupervised_qa.yaml | 0
{legacy => slm}/pipelines/rest_api/schema.py | 0
.../pipelines/rest_api/test/__init__.py | 0
.../pipelines/rest_api/test/test_rest_api.py | 0
{legacy => slm}/pipelines/setup.py | 0
{legacy => slm}/pipelines/tests/__init__.py | 0
.../pipelines/tests/agents/__init__.py | 0
.../pipelines/tests/agents/test_agent.py | 0
.../pipelines/tests/agents/test_agent_step.py | 0
.../pipelines/tests/agents/test_memory.py | 0
.../tests/agents/test_tools_manager.py | 0
{legacy => slm}/pipelines/tests/conftest.py | 0
.../tests/fixtures/example_docx.docx | Bin
.../tests/fixtures/example_markdown.md | 0
.../pipelines/tests/fixtures/example_pdf.pdf | Bin
.../test_combinedocuments.py | 0
.../tests/nodes/file_converter/test_docx.py | 0
.../nodes/file_converter/test_markdown.py | 0
.../tests/nodes/file_converter/test_pdf.py | 0
.../tests/nodes/llm/test_chatglm_bot.py | 0
.../tests/nodes/llm/test_ernie_bot.py | 0
.../pipelines/tests/nodes/llm/test_history.py | 0
.../tests/nodes/llm/test_prompt_template.py | 0
.../nodes/preprocessor/test_preprocessor.py | 0
.../nodes/preprocessor/test_text_splitter.py | 0
.../pipelines/tests/nodes/prompt/__init__.py | 0
.../pipelines/tests/nodes/prompt/conftest.py | 0
.../nodes/prompt/invocation_layer/__init__.py | 0
.../prompt/invocation_layer/test_chatglm.py | 0
.../prompt/invocation_layer/test_chatgpt.py | 0
.../prompt/invocation_layer/test_ernie_bot.py | 0
.../prompt/invocation_layer/test_openai.py | 0
.../tests/nodes/prompt/test_handlers.py | 0
.../tests/nodes/prompt/test_prompt_model.py | 0
.../tests/nodes/prompt/test_prompt_node.py | 0
.../nodes/prompt/test_prompt_template.py | 0
.../tests/pipelines/test_chatbot_pipeline.py | 0
.../pipelines/tests/requirements.txt | 0
{legacy => slm}/pipelines/ui/__init__.py | 0
{legacy => slm}/pipelines/ui/baike_qa.csv | 0
.../pipelines/ui/country_search.csv | 0
.../pipelines/ui/dureader_search.csv | 0
.../pipelines/ui/insurance_faq.csv | 0
{legacy => slm}/pipelines/ui/utils.py | 0
.../pipelines/ui/webapp_chatfile_gradio.py | 0
.../pipelines/ui/webapp_docprompt_gradio.py | 0
{legacy => slm}/pipelines/ui/webapp_faq.py | 0
.../ui/webapp_image_to_text_retrieval.py | 0
.../ui/webapp_multi_recall_semantic_search.py | 0
.../pipelines/ui/webapp_question_answering.py | 0
.../pipelines/ui/webapp_semantic_search.py | 0
{legacy => slm}/pipelines/ui/webapp_senta.py | 0
.../pipelines/ui/webapp_text_to_image.py | 0
.../ui/webapp_text_to_image_retrieval.py | 0
.../webapp_unsupervised_question_answering.py | 0
{legacy => slm}/pipelines/utils/__init__.py | 0
.../pipelines/utils/offline_ann.py | 0
.../pipelines/utils/offline_ann_mm.py | 0
.../benchmark_common/prepare.sh | 2 +-
.../test_tipc/benchmark/modules/ernie_tiny.py | 2 +-
...base_seqlen128_cinn_train_infer_python.txt | 2 +-
.../configs/bert/base/train_infer_python.txt | 2 +-
.../configs/bert/large/train_infer_python.txt | 2 +-
.../configs/gpt2/train_infer_python.txt | 2 +-
.../configs/gpt3/train_infer_python.txt | 2 +-
.../configs/llama/train_infer_python.txt | 2 +-
.../base/train_dy2static_python.txt | 2 +-
.../transformer/base/train_infer_python.txt | 8 +-
.../base/transformer_base_static_params.txt | 2 +-
.../big/train_dy2static_python.txt | 2 +-
.../transformer/big/train_infer_python.txt | 8 +-
.../big/transformer_big_static_params.txt | 2 +-
.../baichun2/benchmark_common/prepare.sh | 2 +-
.../gpt/benchmark_common/prepare.sh | 4 +-
.../gpt/benchmark_common/run_benchmark.sh | 4 +-
.../llama/benchmark_common/prepare.sh | 2 +-
.../llama2/benchmark_common/prepare.sh | 2 +-
.../qwen/benchmark_common/prepare.sh | 2 +-
.../moe/gpt/benchmark_common/prepare.sh | 4 +-
.../moe/gpt/benchmark_common/run_benchmark.sh | 4 +-
tests/test_tipc/prepare.sh | 18 +-
.../llama2/benchmark_common/prepare.sh | 2 +-
.../dp/bert/benchmark_common/run_benchmark.sh | 2 +-
.../static/dp/gpt/benchmark_common/prepare.sh | 4 +-
.../dp/gpt/benchmark_common/run_benchmark.sh | 4 +-
.../gpt/benchmark_common/prepare.sh | 4 +-
.../gpt/benchmark_common/run_benchmark.sh | 6 +-
2107 files changed, 6427 insertions(+), 5331 deletions(-)
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
delete mode 100644 legacy/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
delete mode 100644 legacy/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
delete mode 100644 legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
delete mode 100644 legacy/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
delete mode 100644 legacy/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
delete mode 100644 legacy/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
delete mode 100644 legacy/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
delete mode 100644 legacy/applications/neural_search/recall/milvus/scripts/feature_extract.sh
delete mode 100644 legacy/applications/neural_search/recall/milvus/scripts/search.sh
delete mode 100644 legacy/applications/neural_search/recall/simcse/deploy/python/deploy.sh
delete mode 100755 legacy/applications/neural_search/recall/simcse/scripts/evaluate.sh
delete mode 100644 legacy/applications/neural_search/recall/simcse/scripts/export_model.sh
delete mode 100644 legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
delete mode 100644 legacy/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
delete mode 100644 legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
delete mode 100644 legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
delete mode 100644 legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
delete mode 100755 legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
delete mode 100644 legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
delete mode 100644 legacy/examples/benchmark/ceval/README.md
delete mode 100644 legacy/examples/information_extraction/DuIE/README.md
delete mode 100644 legacy/examples/information_extraction/DuIE/predict.sh
delete mode 100644 legacy/examples/machine_translation/transformer/tls/distributed_utils.py
delete mode 100755 legacy/examples/model_interpretation/download.sh
delete mode 100644 legacy/examples/model_interpretation/task/senti/LIME/exceptions.py
delete mode 100755 legacy/examples/model_interpretation/task/senti/rnn/lstm_train.sh
delete mode 100644 legacy/examples/model_interpretation/task/similarity/LIME/exceptions.py
delete mode 100755 legacy/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
delete mode 100644 legacy/examples/multimodal/layoutlm/train_funsd.sh
delete mode 100644 legacy/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
delete mode 100644 legacy/examples/text_classification/README.md
delete mode 100644 legacy/examples/text_generation/vae-seq2seq/README.md
delete mode 100644 legacy/examples/text_matching/simcse/train.sh
delete mode 100644 legacy/examples/text_summarization/bart/README.md
delete mode 100644 legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
delete mode 100644 legacy/examples/text_to_knowledge/ernie-ctm/README.md
delete mode 100644 legacy/examples/torch_migration/docs/ThesisReproduction_NLP.md
delete mode 100644 legacy/model_zoo/electra/README.md
delete mode 100644 legacy/model_zoo/ernie-3.0-tiny/deploy/README.md
delete mode 100644 legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
delete mode 100644 legacy/model_zoo/ernie-doc/README.md
delete mode 100644 legacy/model_zoo/luke/README.md
delete mode 100644 legacy/model_zoo/xlnet/README.md
rename {legacy => slm}/applications/README.md (76%)
rename {legacy => slm}/applications/information_extraction/README.md (70%)
rename {legacy => slm}/applications/information_extraction/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/document/README.md (79%)
rename {legacy => slm}/applications/information_extraction/document/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/document/deploy/simple_serving/README.md (75%)
rename {legacy => slm}/applications/information_extraction/document/deploy/simple_serving/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/document/deploy/simple_serving/client.py (100%)
rename {legacy => slm}/applications/information_extraction/document/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/information_extraction/document/evaluate.py (100%)
rename {legacy => slm}/applications/information_extraction/document/finetune.py (100%)
rename {legacy => slm}/applications/information_extraction/document/utils.py (100%)
rename {legacy => slm}/applications/information_extraction/label_studio.py (100%)
rename {legacy => slm}/applications/information_extraction/label_studio_doc.md (83%)
rename {legacy => slm}/applications/information_extraction/label_studio_doc_en.md (100%)
rename {legacy => slm}/applications/information_extraction/label_studio_text.md (79%)
rename {legacy => slm}/applications/information_extraction/label_studio_text_en.md (100%)
rename {legacy => slm}/applications/information_extraction/taskflow_doc.md (77%)
rename {legacy => slm}/applications/information_extraction/taskflow_doc_en.md (100%)
rename {legacy => slm}/applications/information_extraction/taskflow_text.md (88%)
rename {legacy => slm}/applications/information_extraction/taskflow_text_en.md (100%)
rename {legacy => slm}/applications/information_extraction/text/README.md (79%)
rename {legacy => slm}/applications/information_extraction/text/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/README.md (73%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/criterion.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/data_collator.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/data_distill.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md (79%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/deploy/simple_serving/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/deploy/simple_serving/client.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/evaluate.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/evaluate_teacher.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/metric.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/train.py (100%)
rename {legacy => slm}/applications/information_extraction/text/data_distill/utils.py (100%)
rename {legacy => slm}/applications/information_extraction/text/deploy/simple_serving/README.md (78%)
rename {legacy => slm}/applications/information_extraction/text/deploy/simple_serving/README_en.md (100%)
rename {legacy => slm}/applications/information_extraction/text/deploy/simple_serving/client.py (100%)
rename {legacy => slm}/applications/information_extraction/text/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/information_extraction/text/evaluate.py (100%)
rename {legacy => slm}/applications/information_extraction/text/finetune.py (100%)
rename {legacy => slm}/applications/information_extraction/text/utils.py (100%)
rename {legacy => slm}/applications/neural_search/README.md (82%)
rename {legacy => slm}/applications/neural_search/img/attu.png (100%)
rename {legacy => slm}/applications/neural_search/img/system_pipeline.png (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/README.md (92%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/data.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/cpp/http_client.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/cpp/rpc_client.py (100%)
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/python/config_nlp.yml (100%)
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/python/predict.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/evaluate.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/export_model.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/export_to_serving.py (99%)
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/predict.py (100%)
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
create mode 100644 slm/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
rename {legacy => slm}/applications/neural_search/ranking/cross_encoder/train_ce.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/README.md (91%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/data.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/cpp/http_client.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/cpp/rpc_client.py (100%)
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/python/config_nlp.yml (100%)
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/python/predict.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/evaluate.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/export_model.py (100%)
rename {legacy/applications/text_classification/multi_label/retrieval_based => slm/applications/neural_search/ranking/ernie_matching}/export_to_serving.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/model.py (100%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/predict_pairwise.py (100%)
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
create mode 100644 slm/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh (50%)
rename {legacy => slm}/applications/neural_search/ranking/ernie_matching/train_pairwise.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/README.md (85%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/ann_util.py (99%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/base_model.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/batch_negative/model.py (100%)
rename {legacy/applications/neural_search/recall/milvus => slm/applications/neural_search/recall/in_batch_negative}/data.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/cpp/http_client.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/cpp/rpc_client.py (100%)
create mode 100644 slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/python/config_nlp.yml (100%)
create mode 100644 slm/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/python/predict.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/evaluate.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/export_model.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/export_to_serving.py (99%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/inference.py (98%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/predict.py (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/recall.py (100%)
create mode 100644 slm/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
create mode 100644 slm/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
create mode 100644 slm/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/scripts/predict.sh (51%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/scripts/run_build_index.sh (100%)
rename {legacy => slm}/applications/neural_search/recall/in_batch_negative/train_batch_neg.py (100%)
rename {legacy => slm}/applications/neural_search/recall/milvus/README.md (89%)
rename {legacy => slm}/applications/neural_search/recall/milvus/base_model.py (100%)
rename {legacy => slm}/applications/neural_search/recall/milvus/config.py (100%)
rename {legacy/applications/neural_search/recall/in_batch_negative => slm/applications/neural_search/recall/milvus}/data.py (99%)
rename {legacy => slm}/applications/neural_search/recall/milvus/feature_extract.py (100%)
rename {legacy => slm}/applications/neural_search/recall/milvus/inference.py (100%)
rename {legacy => slm}/applications/neural_search/recall/milvus/milvus_ann_search.py (100%)
rename {legacy => slm}/applications/neural_search/recall/milvus/milvus_util.py (100%)
create mode 100644 slm/applications/neural_search/recall/milvus/scripts/feature_extract.sh
create mode 100644 slm/applications/neural_search/recall/milvus/scripts/search.sh
rename {legacy => slm}/applications/neural_search/recall/simcse/README.md (87%)
rename {legacy/examples/semantic_indexing => slm/applications/neural_search/recall/simcse}/ann_util.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/data.py (100%)
create mode 100644 slm/applications/neural_search/recall/simcse/deploy/python/deploy.sh
rename {legacy => slm}/applications/neural_search/recall/simcse/deploy/python/predict.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/evaluate.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/export_model.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/inference.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/model.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/predict.py (100%)
rename {legacy => slm}/applications/neural_search/recall/simcse/recall.py (100%)
create mode 100755 slm/applications/neural_search/recall/simcse/scripts/evaluate.sh
create mode 100644 slm/applications/neural_search/recall/simcse/scripts/export_model.sh
rename {legacy => slm}/applications/neural_search/recall/simcse/scripts/predict.sh (50%)
rename {legacy => slm}/applications/neural_search/recall/simcse/scripts/run_build_index.sh (64%)
rename {legacy => slm}/applications/neural_search/recall/simcse/scripts/train.sh (69%)
rename {legacy => slm}/applications/neural_search/recall/simcse/train.py (100%)
rename {legacy => slm}/applications/neural_search/requirements.txt (100%)
rename {legacy => slm}/applications/neural_search/run_system.py (100%)
rename {legacy => slm}/applications/question_answering/README.md (68%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/README.md (71%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/evaluate.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/finetune.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/span.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/utils.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/question_generation/gen_utils.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/question_generation/predict.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/finetune/question_generation/train.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/run_corpus_preparation.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/run_data_preprocess.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/run_pipelines_example.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/run_qa_pairs_generation.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/tools/create_synthetic_answer.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/tools/create_synthetic_question.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/tools/dev_qq_pair_creation.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/tools/json_format_indent.py (100%)
rename {legacy => slm}/applications/question_answering/unsupervised_qa/tools/question_coverage.py (100%)
rename {legacy => slm}/applications/text_classification/README.md (72%)
rename {legacy => slm}/applications/text_classification/doccano.md (79%)
rename {legacy => slm}/applications/text_classification/doccano.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/README.md (74%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/README.md (78%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/aug.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/dirty.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/evaluate.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/sent_interpret.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/sparse.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/analysis/word_interpret.ipynb (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/paddle_serving/README.md (71%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/paddle_serving/config.yml (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/paddle_serving/http_client.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/paddle_serving/rpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/paddle_serving/service.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/predictor/README.md (56%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/predictor/infer.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/predictor/predictor.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/simple_serving/README.md (70%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/simple_serving/client.py (99%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/simple_serving/ernie_m_server.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/README.md (61%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_model/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/deploy/triton_serving/seqcls_grpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/export_model.py (99%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/README.md (86%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/infer.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/metric.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/requirements_cpu.txt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/requirements_gpu.txt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/train.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/few-shot/utils.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/metric.py (97%)
rename {legacy => slm}/applications/text_classification/hierarchical/predict.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/prune.py (96%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/README.md (80%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/base_model.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/data.py (99%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/deploy/python/config_nlp.yml (100%)
create mode 100644 slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/deploy/python/predict.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/evaluate.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/export_model.py (100%)
rename {legacy/applications/neural_search/ranking/ernie_matching => slm/applications/text_classification/hierarchical/retrieval_based}/export_to_serving.py (99%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/model.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/predict.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/recall.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/requirements.txt (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/run_system.py (100%)
create mode 100644 slm/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
create mode 100644 slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
create mode 100644 slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh (50%)
create mode 100644 slm/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
create mode 100755 slm/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/scripts/train.sh (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/train.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/utils/__init__.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/utils/config.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/utils/feature_extract.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/utils/milvus_util.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/retrieval_based/utils/vector_insert.py (100%)
rename {legacy => slm}/applications/text_classification/hierarchical/train.py (100%)
rename {legacy/applications/text_classification/multi_label => slm/applications/text_classification/hierarchical}/utils.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/README.md (75%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/README.md (68%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/aug.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/dirty.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/sent_interpret.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/sparse.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/analysis/word_interpret.ipynb (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/simple_serving/README.md (65%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/simple_serving/client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/README.md (62%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_model/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/deploy/triton_serving/seqcls_grpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/README.md (83%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/infer.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/requirements_cpu.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/requirements_gpu.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/train.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/few-shot/utils.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/README.md (81%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/base_model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/data.py (99%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/deploy/python/config_nlp.yml (100%)
create mode 100644 slm/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/deploy/python/predict.py (100%)
rename {legacy/applications/text_classification/multi_label => slm/applications/text_classification/multi_class}/retrieval_based/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/evaluate.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/export_model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/export_to_serving.py (99%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/predict.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/recall.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/requirements.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/run_system.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/evaluate.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/export_model.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/export_to_serving.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/predict.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/run.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/run_build_index.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/scripts/train.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/train.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/utils/__init__.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/utils/config.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/utils/feature_extract.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/utils/milvus_util.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/retrieval_based/utils/vector_insert.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/train.py (100%)
rename {legacy => slm}/applications/text_classification/multi_class/utils.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/README.md (75%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/README.md (72%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/aug.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/dirty.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/evaluate.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/sent_interpret.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/sparse.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/analysis/word_interpret.ipynb (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/paddle_serving/README.md (73%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/paddle_serving/config.yml (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/paddle_serving/http_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/paddle_serving/rpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/paddle_serving/service.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/predictor/README.md (55%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/predictor/infer.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/predictor/predictor.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/simple_serving/README.md (70%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/simple_serving/client.py (99%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/simple_serving/ernie_m_server.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/README.md (59%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_model/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/1/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/config.pbtxt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/deploy/triton_serving/seqcls_grpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/export_model.py (99%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/README.md (83%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/infer.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/metric.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/requirements_cpu.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/requirements_gpu.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/train.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/few-shot/utils.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/metric.py (97%)
rename {legacy => slm}/applications/text_classification/multi_label/predict.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/prune.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/README.md (78%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/base_model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/data.py (99%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/deploy/python/config_nlp.yml (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/deploy/python/deploy.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/deploy/python/predict.py (100%)
rename {legacy/applications/text_classification/multi_class => slm/applications/text_classification/multi_label}/retrieval_based/deploy/python/rpc_client.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/deploy/python/web_service.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/evaluate.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/export_model.py (100%)
rename {legacy/applications/text_classification/hierarchical => slm/applications/text_classification/multi_label}/retrieval_based/export_to_serving.py (99%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/metric.py (97%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/model.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/predict.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/recall.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/requirements.txt (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/run_system.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/evaluate.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/export_model.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/export_to_serving.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/predict.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/run.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/run_build_index.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/scripts/train.sh (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/train.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/utils/__init__.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/utils/config.py (96%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/utils/feature_extract.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/utils/milvus_util.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/retrieval_based/utils/vector_insert.py (100%)
rename {legacy => slm}/applications/text_classification/multi_label/train.py (100%)
rename {legacy/applications/text_classification/hierarchical => slm/applications/text_classification/multi_label}/utils.py (100%)
rename {legacy => slm}/examples/README.md (97%)
rename {legacy => slm}/examples/RLHF/README.md (95%)
rename {legacy => slm}/examples/RLHF/comm_utils.py (100%)
rename {legacy => slm}/examples/RLHF/data/__init__.py (100%)
rename {legacy => slm}/examples/RLHF/data/alpaca.py (100%)
rename {legacy => slm}/examples/RLHF/data/base.py (99%)
rename {legacy => slm}/examples/RLHF/data/preference.py (100%)
rename {legacy => slm}/examples/RLHF/data/prompt_only.py (100%)
rename {legacy => slm}/examples/RLHF/data/safe_rlhf.py (100%)
rename {legacy => slm}/examples/RLHF/data/supervised.py (100%)
rename {legacy => slm}/examples/RLHF/infer_utils.py (100%)
rename {legacy => slm}/examples/RLHF/models/__init__.py (100%)
rename {legacy => slm}/examples/RLHF/models/infer_model_utils.py (100%)
rename {legacy => slm}/examples/RLHF/models/model_pp.py (100%)
rename {legacy => slm}/examples/RLHF/models/pp_model_utils.py (100%)
rename {legacy => slm}/examples/RLHF/models/ppo_model.py (100%)
rename {legacy => slm}/examples/RLHF/models/ppo_model_utils.py (100%)
rename {legacy => slm}/examples/RLHF/models/score_model.py (100%)
rename {legacy => slm}/examples/RLHF/models/score_model_utils.py (100%)
rename {legacy => slm}/examples/RLHF/ppo_config.json (100%)
rename {legacy => slm}/examples/RLHF/ppo_main.py (100%)
rename {legacy => slm}/examples/RLHF/ppo_trainer.py (100%)
rename {legacy => slm}/examples/RLHF/reward_config.json (100%)
rename {legacy => slm}/examples/RLHF/reward_main.py (100%)
rename {legacy => slm}/examples/RLHF/reward_trainer.py (100%)
rename {legacy => slm}/examples/RLHF/run.sh (100%)
rename {legacy => slm}/examples/RLHF/tests/run_model.py (100%)
rename {legacy => slm}/examples/RLHF/tests/test_export.py (100%)
rename {legacy => slm}/examples/RLHF/trainer_utils.py (100%)
create mode 100644 slm/examples/benchmark/ceval/README.md
rename {legacy => slm}/examples/benchmark/ceval/eval.py (100%)
rename {legacy => slm}/examples/benchmark/ceval/evaluator.py (100%)
rename {legacy => slm}/examples/benchmark/ceval/model_evaluator.py (100%)
rename {legacy => slm}/examples/benchmark/ceval/subject_mapping.json (100%)
rename {legacy => slm}/examples/benchmark/clue/README.md (97%)
rename {legacy => slm}/examples/benchmark/clue/classification/run_clue_classifier.py (100%)
rename {legacy => slm}/examples/benchmark/clue/classification/run_clue_classifier_trainer.py (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/draw_pic.py (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/extract_result.sh (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/grid_search.py (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/run_cls.sh (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/run_mrc.sh (100%)
rename {legacy => slm}/examples/benchmark/clue/grid_search_tools/warmup_dataset_and_model.py (100%)
rename {legacy => slm}/examples/benchmark/clue/mrc/run_c3.py (100%)
rename {legacy => slm}/examples/benchmark/clue/mrc/run_chid.py (100%)
rename {legacy => slm}/examples/benchmark/clue/mrc/run_cmrc2018.py (100%)
rename {legacy => slm}/examples/benchmark/glue/README.md (62%)
rename {legacy => slm}/examples/benchmark/glue/run_glue.py (100%)
rename {legacy => slm}/examples/benchmark/glue/run_glue_trainer.py (100%)
rename {legacy => slm}/examples/benchmark/llm/llama_single_gpu/benchmark.py (100%)
rename {legacy => slm}/examples/benchmark/llm/llama_single_gpu/benchmark_utils.py (100%)
rename {legacy => slm}/examples/benchmark/peft/README.md (95%)
rename {legacy => slm}/examples/benchmark/peft/paddle/benchmark.py (100%)
rename {legacy => slm}/examples/benchmark/peft/paddle/inference_benchmark.py (100%)
rename {legacy => slm}/examples/benchmark/peft/paddle/utils.py (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/benchmark.py (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/ds_config_stage2.json (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/ds_config_stage3.json (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/inference_benchmark.py (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/requirements.txt (100%)
rename {legacy => slm}/examples/benchmark/peft/torch/utils.py (100%)
rename {legacy => slm}/examples/benchmark/wiki_lambada/README.md (86%)
rename {legacy => slm}/examples/benchmark/wiki_lambada/eval.py (100%)
rename {legacy => slm}/examples/code_generation/codegen/README.md (74%)
rename {legacy => slm}/examples/code_generation/codegen/codegen_server.py (100%)
rename {legacy => slm}/examples/code_generation/codegen/requirements.txt (100%)
rename {legacy => slm}/examples/code_generation/codegen/run_clm.py (100%)
rename {legacy => slm}/examples/code_generation/codegen/run_clm.sh (100%)
rename {legacy => slm}/examples/dialogue/README_DGU.md (76%)
rename {legacy => slm}/examples/dialogue/README_LIC2021.md (64%)
rename {legacy => slm}/examples/dialogue/README_PLATO-2.md (77%)
rename {legacy => slm}/examples/dialogue/README_PLATO-XL.md (81%)
rename {legacy => slm}/examples/dialogue/README_UnifiedTransformer.md (67%)
rename {legacy => slm}/examples/dialogue/dgu/README.md (78%)
rename {legacy => slm}/examples/dialogue/dgu/args.py (100%)
rename {legacy => slm}/examples/dialogue/dgu/data.py (100%)
rename {legacy => slm}/examples/dialogue/dgu/main.py (97%)
rename {legacy => slm}/examples/dialogue/dgu/metric.py (99%)
rename {legacy => slm}/examples/dialogue/lic2021_baseline/README.md (66%)
rename {legacy => slm}/examples/dialogue/lic2021_baseline/args.py (100%)
rename {legacy => slm}/examples/dialogue/lic2021_baseline/data.py (100%)
rename {legacy => slm}/examples/dialogue/lic2021_baseline/finetune.py (100%)
rename {legacy => slm}/examples/dialogue/lic2021_baseline/infer.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/README.md (84%)
rename {legacy => slm}/examples/dialogue/plato-2/imgs/case.jpg (100%)
rename {legacy => slm}/examples/dialogue/plato-2/imgs/network.png (100%)
rename {legacy => slm}/examples/dialogue/plato-2/interaction.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/model.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/readers/dialog_reader.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/readers/nsp_reader.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/readers/plato_reader.py (99%)
rename {legacy => slm}/examples/dialogue/plato-2/utils/__init__.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/utils/args.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/utils/masking.py (100%)
rename {legacy => slm}/examples/dialogue/plato-2/utils/tokenization.py (100%)
rename {legacy => slm}/examples/dialogue/plato-xl (100%)
rename {legacy => slm}/examples/dialogue/unified_transformer/README.md (68%)
rename {legacy => slm}/examples/dialogue/unified_transformer/finetune.py (100%)
rename {legacy => slm}/examples/dialogue/unified_transformer/infer.py (100%)
rename {legacy => slm}/examples/dialogue/unified_transformer/interaction.py (100%)
rename {legacy => slm}/examples/dialogue/unified_transformer/utils.py (99%)
rename {legacy => slm}/examples/few_shot/README.md (100%)
rename {legacy => slm}/examples/few_shot/RGL/README.md (100%)
rename {legacy => slm}/examples/few_shot/RGL/data.py (100%)
rename {legacy => slm}/examples/few_shot/RGL/rgl.py (100%)
rename {legacy => slm}/examples/few_shot/RGL/scripts/run_pet.sh (83%)
rename {legacy => slm}/examples/few_shot/RGL/scripts/run_rgl.sh (83%)
rename {legacy => slm}/examples/few_shot/RGL/template.py (100%)
rename {legacy => slm}/examples/few_shot/RGL/tokenizer.py (100%)
rename {legacy => slm}/examples/few_shot/RGL/utils.py (100%)
rename {legacy => slm}/examples/few_shot/RGL/verbalizer.py (100%)
rename {legacy => slm}/examples/few_shot/efl/README.md (100%)
rename {legacy => slm}/examples/few_shot/efl/data.py (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/bustm.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/chid.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/cluewsc.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/csl.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/csldcp.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/eprstmt.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/iflytek.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/ocnli.json (100%)
rename {legacy => slm}/examples/few_shot/efl/prompt/tnews.json (100%)
rename {legacy => slm}/examples/few_shot/efl/run_train.py (100%)
rename {legacy => slm}/examples/few_shot/efl/utils.py (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/README.md (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/data.py (99%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/bustm.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/chid.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/cluewsc.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/csl.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/csldcp.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/eprstmt.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/iflytek.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/ocnli.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/prompt/tnews.json (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/run_train.py (100%)
rename {legacy => slm}/examples/few_shot/p-tuning/utils.py (100%)
rename {legacy => slm}/examples/few_shot/pet/README.md (100%)
rename {legacy => slm}/examples/few_shot/pet/data.py (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/bustm.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/chid.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/cluewsc.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/csl.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/csldcp.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/eprstmt.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/iflytek.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/ocnli.json (100%)
rename {legacy => slm}/examples/few_shot/pet/prompt/tnews.json (100%)
rename {legacy => slm}/examples/few_shot/pet/run_train.py (100%)
rename {legacy => slm}/examples/few_shot/pet/utils.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/README.md (66%)
rename {legacy => slm}/examples/information_extraction/DuEE/classifier.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/duee_1_data_prepare.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/duee_1_postprocess.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/duee_fin_data_prepare.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/duee_fin_postprocess.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/pictures/DuEE-Fin/ee.png (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/pictures/DuEE-Fin/enum_model.png (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/pictures/DuEE-Fin/role_model.png (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/pictures/DuEE-Fin/trigger_model.png (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/run_classifier.sh (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/run_duee_1.sh (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/run_duee_fin.sh (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/run_sequence_labeling.sh (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/sequence_labeling.py (100%)
rename {legacy => slm}/examples/information_extraction/DuEE/utils.py (100%)
create mode 100644 slm/examples/information_extraction/DuIE/README.md
rename {legacy => slm}/examples/information_extraction/DuIE/data/id2spo.json (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/data/predicate2id.json (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/data_loader.py (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/extract_chinese_and_punct.py (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/images/tagging_strategy.png (100%)
create mode 100644 slm/examples/information_extraction/DuIE/predict.sh
rename {legacy => slm}/examples/information_extraction/DuIE/re_official_evaluation.py (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/run_duie.py (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/train.sh (100%)
rename {legacy => slm}/examples/information_extraction/DuIE/utils.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/README.md (92%)
rename {legacy => slm}/examples/information_extraction/DuUIE/config/multi-task-duuie.yaml (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/inference.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/process_data.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/requirements.txt (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/run_seq2struct.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/__init__.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/evaluation/__init__.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/evaluation/constants.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/evaluation/scorer.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/evaluation/sel2record.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/seq2struct/__init__.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/seq2struct/data_collator.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/seq2struct/t5_bert_tokenizer.py (100%)
rename {legacy => slm}/examples/information_extraction/DuUIE/uie/seq2struct/utils.py (100%)
rename {legacy => slm}/examples/information_extraction/msra_ner/README.md (78%)
rename {legacy => slm}/examples/information_extraction/msra_ner/eval.py (100%)
rename {legacy => slm}/examples/information_extraction/msra_ner/predict.py (100%)
rename {legacy => slm}/examples/information_extraction/msra_ner/train.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/README.md (67%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/data.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/deploy/python/predict_bigru_crf.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/deploy/python/predict_ernie.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/deploy/python/predict_ernie_crf.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/download.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/export_bigru_crf_model.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/export_ernie_crf_model.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/export_ernie_model.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/model.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/run_bigru_crf.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/run_ernie.py (100%)
rename {legacy => slm}/examples/information_extraction/waybill_ie/run_ernie_crf.py (100%)
rename {legacy => slm}/examples/lexical_analysis/README.md (87%)
rename {legacy => slm}/examples/lexical_analysis/data.py (100%)
rename {legacy => slm}/examples/lexical_analysis/deploy/predict.py (100%)
rename {legacy => slm}/examples/lexical_analysis/download.py (100%)
rename {legacy => slm}/examples/lexical_analysis/eval.py (100%)
rename {legacy => slm}/examples/lexical_analysis/export_model.py (100%)
rename {legacy => slm}/examples/lexical_analysis/model.py (100%)
rename {legacy => slm}/examples/lexical_analysis/predict.py (100%)
rename {legacy => slm}/examples/lexical_analysis/train.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-robust/README.md (54%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-robust/args.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-robust/run_du.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-yesno/README.md (56%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-yesno/args.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/DuReader-yesno/run_du.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/SQuAD/README.md (75%)
rename {legacy => slm}/examples/machine_reading_comprehension/SQuAD/args.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/SQuAD/deploy/python/predict.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/SQuAD/export_model.py (100%)
rename {legacy => slm}/examples/machine_reading_comprehension/SQuAD/run_squad.py (100%)
rename {legacy => slm}/examples/machine_translation/README.md (100%)
rename {legacy => slm}/examples/machine_translation/preprocessor/prepare-iwslt14.sh (100%)
rename {legacy => slm}/examples/machine_translation/preprocessor/prepare-wmt14en2de.sh (100%)
rename {legacy => slm}/examples/machine_translation/preprocessor/prepare-wmt14en2fr.sh (100%)
rename {legacy => slm}/examples/machine_translation/preprocessor/preprocessor.py (100%)
rename {legacy => slm}/examples/machine_translation/requirements.txt (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/README.md (61%)
rename {legacy => slm}/examples/machine_translation/seq2seq/args.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/data.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/deploy/python/infer.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/export_model.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/predict.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/seq2seq_attn.py (100%)
rename {legacy => slm}/examples/machine_translation/seq2seq/train.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/README.md (99%)
rename {legacy => slm}/examples/machine_translation/transformer/configs/transformer.base.yaml (100%)
rename {legacy => slm}/examples/machine_translation/transformer/configs/transformer.big.yaml (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/CMakeLists.txt (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/README.md (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/helper.h (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/run.sh (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/run_impl.sh (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/cpp/transformer_e2e.cc (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/python/README.md (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/python/benchmark.sh (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/python/inference.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/python/tls/benchmark_utils.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/python/tls/recorder.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/README.md (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/benchmark.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/benchmark_serving.sh (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/export_serving_model.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/transformer_reader.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/transformer_web_client.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/transformer_web_server.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/deploy/serving/utils/recorder.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/export_model.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/images/multi_head_attention.png (100%)
rename {legacy => slm}/examples/machine_translation/transformer/images/transformer_network.png (100%)
rename {legacy => slm}/examples/machine_translation/transformer/predict.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/reader.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/static/predict.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/static/train.py (100%)
create mode 100644 slm/examples/machine_translation/transformer/tls/distributed_utils.py
rename {legacy => slm}/examples/machine_translation/transformer/tls/record.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/tls/to_static.py (100%)
rename {legacy => slm}/examples/machine_translation/transformer/train.py (100%)
rename {legacy => slm}/examples/model_compression/distill_lstm/README.md (58%)
rename {legacy => slm}/examples/model_compression/distill_lstm/args.py (100%)
rename {legacy => slm}/examples/model_compression/distill_lstm/bert_distill.py (100%)
rename {legacy => slm}/examples/model_compression/distill_lstm/data.py (100%)
rename {legacy => slm}/examples/model_compression/distill_lstm/small.py (100%)
rename {legacy => slm}/examples/model_compression/distill_lstm/utils.py (99%)
rename {legacy => slm}/examples/model_compression/minilmv2/README.md (72%)
rename {legacy => slm}/examples/model_compression/minilmv2/general_distill.py (100%)
rename {legacy => slm}/examples/model_compression/minilmv2/run_clue.py (100%)
rename {legacy => slm}/examples/model_compression/ofa/README.md (79%)
rename {legacy => slm}/examples/model_compression/ofa/export_model.py (100%)
rename {legacy => slm}/examples/model_compression/ofa/imgs/ofa_bert.jpg (100%)
rename {legacy => slm}/examples/model_compression/ofa/run_glue_ofa.py (100%)
rename {legacy => slm}/examples/model_compression/ofa/run_glue_ofa_depth.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/README.md (95%)
rename {legacy => slm}/examples/model_compression/pp-minilm/data.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/python/infer.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/python/infer_all.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/python/infer_perf.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/serving/README.md (91%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/serving/config_nlp.yml (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/serving/export_to_serving.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/serving/rpc_client.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/deploy/serving/web_service.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/finetuning/export_model.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/finetuning/run_all_search.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/finetuning/run_clue.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/finetuning/run_clue.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/finetuning/run_one_search.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/general_distill/README.md (77%)
rename {legacy => slm}/examples/model_compression/pp-minilm/general_distill/general_distill.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/general_distill/run.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pp-minilm.png (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pruning/export.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pruning/export_all.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pruning/export_model.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pruning/prune.py (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/pruning/prune.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/quantization/quant_all.sh (100%)
rename {legacy => slm}/examples/model_compression/pp-minilm/quantization/quant_post.py (100%)
rename {legacy => slm}/examples/model_interpretation/README.md (58%)
rename {legacy => slm}/examples/model_interpretation/data/mrc_ch (100%)
rename {legacy => slm}/examples/model_interpretation/data/mrc_en (100%)
rename {legacy => slm}/examples/model_interpretation/data/senti_ch (100%)
rename {legacy => slm}/examples/model_interpretation/data/senti_en (100%)
rename {legacy => slm}/examples/model_interpretation/data/similarity_ch (100%)
rename {legacy => slm}/examples/model_interpretation/data/similarity_en (100%)
create mode 100755 slm/examples/model_interpretation/download.sh
rename {legacy => slm}/examples/model_interpretation/evaluation/accuracy/cal_acc.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/accuracy/mrc_f1_evaluate.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/accuracy/run_acc.sh (58%)
rename {legacy => slm}/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh (58%)
rename {legacy => slm}/examples/model_interpretation/evaluation/consistency/cal_map.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/consistency/run_map.sh (58%)
rename {legacy => slm}/examples/model_interpretation/evaluation/faithfulness/newp_analysis.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/faithfulness/run_newp.sh (57%)
rename {legacy => slm}/examples/model_interpretation/evaluation/plausibility/eval_mrc.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/plausibility/eval_senti.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/plausibility/eval_similarity.py (100%)
rename {legacy => slm}/examples/model_interpretation/evaluation/plausibility/run_f1.sh (60%)
rename {legacy => slm}/examples/model_interpretation/imgs/equation1.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/equation2.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/equation3.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/equation4.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/equation5.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/example1.png (100%)
rename {legacy => slm}/examples/model_interpretation/imgs/structure.png (100%)
rename {legacy => slm}/examples/model_interpretation/punctuations (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/available_gpu.py (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/generate.sh (75%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/generate_evaluation_data.py (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh (54%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/mrc_pred.py (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/newp_text_generate.py (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh (74%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh (82%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh (79%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/sentiment_pred.py (100%)
rename {legacy => slm}/examples/model_interpretation/rationale_extraction/similarity_pred.py (100%)
rename {legacy => slm}/examples/model_interpretation/requirements.txt (100%)
rename {legacy => slm}/examples/model_interpretation/task/README.md (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/roberta/modeling.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/run_1_predict_rc.sh (78%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh (81%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/run_2_inter_rc.sh (76%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh (80%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/run_train_rc.sh (70%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/saliency_map/rc_finetune.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/saliency_map/rc_interpretable.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/saliency_map/rc_prediction.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/saliency_map/squad.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/mrc/saliency_map/utils.py (100%)
create mode 100644 slm/examples/model_interpretation/task/senti/LIME/exceptions.py
rename {legacy => slm}/examples/model_interpretation/task/senti/LIME/explanation.py (99%)
rename {legacy => slm}/examples/model_interpretation/task/senti/LIME/lime_base.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/LIME/lime_text.py (99%)
rename {legacy => slm}/examples/model_interpretation/task/senti/pretrained_models/run_train.sh (53%)
rename {legacy => slm}/examples/model_interpretation/task/senti/pretrained_models/train.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/pretrained_models/utils.py (100%)
create mode 100755 slm/examples/model_interpretation/task/senti/rnn/lstm_train.sh
rename {legacy => slm}/examples/model_interpretation/task/senti/rnn/model.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/rnn/tokenizer_config.json (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/rnn/train.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/rnn/utils.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/roberta/modeling.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/run_inter.sh (81%)
rename {legacy => slm}/examples/model_interpretation/task/senti/run_inter_all.sh (84%)
rename {legacy => slm}/examples/model_interpretation/task/senti/saliency_map/sentiment_interpretable.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/senti/saliency_map/utils.py (100%)
create mode 100644 slm/examples/model_interpretation/task/similarity/LIME/exceptions.py
rename {legacy => slm}/examples/model_interpretation/task/similarity/LIME/explanation.py (99%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/LIME/lime_base.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/LIME/lime_text.py (99%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/pretrained_models/data.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/pretrained_models/model.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/pretrained_models/predict_pointwise.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh (56%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/pretrained_models/train_pointwise.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/roberta/modeling.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/run_inter.sh (81%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/run_inter_all.sh (84%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/saliency_map/similarity_interpretable.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/saliency_map/utils.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/gen_vocab.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/interpreter_attention.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/interpreter_grad.py (100%)
create mode 100755 slm/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/model.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/predict.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/train.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/similarity/simnet/utils.py (100%)
rename {legacy => slm}/examples/model_interpretation/task/transformer.py (100%)
rename {legacy => slm}/examples/model_interpretation/utils.py (100%)
rename {legacy => slm}/examples/multimodal/layoutlm/README.md (62%)
rename {legacy => slm}/examples/multimodal/layoutlm/funsd.py (100%)
rename {legacy => slm}/examples/multimodal/layoutlm/preprocess.py (91%)
rename {legacy => slm}/examples/multimodal/layoutlm/preprocess.sh (53%)
rename {legacy => slm}/examples/multimodal/layoutlm/train_funsd.py (100%)
create mode 100644 slm/examples/multimodal/layoutlm/train_funsd.sh
rename {legacy => slm}/examples/multimodal/layoutlm/utils.py (100%)
rename {legacy => slm}/examples/multimodal/layoutxlm/README.md (74%)
rename {legacy => slm}/examples/multimodal/layoutxlm/compare.py (100%)
rename {legacy => slm}/examples/multimodal/layoutxlm/run_xfun_re.py (95%)
rename {legacy => slm}/examples/multimodal/layoutxlm/run_xfun_re.sh (50%)
rename {legacy => slm}/examples/multimodal/layoutxlm/run_xfun_ser.py (100%)
rename {legacy => slm}/examples/multimodal/layoutxlm/run_xfun_ser.sh (50%)
rename {legacy => slm}/examples/multimodal/layoutxlm/xfun.py (96%)
rename {legacy => slm}/examples/multimodal/minigpt4/README.md (62%)
rename {legacy => slm}/examples/multimodal/minigpt4/merge_weight.py (100%)
rename {legacy => slm}/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md (80%)
rename {legacy => slm}/examples/multimodal/minigpt4/run_predict.py (100%)
rename {legacy => slm}/examples/question_generation/README.md (61%)
rename {legacy => slm}/examples/question_generation/t5/README.md (71%)
rename {legacy => slm}/examples/question_generation/t5/predict.py (100%)
rename {legacy => slm}/examples/question_generation/t5/requirements.txt (100%)
rename {legacy => slm}/examples/question_generation/t5/train.py (100%)
rename {legacy => slm}/examples/question_generation/t5/utils.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/README.md (70%)
create mode 100644 slm/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_inference/infer_utils.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_inference/inference.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_serving/README.md (73%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_serving/config.yml (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_serving/infer_utils.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_client.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_service.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/export_model.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/gen_utils.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/predict.py (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/requirements.txt (100%)
rename {legacy => slm}/examples/question_generation/unimo-text/train.py (100%)
rename {legacy => slm}/examples/semantic_indexing/NQdataset.py (100%)
rename {legacy => slm}/examples/semantic_indexing/README.md (97%)
rename {legacy => slm}/examples/semantic_indexing/README_gradient_cache.md (86%)
rename {legacy => slm}/examples/semantic_indexing/ance/model.py (100%)
rename {legacy/applications/neural_search/recall/simcse => slm/examples/semantic_indexing}/ann_util.py (99%)
rename {legacy => slm}/examples/semantic_indexing/base_model.py (100%)
rename {legacy => slm}/examples/semantic_indexing/batch_negative/model.py (100%)
rename {legacy => slm}/examples/semantic_indexing/biencoder_base_model.py (100%)
rename {legacy => slm}/examples/semantic_indexing/data.py (100%)
rename {legacy => slm}/examples/semantic_indexing/dense_retriever.py (100%)
rename {legacy => slm}/examples/semantic_indexing/evaluate.py (100%)
rename {legacy => slm}/examples/semantic_indexing/faiss_indexer.py (100%)
rename {legacy => slm}/examples/semantic_indexing/fast_predict.py (100%)
rename {legacy => slm}/examples/semantic_indexing/generate_dense_embeddings.py (100%)
rename {legacy => slm}/examples/semantic_indexing/gradient_cache/model.py (100%)
rename {legacy => slm}/examples/semantic_indexing/hardest_negative/model.py (100%)
rename {legacy => slm}/examples/semantic_indexing/predict.py (100%)
rename {legacy => slm}/examples/semantic_indexing/qa_validation.py (100%)
rename {legacy => slm}/examples/semantic_indexing/recall.py (100%)
rename {legacy => slm}/examples/semantic_indexing/requirements.txt (100%)
rename {legacy => slm}/examples/semantic_indexing/run_ann_data_gen.py (100%)
rename {legacy => slm}/examples/semantic_indexing/tokenizers.py (100%)
rename {legacy => slm}/examples/semantic_indexing/train_ance.py (100%)
rename {legacy => slm}/examples/semantic_indexing/train_batch_neg.py (100%)
rename {legacy => slm}/examples/semantic_indexing/train_gradient_cache.py (100%)
rename {legacy => slm}/examples/semantic_indexing/train_gradient_cache_DPR.py (100%)
rename {legacy => slm}/examples/semantic_indexing/train_hardest_neg.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/README.md (73%)
rename {legacy => slm}/examples/sentiment_analysis/skep/deploy/python/predict.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/export_model.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/predict_aspect.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/predict_opinion.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/predict_sentence.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/train_aspect.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/train_opinion.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/skep/train_sentence.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/README.md (76%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/data.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/deploy/python/predict.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/export_model.py (99%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/model.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/predict.py (100%)
rename {legacy => slm}/examples/sentiment_analysis/textcnn/train.py (98%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/README.md (61%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/config/transformer.yaml (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/README.md (59%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/README_ai.md (86%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/const.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/demo.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/paddlenlp.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/speech_demo_show.gif (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step1.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step2.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step3.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step4.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step5.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step6.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step7.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/step8.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/images/text_demo_show.gif (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/model_demo.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/requirements.txt (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/demo/transformer_demo.yaml (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/images/STACL_architecture.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/images/example.png (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/model.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/predict.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/reader.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/requirements.txt (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/train.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/utils/record.py (100%)
rename {legacy => slm}/examples/simultaneous_translation/stacl/utils/tokenizer.py (100%)
create mode 100644 slm/examples/text_classification/README.md
rename {legacy => slm}/examples/text_classification/pretrained_models/README.md (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/README.md (70%)
rename {legacy => slm}/examples/text_correction/ernie-csc/change_sgml_to_txt.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/download.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/export_model.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/model.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/pinyin_vocab.txt (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/predict.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/predict_sighan.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/requirements.txt (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/run_sighan_predict.sh (56%)
rename {legacy => slm}/examples/text_correction/ernie-csc/sighan_evaluate.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/train.py (100%)
rename {legacy => slm}/examples/text_correction/ernie-csc/utils.py (99%)
rename {legacy => slm}/examples/text_generation/couplet/README.md (68%)
rename {legacy => slm}/examples/text_generation/ctrl/README.md (82%)
rename {legacy => slm}/examples/text_generation/ernie-gen (100%)
rename {legacy => slm}/examples/text_generation/opt/README.md (84%)
rename {legacy => slm}/examples/text_generation/opt/demo.py (100%)
rename {legacy => slm}/examples/text_generation/reformer/README.md (100%)
rename {legacy => slm}/examples/text_generation/unimo-text/README.md (72%)
rename {legacy => slm}/examples/text_generation/unimo-text/gen_utils.py (91%)
rename {legacy => slm}/examples/text_generation/unimo-text/run_gen.py (100%)
rename {legacy => slm}/examples/text_generation/unimo-text/scripts/lcsts_train.sh (100%)
rename {legacy => slm}/examples/text_generation/unimo-text/scripts/qg_train.sh (100%)
rename {legacy => slm}/examples/text_generation/unimo-text/scripts/table_train.sh (100%)
create mode 100644 slm/examples/text_generation/vae-seq2seq/README.md
rename {legacy => slm}/examples/text_graph/erniesage/README.md (60%)
rename {legacy => slm}/examples/text_graph/erniesage/config/erniesage_link_prediction.yaml (100%)
rename {legacy => slm}/examples/text_graph/erniesage/data/__init__.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/data/dataset.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/data/graph_reader.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/example_data/graph_data.txt (100%)
rename {legacy => slm}/examples/text_graph/erniesage/example_data/train_data.txt (100%)
rename {legacy => slm}/examples/text_graph/erniesage/link_prediction.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/models/__init__.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/models/conv.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/models/encoder.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/models/loss.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/models/model.py (100%)
rename {legacy => slm}/examples/text_graph/erniesage/preprocessing/dump_graph.py (100%)
rename {legacy => slm}/examples/text_matching/README.md (92%)
rename {legacy => slm}/examples/text_matching/ernie_matching/README.md (92%)
rename {legacy => slm}/examples/text_matching/ernie_matching/data.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/deploy/python/predict.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/export_model.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/model.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/predict_pairwise.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/predict_pointwise.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/train_pairwise.py (100%)
rename {legacy => slm}/examples/text_matching/ernie_matching/train_pointwise.py (100%)
rename {legacy => slm}/examples/text_matching/question_matching/README.md (90%)
rename {legacy => slm}/examples/text_matching/question_matching/data.py (100%)
rename {legacy => slm}/examples/text_matching/question_matching/model.py (100%)
rename {legacy => slm}/examples/text_matching/question_matching/predict.py (100%)
rename {legacy => slm}/examples/text_matching/question_matching/train.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/README.md (53%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md (72%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/deploy/simple_serving/client.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/deploy/simple_serving/server.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/export_model.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/model.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/predict.py (100%)
rename {legacy => slm}/examples/text_matching/sentence_transformers/train.py (100%)
rename {legacy => slm}/examples/text_matching/simbert/README.md (69%)
rename {legacy => slm}/examples/text_matching/simbert/data.py (100%)
rename {legacy => slm}/examples/text_matching/simbert/predict.py (100%)
rename {legacy => slm}/examples/text_matching/simcse/README.md (91%)
rename {legacy => slm}/examples/text_matching/simcse/data.py (100%)
rename {legacy => slm}/examples/text_matching/simcse/model.py (100%)
rename {legacy => slm}/examples/text_matching/simcse/predict.py (100%)
rename {legacy => slm}/examples/text_matching/simcse/train.py (100%)
create mode 100644 slm/examples/text_matching/simcse/train.sh
rename {legacy => slm}/examples/text_matching/simnet/README.md (78%)
rename {legacy => slm}/examples/text_matching/simnet/model.py (100%)
rename {legacy => slm}/examples/text_matching/simnet/predict.py (100%)
rename {legacy => slm}/examples/text_matching/simnet/train.py (100%)
rename {legacy => slm}/examples/text_matching/simnet/utils.py (100%)
create mode 100644 slm/examples/text_summarization/bart/README.md
rename {legacy => slm}/examples/text_summarization/pointer_summarizer/.gitignore (100%)
rename {legacy => slm}/examples/text_summarization/pointer_summarizer/README.md (100%)
rename {legacy => slm}/examples/text_summarization/prophetnet/README.md (98%)
rename {legacy => slm}/examples/text_summarization/unimo-text/README.md (79%)
create mode 100644 slm/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_inference/inference_unimo_text.py (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md (73%)
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_serving/config.yml (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_serving/export_serving.sh (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_client.py (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_service.py (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/export_model.py (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/export_model.sh (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/train.py (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/train.sh (100%)
rename {legacy => slm}/examples/text_summarization/unimo-text/utils.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/README.md (58%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/ernie_ctm_inputs.png (100%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/ernie_ctm_model.png (100%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/text_to_knowledge.png (100%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/text_to_knowledge_example.png (100%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/wordtag_example.png (100%)
rename {legacy => slm}/examples/text_to_knowledge/doc/img/wordtag_model.png (100%)
create mode 100644 slm/examples/text_to_knowledge/ernie-ctm/README.md
rename {legacy => slm}/examples/text_to_knowledge/ernie-ctm/data_process.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/ernie-ctm/metric.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/ernie-ctm/predict.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/ernie-ctm/train.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/ernie-ctm/utils.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/README.md (64%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/data.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/deploy/python/predict.py (99%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/export_model.py (99%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/metric.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/predict.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/train.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/nptag/utils.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/termtree/README.md (52%)
rename {legacy => slm}/examples/text_to_knowledge/termtree/termtree.py (100%)
rename {legacy => slm}/examples/text_to_knowledge/termtree/termtree_type.csv (100%)
rename {legacy => slm}/examples/text_to_knowledge/wordtag-ie/README.md (85%)
rename {legacy => slm}/examples/text_to_knowledge/wordtag-ie/demo_config.json (100%)
rename {legacy => slm}/examples/text_to_knowledge/wordtag/README.md (70%)
rename {legacy => slm}/examples/text_to_knowledge/wordtag/predict.py (100%)
rename {legacy => slm}/examples/torch_migration/README.md (74%)
create mode 100644 slm/examples/torch_migration/docs/ThesisReproduction_NLP.md
rename {legacy => slm}/examples/torch_migration/pipeline/Step1/README.md (90%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step1/check_step1.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step1/pd_forward_bert.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step1/pt_forward_bert.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step1/torch2paddle.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/README.md (94%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/accuracy.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/check_step2.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/demo_sst2_sentence/demo.tsv (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/predict.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/test_data.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step2/test_metric.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step3/README.md (89%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step3/check_step3.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step3/paddle_loss.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step3/torch_loss.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step4/README.md (90%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step4/check_step4.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step4/test_bp.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step4/test_lr_scheduler.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/README.md (61%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_paddle/train.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_paddle/train.sh (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_paddle/utils.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_torch/accuracy.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_torch/glue.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_torch/train.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_torch/train.sh (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/bert_torch/utils.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/Step5/check_step5.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/classifier_weights/generate_classifier_weights.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/fake_data/gen_fake_data.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/models/pd_bert.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/models/pt_bert.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/reprod_log_demo/check_log_diff.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/reprod_log_demo/write_log.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/weights/torch2paddle.py (100%)
rename {legacy => slm}/examples/torch_migration/pipeline/weights/torch_bert_weight.py (100%)
rename {legacy => slm}/examples/torch_migration/requirements.txt (100%)
rename {legacy => slm}/model_zoo/README.md (100%)
rename {legacy => slm}/model_zoo/bert/README.md (63%)
rename {legacy => slm}/model_zoo/bert/create_pretraining_data.py (100%)
rename {legacy => slm}/model_zoo/bert/data/sample_text.txt (100%)
rename {legacy => slm}/model_zoo/bert/deploy/python/README.md (94%)
rename {legacy => slm}/model_zoo/bert/deploy/python/seq_cls_infer.py (100%)
rename {legacy => slm}/model_zoo/bert/export_model.py (100%)
rename {legacy => slm}/model_zoo/bert/run_glue_trainer.py (100%)
rename {legacy => slm}/model_zoo/bert/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/bert/run_pretrain_trainer.py (100%)
rename {legacy => slm}/model_zoo/bert/static/README.md (56%)
rename {legacy => slm}/model_zoo/bert/static/create_pretraining_data.py (100%)
rename {legacy => slm}/model_zoo/bert/static/data/sample_text.txt (100%)
rename {legacy => slm}/model_zoo/bert/static/dataset.py (100%)
rename {legacy => slm}/model_zoo/bert/static/predict_glue.py (100%)
rename {legacy => slm}/model_zoo/bert/static/run_glue.py (100%)
rename {legacy => slm}/model_zoo/bert/static/run_glue_with_sparaity.py (100%)
rename {legacy => slm}/model_zoo/bert/static/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/README.md (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/custom_checkpointoutput.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/custom_detach.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/custom_identity.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/custom_nll_loss.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/custom_shape_infer.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/disable_attn_dropout_bwd_pattern.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/tied_gather.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/tied_gather_pattern.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/utils.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/custom_ops/workarounds/prevent_const_expr_folding_op.cc (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/dataset_ipu.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/load_tf_ckpt.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/modeling.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/requirements.txt (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/run_squad.py (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain_phase2.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod16/run_squad.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod16/run_squad_infer.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain_phase2.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod4/run_squad.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/scripts/pod4/run_squad_infer.sh (100%)
rename {legacy => slm}/model_zoo/bert/static_ipu/utils.py (100%)
rename {legacy => slm}/model_zoo/bigbird/README.md (61%)
rename {legacy => slm}/model_zoo/bigbird/args.py (100%)
rename {legacy => slm}/model_zoo/bigbird/data/data.txt (100%)
rename {legacy => slm}/model_zoo/bigbird/run_classifier.py (100%)
rename {legacy => slm}/model_zoo/bigbird/run_glue.py (100%)
rename {legacy => slm}/model_zoo/bigbird/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/README.md (67%)
rename {legacy => slm}/model_zoo/chinesebert/cmrc_eval.sh (100%)
rename {legacy => slm}/model_zoo/chinesebert/cmrc_evaluate.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/dataset_cmrc2018.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/eval_cmrc.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/metric_cmrc.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/run_chn.sh (100%)
rename {legacy => slm}/model_zoo/chinesebert/run_cmrc2018.sh (100%)
rename {legacy => slm}/model_zoo/chinesebert/run_xnli.sh (100%)
rename {legacy => slm}/model_zoo/chinesebert/train_chn.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/train_cmrc2018.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/train_xnli.py (100%)
rename {legacy => slm}/model_zoo/chinesebert/utils.py (100%)
rename {legacy => slm}/model_zoo/convbert/README.md (66%)
rename {legacy => slm}/model_zoo/convbert/convert.py (100%)
rename {legacy => slm}/model_zoo/convbert/run_glue.py (100%)
rename {legacy => slm}/model_zoo/convbert/run_pretrain.py (100%)
create mode 100644 slm/model_zoo/electra/README.md
rename {legacy => slm}/model_zoo/ernie-1.0/README.md (99%)
rename {legacy => slm}/model_zoo/ernie-1.0/args.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/converter/params_static_to_dygraph.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/data_tools/Makefile (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/data_tools/dataset_utils.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/data_tools/ernie_dataset.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/data_tools/helpers.cpp (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/README.md (56%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/config.yml (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/deploy/README.md (95%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/deploy/seq_cls_infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/question_answering.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/run_ner.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/run_qa.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/run_seq_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/sequence_classification.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/token_classification.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/finetune/utils.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/pretraining_introduction.md (99%)
rename {legacy => slm}/model_zoo/ernie-1.0/run_gb512_s1m.sh (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/run_gb512_s1m_trainer.sh (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/run_npu_single_card.sh (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/run_pretrain_trainer.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/vocab/README.md (71%)
rename {legacy => slm}/model_zoo/ernie-1.0/vocab/gen_char.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/vocab/gen_vocab.py (100%)
rename {legacy => slm}/model_zoo/ernie-1.0/vocab/merge_vocab.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/README.md (98%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/data/intent_label.txt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/data/slot_label.txt (100%)
create mode 100644 slm/model_zoo/ernie-3.0-tiny/deploy/README.md
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/deploy/python/README.md (88%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/deploy/python/infer_demo.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/model.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/run_eval.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/run_train.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0-tiny/utils.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/README.md (97%)
rename {legacy => slm}/model_zoo/ernie-3.0/compress_qa.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/compress_seq_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/compress_token_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/configs/default.yml (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/README.md (92%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/python/README.md (87%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/python/requirements.txt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/README.md (95%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/1/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/1/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/1/model.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/1/model.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/1/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/config.pbtxt (100%)
create mode 100644 slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/1/model.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/1/model.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/config.pbtxt (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/seq_cls_grpc_client.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/serving/token_cls_grpc_client.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/README.md (78%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/client_qa.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/client_seq_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/client_token_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/server_qa.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/server_seq_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/deploy/simple_serving/server_token_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/run_qa.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/run_seq_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/run_token_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-3.0/utils.py (100%)
rename {legacy => slm}/model_zoo/ernie-code/README.md (64%)
create mode 100644 slm/model_zoo/ernie-doc/README.md
rename {legacy => slm}/model_zoo/ernie-gen/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-health/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-layout/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-layout/README_ch.md (79%)
rename {legacy => slm}/model_zoo/ernie-layout/data_collator.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/deploy/python/README.md (100%)
rename {legacy => slm}/model_zoo/ernie-layout/deploy/python/README_ch.md (87%)
rename {legacy => slm}/model_zoo/ernie-layout/deploy/python/infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/deploy/python/predictor.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/deploy/python/requirements.txt (100%)
rename {legacy => slm}/model_zoo/ernie-layout/export_model.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/finetune_args.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/layout_trainer.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/requirements.txt (100%)
rename {legacy => slm}/model_zoo/ernie-layout/run_cls.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/run_mrc.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/run_ner.py (100%)
rename {legacy => slm}/model_zoo/ernie-layout/utils.py (100%)
rename {legacy => slm}/model_zoo/ernie-m/README.md (89%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/README.md (88%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/data_util.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/deploy/python/infer.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/export_model.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/extract_features.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/predict.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/preprocess/create_arrow_dataset.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/requirements.txt (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/run_finetune.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/trainer_util.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/utils/evaluation.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/utils/evaluation_tr.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/utils/make_topk_predictions.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/utils/make_topk_predictions_tr.py (100%)
rename {legacy => slm}/model_zoo/ernie-vil2.0/utils/transform_ir_annotation_to_tr.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/.pre-commit-config.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/README.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/README.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N2C16/gpt_stage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/N1C1/gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N2C16/gpt_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N4C32/gpt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N2C16/gpt_auto_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N4C32/gpt_auto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/prepare.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/clang_format.hook (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/copyright.hook (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/cpplint_pre_commit.hook (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/docstring_checker.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/pylint_pre_commit.hook (100%)
rename {legacy => slm}/model_zoo/gpt-3/codestyle/test_docstring_checker.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/cluster_deployment.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/compression.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/deployment_faq.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/docker_install.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/images/fleetx_arc.png (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/images/throughput_compare.png (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/images/throughput_compare_graph.png (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/quick_start.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/docs/standard.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/.gitignore (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_kernels.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_semi_cuda_kernel.cu (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_cuda_kernel.cu (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_kernels.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_kernel_traits.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fast_ln/ln_utils.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.cu (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.h (100%)
rename {legacy => slm}/model_zoo/gpt-3/external_ops/setup.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/export_gpt_fp16_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_13B_mp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_175B_mp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_mp2.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8_tuning.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_13B_sharding8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_sharding16.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_base.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/qat_generation_gpt_345M_mp2.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_pruned_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_qat_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/export_qat_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_345M_single_card_glue.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_base.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_dp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_mp1.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_6.7B_single_mp1.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_pruned_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_6.7B_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_dp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_dp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_sep8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_base.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_cn_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/prune_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_mp8.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_single_card.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_6.7B_sharding16.yaml (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/engine/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/engine/auto_engine.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/engine/basic_engine.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/engine/eager_engine.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/engine/inference_engine.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/module/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/core/module/basic_module.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/Makefile (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/compile.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/fast_index_map_helpers.cpp (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/README.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/preprocess_data.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/raw_trans_to_json.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/dataset/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/dataset/glue_dataset.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/dataset/gpt_dataset.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/sampler/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/sampler/batch_sampler.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/sampler/collate.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/tokenizers/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/tokenizers/gpt_tokenizer.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/tokenizers/tokenization_utils_base.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/transforms/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/transforms/preprocess.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/transforms/utils.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/utils/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/data/utils/batch_collate_fn.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/auto_env.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/comm_groups.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/env.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/io.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/distributed/apis/strategy.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/auto_utils.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_model.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_module.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/processor.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/single_model.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/language_module.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/metrics.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/models/language_model/utils.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/ops/fused_layers.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/ops/setup_cuda.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/ops/test_topp_sampling.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/ops/topp_sampling.cu (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/optims/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/optims/grad_clip.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/optims/lr_scheduler.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/optims/optimizer.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/tools/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/tools/multiprocess_tool.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/__init__.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/auto_config.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/check.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/compression_helper.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/config.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/device.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/download.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/export.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/file.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/log.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/tensor_fusion_helper.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/ppfleetx/utils/version.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_13B_mp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_175B_mp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_mp2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_6.7B_mp1.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_export_gpt_fp16_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8_tuning.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_13B_sharding8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_sharding16.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/auto_qat_export_gpt_345M_mp2.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/benchmark.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/README.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md (99%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/hybrid_parallel.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/hybrid_profiler.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/inference.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/quantization_aware_training.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/single_card.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/single_finetune.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/docs/structured_pruning.md (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/eval_prune_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/eval_qat_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/evaluate_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/export_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/export_prune_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/export_qat_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/finetune_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/inference.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/inference_gpt_6.7B_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/inference_gpt_multigpu.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/inference_gpt_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_dp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_sep8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_175B_mp8_pp16.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/pretrain_gpt_6.7B_sharding16.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/prune_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_mp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_single_card.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/qat_gpt_6.7B_sharding16.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/projects/gpt/run_benchmark.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/requirements.txt (100%)
rename {legacy => slm}/model_zoo/gpt-3/run_mp8.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/tasks/gpt/generation.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tasks/gpt/inference.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tasks/gpt/run_generation.sh (100%)
rename {legacy => slm}/model_zoo/gpt-3/tasks/gpt/train_pir.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/auto.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/auto_export.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/eval.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/export.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/inference.py (100%)
rename {legacy => slm}/model_zoo/gpt-3/tools/train.py (100%)
create mode 100644 slm/model_zoo/luke/README.md
rename {legacy => slm}/model_zoo/luke/args.py (100%)
rename {legacy => slm}/model_zoo/luke/open_entity_processor.py (100%)
rename {legacy => slm}/model_zoo/luke/run_open_entity.py (100%)
rename {legacy => slm}/model_zoo/luke/run_squad.py (100%)
rename {legacy => slm}/model_zoo/megatronbert/README.md (73%)
rename {legacy => slm}/model_zoo/megatronbert/args.py (100%)
rename {legacy => slm}/model_zoo/megatronbert/run_glue.py (100%)
rename {legacy => slm}/model_zoo/megatronbert/run_squad.py (100%)
rename {legacy => slm}/model_zoo/moe/data_tools (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/args.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/checkpointing.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/dataset.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/framework/__init__.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/framework/group_sharded.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/framework/storage_process.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/modeling.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/run.sh (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/run_moe_pretrain.py (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/sync_files.sh (100%)
rename {legacy => slm}/model_zoo/moe/dygraph/utils.py (100%)
rename {legacy => slm}/model_zoo/mpnet/README.md (63%)
rename {legacy => slm}/model_zoo/mpnet/convert.py (100%)
rename {legacy => slm}/model_zoo/mpnet/glue/predict.sh (100%)
rename {legacy => slm}/model_zoo/mpnet/glue/run_glue.py (100%)
rename {legacy => slm}/model_zoo/mpnet/glue/run_predict.py (100%)
rename {legacy => slm}/model_zoo/mpnet/glue/train.sh (100%)
rename {legacy => slm}/model_zoo/mpnet/squad/run_squad.py (100%)
rename {legacy => slm}/model_zoo/plato-xl/README.md (74%)
rename {legacy => slm}/model_zoo/rembert/README.md (79%)
rename {legacy => slm}/model_zoo/rembert/data_processor.py (100%)
rename {legacy => slm}/model_zoo/rembert/main.py (100%)
rename {legacy => slm}/model_zoo/rembert/trainer.py (100%)
rename {legacy => slm}/model_zoo/roberta/README.md (58%)
rename {legacy => slm}/model_zoo/roberta/create_data.py (100%)
rename {legacy => slm}/model_zoo/roberta/run_pretrain.py (100%)
rename {legacy => slm}/model_zoo/roberta/utils.py (100%)
rename {legacy => slm}/model_zoo/roformer/README.md (60%)
rename {legacy => slm}/model_zoo/roformer/convert.py (100%)
rename {legacy => slm}/model_zoo/roformer/run_cail2019_scm.py (100%)
rename {legacy => slm}/model_zoo/roformer/run_thucnews.py (100%)
rename {legacy => slm}/model_zoo/roformer/test_mlm.py (100%)
rename {legacy => slm}/model_zoo/rw/README.md (59%)
rename {legacy => slm}/model_zoo/rw/predict_generation.py (100%)
rename {legacy => slm}/model_zoo/t5/README.md (77%)
rename {legacy => slm}/model_zoo/t5/convert.py (100%)
rename {legacy => slm}/model_zoo/t5/data.py (100%)
rename {legacy => slm}/model_zoo/t5/dataset_utils.py (100%)
rename {legacy => slm}/model_zoo/t5/glue_demo.py (100%)
rename {legacy => slm}/model_zoo/t5/run_clue_trainer.py (100%)
rename {legacy => slm}/model_zoo/t5/run_glue.py (100%)
rename {legacy => slm}/model_zoo/t5/run_glue_trainer.py (100%)
rename {legacy => slm}/model_zoo/t5/t5_dataset.py (100%)
rename {legacy => slm}/model_zoo/t5/t5_run_pretrain_trainer.py (100%)
rename {legacy => slm}/model_zoo/t5/tests/t5_mp.py (100%)
rename {legacy => slm}/model_zoo/t5/tests/test_parallel_dygraph_dataparallel.py (100%)
rename {legacy => slm}/model_zoo/t5/tests/test_t5_mp.py (100%)
rename {legacy => slm}/model_zoo/t5/utils.py (100%)
rename {legacy => slm}/model_zoo/t5/zero_shot_demo.py (100%)
rename {legacy => slm}/model_zoo/tinybert/README.md (56%)
rename {legacy => slm}/model_zoo/tinybert/data_augmentation.py (100%)
rename {legacy => slm}/model_zoo/tinybert/general_distill.py (100%)
rename {legacy => slm}/model_zoo/tinybert/imgs/tinybert.png (100%)
rename {legacy => slm}/model_zoo/tinybert/task_distill.py (100%)
rename {legacy => slm}/model_zoo/transformer-xl/README.md (100%)
rename {legacy => slm}/model_zoo/uie/README.md (86%)
rename {legacy => slm}/model_zoo/uie/deploy/python/README.md (95%)
rename {legacy => slm}/model_zoo/uie/deploy/python/infer.py (100%)
rename {legacy => slm}/model_zoo/uie/deploy/serving/simple_serving/README.md (74%)
rename {legacy => slm}/model_zoo/uie/deploy/serving/simple_serving/client.py (100%)
rename {legacy => slm}/model_zoo/uie/deploy/serving/simple_serving/server.py (100%)
rename {legacy => slm}/model_zoo/uie/doccano.md (69%)
rename {legacy => slm}/model_zoo/uie/doccano.py (100%)
rename {legacy => slm}/model_zoo/uie/evaluate.py (100%)
rename {legacy => slm}/model_zoo/uie/finetune.py (100%)
rename {legacy => slm}/model_zoo/uie/labelstudio2doccano.py (100%)
rename {legacy => slm}/model_zoo/uie/utils.py (100%)
rename {legacy => slm}/model_zoo/xlm/README.md (69%)
rename {legacy => slm}/model_zoo/xlm/framework.jpg (100%)
rename {legacy => slm}/model_zoo/xlm/xnli_eval.py (100%)
rename {legacy => slm}/model_zoo/xlm/xnli_train.py (100%)
create mode 100644 slm/model_zoo/xlnet/README.md
rename {legacy => slm}/pipelines/.readthedocs.yaml (100%)
rename {legacy => slm}/pipelines/API.md (95%)
rename {legacy => slm}/pipelines/FAQ.md (69%)
rename {legacy => slm}/pipelines/Makefile (100%)
rename {legacy => slm}/pipelines/README.md (75%)
rename {legacy => slm}/pipelines/VERSION (100%)
rename {legacy => slm}/pipelines/VERSION.txt (100%)
rename {legacy => slm}/pipelines/benchmarks/README.md (80%)
rename {legacy => slm}/pipelines/benchmarks/requirements.txt (100%)
rename {legacy => slm}/pipelines/benchmarks/retrieval_benchmarks.py (100%)
rename {legacy => slm}/pipelines/docker/Dockerfile (100%)
rename {legacy => slm}/pipelines/docker/Dockerfile-GPU (100%)
rename {legacy => slm}/pipelines/docker/README.md (58%)
rename {legacy => slm}/pipelines/docker/create_index.sh (100%)
rename {legacy => slm}/pipelines/docker/dense_qa.yaml (100%)
rename {legacy => slm}/pipelines/docker/docker-compose-gpu.yml (100%)
rename {legacy => slm}/pipelines/docker/docker-compose.yml (100%)
rename {legacy => slm}/pipelines/docker/run_client.sh (100%)
rename {legacy => slm}/pipelines/docker/run_server.sh (100%)
rename {legacy => slm}/pipelines/docker/semantic_search.yaml (100%)
rename {legacy => slm}/pipelines/docker/start.sh (100%)
rename {legacy => slm}/pipelines/docker/start_compose.sh (100%)
rename {legacy => slm}/pipelines/docs/index.md (74%)
rename {legacy => slm}/pipelines/docs/package/agents/agents.md (100%)
rename {legacy => slm}/pipelines/docs/package/agents/memory.md (100%)
rename {legacy => slm}/pipelines/docs/package/docstore/elasticsearch.md (100%)
rename {legacy => slm}/pipelines/docs/package/docstore/faiss.md (100%)
rename {legacy => slm}/pipelines/docs/package/docstore/milvus2.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/answer_extractor.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/document_intelligence.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/file_converter.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/llm.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/other.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/preprocessor.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/question_generator.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/ranker.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/reader.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/retriever.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/search_engine.md (100%)
rename {legacy => slm}/pipelines/docs/package/nodes/sentiment_analysis.md (100%)
rename {legacy => slm}/pipelines/docs/package/pipelines/standard_pipelines.md (100%)
rename {legacy => slm}/pipelines/docs/package/rest_api/application.md (100%)
rename {legacy => slm}/pipelines/docs/package/rest_api/controller.md (100%)
rename {legacy => slm}/pipelines/docs/requirements.txt (100%)
rename {legacy => slm}/pipelines/examples/FAQ/Install_windows.md (60%)
rename {legacy => slm}/pipelines/examples/FAQ/README.md (66%)
rename {legacy => slm}/pipelines/examples/FAQ/dense_faq_example.py (100%)
rename {legacy => slm}/pipelines/examples/FAQ/run_faq_server.sh (100%)
rename {legacy => slm}/pipelines/examples/FAQ/run_faq_web.sh (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/README.md (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/arguments.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/data.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/data/toy_finetune_data.jsonl (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/__init__.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/benchmarks.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py (96%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py (83%)
rename {legacy => slm}/pipelines/examples/contrastive_training/evaluation/prediction.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/models/__init__.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/models/modeling.py (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/requirements.txt (100%)
rename {legacy => slm}/pipelines/examples/contrastive_training/train.py (100%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md (82%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/README.md (79%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/image_to_text_retrieval_example.py (100%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/run_search_server.sh (100%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/run_search_web.sh (100%)
rename {legacy => slm}/pipelines/examples/image_text_retrieval/text_to_image_retrieval_example.py (100%)
rename {legacy => slm}/pipelines/examples/question-answering/Install_windows.md (72%)
rename {legacy => slm}/pipelines/examples/question-answering/README.md (83%)
rename {legacy => slm}/pipelines/examples/question-answering/dense_qa_example.py (100%)
rename {legacy => slm}/pipelines/examples/question-answering/run_qa_server.sh (100%)
rename {legacy => slm}/pipelines/examples/question-answering/run_qa_web.sh (100%)
rename {legacy => slm}/pipelines/examples/semantic-search/Install_windows.md (63%)
rename {legacy => slm}/pipelines/examples/semantic-search/Multi_Recall.md (72%)
rename {legacy => slm}/pipelines/examples/semantic-search/Neural_Search.md (85%)
rename {legacy => slm}/pipelines/examples/semantic-search/README.md (81%)
rename {legacy => slm}/pipelines/examples/semantic-search/multi_recall_semantic_search_example.py (100%)
rename {legacy => slm}/pipelines/examples/semantic-search/run_neural_search_server.sh (100%)
rename {legacy => slm}/pipelines/examples/semantic-search/run_search_server.sh (100%)
rename {legacy => slm}/pipelines/examples/semantic-search/run_search_web.sh (100%)
rename {legacy => slm}/pipelines/examples/semantic-search/semantic_search_example.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/README.md (95%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/demo.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/requirements.txt (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/run.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/llm/__init__.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/llm/chat_template.json (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/llm/ernie_bot.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/llm/llama.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/__init__.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/methods/bfs.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/models.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/prompts/crosswords.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/prompts/game24.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/prompts/text.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/tasks/__init__.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/tasks/base.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/tasks/crosswords.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/tasks/game24.py (100%)
rename {legacy => slm}/pipelines/examples/tree-of-thought/src/tot/tasks/text.py (100%)
rename {legacy => slm}/pipelines/mkdocs.yml (99%)
rename {legacy => slm}/pipelines/pipelines/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/agent_step.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/memory/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/memory/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/memory/conversation_memory.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/memory/no_memory.py (100%)
rename {legacy => slm}/pipelines/pipelines/agents/types.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/dataset.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/inputs.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/predictions.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/processor.py (100%)
rename {legacy => slm}/pipelines/pipelines/data_handler/samples.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/elasticsearch.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/faiss.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/filter_utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/milvus2.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/sql.py (100%)
rename {legacy => slm}/pipelines/pipelines/document_stores/utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/errors.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/answer_extractor/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/answer_extractor/answer_extractor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/answer_extractor/answer_extractor_preprocessor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/answer_extractor/qa_filter.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/answer_extractor/qa_filter_postprocessor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/combine_documents/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/combine_documents/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/combine_documents/map_reduce.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/combine_documents/reduce.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/combine_documents/stuff.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/document/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/document/document_intelligence.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/document/document_preprocessor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_classifier/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_classifier/file_type.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/docx.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/image.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/markdown.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/pdf.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/file_converter/txt.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/llm/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/llm/chatglm.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/llm/ernie_bot.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/llm/history.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/llm/prompt_template.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/models/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/models/neural_search_model.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/other/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/other/docs2answers.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/other/join_answers.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/other/join_docs.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/other/route_documents.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/preprocessor/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/preprocessor/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/preprocessor/preprocessor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/preprocessor/text_splitter.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/chatglm.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/chatgpt.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/ernie_bot.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/handlers.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/invocation_layer/open_ai.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/prompt_model.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/prompt_node.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/prompt_template.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/prompt/shapers.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/question_generator/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/question_generator/question_generator.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/ranker/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/ranker/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/ranker/ernie_ranker.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/reader/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/reader/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/reader/ernie_dureader.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/base_embedding_encoder.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/dense.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/embedder.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/ernie_encoder.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/multimodal_retriever.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/parallel_retriever.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/sparse.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/retriever/web.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/search_engine/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/search_engine/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/search_engine/providers.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/search_engine/utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/search_engine/web.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/sentiment_analysis/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/sentiment_analysis/senta.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/sentiment_analysis/senta_preprocessor.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/sentiment_analysis/senta_visualization.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/text_to_image_generator/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/nodes/text_to_image_generator/text_to_image_generator.py (100%)
rename {legacy => slm}/pipelines/pipelines/pipelines/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/pipelines/base.py (100%)
rename {legacy => slm}/pipelines/pipelines/pipelines/config.py (100%)
rename {legacy => slm}/pipelines/pipelines/pipelines/standard_pipelines.py (100%)
rename {legacy => slm}/pipelines/pipelines/pipelines/utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/schema.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/__init__.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/cleaning.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/common_utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/doc_store.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/export_utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/import_utils.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/logger.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/preprocessing.py (100%)
rename {legacy => slm}/pipelines/pipelines/utils/tokenization.py (100%)
rename {legacy => slm}/pipelines/pipelines/version.py (100%)
rename {legacy => slm}/pipelines/requirements.txt (100%)
rename {legacy => slm}/pipelines/rest_api/__init__.py (100%)
rename {legacy => slm}/pipelines/rest_api/application.py (100%)
rename {legacy => slm}/pipelines/rest_api/config.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/__init__.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/document.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/errors/__init__.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/errors/http_error.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/feedback.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/file_upload.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/router.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/search.py (100%)
rename {legacy => slm}/pipelines/rest_api/controller/utils.py (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/__init__.py (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/chatfile.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/custom_component.py (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/dense_faq.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/dense_qa.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/docprompt.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/image_to_text_retrieval.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/multi_recall_semantic_search.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/pipelines.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/semantic_ernie_search_en.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/semantic_search.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/semantic_search_custom.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/semantic_search_en.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/semantic_search_milvus.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/senta.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/text_to_image.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/text_to_image_retrieval.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/pipeline/unsupervised_qa.yaml (100%)
rename {legacy => slm}/pipelines/rest_api/schema.py (100%)
rename {legacy => slm}/pipelines/rest_api/test/__init__.py (100%)
rename {legacy => slm}/pipelines/rest_api/test/test_rest_api.py (100%)
rename {legacy => slm}/pipelines/setup.py (100%)
rename {legacy => slm}/pipelines/tests/__init__.py (100%)
rename {legacy => slm}/pipelines/tests/agents/__init__.py (100%)
rename {legacy => slm}/pipelines/tests/agents/test_agent.py (100%)
rename {legacy => slm}/pipelines/tests/agents/test_agent_step.py (100%)
rename {legacy => slm}/pipelines/tests/agents/test_memory.py (100%)
rename {legacy => slm}/pipelines/tests/agents/test_tools_manager.py (100%)
rename {legacy => slm}/pipelines/tests/conftest.py (100%)
rename {legacy => slm}/pipelines/tests/fixtures/example_docx.docx (100%)
rename {legacy => slm}/pipelines/tests/fixtures/example_markdown.md (100%)
rename {legacy => slm}/pipelines/tests/fixtures/example_pdf.pdf (100%)
rename {legacy => slm}/pipelines/tests/nodes/combine_documents/test_combinedocuments.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/file_converter/test_docx.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/file_converter/test_markdown.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/file_converter/test_pdf.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/llm/test_chatglm_bot.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/llm/test_ernie_bot.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/llm/test_history.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/llm/test_prompt_template.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/preprocessor/test_preprocessor.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/preprocessor/test_text_splitter.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/__init__.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/conftest.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/invocation_layer/__init__.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/invocation_layer/test_chatglm.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/invocation_layer/test_chatgpt.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/invocation_layer/test_ernie_bot.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/invocation_layer/test_openai.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/test_handlers.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/test_prompt_model.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/test_prompt_node.py (100%)
rename {legacy => slm}/pipelines/tests/nodes/prompt/test_prompt_template.py (100%)
rename {legacy => slm}/pipelines/tests/pipelines/test_chatbot_pipeline.py (100%)
rename {legacy => slm}/pipelines/tests/requirements.txt (100%)
rename {legacy => slm}/pipelines/ui/__init__.py (100%)
rename {legacy => slm}/pipelines/ui/baike_qa.csv (100%)
rename {legacy => slm}/pipelines/ui/country_search.csv (100%)
rename {legacy => slm}/pipelines/ui/dureader_search.csv (100%)
rename {legacy => slm}/pipelines/ui/insurance_faq.csv (100%)
rename {legacy => slm}/pipelines/ui/utils.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_chatfile_gradio.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_docprompt_gradio.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_faq.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_image_to_text_retrieval.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_multi_recall_semantic_search.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_question_answering.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_semantic_search.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_senta.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_text_to_image.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_text_to_image_retrieval.py (100%)
rename {legacy => slm}/pipelines/ui/webapp_unsupervised_question_answering.py (100%)
rename {legacy => slm}/pipelines/utils/__init__.py (100%)
rename {legacy => slm}/pipelines/utils/offline_ann.py (100%)
rename {legacy => slm}/pipelines/utils/offline_ann_mm.py (100%)
diff --git a/.github/workflows/pipelines.yml b/.github/workflows/pipelines.yml
index 9e11ef11269a..f837b5015ab7 100644
--- a/.github/workflows/pipelines.yml
+++ b/.github/workflows/pipelines.yml
@@ -3,10 +3,10 @@ name: Pipelines-Test
on:
push:
paths:
- - 'legacy/pipelines/*'
+ - 'slm/pipelines/*'
pull_request:
paths:
- - 'legacy/pipelines/*'
+ - 'slm/pipelines/*'
jobs:
@@ -20,11 +20,11 @@ jobs:
python-version: '3.10'
cache: 'pip' # caching pip dependencies
- name: Install dependencies
- working-directory: ./legacy/pipelines
+ working-directory: ./slm/pipelines
run: |
python -m pip install --upgrade pip
make install
pip install -r tests/requirements.txt
- name: run the command
- working-directory: ./legacy/pipelines
+ working-directory: ./slm/pipelines
run: make test
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index b1f65cfa7d0e..beb8aa7f558d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,4 +1,4 @@
-exclude: 'legacy/model_zoo/gpt-3'
+exclude: 'slm/model_zoo/gpt-3'
repos:
# For Python files
- repo: https://github.com/psf/black.git
diff --git a/README.md b/README.md
index a3a1a2bec419..93de718ee737 100644
--- a/README.md
+++ b/README.md
@@ -208,8 +208,8 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_finetune.py
更多 PaddleNLP 内容可参考:
-* [精选模型库](./legacy/model_zoo),包含优质预训练模型的端到端全流程使用。
-* [多场景示例](./legacy/examples),了解如何使用 PaddleNLP 解决 NLP 多种技术问题,包含基础技术、系统应用与拓展应用。
+* [精选模型库](./slm/model_zoo),包含优质预训练模型的端到端全流程使用。
+* [多场景示例](./slm/examples),了解如何使用 PaddleNLP 解决 NLP 多种技术问题,包含基础技术、系统应用与拓展应用。
* [交互式教程](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/574995),在🆓免费算力平台 AI Studio 上快速学习 PaddleNLP。
------------------------------------------------------------------------------------------
diff --git a/README_en.md b/README_en.md
index 16656740f186..42f6829bacf5 100644
--- a/README_en.md
+++ b/README_en.md
@@ -122,8 +122,8 @@ For more steps in the entire large model process, please refer to the[Large Mode
For more PaddleNLP content, please refer to:
-* [Model Library](./legacy/model_zoo),which includes end-to-end usage of high-quality pre-trained models.
-* [Multi-scenario Examples](./legacy/examples),to understand how to use PaddleNLP to solve various NLP technical problems, including basic techniques, system applications, and extended applications.
+* [Model Library](./slm/model_zoo),which includes end-to-end usage of high-quality pre-trained models.
+* [Multi-scenario Examples](./slm/examples),to understand how to use PaddleNLP to solve various NLP technical problems, including basic techniques, system applications, and extended applications.
* [Interactive Tutorial](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/574995),to quickly learn PaddleNLP on the free computing platform AI Studio.
------------------------------------------------------------------------------------------
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 8b4dd5f0efa9..4a5112594201 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -1,19 +1,19 @@
-## PaddleNLP常见问题汇总(持续更新)
+## PaddleNLP 常见问题汇总(持续更新)
-+ [【精选】NLP精选5问](#NLP精选)
++ [【精选】NLP 精选5问](#NLP 精选)
- + [Q1.1 如何加载自己的本地数据集,以便使用PaddleNLP的功能?](#1-1)
- + [Q1.2 PaddleNLP会将内置的数据集、模型下载到默认路径,如何修改路径?](#1-2)
- + [Q1.3 PaddleNLP中如何保存、加载训练好的模型?](#1-3)
+ + [Q1.1 如何加载自己的本地数据集,以便使用 PaddleNLP 的功能?](#1-1)
+ + [Q1.2 PaddleNLP 会将内置的数据集、模型下载到默认路径,如何修改路径?](#1-2)
+ + [Q1.3 PaddleNLP 中如何保存、加载训练好的模型?](#1-3)
+ [Q1.4 当训练样本较少时,有什么推荐的方法能提升模型效果吗?](#1-4)
- + [Q1.5 如何提升模型的性能,提升QPS?](#1-5)
+ + [Q1.5 如何提升模型的性能,提升 QPS?](#1-5)
-+ [【理论篇】NLP通用问题](#NLP通用问题 )
++ [【理论篇】NLP 通用问题](#NLP 通用问题 )
+ [Q2.1 数据类别分布不均衡, 有哪些应对方法?](#2-2)
+ [Q2.2 如果使用预训练模型,一般需要多少条样本?](#2-3)
-+ [【实战篇】PaddleNLP实战问题](#PaddleNLP实战问题)
++ [【实战篇】PaddleNLP 实战问题](#PaddleNLP 实战问题)
[数据集和数据处理](#数据问题)
@@ -21,46 +21,46 @@
[模型训练调优](#训练调优问题)
- + [Q3.2 如何加载自己的预训练模型,进而使用PaddleNLP的功能?](#4-1)
+ + [Q3.2 如何加载自己的预训练模型,进而使用 PaddleNLP 的功能?](#4-1)
+ [Q3.3 如果训练中断,需要继续热启动训练,如何保证学习率和优化器能从中断地方继续迭代?](#4-2)
+ [Q3.4 如何冻结模型梯度?](#4-3)
- + [Q3.5 如何在eval阶段打印评价指标,在各epoch保存模型参数?](#4-4)
- + [Q3.6 训练过程中,训练程序意外退出或Hang住,应该如何排查?](#4-5)
+ + [Q3.5 如何在 eval 阶段打印评价指标,在各 epoch 保存模型参数?](#4-4)
+ + [Q3.6 训练过程中,训练程序意外退出或 Hang 住,应该如何排查?](#4-5)
+ [Q3.7 在模型验证和测试过程中,如何保证每一次的结果是相同的?](#4-6)
- + [Q3.8 ERNIE模型如何返回中间层的输出?](#4-7)
+ + [Q3.8 ERNIE 模型如何返回中间层的输出?](#4-7)
[预测部署](#部署问题)
- + [Q3.9 PaddleNLP训练好的模型如何部署到服务器 ?](#5-1)
+ + [Q3.9 PaddleNLP 训练好的模型如何部署到服务器 ?](#5-1)
+ [Q3.10 静态图模型如何转换成动态图模型?](#5-2)
-+ [特定模型和应用场景咨询](#NLP应用场景)
- + [Q4.1 【词法分析】LAC模型,如何自定义标签label,并继续训练?](#6-1)
++ [特定模型和应用场景咨询](#NLP 应用场景)
+ + [Q4.1 【词法分析】LAC 模型,如何自定义标签 label,并继续训练?](#6-1)
+ [Q4.2 信息抽取任务中,是否推荐使用预训练模型+CRF,怎么实现呢?](#6-2)
+ [Q4.3 【阅读理解】`MapDatasets`的`map()`方法中对应的`batched=True`怎么理解,在阅读理解任务中为什么必须把参数`batched`设置为`True`?](#6-3)
+ [Q4.4 【语义匹配】语义索引和语义匹配有什么区别?](#6-4)
- + [Q4.5 【解语】wordtag模型如何自定义添加命名实体及对应词类?](#6-5)
+ + [Q4.5 【解语】wordtag 模型如何自定义添加命名实体及对应词类?](#6-5)
+ [其他使用咨询](#使用咨询问题)
- + [Q5.1 在CUDA11使用PaddlNLP报错?](#7-1)
- + [Q5.2 如何设置parameter?](#7-2)
- + [Q5.3 GPU版的Paddle虽然能在CPU上运行,但是必须要有GPU设备吗?](#7-3)
- + [Q5.4 如何指定用CPU还是GPU训练模型?](#7-4)
+ + [Q5.1 在 CUDA11使用 PaddlNLP 报错?](#7-1)
+ + [Q5.2 如何设置 parameter?](#7-2)
+ + [Q5.3 GPU 版的 Paddle 虽然能在 CPU 上运行,但是必须要有 GPU 设备吗?](#7-3)
+ + [Q5.4 如何指定用 CPU 还是 GPU 训练模型?](#7-4)
+ [Q5.5 动态图模型和静态图模型的预测结果一致吗?](#7-5)
- + [Q5.6 如何可视化acc、loss曲线图、模型网络结构图等?](#7-6)
+ + [Q5.6 如何可视化 acc、loss 曲线图、模型网络结构图等?](#7-6)
-
+
-## ⭐️【精选】NLP精选5问
+## ⭐️【精选】NLP 精选5问
-##### Q1.1 如何加载自己的本地数据集,以便使用PaddleNLP的功能?
+##### Q1.1 如何加载自己的本地数据集,以便使用 PaddleNLP 的功能?
-**A:** 通过使用PaddleNLP提供的 `load_dataset`, `MapDataset` 和 `IterDataset` ,可以方便的自定义属于自己的数据集哦,也欢迎您贡献数据集到PaddleNLP repo。
+**A:** 通过使用 PaddleNLP 提供的 `load_dataset`, `MapDataset` 和 `IterDataset` ,可以方便的自定义属于自己的数据集哦,也欢迎您贡献数据集到 PaddleNLP repo。
-从本地文件创建数据集时,我们 **推荐** 根据本地数据集的格式给出读取function并传入 `load_dataset()` 中创建数据集。
+从本地文件创建数据集时,我们 **推荐** 根据本地数据集的格式给出读取 function 并传入 `load_dataset()` 中创建数据集。
```python
from paddlenlp.datasets import load_dataset
@@ -80,23 +80,23 @@ map_ds = load_dataset(read, data_path='train.txt', lazy=False)
iter_ds = load_dataset(read, data_path='train.txt', lazy=True)
```
-如果您习惯使用`paddle.io.Dataset/IterableDataset`来创建数据集也是支持的,您也可以从其他python对象如`List`对象创建数据集,详细内容可参照[官方文档-自定义数据集](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_self_defined.html)。
+如果您习惯使用`paddle.io.Dataset/IterableDataset`来创建数据集也是支持的,您也可以从其他 python 对象如`List`对象创建数据集,详细内容可参照[官方文档-自定义数据集](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_self_defined.html)。
-##### Q1.2 PaddleNLP会将内置的数据集、模型下载到默认路径,如何修改路径?
+##### Q1.2 PaddleNLP 会将内置的数据集、模型下载到默认路径,如何修改路径?
**A:** 内置的数据集、模型默认会下载到`$HOME/.paddlenlp/`下,通过配置环境变量可下载到指定路径:
-(1)Linux下,设置 `export PPNLP_HOME="xxxx"`,注意不要设置带有中文字符的路径。
+(1)Linux 下,设置 `export PPNLP_HOME="xxxx"`,注意不要设置带有中文字符的路径。
-(2)Windows下,同样配置环境变量 PPNLP_HOME 到其他非中文字符路径,重启即可。
+(2)Windows 下,同样配置环境变量 PPNLP_HOME 到其他非中文字符路径,重启即可。
-##### Q1.3 PaddleNLP中如何保存、加载训练好的模型?
+##### Q1.3 PaddleNLP 中如何保存、加载训练好的模型?
-**A:**(1)PaddleNLP预训练模型
+**A:**(1)PaddleNLP 预训练模型
保存:
@@ -132,19 +132,19 @@ emb.set_state_dict(load_layer_state_dict) # 加载模型参数
##### Q1.4 当训练样本较少时,有什么推荐的方法能提升模型效果吗?
-**A:** 增加训练样本带来的效果是最直接的。此外,可以基于我们开源的[预训练模型](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/transformers)进行热启,再用少量数据集fine-tune模型。此外,针对分类、匹配等场景,[小样本学习](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/few_shot)也能够带来不错的效果。
+**A:** 增加训练样本带来的效果是最直接的。此外,可以基于我们开源的[预训练模型](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/transformers)进行热启,再用少量数据集 fine-tune 模型。此外,针对分类、匹配等场景,[小样本学习](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/few_shot)也能够带来不错的效果。
-##### Q1.5 如何提升模型的性能,提升QPS?
+##### Q1.5 如何提升模型的性能,提升 QPS?
-**A:** 从工程角度,对于服务器端部署可以使用[Paddle Inference](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/inference_cn.html)高性能预测引擎进行预测部署。对于Transformer类模型的GPU预测还可以使用PaddleNLP中提供的[FastGeneration](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/ops)功能来进行快速预测,其集成了[NV FasterTransformer](https://github.com/NVIDIA/FasterTransformer)并进行了功能增强。
+**A:** 从工程角度,对于服务器端部署可以使用[Paddle Inference](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/inference_cn.html)高性能预测引擎进行预测部署。对于 Transformer 类模型的 GPU 预测还可以使用 PaddleNLP 中提供的[FastGeneration](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/ops)功能来进行快速预测,其集成了[NV FasterTransformer](https://github.com/NVIDIA/FasterTransformer)并进行了功能增强。
-从模型策略角度,可以使用一些模型小型化技术来进行模型压缩,如模型蒸馏和裁剪,通过小模型来实现加速。PaddleNLP中集成了ERNIE-Tiny这样一些通用小模型供下游任务微调使用。另外PaddleNLP提供了[模型压缩示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/model_compression),实现了DynaBERT、TinyBERT、MiniLM等方法策略,可以参考对自己的模型进行蒸馏压缩。
+从模型策略角度,可以使用一些模型小型化技术来进行模型压缩,如模型蒸馏和裁剪,通过小模型来实现加速。PaddleNLP 中集成了 ERNIE-Tiny 这样一些通用小模型供下游任务微调使用。另外 PaddleNLP 提供了[模型压缩示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/model_compression),实现了 DynaBERT、TinyBERT、MiniLM 等方法策略,可以参考对自己的模型进行蒸馏压缩。
-
+
-## ⭐️【理论篇】NLP通用问题
+## ⭐️【理论篇】NLP 通用问题
@@ -158,7 +158,7 @@ emb.set_state_dict(load_layer_state_dict) # 加载模型参数
(3)修改分类阈值:直接使用类别分布不均衡的数据训练分类器,会使得模型在预测时更偏向于多数类,所以不再以0.5为分类阈值,而是针对少数类在模型仅有较小把握时就将样本归为少数类。
-(4)代价敏感学习:比如LR算法中设置class_weight参数。
+(4)代价敏感学习:比如 LR 算法中设置 class_weight 参数。
@@ -167,9 +167,9 @@ emb.set_state_dict(load_layer_state_dict) # 加载模型参数
**A:** 很难定义具体需要多少条样本,取决于具体的任务以及数据的质量。如果数据质量没问题的话,分类、文本匹配任务所需数据量级在百级别,翻译则需要百万级能够训练出一个比较鲁棒的模型。如果样本量较少,可以考虑数据增强,或小样本学习。
-
+
-## ⭐️【实战篇】PaddleNLP实战问题
+## ⭐️【实战篇】PaddleNLP 实战问题
@@ -179,12 +179,12 @@ emb.set_state_dict(load_layer_state_dict) # 加载模型参数
##### Q3.1 使用自己的数据集训练预训练模型时,如何引入额外的词表?
-**A:** 预训练模型通常会有配套的tokenzier和词典,对于大多数中文预训练模型,如ERNIE-3.0,使用的都是字粒度的输入,tokenzier会将句子转换为字粒度的形式,模型无法收到词粒度的输入。如果希望引入额外的词典,需要修改预训练模型的tokenizer和词典,可以参考这里[blog](https://kexue.fm/archives/7758/comment-page-1#Tokenizer ),另外注意embedding矩阵也要加上这些新增词的embedding表示。
+**A:** 预训练模型通常会有配套的 tokenzier 和词典,对于大多数中文预训练模型,如 ERNIE-3.0,使用的都是字粒度的输入,tokenzier 会将句子转换为字粒度的形式,模型无法收到词粒度的输入。如果希望引入额外的词典,需要修改预训练模型的 tokenizer 和词典,可以参考这里[blog](https://kexue.fm/archives/7758/comment-page-1#Tokenizer ),另外注意 embedding 矩阵也要加上这些新增词的 embedding 表示。
-另外还有一种方式可以使用这些字典信息,可以将数据中在词典信息中的词进行整体mask进行一个mask language model的二次预训练,这样经过二次训练的模型就包含了对额外字典的表征。可参考 [PaddleNLP 预训练数据流程](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/ernie-1.0/)。
+另外还有一种方式可以使用这些字典信息,可以将数据中在词典信息中的词进行整体 mask 进行一个 mask language model 的二次预训练,这样经过二次训练的模型就包含了对额外字典的表征。可参考 [PaddleNLP 预训练数据流程](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/ernie-1.0/)。
-此外还有些词粒度及字词混合粒度的预训练模型,在这些词粒度的模型下引入额外的词表也会容易些,我们也将持续丰富PaddleNLP中的预训练模型。
+此外还有些词粒度及字词混合粒度的预训练模型,在这些词粒度的模型下引入额外的词表也会容易些,我们也将持续丰富 PaddleNLP 中的预训练模型。
@@ -192,16 +192,16 @@ emb.set_state_dict(load_layer_state_dict) # 加载模型参数
-##### Q3.2 如何加载自己的预训练模型,进而使用PaddleNLP的功能?
+##### Q3.2 如何加载自己的预训练模型,进而使用 PaddleNLP 的功能?
-**A:** 以bert为例,如果是使用PaddleNLP训练,通过`save_pretrained()`接口保存的模型,可通过`from_pretrained()`来加载:
+**A:** 以 bert 为例,如果是使用 PaddleNLP 训练,通过`save_pretrained()`接口保存的模型,可通过`from_pretrained()`来加载:
```python
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = BertModel.from_pretrained("bert-base-uncased")
```
-如果不是上述情况,可以使用如下方式加载模型,也欢迎您贡献模型到PaddleNLP repo中。
+如果不是上述情况,可以使用如下方式加载模型,也欢迎您贡献模型到 PaddleNLP repo 中。
(1)加载`BertTokenizer`和`BertModel`
@@ -292,7 +292,7 @@ model.set_state_dict(paddle.load("xxx_para"))
```
-(2)第二种方法:以ERNIE为例,将模型输出的 tensor 设置 `stop_gradient` 为 True。可以使用 `register_forward_post_hook` 按照如下的方式尝试:
+(2)第二种方法:以 ERNIE 为例,将模型输出的 tensor 设置 `stop_gradient` 为 True。可以使用 `register_forward_post_hook` 按照如下的方式尝试:
``` python
def forward_post_hook(layer, input, output):
@@ -309,29 +309,29 @@ model.set_state_dict(paddle.load("xxx_para"))
-##### Q3.5 如何在eval阶段打印评价指标,在各epoch保存模型参数?
+##### Q3.5 如何在 eval 阶段打印评价指标,在各 epoch 保存模型参数?
-**A:** 飞桨主框架提供了两种训练与预测的方法,一种是用 [paddle.Model()](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Model_cn.html)对模型进行封装,通过高层API如`Model.fit()`、`Model.evaluate()`、`Model.predict()`等完成模型的训练与预测;另一种就是基于基础API常规的训练方式。
+**A:** 飞桨主框架提供了两种训练与预测的方法,一种是用 [paddle.Model()](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Model_cn.html)对模型进行封装,通过高层 API 如`Model.fit()`、`Model.evaluate()`、`Model.predict()`等完成模型的训练与预测;另一种就是基于基础 API 常规的训练方式。
(1)对于第一种方法:
-- 我们可以设置 `paddle.Model.fit() ` API中的 *eval_data* 和 *eval_freq* 参数在训练过程中打印模型评价指标:*eval_data* 参数是一个可迭代的验证集数据源,*eval_freq* 参数是评估的频率;当*eval_data* 给定后,*eval_freq* 的默认值为1,即每一个epoch进行一次评估。注意:在训练前,我们需要在 `Model.prepare()` 接口传入metrics参数才能在eval时打印模型评价指标。
+- 我们可以设置 `paddle.Model.fit() ` API 中的 *eval_data* 和 *eval_freq* 参数在训练过程中打印模型评价指标:*eval_data* 参数是一个可迭代的验证集数据源,*eval_freq* 参数是评估的频率;当*eval_data* 给定后,*eval_freq* 的默认值为1,即每一个 epoch 进行一次评估。注意:在训练前,我们需要在 `Model.prepare()` 接口传入 metrics 参数才能在 eval 时打印模型评价指标。
-- 关于模型保存,我们可以设置 `paddle.Model.fit()` 中的 *save_freq* 参数控制模型保存的频率:*save_freq* 的默认值为1,即每一个epoch保存一次模型。
+- 关于模型保存,我们可以设置 `paddle.Model.fit()` 中的 *save_freq* 参数控制模型保存的频率:*save_freq* 的默认值为1,即每一个 epoch 保存一次模型。
(2)对于第二种方法:
-- 我们在PaddleNLP的examples目录下提供了常见任务的训练与预测脚本:如[GLUE](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/benchmark/glue) 和 [SQuAD](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/machine_reading_comprehension/SQuAD)等
+- 我们在 PaddleNLP 的 examples 目录下提供了常见任务的训练与预测脚本:如[GLUE](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/benchmark/glue) 和 [SQuAD](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/machine_reading_comprehension/SQuAD)等
- 开发者可以参考上述脚本进行自定义训练与预测脚本的开发。
-##### Q3.6 训练过程中,训练程序意外退出或Hang住,应该如何排查?
+##### Q3.6 训练过程中,训练程序意外退出或 Hang 住,应该如何排查?
-**A:** 一般先考虑内存、显存(使用GPU训练的话)是否不足,可将训练和评估的batch size调小一些。
+**A:** 一般先考虑内存、显存(使用 GPU 训练的话)是否不足,可将训练和评估的 batch size 调小一些。
-需要注意,batch size调小时,学习率learning rate也要调小,一般可按等比例调整。
+需要注意,batch size 调小时,学习率 learning rate 也要调小,一般可按等比例调整。
@@ -339,18 +339,18 @@ model.set_state_dict(paddle.load("xxx_para"))
**A:** 在验证和测试过程中常常出现的结果不一致情况一般有以下几种解决方法:
-(1)确保设置了eval模式,并保证数据相关的seed设置保证数据一致性。
+(1)确保设置了 eval 模式,并保证数据相关的 seed 设置保证数据一致性。
-(2)如果是下游任务模型,查看是否所有模型参数都被导入了,直接使用bert-base这种预训练模型是不包含任务相关参数的,要确认导入的是微调后的模型,否则任务相关参数会随机初始化导致出现随机性。
+(2)如果是下游任务模型,查看是否所有模型参数都被导入了,直接使用 bert-base 这种预训练模型是不包含任务相关参数的,要确认导入的是微调后的模型,否则任务相关参数会随机初始化导致出现随机性。
-(3)部分算子使用CUDNN后端产生的不一致性可以通过环境变量的设置来避免。如果模型中使用了CNN相关算子,可以设置`FLAGS_cudnn_deterministic=True`。如果模型中使用了RNN相关算子,可以设置`CUBLAS_WORKSPACE_CONFIG=:16:8`或`CUBLAS_WORKSPACE_CONFIG=:4096:2`(CUDNN 10.2以上版本可用,参考[CUDNN 8 release note](https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-894/release-notes/index.html))。
+(3)部分算子使用 CUDNN 后端产生的不一致性可以通过环境变量的设置来避免。如果模型中使用了 CNN 相关算子,可以设置`FLAGS_cudnn_deterministic=True`。如果模型中使用了 RNN 相关算子,可以设置`CUBLAS_WORKSPACE_CONFIG=:16:8`或`CUBLAS_WORKSPACE_CONFIG=:4096:2`(CUDNN 10.2以上版本可用,参考[CUDNN 8 release note](https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-894/release-notes/index.html))。
-##### Q3.8 ERNIE模型如何返回中间层的输出?
+##### Q3.8 ERNIE 模型如何返回中间层的输出?
-**A:** 目前的API设计不保留中间层输出,当然在PaddleNLP里可以很方便地修改源码。
-此外,还可以在`ErnieModel`的`__init__`函数中通过`register_forward_post_hook()`为想要保留输出的Layer注册一个`forward_post_hook`函数,在`forward_post_hook`函数中把Layer的输出保存到一个全局的`List`里面。`forward_post_hook`函数将会在`forward`函数调用之后被调用,并保存Layer输出到全局的`List`。详情参考[`register_forward_post_hook()`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Layer_cn.html#register_forward_post_hook)。
+**A:** 目前的 API 设计不保留中间层输出,当然在 PaddleNLP 里可以很方便地修改源码。
+此外,还可以在`ErnieModel`的`__init__`函数中通过`register_forward_post_hook()`为想要保留输出的 Layer 注册一个`forward_post_hook`函数,在`forward_post_hook`函数中把 Layer 的输出保存到一个全局的`List`里面。`forward_post_hook`函数将会在`forward`函数调用之后被调用,并保存 Layer 输出到全局的`List`。详情参考[`register_forward_post_hook()`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Layer_cn.html#register_forward_post_hook)。
@@ -358,7 +358,7 @@ model.set_state_dict(paddle.load("xxx_para"))
-##### Q3.9 PaddleNLP训练好的模型如何部署到服务器 ?
+##### Q3.9 PaddleNLP 训练好的模型如何部署到服务器 ?
**A:** 我们推荐在动态图模式下开发,静态图模式部署。
@@ -369,10 +369,10 @@ model.set_state_dict(paddle.load("xxx_para"))
可以参考官方文档 [动态图转静态图文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/04_dygraph_to_static/index_cn.html),使用 `paddle.jit.to_static` 完成动转静。
另外,在 PaddleNLP 我们也提供了导出静态图模型的例子。
-(2)借助Paddle Inference部署
+(2)借助 Paddle Inference 部署
- 动转静之后保存下来的模型可以借助Paddle Inference完成高性能推理部署。Paddle Inference内置高性能的CPU/GPU Kernel,结合细粒度OP横向纵向融合等策略,并集成 TensorRT 实现模型推理的性能提升。具体可以参考文档 [Paddle Inference 简介](https://paddleinference.paddlepaddle.org.cn/master/product_introduction/inference_intro.html)。
- 为便于初次上手的用户更易理解 NLP 模型如何使用Paddle Inference,PaddleNLP 也提供了对应的例子以供参考,可以参考 [/PaddleNLP/examples](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/) 下的deploy目录。
+ 动转静之后保存下来的模型可以借助 Paddle Inference 完成高性能推理部署。Paddle Inference 内置高性能的 CPU/GPU Kernel,结合细粒度 OP 横向纵向融合等策略,并集成 TensorRT 实现模型推理的性能提升。具体可以参考文档 [Paddle Inference 简介](https://paddleinference.paddlepaddle.org.cn/master/product_introduction/inference_intro.html)。
+ 为便于初次上手的用户更易理解 NLP 模型如何使用 Paddle Inference,PaddleNLP 也提供了对应的例子以供参考,可以参考 [/PaddleNLP/examples](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/) 下的 deploy 目录。
@@ -380,46 +380,46 @@ model.set_state_dict(paddle.load("xxx_para"))
**A:** 首先,需要将静态图参数保存成`ndarray`数据,然后将静态图参数名和对应动态图参数名对应,最后保存成动态图参数即可。详情可参考[参数转换脚本](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/paddlenlp/transformers/ernie/static_to_dygraph_params)。
-
+
### ⭐️特定模型和应用场景咨询
-##### Q4.1 【词法分析】LAC模型,如何自定义标签label,并继续训练?
+##### Q4.1 【词法分析】LAC 模型,如何自定义标签 label,并继续训练?
-**A:** 更新label文件`tag.dict`,添加 修改下CRF的标签数即可。
+**A:** 更新 label 文件`tag.dict`,添加 修改下 CRF 的标签数即可。
-可参考[自定义标签示例](https://github.com/PaddlePaddle/PaddleNLP/issues/662),[增量训练自定义LABLE示例](https://github.com/PaddlePaddle/PaddleNLP/issues/657)。
+可参考[自定义标签示例](https://github.com/PaddlePaddle/PaddleNLP/issues/662),[增量训练自定义 LABLE 示例](https://github.com/PaddlePaddle/PaddleNLP/issues/657)。
##### Q4.2 信息抽取任务中,是否推荐使用预训练模型+CRF,怎么实现呢?
-**A:** 预训练模型+CRF是一个通用的序列标注的方法,目前预训练模型对序列信息的表达也是非常强的,也可以尝试直接使用预训练模型对序列标注任务建模。
+**A:** 预训练模型+CRF 是一个通用的序列标注的方法,目前预训练模型对序列信息的表达也是非常强的,也可以尝试直接使用预训练模型对序列标注任务建模。
##### Q4.3.【阅读理解】`MapDatasets`的`map()`方法中对应的`batched=True`怎么理解,在阅读理解任务中为什么必须把参数`batched`设置为`True`?
-**A:** `batched=True`就是对整个batch(这里不一定是训练中的batch,理解为一组数据就可以)的数据进行map,即map中的trans_func接受一组数据为输入,而非逐条进行map。在阅读理解任务中,根据使用的doc_stride不同,一条样本可能被转换成多条feature,对数据逐条map是行不通的,所以需要设置`batched=True`。
+**A:** `batched=True`就是对整个 batch(这里不一定是训练中的 batch,理解为一组数据就可以)的数据进行 map,即 map 中的 trans_func 接受一组数据为输入,而非逐条进行 map。在阅读理解任务中,根据使用的 doc_stride 不同,一条样本可能被转换成多条 feature,对数据逐条 map 是行不通的,所以需要设置`batched=True`。
##### Q4.4 【语义匹配】语义索引和语义匹配有什么区别?
-**A:** 语义索引要解决的核心问题是如何从海量 Doc 中通过 ANN 索引的方式快速、准确地找出与 query 相关的文档,语义匹配要解决的核心问题是对 query和文档更精细的语义匹配信息建模。换个角度理解, [语义索引](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/semantic_indexing)是要解决搜索、推荐场景下的召回问题,而[语义匹配](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_matching)是要解决排序问题,两者要解决的问题不同,所采用的方案也会有很大不同,但两者间存在一些共通的技术点,可以互相借鉴。
+**A:** 语义索引要解决的核心问题是如何从海量 Doc 中通过 ANN 索引的方式快速、准确地找出与 query 相关的文档,语义匹配要解决的核心问题是对 query 和文档更精细的语义匹配信息建模。换个角度理解, [语义索引](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/semantic_indexing)是要解决搜索、推荐场景下的召回问题,而[语义匹配](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_matching)是要解决排序问题,两者要解决的问题不同,所采用的方案也会有很大不同,但两者间存在一些共通的技术点,可以互相借鉴。
-##### Q4.5 【解语】wordtag模型如何自定义添加命名实体及对应词类?
+##### Q4.5 【解语】wordtag 模型如何自定义添加命名实体及对应词类?
-**A:** 其主要依赖于二次构造数据来进行finetune,同时要更新termtree信息。wordtag分为两个步骤:
-(1)通过BIOES体系进行分词;
-(2)将分词后的信息和TermTree进行匹配。
+**A:** 其主要依赖于二次构造数据来进行 finetune,同时要更新 termtree 信息。wordtag 分为两个步骤:
+(1)通过 BIOES 体系进行分词;
+(2)将分词后的信息和 TermTree 进行匹配。
因此我们需要:
-(1)分词正确,这里可能依赖于wordtag的finetune数据,来让分词正确;
-(2)wordtag里面也需要把分词正确后term打上相应的知识信息。wordtag自定义TermTree的方式将在后续版本提供出来。
+(1)分词正确,这里可能依赖于 wordtag 的 finetune 数据,来让分词正确;
+(2)wordtag 里面也需要把分词正确后 term 打上相应的知识信息。wordtag 自定义 TermTree 的方式将在后续版本提供出来。
可参考[issue](https://github.com/PaddlePaddle/PaddleNLP/issues/822)。
@@ -429,16 +429,16 @@ model.set_state_dict(paddle.load("xxx_para"))
-##### Q5.1 在CUDA11使用PaddlNLP报错?
+##### Q5.1 在 CUDA11使用 PaddlNLP 报错?
-**A:** 在CUDA11安装,可参考[issue](https://github.com/PaddlePaddle/PaddleNLP/issues/348),其他CUDA版本安装可参考 [官方文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/conda/linux-conda.html)
+**A:** 在 CUDA11安装,可参考[issue](https://github.com/PaddlePaddle/PaddleNLP/issues/348),其他 CUDA 版本安装可参考 [官方文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/conda/linux-conda.html)
-##### Q5.2 如何设置parameter?
+##### Q5.2 如何设置 parameter?
**A:** 有多种方法:
-(1)可以通过`set_value()`来设置parameter,`set_value()`的参数可以是`numpy`或者`tensor`。
+(1)可以通过`set_value()`来设置 parameter,`set_value()`的参数可以是`numpy`或者`tensor`。
```python
layer.weight.set_value(
@@ -469,17 +469,17 @@ model.set_state_dict(paddle.load("xxx_para"))
-##### Q5.3 GPU版的Paddle虽然能在CPU上运行,但是必须要有GPU设备吗?
+##### Q5.3 GPU 版的 Paddle 虽然能在 CPU 上运行,但是必须要有 GPU 设备吗?
**A:** 不支持 GPU 的设备只能安装 CPU 版本的 PaddlePaddle。 GPU 版本的 PaddlePaddle 如果想只在 CPU 上运行,可以通过 `export CUDA_VISIBLE_DEVICES=-1` 来设置。
-##### Q5.4 如何指定用CPU还是GPU训练模型?
+##### Q5.4 如何指定用 CPU 还是 GPU 训练模型?
**A:** 一般我们的训练脚本提供了 `--device` 选项,用户可以通过 `--device` 选择需要使用的设备。
-具体而言,在Python文件中,我们可以通过·paddle.device.set_device()·,设置为gpu或者cpu,可参考 [set_device文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/device/set_device_cn.html#set-device)。
+具体而言,在 Python 文件中,我们可以通过·paddle.device.set_device()·,设置为 gpu 或者 cpu,可参考 [set_device 文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/device/set_device_cn.html#set-device)。
@@ -489,6 +489,6 @@ model.set_state_dict(paddle.load("xxx_para"))
-##### Q5.6 如何可视化acc、loss曲线图、模型网络结构图等?
+##### Q5.6 如何可视化 acc、loss 曲线图、模型网络结构图等?
-**A:** 可使用[VisualDL](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/index_cn.html)进行可视化。其中acc、loss曲线图的可视化可参考[Scalar——折线图组件](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/visualdl_usage_cn.html#scalar)使用指南,模型网络结构的可视化可参考[Graph——网络结构组件](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/visualdl_usage_cn.html#graph)使用指南。
+**A:** 可使用[VisualDL](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/index_cn.html)进行可视化。其中 acc、loss 曲线图的可视化可参考[Scalar——折线图组件](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/visualdl_usage_cn.html#scalar)使用指南,模型网络结构的可视化可参考[Graph——网络结构组件](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/03_VisualDL/visualdl_usage_cn.html#graph)使用指南。
diff --git a/docs/advanced_guide/prompt.md b/docs/advanced_guide/prompt.md
index 160dab275bbf..486991aa8b27 100644
--- a/docs/advanced_guide/prompt.md
+++ b/docs/advanced_guide/prompt.md
@@ -31,7 +31,7 @@ Prompt API 提供了这类算法实现的基本模块,支持[PET](https://arxi
* [数据准备](#数据准备)
* [预训练参数准备](#预训练参数准备)
* [定义提示学习模型](#定义提示学习模型)
- * [使用PromptTrainer训练](#使用PromptTrainer训练)
+ * [使用 PromptTrainer 训练](#使用 PromptTrainer 训练)
* [实践教程](#实践教程)
* [文本分类示例](#文本分类示例)
* 其他任务示例(待更新)
@@ -486,13 +486,13 @@ prompt_model = PromptModelForSequenceClassification(model,
- ``freeze_dropout`` : 在训练时固定预训练模型参数并关闭 ``dropout`` 。 当 ``freeze_dropout=True`` ,``freeze_plm`` 也为 ``True`` 。
-### 使用PromptTrainer训练
+### 使用 PromptTrainer 训练
``PromptTrainer`` 继承自 ``Trainer`` , 封装了数据处理,模型训练、测试,训练策略等,便于训练流程的快速搭建。
**配置训练参数**
-``PromptTuningArguments`` 继承自 ``TrainingArguments`` ,包含了提示学习的主要训练参数。其中 ``TrainingArguments`` 参数见 `Trainer API 文档 `_ ,其余参数详见 [Prompt Trainer参数列表](#PromptTrainer参数列表) 。推荐使用 **命令行** 的形式进行参数配置,即
+``PromptTuningArguments`` 继承自 ``TrainingArguments`` ,包含了提示学习的主要训练参数。其中 ``TrainingArguments`` 参数见 `Trainer API 文档 `_ ,其余参数详见 [Prompt Trainer 参数列表](#PromptTrainer 参数列表) 。推荐使用 **命令行** 的形式进行参数配置,即
```shell
python xxx.py --output_dir xxx --learning_rate xxx
@@ -561,11 +561,11 @@ if training_args.do_train:
### 文本分类示例
-- [多分类文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class/few-shot)
+- [多分类文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class/few-shot)
-- [多标签文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label/few-shot)
+- [多标签文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label/few-shot)
-- [多层次文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical/few-shot)
+- [多层次文本分类示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical/few-shot)
## Reference
@@ -581,7 +581,7 @@ if training_args.do_train:
### 附录
-#### PromptTrainer参数列表
+#### PromptTrainer 参数列表
| 参数 | 类型 | 默认值 | 含义 |
diff --git a/docs/compression.md b/docs/compression.md
index 3d54158498e4..c7e60669c5cc 100644
--- a/docs/compression.md
+++ b/docs/compression.md
@@ -1,21 +1,21 @@
# PaddleNLP 模型压缩 API
**目录**
- * [模型压缩 API 功能简介](#模型压缩API功简介)
+ * [模型压缩 API 功能简介](#模型压缩 API 功简介)
* [三大场景快速启动模型压缩示例](#三大场景快速启动模型压缩示例)
* [四步启动模型压缩](#四步启动模型压缩)
- * [Step1:获取模型压缩参数 compression_args](#获取模型压缩参数compression_args)
- * [Step2:实例化 Trainer 并调用 compress()](#实例化Trainer并调用compress())
- * [Trainer 实例化参数介绍](#Trainer实例化参数介绍)
+ * [Step1:获取模型压缩参数 compression_args](#获取模型压缩参数 compression_args)
+ * [Step2:实例化 Trainer 并调用 compress()](#实例化 Trainer 并调用 compress())
+ * [Trainer 实例化参数介绍](#Trainer 实例化参数介绍)
* [Step3:实现自定义评估函数(按需可选)](#实现自定义评估函数(按需可选))
* [Step4:传参并运行压缩脚本](#传参并运行压缩脚本)
- * [CompressionArguments 参数介绍](#CompressionArguments参数介绍)
+ * [CompressionArguments 参数介绍](#CompressionArguments 参数介绍)
* [模型评估与部署](#模型评估与部署)
* [FAQ](#FAQ)
* [参考文献](#References)
-
+
## 模型压缩 API 功能简介
@@ -35,7 +35,7 @@ PaddleNLP 模型压缩 API 功能支持对 ERNIE 类下游任务上微调后的
| ERNIE 3.0-Medium+裁剪+FP32 | 1424.01(1.3x) | 57.31(-0.14) | 454.27(1.2x) | 93.27(+0.23) | 183.77(1.3x) | 65.92(-1.03) |
| ERNIE 3.0-Medium+裁剪+INT8 | 3635.48(3.2x) | 57.26(-0.19) | 1105.26(3.0x) | 93.20(+0.16) | 444.27(3.0x) | 66.17(-0.78) |
-(以上数据来自 [ERNIE 3.0 性能测试文档](../legacy/model_zoo/ernie-3.0/README.md#性能测试),文档包含测试环境介绍)
+(以上数据来自 [ERNIE 3.0 性能测试文档](../slm/model_zoo/ernie-3.0/README.md#性能测试),文档包含测试环境介绍)
##### UIE 压缩效果
@@ -51,7 +51,7 @@ PaddleNLP 模型压缩 API 功能支持对 ERNIE 类下游任务上微调后的
### 三大场景快速启动模型压缩示例
-本项目提供了压缩 API 在分类(包含文本分类、文本匹配、自然语言推理、代词消歧等任务)、序列标注、抽取式阅读理解三大场景下的使用样例,可以分别参考 [ERNIE 3.0](../legacy/model_zoo/ernie-3.0) 目录下的 [compress_seq_cls.py](../legacy/model_zoo/ernie-3.0/compress_seq_cls.py) 、[compress_token_cls.py](../legacy/model_zoo/ernie-3.0/compress_token_cls.py)、[compress_qa.py](../legacy/model_zoo/ernie-3.0/compress_qa.py) 脚本,启动方式如下:
+本项目提供了压缩 API 在分类(包含文本分类、文本匹配、自然语言推理、代词消歧等任务)、序列标注、抽取式阅读理解三大场景下的使用样例,可以分别参考 [ERNIE 3.0](../slm/model_zoo/ernie-3.0) 目录下的 [compress_seq_cls.py](../slm/model_zoo/ernie-3.0/compress_seq_cls.py) 、[compress_token_cls.py](../slm/model_zoo/ernie-3.0/compress_token_cls.py)、[compress_qa.py](../slm/model_zoo/ernie-3.0/compress_qa.py) 脚本,启动方式如下:
```shell
# 分类任务
@@ -149,7 +149,7 @@ python compress.py \
```
-
+
### Step 1:获取模型压缩参数 compression_args
@@ -163,16 +163,16 @@ parser = PdArgumentParser(CompressionArguments)
compression_args = parser.parse_args_into_dataclasses()
```
-
+
### Step 2:实例化 Trainer 并调用 compress
-
+
#### Trainer 实例化参数介绍
- **--model** 待压缩的模型,目前支持 ERNIE、BERT、RoBERTa、ERNIE-M、ELECTRA、ERNIE-Gram、PP-MiniLM、TinyBERT 等结构相似的模型,是在下游任务中微调后的模型,当预训练模型选择 ERNIE 时,需要继承 `ErniePretrainedModel`。以分类任务为例,可通过`AutoModelForSequenceClassification.from_pretrained(model_name_or_path)` 等方式来获取,这种情况下,`model_name_or_path`目录下需要有 model_config.json, model_state.pdparams 文件;
-- **--data_collator** 三类任务均可使用 PaddleNLP 预定义好的 [DataCollator 类](../paddlenlp/data/data_collator.py),`data_collator` 可对数据进行 `Pad` 等操作。使用方法参考 [示例代码](../legacy/model_zoo/ernie-3.0/compress_seq_cls.py) 即可;
+- **--data_collator** 三类任务均可使用 PaddleNLP 预定义好的 [DataCollator 类](../paddlenlp/data/data_collator.py),`data_collator` 可对数据进行 `Pad` 等操作。使用方法参考 [示例代码](../slm/model_zoo/ernie-3.0/compress_seq_cls.py) 即可;
- **--train_dataset** 裁剪训练需要使用的训练集,是任务相关的数据。自定义数据集的加载可参考 [文档](https://huggingface.co/docs/datasets/loading)。不启动裁剪时,可以为 None;
- **--eval_dataset** 裁剪训练使用的评估集,也是量化使用的校准数据,是任务相关的数据。自定义数据集的加载可参考 [文档](https://huggingface.co/docs/datasets/loading)。是 Trainer 的必选参数;
- **--tokenizer** 模型 `model` 对应的 `tokenizer`,可使用 `AutoTokenizer.from_pretrained(model_name_or_path)` 来获取。
@@ -313,7 +313,7 @@ python compress.py \
下面会介绍模型压缩启动命令可以传递的超参数。
-
+
#### CompressionArguments 参数介绍
@@ -350,7 +350,7 @@ python compress.py \
- **--save_steps** 评估模型的步数。默认为 100;
-- **--optim** 裁剪训练使用的优化器名称,默认为adamw,默认为 'adamw';
+- **--optim** 裁剪训练使用的优化器名称,默认为 adamw,默认为 'adamw';
- **--learning_rate** 裁剪训练使用优化器的初始学习率,默认为 5e-05;
@@ -415,19 +415,19 @@ python compress.py \
裁剪、量化后的模型不能再通过 `from_pretrained` 导入进行预测,而是需要使用 Paddle 部署工具才能完成预测。
-压缩后的模型部署可以参考 [部署文档](../legacy/model_zoo/ernie-3.0/deploy) 完成。
+压缩后的模型部署可以参考 [部署文档](../slm/model_zoo/ernie-3.0/deploy) 完成。
### Python 部署
-服务端部署可以从这里开始。可以参考 [seq_cls_infer.py](../legacy/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py) 或者 [token_cls_infer.py](../legacy/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py) 来编写自己的预测脚本。并根据 [Python 部署指南](../legacy/model_zoo/ernie-3.0/deploy/python/README.md) 的介绍安装预测环境,对压缩后的模型进行精度评估、性能测试以及部署。
+服务端部署可以从这里开始。可以参考 [seq_cls_infer.py](../slm/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py) 或者 [token_cls_infer.py](../slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py) 来编写自己的预测脚本。并根据 [Python 部署指南](../slm/model_zoo/ernie-3.0/deploy/python/README.md) 的介绍安装预测环境,对压缩后的模型进行精度评估、性能测试以及部署。
### 服务化部署
-- [FastDeploy ERNIE 3.0 模型 Serving 部署示例](../legacy/model_zoo/ernie-3.0/deploy/serving/README.md)
-- [基于PaddleNLP SimpleServing 的服务化部署](../legacy/model_zoo/ernie-3.0/deploy/simple_serving/README.md)
+- [FastDeploy ERNIE 3.0 模型 Serving 部署示例](../slm/model_zoo/ernie-3.0/deploy/serving/README.md)
+- [基于 PaddleNLP SimpleServing 的服务化部署](../slm/model_zoo/ernie-3.0/deploy/simple_serving/README.md)
### 移动端部署
diff --git a/docs/model_zoo/model_list_multy_device.md b/docs/model_zoo/model_list_multy_device.md
index 5109f1478cfa..bee31ba526f0 100644
--- a/docs/model_zoo/model_list_multy_device.md
+++ b/docs/model_zoo/model_list_multy_device.md
@@ -3,11 +3,11 @@
## 1.模型列表
| 模型名称/硬件支持 | NPU | XPU | MLU |
| - | - | - | - |
-| [BERT](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/bert) | ✅ | ✅ | ✅ |
-| [ERNIE-3.0](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/ernie-3.0) | ✅ | ❌ | ❌ |
-| [UIE](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/uie) | ✅ | ❌ | ❌ |
+| [BERT](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/bert) | ✅ | ✅ | ✅ |
+| [ERNIE-3.0](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/ernie-3.0) | ✅ | ❌ | ❌ |
+| [UIE](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/uie) | ✅ | ❌ | ❌ |
| [UTC](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/zero_shot_text_classification) | ✅ | ❌ | ❌ |
-| [RoBERTa](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/roberta) | ✅ | ❌ | ❌ |
+| [RoBERTa](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/roberta) | ✅ | ❌ | ❌ |
## 2.各硬件使用指南
首先在硬件平台上安装飞桨环境,然后参照模型文档中的使用方法,只需将 device 参数改为对应的硬件平台即可。
diff --git a/docs/model_zoo/taskflow.md b/docs/model_zoo/taskflow.md
index 08750fe62fb8..34d4cd7ab321 100644
--- a/docs/model_zoo/taskflow.md
+++ b/docs/model_zoo/taskflow.md
@@ -1,4 +1,4 @@
-# PaddleNLP一键预测功能:Taskflow API
+# PaddleNLP 一键预测功能:Taskflow API
@@ -22,7 +22,7 @@
------------------------------------------------------------------------------------------
## 特性
-PaddleNLP提供**开箱即用**的产业级NLP预置任务能力,无需训练,一键预测。
+PaddleNLP 提供**开箱即用**的产业级 NLP 预置任务能力,无需训练,一键预测。
- 最全的中文任务:覆盖自然语言理解与自然语言生成两大核心应用;
- 极致的产业级效果:在多个中文场景上提供产业级的精度与预测性能;
- 统一的应用范式:通过`paddlenlp.Taskflow`调用,简捷易用。
@@ -30,20 +30,20 @@ PaddleNLP提供**开箱即用**的产业级NLP预置任务能力,无需训练
| 任务名称 | 调用方式 | 一键预测 | 单条输入 | 多条输入 | 文档级输入 | 定制化训练 | 其它特性 |
|:-----------------------------------|---------------------------------------------|----------|----------|----------|------------|------------|---------------------------------------------------------------------------------|
| [中文分词](#中文分词) | `Taskflow("word_segmentation")` | ✅ | ✅ | ✅ | ✅ | ✅ | 多种分词模式,满足快速切分和实体粒度精准切分 |
-| [词性标注](#词性标注) | `Taskflow("pos_tagging")` | ✅ | ✅ | ✅ | ✅ | ✅ | 基于百度前沿词法分析工具LAC |
+| [词性标注](#词性标注) | `Taskflow("pos_tagging")` | ✅ | ✅ | ✅ | ✅ | ✅ | 基于百度前沿词法分析工具 LAC |
| [命名实体识别](#命名实体识别) | `Taskflow("ner")` | ✅ | ✅ | ✅ | ✅ | ✅ | 覆盖最全中文实体标签 |
-| [依存句法分析](#依存句法分析) | `Taskflow("dependency_parsing")` | ✅ | ✅ | ✅ | | ✅ | 基于最大规模中文依存句法树库研发的DDParser |
+| [依存句法分析](#依存句法分析) | `Taskflow("dependency_parsing")` | ✅ | ✅ | ✅ | | ✅ | 基于最大规模中文依存句法树库研发的 DDParser |
| [信息抽取](#信息抽取) | `Taskflow("information_extraction")` | ✅ | ✅ | ✅ | ✅ | ✅ | 适配多场景的开放域通用信息抽取工具 |
| [『解语』-知识标注](#解语知识标注) | `Taskflow("knowledge_mining")` | ✅ | ✅ | ✅ | ✅ | ✅ | 覆盖所有中文词汇的知识标注工具 |
-| [文本纠错](#文本纠错) | `Taskflow("text_correction")` | ✅ | ✅ | ✅ | ✅ | ✅ | 融合拼音特征的端到端文本纠错模型ERNIE-CSC |
-| [文本相似度](#文本相似度) | `Taskflow("text_similarity")` | ✅ | ✅ | ✅ | | | 基于百万量级Dureader Retrieval数据集训练RocketQA并达到前沿文本相似效果 |
-| [情感分析](#情感分析) | `Taskflow("sentiment_analysis")` | ✅ | ✅ | ✅ | | ✅ | 集成BiLSTM、SKEP、UIE等模型,支持评论维度、观点抽取、情感极性分类等情感分析任务 |
-| [生成式问答](#生成式问答) | `Taskflow("question_answering")` | ✅ | ✅ | ✅ | | | 使用最大中文开源CPM模型完成问答 |
-| [智能写诗](#智能写诗) | `Taskflow("poetry_generation")` | ✅ | ✅ | ✅ | | | 使用最大中文开源CPM模型完成写诗 |
-| [开放域对话](#开放域对话) | `Taskflow("dialogue")` | ✅ | ✅ | ✅ | | | 十亿级语料训练最强中文闲聊模型PLATO-Mini,支持多轮对话 |
+| [文本纠错](#文本纠错) | `Taskflow("text_correction")` | ✅ | ✅ | ✅ | ✅ | ✅ | 融合拼音特征的端到端文本纠错模型 ERNIE-CSC |
+| [文本相似度](#文本相似度) | `Taskflow("text_similarity")` | ✅ | ✅ | ✅ | | | 基于百万量级 Dureader Retrieval 数据集训练 RocketQA 并达到前沿文本相似效果 |
+| [情感分析](#情感分析) | `Taskflow("sentiment_analysis")` | ✅ | ✅ | ✅ | | ✅ | 集成 BiLSTM、SKEP、UIE 等模型,支持评论维度、观点抽取、情感极性分类等情感分析任务 |
+| [生成式问答](#生成式问答) | `Taskflow("question_answering")` | ✅ | ✅ | ✅ | | | 使用最大中文开源 CPM 模型完成问答 |
+| [智能写诗](#智能写诗) | `Taskflow("poetry_generation")` | ✅ | ✅ | ✅ | | | 使用最大中文开源 CPM 模型完成写诗 |
+| [开放域对话](#开放域对话) | `Taskflow("dialogue")` | ✅ | ✅ | ✅ | | | 十亿级语料训练最强中文闲聊模型 PLATO-Mini,支持多轮对话 |
| [代码生成](#代码生成) | `Taskflow("code_generation")` | ✅ | ✅ | ✅ | ✅ | | 代码生成大模型 |
| [文本摘要](#文本摘要) | `Taskflow("text_summarization")` | ✅ | ✅ | ✅ | ✅ | | 文本摘要大模型 |
-| [文档智能](#文档智能) | `Taskflow("document_intelligence")` | ✅ | ✅ | ✅ | ✅ | | 以多语言跨模态布局增强文档预训练模型ERNIE-Layout为核心底座 |
+| [文档智能](#文档智能) | `Taskflow("document_intelligence")` | ✅ | ✅ | ✅ | ✅ | | 以多语言跨模态布局增强文档预训练模型 ERNIE-Layout 为核心底座 |
| [问题生成](#问题生成) | `Taskflow("question_generation")` | ✅ | ✅ | ✅ | ✅ | | 问题生成大模型 |
| [零样本文本分类](#零样本文本分类) | `Taskflow("zero_shot_text_classification")` | ✅ | ✅ | ✅ | | ✅ | 集成多场景的通用文本分类工具 |
| [模型特征提取](#模型特征提取) | `Taskflow("feature_extraction")` | ✅ | ✅ | ✅ | ✅ | | 集成文本,图片的特征抽取工具 |
@@ -59,13 +59,13 @@ PaddleNLP提供**开箱即用**的产业级NLP预置任务能力,无需训练
可进入 Jupyter Notebook 环境,在线体验 👉🏻 [进入在线运行环境](https://aistudio.baidu.com/aistudio/projectdetail/3696243)
-PaddleNLP Taskflow API 支持任务持续丰富中,我们将根据开发者反馈,灵活调整功能建设优先级,可通过Issue或[问卷](https://iwenjuan.baidu.com/?code=44amg8)反馈给我们。
+PaddleNLP Taskflow API 支持任务持续丰富中,我们将根据开发者反馈,灵活调整功能建设优先级,可通过 Issue 或[问卷](https://iwenjuan.baidu.com/?code=44amg8)反馈给我们。
## 社区交流👬
- 微信扫描二维码并填写问卷之后,加入交流群领取福利
- - 获取5月18-19日每晚20:30《产业级通用信息抽取技术UIE+ERNIE轻量级模型》直播课链接
- - 10G重磅NLP学习大礼包:
+ - 获取5月18-19日每晚20:30《产业级通用信息抽取技术 UIE+ERNIE 轻量级模型》直播课链接
+ - 10G 重磅 NLP 学习大礼包:

@@ -103,7 +103,7 @@ from paddlenlp import Taskflow
#### 批量样本输入,平均速度更快
-输入为多个句子组成的list,平均速度会更快。
+输入为多个句子组成的 list,平均速度会更快。
```python
>>> from paddlenlp import Taskflow
@@ -115,13 +115,13 @@ from paddlenlp import Taskflow
#### 自定义词典
你可以通过传入`user_dict`参数,装载自定义词典来定制分词结果。
-在默认模式和精确模式下,词典文件每一行由一个或多个自定义item组成。词典文件`user_dict.txt`示例:
+在默认模式和精确模式下,词典文件每一行由一个或多个自定义 item 组成。词典文件`user_dict.txt`示例:
```text
平原上的火焰
上 映
```
-在快速模式下,词典文件每一行为一个自定义item+"\t"+词频(词频可省略,词频省略则自动计算能保证分出该词的词频),暂时不支持黑名单词典(即通过设置”年“、”末“,以达到切分”年末“的目的)。词典文件`user_dict.txt`示例:
+在快速模式下,词典文件每一行为一个自定义 item+"\t"+词频(词频可省略,词频省略则自动计算能保证分出该词的词频),暂时不支持黑名单词典(即通过设置”年“、”末“,以达到切分”年末“的目的)。词典文件`user_dict.txt`示例:
```text
平原上的火焰 10
@@ -138,15 +138,15 @@ from paddlenlp import Taskflow
['平原上的火焰', '宣布', '延期', '上', '映']
```
#### 参数说明
-* `mode`:指定分词模式,默认为None。
+* `mode`:指定分词模式,默认为 None。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `user_dict`:自定义词典文件路径,默认为None。
-* `task_path`:自定义任务路径,默认为None。
+* `user_dict`:自定义词典文件路径,默认为 None。
+* `task_path`:自定义任务路径,默认为 None。
### 词性标注
- 基于百度词法分析工具LAC
+
基于百度词法分析工具 LAC
#### 支持单条和批量预测
```python
@@ -175,7 +175,7 @@ from paddlenlp import Taskflow
#### 自定义词典
-你可以通过装载自定义词典来定制化分词和词性标注结果。词典文件每一行表示一个自定义item,可以由一个单词或者多个单词组成,单词后面可以添加自定义标签,格式为`item/tag`,如果不添加自定义标签,则使用模型默认标签`n`。
+你可以通过装载自定义词典来定制化分词和词性标注结果。词典文件每一行表示一个自定义 item,可以由一个单词或者多个单词组成,单词后面可以添加自定义标签,格式为`item/tag`,如果不添加自定义标签,则使用模型默认标签`n`。
词典文件`user_dict.txt`示例:
@@ -198,8 +198,8 @@ from paddlenlp import Taskflow
```
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `user_dict`:用户自定义词典文件,默认为None。
-* `task_path`:自定义任务路径,默认为None。
+* `user_dict`:用户自定义词典文件,默认为 None。
+* `task_path`:自定义任务路径,默认为 None。
### 命名实体识别
@@ -242,7 +242,7 @@ from paddlenlp import Taskflow
- WordTag标签集合 |
+ WordTag 标签集合 |
@@ -379,7 +379,7 @@ from paddlenlp import Taskflow
#### 自定义词典
-你可以通过装载自定义词典来定制化命名实体识别结果。词典文件每一行表示一个自定义item,可以由一个term或者多个term组成,term后面可以添加自定义标签,格式为`item/tag`,如果不添加自定义标签,则使用模型默认标签。
+你可以通过装载自定义词典来定制化命名实体识别结果。词典文件每一行表示一个自定义 item,可以由一个 term 或者多个 term 组成,term 后面可以添加自定义标签,格式为`item/tag`,如果不添加自定义标签,则使用模型默认标签。
词典文件`user_dict.txt`示例:
@@ -408,14 +408,14 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `user_dict`:用户自定义词典文件,默认为None。
-* `task_path`:自定义任务路径,默认为None。
+* `user_dict`:用户自定义词典文件,默认为 None。
+* `task_path`:自定义任务路径,默认为 None。
* `entity_only`:只返回实体/概念词及其对应标签。
### 依存句法分析
- 基于最大规模中文依存句法树库研发的DDParser
+
基于最大规模中文依存句法树库研发的 DDParser
#### 支持多种形式输入
@@ -447,7 +447,7 @@ from paddlenlp import Taskflow
#### 多种模型选择,满足精度、速度需求
-使用ERNIE 1.0进行预测
+使用 ERNIE 1.0进行预测
```python
>>> ddp = Taskflow("dependency_parsing", model="ddparser-ernie-1.0")
@@ -455,7 +455,7 @@ from paddlenlp import Taskflow
[{'word': ['2月8日', '谷爱凌', '夺得', '北京冬奥会', '第三金'], 'head': [3, 3, 0, 5, 3], 'deprel': ['ADV', 'SBV', 'HED', 'ATT', 'VOB']}]
```
-除ERNIE 1.0外,还可使用ERNIE-Gram预训练模型,其中`model=ddparser`(基于LSTM Encoder)速度最快,`model=ddparser-ernie-gram-zh`和`model=ddparser-ernie-1.0`效果更优(两者效果相当)。
+除 ERNIE 1.0外,还可使用 ERNIE-Gram 预训练模型,其中`model=ddparser`(基于 LSTM Encoder)速度最快,`model=ddparser-ernie-gram-zh`和`model=ddparser-ernie-1.0`效果更优(两者效果相当)。
#### 输出方式
@@ -503,12 +503,12 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `model`:选择任务使用的模型,可选有`ddparser`,`ddparser-ernie-1.0`和`ddparser-ernie-gram-zh`。
-* `tree`:确保输出结果是正确的依存句法树,默认为True。
-* `prob`:是否输出每个弧对应的概率值,默认为False。
-* `use_pos`:是否返回词性标签,默认为False。
-* `use_cuda`:是否使用GPU进行切词,默认为False。
-* `return_visual`:是否返回句法树的可视化结果,默认为False。
-* `task_path`:自定义任务路径,默认为None。
+* `tree`:确保输出结果是正确的依存句法树,默认为 True。
+* `prob`:是否输出每个弧对应的概率值,默认为 False。
+* `use_pos`:是否返回词性标签,默认为 False。
+* `use_cuda`:是否使用 GPU 进行切词,默认为 False。
+* `return_visual`:是否返回句法树的可视化结果,默认为 False。
+* `task_path`:自定义任务路径,默认为 None。
### 信息抽取
@@ -518,9 +518,9 @@ from paddlenlp import Taskflow
#### 实体抽取
- 命名实体识别(Named Entity Recognition,简称NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
+ 命名实体识别(Named Entity Recognition,简称 NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
- - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema构造如下:
+ - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema 构造如下:
```text
['时间', '选手', '赛事名称']
@@ -549,7 +549,7 @@ from paddlenlp import Taskflow
'text': '谷爱凌'}]}]
```
- - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema构造如下:
+ - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema 构造如下:
```text
['肿瘤的大小', '肿瘤的个数', '肝癌级别', '脉管内癌栓分级']
@@ -581,7 +581,7 @@ from paddlenlp import Taskflow
'text': 'M0级'}]}]
```
- - 例如抽取的目标实体类型是"person"和"organization",schema构造如下:
+ - 例如抽取的目标实体类型是"person"和"organization",schema 构造如下:
```text
['person', 'organization']
@@ -607,9 +607,9 @@ from paddlenlp import Taskflow
#### 关系抽取
- 关系抽取(Relation Extraction,简称RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
+ 关系抽取(Relation Extraction,简称 RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
- - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema构造如下:
+ - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema 构造如下:
```text
{
@@ -657,7 +657,7 @@ from paddlenlp import Taskflow
'text': '2022语言与智能技术竞赛'}]}]
```
- - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema构造如下:
+ - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema 构造如下:
```text
{
@@ -690,9 +690,9 @@ from paddlenlp import Taskflow
#### 事件抽取
- 事件抽取 (Event Extraction, 简称EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
+ 事件抽取 (Event Extraction, 简称 EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
- - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema构造如下:
+ - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema 构造如下:
```text
{
@@ -705,7 +705,7 @@ from paddlenlp import Taskflow
}
```
- 触发词的格式统一为`触发词`或``XX触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
+ 触发词的格式统一为`触发词`或``XX 触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
调用示例:
@@ -716,13 +716,13 @@ from paddlenlp import Taskflow
[{'地震触发词': [{'text': '地震', 'start': 56, 'end': 58, 'probability': 0.9987181623528585, 'relations': {'地震强度': [{'text': '3.5级', 'start': 52, 'end': 56, 'probability': 0.9962985320905915}], '时间': [{'text': '5月16日06时08分', 'start': 11, 'end': 22, 'probability': 0.9882578028575182}], '震中位置': [{'text': '云南临沧市凤庆县(北纬24.34度,东经99.98度)', 'start': 23, 'end': 50, 'probability': 0.8551415716584501}], '震源深度': [{'text': '10千米', 'start': 63, 'end': 67, 'probability': 0.999158304648045}]}}]}]
```
- - 英文模型zero-shot方式**暂不支持事件抽取**,如有英文事件抽取相关语料请进行训练定制。
+ - 英文模型 zero-shot 方式**暂不支持事件抽取**,如有英文事件抽取相关语料请进行训练定制。
#### 评论观点抽取
评论观点抽取,是指抽取文本中包含的评价维度、观点词。
- - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema构造如下:
+ - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema 构造如下:
```text
{
@@ -761,7 +761,7 @@ from paddlenlp import Taskflow
'text': '店面'}]}]
```
- - 英文模型schema构造如下:
+ - 英文模型 schema 构造如下:
```text
{
@@ -792,7 +792,7 @@ from paddlenlp import Taskflow
#### 情感分类
- - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema构造如下:
+ - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema 构造如下:
```text
'情感倾向[正向,负向]'
@@ -807,7 +807,7 @@ from paddlenlp import Taskflow
[{'情感倾向[正向,负向]': [{'text': '正向', 'probability': 0.9988661643929895}]}]
```
- 英文模型schema构造如下:
+ 英文模型 schema 构造如下:
```text
'情感倾向[正向,负向]'
@@ -824,7 +824,7 @@ from paddlenlp import Taskflow
#### 跨任务抽取
- - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema可按照如下方式进行构造:
+ - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema 可按照如下方式进行构造:
```text
[
@@ -930,7 +930,7 @@ from paddlenlp import Taskflow
#### 定制训练
-对于简单的抽取目标可以直接使用```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用[定制训练](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/uie)(标注少量数据进行模型微调)以进一步提升效果。
+对于简单的抽取目标可以直接使用 ```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用[定制训练](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/uie)(标注少量数据进行模型微调)以进一步提升效果。
我们在互联网、医疗、金融三大垂类自建测试集上进行了实验:
@@ -946,16 +946,16 @@ from paddlenlp import Taskflow
uie-m-base (12L768H) | 38.46 | 74.31 | 63.37 | 87.32 | 76.27 | 80.13
|
-0-shot表示无训练数据直接通过```paddlenlp.Taskflow```进行预测,5-shot表示每个类别包含5条标注数据进行模型微调。**实验表明UIE在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
+0-shot 表示无训练数据直接通过 ```paddlenlp.Taskflow```进行预测,5-shot 表示每个类别包含5条标注数据进行模型微调。**实验表明 UIE 在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
#### 可配置参数说明
* `schema`:定义任务抽取目标,可参考开箱即用中不同任务的调用示例进行配置。
-* `schema_lang`:设置schema的语言,默认为`zh`, 可选有`zh`和`en`。因为中英schema的构造有所不同,因此需要指定schema的语言。该参数只对`uie-m-base`和`uie-m-large`模型有效。
+* `schema_lang`:设置 schema 的语言,默认为`zh`, 可选有`zh`和`en`。因为中英 schema 的构造有所不同,因此需要指定 schema 的语言。该参数只对`uie-m-base`和`uie-m-large`模型有效。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `model`:选择任务使用的模型,默认为`uie-base`,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`, `uie-nano`, `uie-medical-base`, `uie-base-en`。
-* `position_prob`:模型对于span的起始位置/终止位置的结果概率0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span的最终概率输出为起始位置概率和终止位置概率的乘积。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖(主要是**确保安装onnxruntime-gpu**)。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `position_prob`:模型对于 span 的起始位置/终止位置的结果概率0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span 的最终概率输出为起始位置概率和终止位置概率的乘积。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖(主要是**确保安装 onnxruntime-gpu**)。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
### 解语知识标注
@@ -972,16 +972,16 @@ from paddlenlp import Taskflow
**可配置参数说明:**
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `linking`:实现基于词类的linking,默认为True。
-* `task_path`:自定义任务路径,默认为None。
-* `user_dict`:用户自定义词典文件,默认为None。
+* `linking`:实现基于词类的 linking,默认为 True。
+* `task_path`:自定义任务路径,默认为 None。
+* `user_dict`:用户自定义词典文件,默认为 None。
知识挖掘-词类知识标注任务共包含91种词性及专名类别标签,标签集合如下表:
- WordTag标签集合 |
+ WordTag 标签集合 |
@@ -1113,7 +1113,7 @@ from paddlenlp import Taskflow
```
-**自定义抽取的schema**
+**自定义抽取的 schema**
``` python
>>> from pprint import pprint
@@ -1150,7 +1150,7 @@ from paddlenlp import Taskflow
'TAIL_ROLE': [{'item': '王杰', 'offset': 10, 'type': '人物类_实体'}],
'TRIG': [{'item': '作词', 'offset': 12}]}]]
```
-具体的WordTag-IE信息抽取的功能可以见[WordTag-IE具体介绍](../../legacy/examples/text_to_knowledge/wordtag-ie/README.md) .
+具体的 WordTag-IE 信息抽取的功能可以见[WordTag-IE 具体介绍](../../slm/examples/text_to_knowledge/wordtag-ie/README.md) .
#### 名词短语标注
@@ -1171,14 +1171,14 @@ from paddlenlp import Taskflow
**可配置参数说明:**
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `max_seq_len`:最大序列长度,默认为64。
-* `linking`:实现与WordTag类别标签的linking,默认为False。
-* `task_path`:自定义任务路径,默认为None。
+* `linking`:实现与 WordTag 类别标签的 linking,默认为 False。
+* `task_path`:自定义任务路径,默认为 None。
### 文本纠错
- 融合拼音特征的端到端文本纠错模型ERNIE-CSC
+
融合拼音特征的端到端文本纠错模型 ERNIE-CSC
#### 支持单条、批量预测
@@ -1197,15 +1197,15 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `task_path`:自定义任务路径,默认为None。
+* `task_path`:自定义任务路径,默认为 None。
### 文本相似度
-
基于百万量级Dureader Retrieval数据集训练RocketQA并达到前沿文本相似效果
+
基于百万量级 Dureader Retrieval 数据集训练 RocketQA 并达到前沿文本相似效果
#### 单条输入
-+ Query-Query的相似度匹配
++ Query-Query 的相似度匹配
```python
>>> from paddlenlp import Taskflow
@@ -1214,7 +1214,7 @@ from paddlenlp import Taskflow
[{'text1': '春天适合种什么花?', 'text2': '春天适合种什么菜?', 'similarity': 0.83402544}]
```
-+ Query-Passage的相似度匹配
++ Query-Passage 的相似度匹配
```python
>>> similarity = Taskflow("text_similarity", model='rocketqa-base-cross-encoder')
@@ -1224,7 +1224,7 @@ from paddlenlp import Taskflow
#### 批量样本输入,平均速度更快
-+ Query-Query的相似度匹配
++ Query-Query 的相似度匹配
```python
>>> from paddlenlp import Taskflow
@@ -1233,7 +1233,7 @@ from paddlenlp import Taskflow
[{'text1': '春天适合种什么花?', 'text2': '春天适合种什么菜?', 'similarity': 0.83402544}, {'text1': '谁有狂三这张高清的', 'text2': '这张高清图,谁有', 'similarity': 0.6540646}]
```
-+ Query-Passage的相似度匹配
++ Query-Passage 的相似度匹配
```python
>>> similarity = Taskflow("text_similarity", model='rocketqa-base-cross-encoder')
@@ -1261,11 +1261,11 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `max_seq_len`:最大序列长度,默认为384。
-* `task_path`:自定义任务路径,默认为None。
+* `task_path`:自定义任务路径,默认为 None。
### 情感分析
-
集成BiLSTM、SKEP、UIE等模型,支持评论维度、观点抽取、情感极性分类等情感分析任务
+
集成 BiLSTM、SKEP、UIE 等模型,支持评论维度、观点抽取、情感极性分类等情感分析任务
#### 支持不同模型,速度快和精度高两种模式
@@ -1315,11 +1315,11 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `model`:选择任务使用的模型,可选有`bilstm`,`skep_ernie_1.0_large_ch`,`uie-senta-base`,`uie-senta-medium`,`uie-senta-mini`,`uie-senta-micro`,`uie-senta-nano`。
-* `task_path`:自定义任务路径,默认为None。
+* `task_path`:自定义任务路径,默认为 None。
### 生成式问答
-
使用最大中文开源CPM模型完成问答
+
使用最大中文开源 CPM 模型完成问答
#### 支持单条、批量预测
@@ -1339,7 +1339,7 @@ from paddlenlp import Taskflow
### 智能写诗
-
使用最大中文开源CPM模型完成写诗
+
使用最大中文开源 CPM 模型完成写诗
#### 支持单条、批量预测
@@ -1359,7 +1359,7 @@ from paddlenlp import Taskflow
### 开放域对话
-
十亿级语料训练最强中文闲聊模型PLATO-Mini,支持多轮对话
+
十亿级语料训练最强中文闲聊模型 PLATO-Mini,支持多轮对话
#### 非交互模式
```python
@@ -1396,11 +1396,11 @@ from paddlenlp import Taskflow
```
交互模式参数:
-* `max_turn`:任务能记忆的对话轮数,当max_turn为1时,模型只能记住当前对话,无法获知之前的对话内容。
+* `max_turn`:任务能记忆的对话轮数,当 max_turn 为1时,模型只能记住当前对话,无法获知之前的对话内容。
### 代码生成
-
通过CodeGen模型来生成代码
+
通过 CodeGen 模型来生成代码
#### 支持单条、批量预测
@@ -1417,24 +1417,24 @@ from paddlenlp import Taskflow
```
#### 可配置参数说明
-* `model`:可选模型,默认为Salesforce/codegen-350M-mono,支持的模型参考[CodeGen文档](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/examples/code_generation/codegen/README.md)。
+* `model`:可选模型,默认为 Salesforce/codegen-350M-mono,支持的模型参考[CodeGen 文档](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/examples/code_generation/codegen/README.md)。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `max_length`:生成代码的最大长度,默认为128。
* `min_length`:生成代码的最小长度,默认为0。
-* `decode_strategy`:解码策略,支持greedy_search,beam_search和sampling,默认为sampling。
-* `temperature`:解码参数temperature,默认为0.6。
-* `top_k`:解码参数top_k,默认为5。
-* `top_p`:解码参数top_p,默认为1.0。
-* `num_beams`:beam_search解码的beam size,默认为4。
+* `decode_strategy`:解码策略,支持 greedy_search,beam_search 和 sampling,默认为 sampling。
+* `temperature`:解码参数 temperature,默认为0.6。
+* `top_k`:解码参数 top_k,默认为5。
+* `top_p`:解码参数 top_p,默认为1.0。
+* `num_beams`:beam_search 解码的 beam size,默认为4。
* `length_penalty`:解码长度控制值,默认为1.0。
* `repetition_penalty`:解码重复惩罚值,默认为1.1。
-* `output_scores`:是否要输出解码得分,请默认为False。
+* `output_scores`:是否要输出解码得分,请默认为 False。
### 文本摘要
-
通过Pegasus模型来生成摘要
+
通过 Pegasus 模型来生成摘要
#### 支持单条、批量预测
@@ -1460,7 +1460,7 @@ from paddlenlp import Taskflow
### 文档智能
-
以多语言跨模态布局增强文档预训练模型ERNIE-Layout为核心底座
+
以多语言跨模态布局增强文档预训练模型 ERNIE-Layout 为核心底座
#### 输入格式
@@ -1471,7 +1471,7 @@ from paddlenlp import Taskflow
]
```
-默认使用PaddleOCR进行OCR识别,同时支持用户通过``word_boxes``传入自己的OCR结果,格式为``List[str, List[float, float, float, float]]``。
+默认使用 PaddleOCR 进行 OCR 识别,同时支持用户通过``word_boxes``传入自己的 OCR 结果,格式为``List[str, List[float, float, float, float]]``。
```
[
@@ -1502,7 +1502,7 @@ from paddlenlp import Taskflow
'result': [{'end': 44, 'prob': 0.82, 'start': 38, 'value': '金融学(本科)'}]}]
```
-- http图片链接输入
+- http 图片链接输入

@@ -1526,14 +1526,14 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `lang`:选择PaddleOCR的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
-* `topn`: 如果模型识别出多个结果,将返回前n个概率值最高的结果,默认为1。
+* `lang`:选择 PaddleOCR 的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
+* `topn`: 如果模型识别出多个结果,将返回前 n 个概率值最高的结果,默认为1。
### 问题生成
-
基于百度自研中文预训练模型UNIMO-Text和大规模多领域问题生成数据集
+
基于百度自研中文预训练模型 UNIMO-Text 和大规模多领域问题生成数据集
#### 支持单条、批量预测
@@ -1559,26 +1559,26 @@ from paddlenlp import Taskflow
```
#### 可配置参数说明
-* `model`:可选模型,默认为unimo-text-1.0-dureader_qg,支持的模型有["unimo-text-1.0", "unimo-text-1.0-dureader_qg", "unimo-text-1.0-question-generation", "unimo-text-1.0-question-generation-dureader_qg"]。
+* `model`:可选模型,默认为 unimo-text-1.0-dureader_qg,支持的模型有["unimo-text-1.0", "unimo-text-1.0-dureader_qg", "unimo-text-1.0-question-generation", "unimo-text-1.0-question-generation-dureader_qg"]。
* `device`:运行设备,默认为"gpu"。
* `template`:模版,可选项有[0, 1, 2, 3],1表示使用默认模版,0表示不使用模版。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `output_scores`:是否要输出解码得分,默认为False。
-* `is_select_from_num_return_sequences`:是否对多个返回序列挑选最优项输出,当为True时,若num_return_sequences不为1则自动根据解码得分选择得分最高的序列最为最终结果,否则返回num_return_sequences个序列,默认为True。
+* `output_scores`:是否要输出解码得分,默认为 False。
+* `is_select_from_num_return_sequences`:是否对多个返回序列挑选最优项输出,当为 True 时,若 num_return_sequences 不为1则自动根据解码得分选择得分最高的序列最为最终结果,否则返回 num_return_sequences 个序列,默认为 True。
* `max_length`:生成代码的最大长度,默认为50。
* `min_length`:生成代码的最小长度,默认为3。
-* `decode_strategy`:解码策略,支持beam_search和sampling,默认为beam_search。
-* `temperature`:解码参数temperature,默认为1.0。
-* `top_k`:解码参数top_k,默认为0。
-* `top_p`:解码参数top_p,默认为1.0。
-* `num_beams`:解码参数num_beams,表示beam_search解码的beam size,默认为6。
-* `num_beam_groups`:解码参数num_beam_groups,默认为1。
-* `diversity_rate`:解码参数diversity_rate,默认为0.0。
+* `decode_strategy`:解码策略,支持 beam_search 和 sampling,默认为 beam_search。
+* `temperature`:解码参数 temperature,默认为1.0。
+* `top_k`:解码参数 top_k,默认为0。
+* `top_p`:解码参数 top_p,默认为1.0。
+* `num_beams`:解码参数 num_beams,表示 beam_search 解码的 beam size,默认为6。
+* `num_beam_groups`:解码参数 num_beam_groups,默认为1。
+* `diversity_rate`:解码参数 diversity_rate,默认为0.0。
* `length_penalty`:解码长度控制值,默认为1.2。
* `num_return_sequences`:解码返回序列数,默认为1。
* `repetition_penalty`:解码重复惩罚值,默认为1。
-* `use_fast`:表示是否开启基于FastGeneration的高性能预测,注意FastGeneration的高性能预测仅支持gpu,默认为False。
-* `use_fp16_decoding`: 表示在开启高性能预测的时候是否使用fp16来完成预测过程,若不使用则使用fp32,默认为False。
+* `use_fast`:表示是否开启基于 FastGeneration 的高性能预测,注意 FastGeneration 的高性能预测仅支持 gpu,默认为 False。
+* `use_fp16_decoding`: 表示在开启高性能预测的时候是否使用 fp16来完成预测过程,若不使用则使用 fp32,默认为 False。
@@ -1636,18 +1636,18 @@ from paddlenlp import Taskflow
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `task_path`:自定义任务路径,默认为None。
+* `task_path`:自定义任务路径,默认为 None。
* `schema`:定义任务标签候选集合。
* `model`:选择任务使用的模型,默认为`utc-base`, 支持`utc-xbase`, `utc-base`, `utc-medium`, `utc-micro`, `utc-mini`, `utc-nano`, `utc-pico`。
* `max_seq_len`:最长输入长度,包括所有标签的长度,默认为512。
* `pred_threshold`:模型对标签预测的概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
### 模型特征提取
-
基于百度自研中文图文跨模态预训练模型ERNIE-ViL 2.0
+
基于百度自研中文图文跨模态预训练模型 ERNIE-ViL 2.0
#### 多模态特征提取
@@ -1762,7 +1762,7 @@ Tensor(shape=[2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
#### 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `max_seq_len`:文本序列的最大长度,默认为128。
-* `return_tensors`: 返回的类型,有pd和np,默认为pd。
+* `return_tensors`: 返回的类型,有 pd 和 np,默认为 pd。
* `model`:选择任务使用的模型,默认为`PaddlePaddle/ernie_vil-2.0-base-zh`。
* `pooling_mode`:选择句向量获取方式,有'max_tokens','mean_tokens','mean_sqrt_len_tokens','cls_token',默认为'cls_token'(`moka-ai/m3e-base`)。
@@ -1776,20 +1776,20 @@ Tensor(shape=[2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
| 任务名称 | 默认路径 | |
|:-----------------------------------------------------------------:|:----------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------:|
-| `Taskflow("word_segmentation", mode="base")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/lexical_analysis) |
-| `Taskflow("word_segmentation", mode="accurate")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_to_knowledge/ernie-ctm) |
-| `Taskflow("pos_tagging")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/lexical_analysis) |
-| `Taskflow("ner", mode="fast")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/lexical_analysis) |
-| `Taskflow("ner", mode="accurate")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_to_knowledge/ernie-ctm) |
-| `Taskflow("information_extraction", model="uie-base")` | `$HOME/.paddlenlp/taskflow/information_extraction/uie-base` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/uie) |
-| `Taskflow("information_extraction", model="uie-tiny")` | `$HOME/.paddlenlp/taskflow/information_extraction/uie-tiny` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/uie) |
-| `Taskflow("text_correction", model="ernie-csc")` | `$HOME/.paddlenlp/taskflow/text_correction/ernie-csc` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_correction/ernie-csc) |
+| `Taskflow("word_segmentation", mode="base")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/lexical_analysis) |
+| `Taskflow("word_segmentation", mode="accurate")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_to_knowledge/ernie-ctm) |
+| `Taskflow("pos_tagging")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/lexical_analysis) |
+| `Taskflow("ner", mode="fast")` | `$HOME/.paddlenlp/taskflow/lac` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/lexical_analysis) |
+| `Taskflow("ner", mode="accurate")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_to_knowledge/ernie-ctm) |
+| `Taskflow("information_extraction", model="uie-base")` | `$HOME/.paddlenlp/taskflow/information_extraction/uie-base` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/uie) |
+| `Taskflow("information_extraction", model="uie-tiny")` | `$HOME/.paddlenlp/taskflow/information_extraction/uie-tiny` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/uie) |
+| `Taskflow("text_correction", model="ernie-csc")` | `$HOME/.paddlenlp/taskflow/text_correction/ernie-csc` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_correction/ernie-csc) |
| `Taskflow("dependency_parsing", model="ddparser")` | `$HOME/.paddlenlp/taskflow/dependency_parsing/ddparser` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dependency_parsing/ddparser) |
| `Taskflow("dependency_parsing", model="ddparser-ernie-1.0")` | `$HOME/.paddlenlp/taskflow/dependency_parsing/ddparser-ernie-1.0` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dependency_parsing/ddparser) |
| `Taskflow("dependency_parsing", model="ddparser-ernie-gram-zh")` | `$HOME/.paddlenlp/taskflow/dependency_parsing/ddparser-ernie-gram-zh` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dependency_parsing/ddparser) |
-| `Taskflow("sentiment_analysis", model="skep_ernie_1.0_large_ch")` | `$HOME/.paddlenlp/taskflow/sentiment_analysis/skep_ernie_1.0_large_ch` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/sentiment_analysis/skep) |
-| `Taskflow("knowledge_mining", model="wordtag")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_to_knowledge/ernie-ctm) |
-| `Taskflow("knowledge_mining", model="nptag")` | `$HOME/.paddlenlp/taskflow/knowledge_mining/nptag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_to_knowledge/nptag) |
+| `Taskflow("sentiment_analysis", model="skep_ernie_1.0_large_ch")` | `$HOME/.paddlenlp/taskflow/sentiment_analysis/skep_ernie_1.0_large_ch` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/sentiment_analysis/skep) |
+| `Taskflow("knowledge_mining", model="wordtag")` | `$HOME/.paddlenlp/taskflow/wordtag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_to_knowledge/ernie-ctm) |
+| `Taskflow("knowledge_mining", model="nptag")` | `$HOME/.paddlenlp/taskflow/knowledge_mining/nptag` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_to_knowledge/nptag) |
| `Taskflow("zero_shot_text_classification", model="utc-base")` | `$HOME/.paddlenlp/taskflow/zero_shot_text_classification/utc-base` | [示例](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/zero_shot_text_classification) |
@@ -1808,7 +1808,7 @@ $HOME/.paddlenlp/taskflow/wordtag/
└── tags.txt # 默认标签文件
```
-* 参考上表中对应[示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_to_knowledge/ernie-ctm)准备数据集和标签文件`tags.txt`,执行相应训练脚本得到自己的`model_state.pdparams`和`model_config.json`。
+* 参考上表中对应[示例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/text_to_knowledge/ernie-ctm)准备数据集和标签文件`tags.txt`,执行相应训练脚本得到自己的`model_state.pdparams`和`model_config.json`。
* 根据自己数据集情况,修改标签文件`tags.txt`。
@@ -1820,7 +1820,7 @@ custom_task_path/
├── model_config.json # 定制模型配置文件
└── tags.txt # 定制标签文件
```
-* 通过`task_path`指定自定义路径,使用Taskflow加载自定义模型进行一键预测:
+* 通过`task_path`指定自定义路径,使用 Taskflow 加载自定义模型进行一键预测:
```python
from paddlenlp import Taskflow
@@ -1834,23 +1834,23 @@ my_ner = Taskflow("ner", mode="accurate", task_path="./custom_task_path/")
@@ -1859,27 +1859,27 @@ my_ner = Taskflow("ner", mode="accurate", task_path="./custom_task_path/")
## FAQ
-
Q:Taskflow如何修改任务保存路径?
+
Q:Taskflow 如何修改任务保存路径?
-**A:** Taskflow默认会将任务相关模型等文件保存到`$HOME/.paddlenlp`下,可以在任务初始化的时候通过`home_path`自定义修改保存路径。示例:
+**A:** Taskflow 默认会将任务相关模型等文件保存到`$HOME/.paddlenlp`下,可以在任务初始化的时候通过`home_path`自定义修改保存路径。示例:
```python
from paddlenlp import Taskflow
ner = Taskflow("ner", home_path="/workspace")
```
-通过以上方式即可将ner任务相关文件保存至`/workspace`路径下。
+通过以上方式即可将 ner 任务相关文件保存至`/workspace`路径下。
Q:下载或调用模型失败,多次下载均失败怎么办?
-**A:** Taskflow默认会将任务相关模型等文件保存到`$HOME/.paddlenlp/taskflow`下,如果下载或调用失败,可删除相应路径下的文件,重新尝试即可
+**A:** Taskflow 默认会将任务相关模型等文件保存到`$HOME/.paddlenlp/taskflow`下,如果下载或调用失败,可删除相应路径下的文件,重新尝试即可
-
Q:Taskflow如何提升预测速度?
+
Q:Taskflow 如何提升预测速度?
-**A:** 可以结合设备情况适当调整batch_size,采用批量输入的方式来提升平均速率。示例:
+**A:** 可以结合设备情况适当调整 batch_size,采用批量输入的方式来提升平均速率。示例:
```python
from paddlenlp import Taskflow
@@ -1896,7 +1896,7 @@ seg_accurate(texts)
Q:后续会增加更多任务支持吗?
-**A:** Taskflow支持任务持续丰富中,我们将根据开发者反馈,灵活调整功能建设优先级,可通过Issue或[问卷](https://wenjuan.baidu-int.com/manage/?r=survey/pageEdit&sid=85827)反馈给我们。
+**A:** Taskflow 支持任务持续丰富中,我们将根据开发者反馈,灵活调整功能建设优先级,可通过 Issue 或[问卷](https://wenjuan.baidu-int.com/manage/?r=survey/pageEdit&sid=85827)反馈给我们。
diff --git a/docs/server.md b/docs/server.md
index 994967859506..17b8ccb61f05 100644
--- a/docs/server.md
+++ b/docs/server.md
@@ -1,13 +1,13 @@
# PaddleNLP SimpleSevring
-PaddleNLP SimpleServing 是基于 unicorn 封装的模型部署服务化工具,该服务化工具具备灵活、易用的特性,可以简易部署预训练模型和预训练模型工具Taskflow,PaddleNLP SimpleServing 具备以下两个特性:
- - 易用:一行代码即可部署预训练模型和预训练工具Taskflow
- - 灵活:Handler机制可以快速定制化服务化部署方式
+PaddleNLP SimpleServing 是基于 unicorn 封装的模型部署服务化工具,该服务化工具具备灵活、易用的特性,可以简易部署预训练模型和预训练模型工具 Taskflow,PaddleNLP SimpleServing 具备以下两个特性:
+ - 易用:一行代码即可部署预训练模型和预训练工具 Taskflow
+ - 灵活:Handler 机制可以快速定制化服务化部署方式
-## Tasflow部署
+## Tasflow 部署
-Taskflow 是 PaddleNLP 预训练模型工具,具备开箱即用的特性,同时 Taskflow 可以支持加载微调后的模型,基于 Taskflow 的服务化方式可以进一步降低使用者的部署难度。PaddleNLP SimpleServing 基于这样的设计需求,设计了一套基于Taskflow的快速部署方式。下面从 server 搭建,client 发送请求来详细介绍使用方式。
+Taskflow 是 PaddleNLP 预训练模型工具,具备开箱即用的特性,同时 Taskflow 可以支持加载微调后的模型,基于 Taskflow 的服务化方式可以进一步降低使用者的部署难度。PaddleNLP SimpleServing 基于这样的设计需求,设计了一套基于 Taskflow 的快速部署方式。下面从 server 搭建,client 发送请求来详细介绍使用方式。
### server 搭建
@@ -35,7 +35,7 @@ taskflow_handler(paddlenlp.server.BaseTaskflowHandler, 可选):
Taskflow句柄处理类,可以自定义处理类来定制化Taskflow服务,默认为None,是默认的TaskflowHandler
```
### 多卡服务化(可选)
-在机器环境里面如果有多卡,那就可以register taskflow服务化时,可以注册多个Taskflow实例,在服务化处理请求的过程中做了负载均衡,保证机器设备利用率充分利用,下面是具体的使用例子
+在机器环境里面如果有多卡,那就可以 register taskflow 服务化时,可以注册多个 Taskflow 实例,在服务化处理请求的过程中做了负载均衡,保证机器设备利用率充分利用,下面是具体的使用例子
```python
schema = ['出发地', '目的地', '费用', '时间']
uie1 = Taskflow("information_extraction", schema=schema, device_id=0)
@@ -77,9 +77,9 @@ r = requests.post(url=url, headers=headers, data=json.dumps(data))
datas = json.loads(r.text)
print(datas)
```
-通过上述代码配置即可发送POST请求,同时注意在`data`这个key填入相关请求
+通过上述代码配置即可发送 POST 请求,同时注意在`data`这个 key 填入相关请求
-同时可以支持定义 `schema` 传入到client请求中,可以快速切换 `schema`
+同时可以支持定义 `schema` 传入到 client 请求中,可以快速切换 `schema`
```python
import requests
@@ -102,7 +102,7 @@ print(datas)
```
## 预训练模型部署
-PaddleNLP SimpleServing 除了能支持Taskflow的服务化部署,也能支持预训练模型的部署,通过简单的配置即可加载预训练模型来进行服务化,同时在接口层面也能支持服务化的扩展,支持模型前后处理的定制化需求。
+PaddleNLP SimpleServing 除了能支持 Taskflow 的服务化部署,也能支持预训练模型的部署,通过简单的配置即可加载预训练模型来进行服务化,同时在接口层面也能支持服务化的扩展,支持模型前后处理的定制化需求。
## server 搭建
@@ -142,8 +142,8 @@ precision(str):
device_id(int, list(int)):
GPU设备,device_id默认为0,同时如果有多张显卡,可以设置成list,例如[0, 1]就可以支持多卡服务化;CPU设备,不用设置。
```
-- BaseModelHandler继承类:主要是 `CustomModelHandler`,该类的实现可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/custom_model_handler.py), 绝大多数语义理解模型均可使用该继承类
-- BasePostHandler继承类:主要是文本分类 `MultiClassificationPostHandler`、`MultiLabelClassificationPostHandler` 来支持多分类、多标签分类,实现代码部分可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/cls_post_handler.py);`TokenClsModelHandler` 支持 序列标注任务,实现代码部分可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/token_model_handler.py)
+- BaseModelHandler 继承类:主要是 `CustomModelHandler`,该类的实现可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/custom_model_handler.py), 绝大多数语义理解模型均可使用该继承类
+- BasePostHandler 继承类:主要是文本分类 `MultiClassificationPostHandler`、`MultiLabelClassificationPostHandler` 来支持多分类、多标签分类,实现代码部分可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/cls_post_handler.py);`TokenClsModelHandler` 支持 序列标注任务,实现代码部分可以参考[链接](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/server/handlers/token_model_handler.py)
### 启动服务化
执行代码的即可启动服务
@@ -199,9 +199,9 @@ texts = [
result_json = json.loads(r.text)
print(result_json)
```
-在Client发送请求的过程中可以一些参数来控制服务化处理逻辑,例如上面的 `max_seq_len`和 `batch_size` 均可以控制服务化处理时的序列长度和处理batch_size 。
+在 Client 发送请求的过程中可以一些参数来控制服务化处理逻辑,例如上面的 `max_seq_len`和 `batch_size` 均可以控制服务化处理时的序列长度和处理 batch_size 。
## 参考示例
-- [UIE 服务化部署](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/uie/deploy/serving/simple_serving)
-- [文本分类服务化部署](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class/deploy/simple_serving)
-- [预训练模型定制化post_handler](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/model_zoo/ernie-health/cblue/deploy/serving/simple_serving)
+- [UIE 服务化部署](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/uie/deploy/serving/simple_serving)
+- [文本分类服务化部署](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class/deploy/simple_serving)
+- [预训练模型定制化 post_handler](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/model_zoo/ernie-health/cblue/deploy/serving/simple_serving)
diff --git a/docs/trainer.md b/docs/trainer.md
index 3f5c0cab7df8..fd4974b3bf7c 100644
--- a/docs/trainer.md
+++ b/docs/trainer.md
@@ -14,7 +14,7 @@ PaddleNLP 提供了 Trainer 训练 API,针对训练过程的通用训练配置
## Trainer 基本使用方法介绍
下面是用户使用 Trainer API 进行 finetune 任务的简单示例,这里以中文情感分类数据集`chnsenticorp`为例。
-更详细的使用可以参考[CLUE Trainer](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/examples/benchmark/clue/classification/run_clue_classifier_trainer.py)版本。
+更详细的使用可以参考[CLUE Trainer](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/examples/benchmark/clue/classification/run_clue_classifier_trainer.py)版本。
1. 导入需要用到的头文件。
- 主要是模型、Tokenizer
@@ -82,7 +82,7 @@ if training_args.do_train:
trainer.log_metrics("train", metrics)
trainer.save_state()
```
-预训练的使用方式可以参考[ERNIE-1.0 Trainer](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/model_zoo/ernie-1.0/run_pretrain_trainer.py)版本。
+预训练的使用方式可以参考[ERNIE-1.0 Trainer](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/model_zoo/ernie-1.0/run_pretrain_trainer.py)版本。
## Trainer 进阶分布式能力使用介绍
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh b/legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
deleted file mode 100644
index 0197b9a6c223..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
+++ /dev/null
@@ -1 +0,0 @@
-python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh b/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
deleted file mode 100644
index c20a4d057ab1..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python deploy/python/predict.py --model_dir ./output \
- --input_file data/test.csv \
- --model_name_or_path rocketqa-base-cross-encoder
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh b/legacy/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
deleted file mode 100644
index f42491cda38d..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python evaluate.py --model_name_or_path rocketqa-base-cross-encoder \
- --init_from_ckpt checkpoints/model_80000/model_state.pdparams \
- --test_file data/dev_pairwise.csv
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh b/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
deleted file mode 100644
index a6c54ae878d9..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-python export_model.py \
- --params_path checkpoints/model_80000/model_state.pdparams \
- --model_name_or_path rocketqa-base-cross-encoder \
- --output_path=./output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh b/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
deleted file mode 100644
index 4a5fe6bfe576..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-python export_to_serving.py \
- --dirname "output" \
- --model_filename "inference.pdmodel" \
- --params_filename "inference.pdiparams" \
- --server_path "serving_server" \
- --client_path "serving_client" \
- --fetch_alias_names "predict"
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh b/legacy/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
deleted file mode 100644
index 46f6fc50d099..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-unset CUDA_VISIBLE_DEVICES
-export CUDA_VISIBLE_DEVICES=0
-python predict.py \
- --device 'gpu' \
- --params_path checkpoints/model_80000/model_state.pdparams \
- --model_name_or_path rocketqa-base-cross-encoder \
- --test_set data/test.csv \
- --topk 10 \
- --batch_size 128 \
- --max_seq_length 384
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh b/legacy/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
deleted file mode 100644
index 570f528902c6..000000000000
--- a/legacy/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-unset CUDA_VISIBLE_DEVICES
-python -u -m paddle.distributed.launch --gpus "0,1,2,3" --log_dir="logs" train_ce.py \
- --device gpu \
- --train_set data/train.csv \
- --test_file data/dev_pairwise.csv \
- --save_dir ./checkpoints \
- --model_name_or_path rocketqa-base-cross-encoder \
- --batch_size 32 \
- --save_steps 10000 \
- --max_seq_len 384 \
- --learning_rate 1E-5 \
- --weight_decay 0.01 \
- --warmup_proportion 0.0 \
- --logging_steps 10 \
- --seed 1 \
- --epochs 3 \
- --eval_step 1000
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh b/legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
deleted file mode 100644
index 0197b9a6c223..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
+++ /dev/null
@@ -1 +0,0 @@
-python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh b/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
deleted file mode 100644
index 2eeeb719b514..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python deploy/python/predict.py --model_dir ./output \
- --input_file sort/test_pairwise.csv \
- --model_name_or_path ernie-3.0-medium-zh
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh b/legacy/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
deleted file mode 100644
index bfb8c120a4cf..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-unset CUDA_VISIBLE_DEVICES
-# gpu
-python -u -m paddle.distributed.launch --gpus "0" evaluate.py \
- --device gpu \
- --batch_size 32 \
- --learning_rate 2E-5 \
- --init_from_ckpt "./checkpoints/model_30000/model_state.pdparams" \
- --test_file sort/dev_pairwise.csv
-
-# cpu
-# python evaluate.py \
-# --device cpu \
-# --batch_size 32 \
-# --learning_rate 2E-5 \
-# --init_from_ckpt "./checkpoints/model_30000/model_state.pdparams" \
-# --test_file sort/dev_pairwise.csv
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh b/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
deleted file mode 100644
index f6849a95eb80..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python export_model.py --params_path checkpoints/model_30000/model_state.pdparams \
- --output_path=./output \
- --model_name_or_path ernie-3.0-medium-zh
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh b/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
deleted file mode 100644
index c252f811e29c..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-python export_to_serving.py \
- --dirname "output" \
- --model_filename "inference.predict.pdmodel" \
- --params_filename "inference.predict.pdiparams" \
- --server_path "serving_server" \
- --client_path "serving_client" \
- --fetch_alias_names "predict"
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh b/legacy/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
deleted file mode 100644
index fe0767e14bfa..000000000000
--- a/legacy/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-# gpu
-python -u -m paddle.distributed.launch --gpus "0" \
- predict_pairwise.py \
- --device gpu \
- --params_path "./checkpoints/model_30000/model_state.pdparams"\
- --batch_size 128 \
- --max_seq_length 64 \
- --input_file 'sort/test_pairwise.csv'
-# cpu
-# python predict_pairwise.py \
-# --device gpu \
-# --params_path "./checkpoints/model_30000/model_state.pdparams"\
-# --batch_size 128 \
-# --max_seq_length 64 \
-# --input_file 'sort/test_pairwise.csv'
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh b/legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
deleted file mode 100644
index 55d380d6f873..000000000000
--- a/legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
+++ /dev/null
@@ -1 +0,0 @@
-python -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_id 2 --thread 5 --ir_optim True --use_trt --precision FP16
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh b/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
deleted file mode 100644
index fe8f071e0a47..000000000000
--- a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
+++ /dev/null
@@ -1 +0,0 @@
-python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh b/legacy/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
deleted file mode 100644
index 84d6f162b80e..000000000000
--- a/legacy/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-python -u evaluate.py \
- --similar_text_pair "recall/dev.csv" \
- --recall_result_file "./recall_result_dir/recall_result.txt" \
- --recall_num 50
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh b/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
deleted file mode 100644
index 99d01c7b5aae..000000000000
--- a/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python export_model.py --params_path checkpoints/inbatch/model_40/model_state.pdparams \
- --model_name_or_path rocketqa-zh-base-query-encoder \
- --output_path=./output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh b/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
deleted file mode 100644
index b0d7a422551f..000000000000
--- a/legacy/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-python export_to_serving.py \
- --dirname "output" \
- --model_filename "inference.get_pooled_embedding.pdmodel" \
- --params_filename "inference.get_pooled_embedding.pdiparams" \
- --server_path "serving_server" \
- --client_path "serving_client" \
- --fetch_alias_names "output_embedding"
diff --git a/legacy/applications/neural_search/recall/milvus/scripts/feature_extract.sh b/legacy/applications/neural_search/recall/milvus/scripts/feature_extract.sh
deleted file mode 100644
index 7f996ac0600a..000000000000
--- a/legacy/applications/neural_search/recall/milvus/scripts/feature_extract.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-CUDA_VISIBLE_DEVICES=2 python feature_extract.py \
- --model_dir ./output \
- --model_name_or_path rocketqa-zh-base-query-encoder \
- --batch_size 512 \
- --corpus_file "milvus/milvus_data.csv"
-
diff --git a/legacy/applications/neural_search/recall/milvus/scripts/search.sh b/legacy/applications/neural_search/recall/milvus/scripts/search.sh
deleted file mode 100644
index 5c4cdeea3536..000000000000
--- a/legacy/applications/neural_search/recall/milvus/scripts/search.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-python milvus_ann_search.py --data_path milvus/milvus_data.csv \
- --embedding_path corpus_embedding.npy \
- --batch_size 100000 \
- --index 18 \
- --insert \
- --search
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/deploy/python/deploy.sh b/legacy/applications/neural_search/recall/simcse/deploy/python/deploy.sh
deleted file mode 100644
index fe8f071e0a47..000000000000
--- a/legacy/applications/neural_search/recall/simcse/deploy/python/deploy.sh
+++ /dev/null
@@ -1 +0,0 @@
-python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/scripts/evaluate.sh b/legacy/applications/neural_search/recall/simcse/scripts/evaluate.sh
deleted file mode 100755
index a95782c94d3e..000000000000
--- a/legacy/applications/neural_search/recall/simcse/scripts/evaluate.sh
+++ /dev/null
@@ -1,4 +0,0 @@
- python -u evaluate.py \
- --similar_text_pair "recall/dev.csv" \
- --recall_result_file "./recall_result_dir/recall_result.txt" \
- --recall_num 50
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/scripts/export_model.sh b/legacy/applications/neural_search/recall/simcse/scripts/export_model.sh
deleted file mode 100644
index 629440b9b079..000000000000
--- a/legacy/applications/neural_search/recall/simcse/scripts/export_model.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-python export_model.py --params_path checkpoints/model_12000/model_state.pdparams \
- --model_name_or_path rocketqa-zh-base-query-encoder \
- --output_path=./output
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
deleted file mode 100644
index fe8f071e0a47..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
+++ /dev/null
@@ -1 +0,0 @@
-python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
deleted file mode 100644
index 900d7283f76e..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-python -u evaluate.py \
- --similar_text_pair "data/dev.txt" \
- --recall_result_file "./recall_result_dir/recall_result.txt" \
- --recall_num 50
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
deleted file mode 100644
index bda31ba21ea8..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
+++ /dev/null
@@ -1 +0,0 @@
-python export_model.py --params_path checkpoints/inbatch/model_best/model_state.pdparams --output_path=./output
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
deleted file mode 100644
index b0d7a422551f..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-python export_to_serving.py \
- --dirname "output" \
- --model_filename "inference.get_pooled_embedding.pdmodel" \
- --params_filename "inference.get_pooled_embedding.pdiparams" \
- --server_path "serving_server" \
- --client_path "serving_client" \
- --fetch_alias_names "output_embedding"
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
deleted file mode 100644
index 8bcd987f155e..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-CUDA_VISIBLE_DEVICES=0 python utils/feature_extract.py \
- --data_name label \
- --model_dir ./output \
- --output_dir data \
- --corpus_file "./data/label.txt"
-
-python utils/vector_insert.py \
- --vector_path ./data/label_embedding.npy
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh b/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
deleted file mode 100755
index 3fa603020713..000000000000
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-# GPU version
-root_dir="checkpoints/inbatch"
-python -u -m paddle.distributed.launch --gpus "0" --log_dir "recall_log/" \
- recall.py \
- --device gpu \
- --recall_result_dir "recall_result_dir" \
- --recall_result_file "recall_result.txt" \
- --params_path "${root_dir}/model_best/model_state.pdparams" \
- --hnsw_m 100 \
- --hnsw_ef 100 \
- --batch_size 64 \
- --output_emb_size 0 \
- --max_seq_length 384 \
- --recall_num 50 \
- --similar_text_pair "data/dev.txt" \
- --corpus_file "data/train.txt"
\ No newline at end of file
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh b/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
deleted file mode 100644
index fe8f071e0a47..000000000000
--- a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
+++ /dev/null
@@ -1 +0,0 @@
-python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/examples/benchmark/ceval/README.md b/legacy/examples/benchmark/ceval/README.md
deleted file mode 100644
index 67b803ed81dc..000000000000
--- a/legacy/examples/benchmark/ceval/README.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# C-Eval评测脚本
-
-此C-Eval评测脚本修改自[ymcui/Chinese-LLaMA-Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca)项目。
-
-## 数据准备
-
-从C-Eval官方指定路径下载评测数据集,并解压至data文件夹:
-
-```
-wget https://huggingface.co/datasets/ceval/ceval-exam/resolve/main/ceval-exam.zip
-unzip ceval-exam.zip -d data
-```
-将data文件夹放置于本项目的scripts/ceval目录下。
-
-## 运行预测脚本
-
-运行以下脚本:
-
-```
-cd scripts/ceval
-python eval.py \
- --model_name_or_path /path/to/your/model \
- --cot False \
- --few_shot False \
- --with_prompt True \
- --constrained_decoding True \
- --temperature 0.2 \
- --n_times 1 \
- --ntrain 5 \
- --do_save_csv False \
- --do_test False \
- --output_dir ${output_path} \
-```
-
-参数说明
-
-- model_path:待评测模型所在目录(合并LoRA后的HF格式模型)
-- cot:是否使用chain-of-thought
-- few_shot:是否使用few-shot
-- ntrain:few_shot=True时,指定few-shot实例的数量(5-shot:ntrain=5);few_shot=False时该项不起作用
-- with_prompt:模型输入是否包含针对Alpaca模型的指令模板
-- constrained_decoding:由于C-Eval评测的标准答案格式为选项'A'/'B'/'C'/'D',所以我们提供了两种从模型生成内容中抽取答案的方案:
- - 当constrained_decoding=True,计算模型生成的第一个token分别为'A', 'B', 'C', 'D'的概率,选择其中概率最大的一个作为答案
- - 当constrained_decoding=False,用正则表达式从模型生成内容中提取答案
-- temperature:模型解码时的温度
-- n_times:指定评测的重复次数,将在output_dir下生成指定次数的文件夹
-- do_save_csv:是否将模型生成结果、提取的答案等内容保存在csv文件中
-- output_dir:指定评测结果的输出路径
-- do_test:在valid或test集上测试:当do_test=False,在valid集上测试;当do_test=True,在test集上测试
-
-## 评测输出
-模型预测完成后,生成目录`outputs/take*`,其中*代表数字,范围为0至`n_times-1`,分别储存了`n_times`次解码的结果。
-
-`outputs/take*`下包含`submission.json`和`summary.json`两个json文件。若`do_save_csv=True`,还将包含52个保存的模型生成结果、提取的答案等内容的csv文件。
-
-`submission.json`为依据官方提交规范生成的存储模型评测答案的文件,形式如:
-
-```
-{
- "computer_network": {
- "0": "A",
- "1": "B",
- ...
- },
- "marxism": {
- "0": "B",
- "1": "A",
- ...
- },
- ...
-}
-```
-
-summary.json包含模型在52个主题下、4个大类下和总体平均的评测结果。例如,json文件最后的All字段中会显示总体平均效果:
-
-```
- "All": {
- "score": 0.36701337295690933,
- "num": 1346,
- "correct": 494.0
-}
-```
-
-其中score为准确率,num为测试的总样本条数,correct为正确的数量。
diff --git a/legacy/examples/information_extraction/DuIE/README.md b/legacy/examples/information_extraction/DuIE/README.md
deleted file mode 100644
index c40cd28a3e15..000000000000
--- a/legacy/examples/information_extraction/DuIE/README.md
+++ /dev/null
@@ -1,142 +0,0 @@
-# LIC2021 DuIE 关系抽取基线
-
-信息抽取旨在从非结构化自然语言文本中提取结构化知识,如实体、关系、事件等。关系抽取的目标是对于给定的自然语言句子,根据预先定义的schema集合,抽取出所有满足schema约束的SPO三元组。schema定义了关系P以及其对应的主体S和客体O的类别。
-本基线系统基于预训练语言模型ERNIE设计了结构化的标注策略,可以实现多条、交叠的SPO抽取。
-
-该示例展示了如何使用PaddleNLP快速复现[LIC2021关系抽取比赛](http://lic2021.ccf.org.cn/)基线并进阶优化模型基线。
-
-同时,我们提供了该示例在线运行展示教程:
-[PaddleNLP实战——LIC2021关系抽取任务基线](https://aistudio.baidu.com/aistudio/projectdetail/1639963)
-
-
-## 目录结构
-
-以下是本项目主要目录结构及说明:
-
-```text
-DuIE/
-├── data_loader.py # 加载数据
-├── extract_chinese_and_punct.py # 文本数据预处理
-├── README.md # 文档说明
-├── re_official_evaluation.py # 比赛评价脚本
-├── run_duie.py # 模型训练脚本
-├── train.sh # 启动脚本
-└── utils.py # 效能函数
-```
-
-## 关系抽取基线
-
-针对 DuIE2.0 任务中多条、交叠SPO这一抽取目标,比赛对标准的 'BIO' 标注进行了扩展。
-对于每个 token,根据其在实体span中的位置(包括B、I、O三种),我们为其打上三类标签,并且根据其所参与构建的predicate种类,将 B 标签进一步区分。给定 schema 集合,对于 N 种不同 predicate,以及头实体/尾实体两种情况,我们设计对应的共 2*N 种 B 标签,再合并 I 和 O 标签,故每个 token 一共有 (2*N+2) 个标签,如下图所示。
-
-
-

-
-
-### 评价方法
-
-对测试集上参评系统输出的SPO结果和人工标注的SPO结果进行精准匹配,采用F1值作为评价指标。注意,对于复杂O值类型的SPO,必须所有槽位都精确匹配才认为该SPO抽取正确。针对部分文本中存在实体别名的问题,使用百度知识图谱的别名词典来辅助评测。F1值的计算方式如下:
-
-F1 = (2 * P * R) / (P + R),其中
-
-- P = 测试集所有句子中预测正确的SPO个数 / 测试集所有句子中预测出的SPO个数
-- R = 测试集所有句子中预测正确的SPO个数 / 测试集所有句子中人工标注的SPO个数
-
-### 快速复现基线Step1:构建模型
-
-该任务可以看作一个序列标注任务,所以基线模型采用的是ERNIE序列标注模型。
-
-**PaddleNLP提供了ERNIE预训练模型常用序列标注模型,可以通过指定模型名字完成一键加载.PaddleNLP为了方便用户处理数据,内置了对于各个预训练模型对应的Tokenizer,可以完成文本token化,转token ID,文本长度截断等操作。**
-
-```python
-from paddlenlp.transformers import AutoModelForTokenClassification, AutoTokenizer
-
-model = AutoModelForTokenClassification.from_pretrained("ernie-3.0-medium-zh", num_classes=(len(label_map) - 2) * 2 + 2)
-tokenizer = AutoTokenizer.from_pretrained("ernie-3.0-medium-zh")
-```
-
-文本数据处理直接调用tokenizer即可输出模型所需输入数据。
-
-```python
-inputs = tokenizer(text="请输入测试样例", max_seq_len=20)
-# {'input_ids': [1, 647, 789, 109, 558, 525, 314, 656, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
-# 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
-# 'seq_len': 9}
-```
-
-### 快速复现基线Step2:加载并处理
-
-
-
-从比赛官网[下载数据集](https://aistudio.baidu.com/aistudio/competition/detail/65),解压存放于data/目录下并重命名为train_data.json, dev_data.json, test_data.json.
-
-我们可以加载自定义数据集。通过继承[`paddle.io.Dataset`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/io/Dataset_cn.html#dataset),自定义实现`__getitem__` 和 `__len__`两个方法。
-
-
-如下代码已完成加载数据集操作:
-
-```python
-train_dataset = DuIEDataset.from_file(
- os.path.join(args.data_path, 'train_data.json'),
- tokenizer,
- args.max_seq_length,
- True)
-test_dataset = DuIEDataset.from_file(
- os.path.join(args.data_path, 'dev_data.json'),
- tokenizer,
- args.max_seq_length,
- True)
-```
-
-### 快速复现基线Step3:定义损失函数和优化器,开始训练
-
-在该基线上,我们选择均方误差作为损失函数,使用[`paddle.optimizer.AdamW`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/adamw/AdamW_cn.html#adamw)作为优化器。
-
-
-启动训练:
-```shell
-sh train.sh
-```
-
-在训练过程中,模型保存在当前目录checkpoints文件夹下。同时在训练的同时使用官方评测脚本进行评估,输出P/R/F1指标。
-在验证集上F1可以达到69.42。
-
-
-### 快速复现基线Step4:提交预测结果
-
-将训练保存的模型加载后进行预测
-
-```shell
-sh predict.sh
-```
-
-预测结果会被保存在data/predictions.json,data/predictions.json.zip,其格式与原数据集文件一致。
-
-之后可以使用官方评估脚本评估训练模型在dev_data.json上的效果。如:
-
-```shell
-python re_official_evaluation.py --golden_file=dev_data.json --predict_file=predicitons.json.zip [--alias_file alias_dict]
-```
-输出指标为Precision, Recall 和 F1,Alias file包含了合法的实体别名,最终评测的时候会使用,这里不予提供。
-
-之后在test_data.json上预测,然后预测结果(.zip文件)至[评测网站](http://aistudio-bce.bcc-bdbl.baidu.com/aistudio/competition/detail/141)。
-
-
-## 进阶优化基线效果
-
-基线采用的预训练模型为ERNIE,PaddleNLP提供了丰富的预训练模型,如BERT,RoBERTa,Electra,XLNet等
-参考[PaddleNLP预训练模型介绍](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer)
-
-如可以选择RoBERTa large中文模型优化模型效果,只需更换模型和tokenizer即可无缝衔接。
-
-```python
-from paddlenlp.transformers import RobertaForTokenClassification, RobertaTokenizer
-
-model = RobertaForTokenClassification.from_pretrained(
- "roberta-wwm-ext-large",
- num_classes=(len(label_map) - 2) * 2 + 2)
-tokenizer = RobertaTokenizer.from_pretrained("roberta-wwm-ext-large")
-```
-## Reference
-
-- [DuIE: A Large-scale Chinese Dataset for Information Extraction](http://tcci.ccf.org.cn/conference/2019/papers/EV10.pdf)
diff --git a/legacy/examples/information_extraction/DuIE/predict.sh b/legacy/examples/information_extraction/DuIE/predict.sh
deleted file mode 100644
index dd4a1da7f4cd..000000000000
--- a/legacy/examples/information_extraction/DuIE/predict.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-set -eux
-
-export CUDA_VISIBLE_DEVICES=0
-export BATCH_SIZE=64
-export CKPT=./checkpoints/model_90000.pdparams
-export DATASET_FILE=./data/test1.json
-
-python run_duie.py \
- --do_predict \
- --init_checkpoint $CKPT \
- --predict_data_file $DATASET_FILE \
- --max_seq_length 128 \
- --batch_size $BATCH_SIZE
-
diff --git a/legacy/examples/machine_translation/transformer/tls/distributed_utils.py b/legacy/examples/machine_translation/transformer/tls/distributed_utils.py
deleted file mode 100644
index 26d6c0ca8d90..000000000000
--- a/legacy/examples/machine_translation/transformer/tls/distributed_utils.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import paddle
-import paddle.distributed as dist
-
-
-def all_gather_tokens(data):
- """Gathers num of tokens from all nodes.
- `data` should be a tensor of num of tokens.
- """
- if dist.get_world_size() < 2:
- return data
- if not hasattr(all_gather_tokens, "_in_buffer") or all_gather_tokens._in_buffer is None:
- all_gather_tokens._in_buffer = data
- all_gather_tokens._out_buffers = []
- in_buffer = all_gather_tokens._in_buffer
- out_buffers = all_gather_tokens._out_buffers
-
- dist.all_gather(out_buffers, in_buffer)
-
- return paddle.add_n(out_buffers)
diff --git a/legacy/examples/model_interpretation/download.sh b/legacy/examples/model_interpretation/download.sh
deleted file mode 100755
index 7d98bfaceecc..000000000000
--- a/legacy/examples/model_interpretation/download.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-wget https://paddlenlp.bj.bcebos.com/data/model_interpretation.tar
-wait
-tar -xvf model_interpretation.tar
-wait
-mv ./model_interpretation/vocab.char ./task/similarity/simnet/
-mv ./model_interpretation/vocab_QQP ./task/similarity/simnet/
-mv ./model_interpretation/simnet_vocab.txt ./task/similarity/simnet/
-
-mv ./model_interpretation/vocab.sst2_train ./task/senti/rnn/
-mv ./model_interpretation/vocab.txt ./task/senti/rnn
\ No newline at end of file
diff --git a/legacy/examples/model_interpretation/task/senti/LIME/exceptions.py b/legacy/examples/model_interpretation/task/senti/LIME/exceptions.py
deleted file mode 100644
index c5fa1a29924a..000000000000
--- a/legacy/examples/model_interpretation/task/senti/LIME/exceptions.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class LimeError(Exception):
- """Raise for errors"""
diff --git a/legacy/examples/model_interpretation/task/senti/rnn/lstm_train.sh b/legacy/examples/model_interpretation/task/senti/rnn/lstm_train.sh
deleted file mode 100755
index fd3b4a4cc2b8..000000000000
--- a/legacy/examples/model_interpretation/task/senti/rnn/lstm_train.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-###
- # This script is used to train lstm models
-###
-
-unset CUDA_VISIBLE_DEVICES
-LANGUAGE=en
-
-if [[ $LANGUAGE == 'ch' ]]; then
- VOCAB_PATH='./vocab.txt'
-else
- VOCAB_PATH='vocab.sst2_train'
-fi
-python -m paddle.distributed.launch --gpus "5" train.py \
- --device=gpu \
- --lr=4e-4 \
- --batch_size=64 \
- --epochs=12 \
- --vocab_path=$VOCAB_PATH \
- --language=$LANGUAGE \
- --save_dir="./checkpoints_"${LANGUAGE}
diff --git a/legacy/examples/model_interpretation/task/similarity/LIME/exceptions.py b/legacy/examples/model_interpretation/task/similarity/LIME/exceptions.py
deleted file mode 100644
index c5fa1a29924a..000000000000
--- a/legacy/examples/model_interpretation/task/similarity/LIME/exceptions.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class LimeError(Exception):
- """Raise for errors"""
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/lstm_train.sh b/legacy/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
deleted file mode 100755
index 5c1b671f0930..000000000000
--- a/legacy/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-###
- # This script is used to train lstm models
-###
-
-unset CUDA_VISIBLE_DEVICES
-LANGUAGE=en
-
-if [[ $LANGUAGE == "ch" ]]; then
- VOCAB_PATH=vocab.char
-elif [[ $LANGUAGE == "en" ]]; then
- VOCAB_PATH=vocab_QQP
-fi
-
-python -m paddle.distributed.launch --gpus "5" train.py \
- --device=gpu \
- --lr=4e-4 \
- --batch_size=64 \
- --epochs=12 \
- --vocab_path=$VOCAB_PATH \
- --language=$LANGUAGE \
- --save_dir="./checkpoints_"${LANGUAGE}
diff --git a/legacy/examples/multimodal/layoutlm/train_funsd.sh b/legacy/examples/multimodal/layoutlm/train_funsd.sh
deleted file mode 100644
index cfd65d6c3ba1..000000000000
--- a/legacy/examples/multimodal/layoutlm/train_funsd.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-export CUDA_VISIBLE_DEVICES=7
-
-python3.7 train_funsd.py \
- --data_dir "./data/" \
- --model_name_or_path "layoutlm-base-uncased" \
- --do_lower_case \
- --max_seq_length 512 \
- --do_train \
- --do_eval \
- --num_train_epochs 100 \
- --logging_steps 10 \
- --save_steps 500 \
- --output_dir "output/" \
- --labels "./data/labels.txt" \
- --per_gpu_train_batch_size 16 \
- --per_gpu_eval_batch_size 16 \
- --evaluate_during_training
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_inference/README.md b/legacy/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
deleted file mode 100644
index 93f1eaf34940..000000000000
--- a/legacy/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Paddle Inference部署
-本文档将介绍如何使用[Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/guides/introduction/index_intro.html#paddle-inference)工具进行问题生成应用高性能推理推理部署。
-
-**目录**
- * [背景介绍](#背景介绍)
- * [导出预测部署模型](#导出预测部署模型)
- * [基于Python预测](#基于Python预测)
-
-
-## 背景介绍
-Paddle inference和主框架的Model.predict均可实现推理预测,Paddle Inference 是飞桨的原生推理库, 作用于服务器端和云端,提供高性能的推理能力,主框架的Model 对象是一个具备训练、测试、推理的神经网络。相比于Model.predict,inference可使用MKLDNN、CUDNN、TensorRT进行预测加速。Model.predict适用于训练好的模型直接进行预测,paddle inference适用于对推理性能、通用性有要求的用户,针对不同平台不同的应用场景进行了深度的适配优化,保证模型在服务器端即训即用,快速部署。由于 Paddle Inference 能力直接基于飞桨的训练算子,因此它支持飞桨训练出的所有模型的推理。
-
-
-
-Paddle Inference Python端预测部署主要包含两个步骤:
-- 导出预测部署模型
-- 基于Python预测
-
-
-## 导出预测部署模型
-部署时需要使用预测格式的模型(即动态图转静态图操作)。预测格式模型相对训练格式模型而言,在拓扑上裁剪掉了预测不需要的算子,并且会做特定部署优化。具体操作详见[FasterTransformer加速及模型静态图导出](../../README.md)。
-
-## 基于Python预测
-
-
-在终端输入以下命令可在GPU上进行预测:
-```shell
-python deploy/paddle_inference/inference.py \
- --inference_model_dir ./export_checkpoint \
- --model_name_or_path "unimo-text-1.0" \
- --predict_file predict_file_name \
- --output_path output_path_name \
- --device gpu \
-```
-
-
-经静态图转换,FastTransformer性能优化,Paddle Inference加速后的部署模型在dureader_qg devset的预测时间为27.74秒,相较于未优化前169.24秒,耗时缩减为原来的16.39%。
-关键参数释义如下:
-* `inference_model_dir`:用于高性能推理的静态图模型参数路径,默认为"./export_checkpoint"。
-* `model_name_or_path`:tokenizer对应模型或路径,默认为"unimo-text-1.0"。
-* `dataset_name`:数据集名称,默认为`dureader_qg`。
-* `predict_file`:本地预测数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为None,当为None时默认加载`dataset_name`的dev集。
-* `output_path`:表示预测结果的保存路径。
-* `device`:推理时使用的设备,可选项["gpu"],默认为"gpu"。
-* `batch_size`:进行推理时的批大小,默认为16。
-* `precision`:当使用TensorRT进行加速推理时,所使用的TensorRT精度,可选项["fp32", "fp16"],默认为"fp32"。
-
-
-
-
-
diff --git a/legacy/examples/text_classification/README.md b/legacy/examples/text_classification/README.md
deleted file mode 100644
index 5618623f0070..000000000000
--- a/legacy/examples/text_classification/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# 文本分类
-
-提供了文本分类任务示例,基于ERNIE 3.0预训练模型。
-
-## Pretrained Model (PTMs)
-
-[Pretrained Models](./pretrained_models) 展示了如何使用以ERNIE 3.0 为代表的预模型,在多分类、多标签、层次分类场景下,基于预训练模型微调、提示学习(小样本)、语义索引等三种不同方案进行文本分类。预训练模型文本分类打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,旨在解决细分场景应用的痛点和难点,快速实现文本分类产品落地。
-
diff --git a/legacy/examples/text_generation/vae-seq2seq/README.md b/legacy/examples/text_generation/vae-seq2seq/README.md
deleted file mode 100644
index 14670b52a7f8..000000000000
--- a/legacy/examples/text_generation/vae-seq2seq/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Variational Autoencoder (VAE) for Text Generation
-
-## 简介
-
-本目录下此范例模型的实现,旨在展示如何用Paddle构建用于文本生成的VAE示例,其中LSTM作为编码器和解码器。分别对PTB数据集和Yahoo Answer(采样100k)数据集进行训练。
-
-关于VAE的详细介绍参照: [(Bowman et al., 2015) Generating Sentences from a Continuous Space](https://arxiv.org/pdf/1511.06349.pdf)
-
-## 数据介绍
-
-本教程使用了两个文本数据集:
-
-PTB数据集由华尔街日报的文章组成,包含929k个训练tokens,词汇量为10k。下载地址为: [PTB](https://dataset.bj.bcebos.com/imikolov%2Fsimple-examples.tgz)。
-
-Yahoo数据集来自[(Yang et al., 2017) Improved Variational Autoencoders for Text Modeling using Dilated Convolutions](https://arxiv.org/pdf/1702.08139.pdf),该数据集从原始Yahoo Answer数据中采样100k个文档,数据集的平均文档长度为78,词汇量为200k。下载地址为:[YahooAnswer100k](https://bj.bcebos.com/paddlenlp/datasets/yahoo-answer-100k.tar.gz),运行本例程序后,数据集会自动下载到`~/.paddlenlp/datasets/YahooAnswer100k`目录下。
-
-
-## 生成样例
-
-shareholders were spent about N shares to spend $ N million to ual sell this trust stock last week
-
-new york stock exchange composite trading trading outnumbered closed at $ N a share down N cents
-
-the company cited pressure to pursue up existing facilities in the third quarter was for
and four N million briefly stocks for so-called unusual liability
-
-people had down out the kind of and much why your relationship are anyway
-
-there are a historic investment giant chips which ran the benefit the attempting to original maker
-
-使用请[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_generation/vae-seq2seq)
diff --git a/legacy/examples/text_matching/simcse/train.sh b/legacy/examples/text_matching/simcse/train.sh
deleted file mode 100644
index 145be555a3b1..000000000000
--- a/legacy/examples/text_matching/simcse/train.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-python -u -m paddle.distributed.launch --gpus '4' \
- train.py \
- --device gpu \
- --save_dir ./checkpoints/ \
- --batch_size 64 \
- --learning_rate 5E-5 \
- --epochs 8 \
- --save_steps 2000 \
- --eval_steps 100 \
- --max_seq_length 64 \
- --dropout 0.3 \
- --output_emb_size 256 \
- --dup_rate 0.32 \
- --train_set_file "./senteval_cn/STS-B/train.txt" \
- --test_set_file "./senteval_cn/STS-B/dev.tsv"
\ No newline at end of file
diff --git a/legacy/examples/text_summarization/bart/README.md b/legacy/examples/text_summarization/bart/README.md
deleted file mode 100644
index 0e3d9369d8dd..000000000000
--- a/legacy/examples/text_summarization/bart/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# BART
-
-## 模型简介
-
-BART是一种Seq2Seq结构的降噪自编码器,通过增加噪声来破环文本然后重建原文本来训练模型。它使用一个标准的Transformer结构,可以被看作泛化的BERT(由于是双向编码器),GPT(由于是从左到右解码器),和一些其他的预训练模型结构。
-
-本项目是BART在 PaddlePaddle 2.2上开源实现的文本摘要的例子,包含了在[CNN/DailyMail](https://arxiv.org/pdf/1704.04368.pdf)数据集上微调和生成的代码。
-
-使用请[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_summarization/bart)
-
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md b/legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
deleted file mode 100644
index ca5577601cf2..000000000000
--- a/legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# Paddle Inference部署
-本文档将介绍如何使用[Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/guides/introduction/index_intro.html#paddle-inference)工具进行自动文本摘要应用高性能推理推理部署。
-
-**目录**
- * [背景介绍](#背景介绍)
- * [导出预测部署模型](#导出预测部署模型)
- * [基于Python预测](#基于Python预测)
-
-
-## 背景介绍
-Paddle inference和主框架的Model.predict均可实现推理预测,Paddle Inference 是飞桨的原生推理库, 作用于服务器端和云端,提供高性能的推理能力,主框架的Model 对象是一个具备训练、测试、推理的神经网络。相比于Model.predict,inference可使用MKLDNN、CUDNN、TensorRT进行预测加速。Model.predict适用于训练好的模型直接进行预测,paddle inference适用于对推理性能、通用性有要求的用户,针对不同平台不同的应用场景进行了深度的适配优化,保证模型在服务器端即训即用,快速部署。由于 Paddle Inference 能力直接基于飞桨的训练算子,因此它支持飞桨训练出的所有模型的推理。
-
-
-Paddle Inference Python端预测部署主要包含两个步骤:
-- 导出预测部署模型
-- 基于Python预测
-
-
-## 导出预测部署模型
-部署时需要使用预测格式的模型(即动态图转静态图操作)。预测格式模型相对训练格式模型而言,在拓扑上裁剪掉了预测不需要的算子,并且会做特定部署优化。具体操作详见[FastGeneration加速及模型静态图导出](../../README.md)。
-
-## 基于Python预测
-
-
-在终端输入以下命令可在GPU上进行预测:
-```shell
-python inference_unimo_text.py --inference_model_dir ../../inference_model
-```
-
-关键参数释义如下:
-* `inference_model_dir`:用于高性能推理的静态图模型参数路径;默认为"../../inference_model"。
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/README.md b/legacy/examples/text_to_knowledge/ernie-ctm/README.md
deleted file mode 100644
index 1e6a85355c60..000000000000
--- a/legacy/examples/text_to_knowledge/ernie-ctm/README.md
+++ /dev/null
@@ -1,167 +0,0 @@
-
-# 解语:ERNIE-CTM(ERNIE for **Chinese Text Mining**)
-
-ERNIE-CTM是适用于中文文本挖掘任务的预训练语言模型,拥有更全面的汉字字表集合,更优的中文文本挖掘任务表现,与PaddleNLP深度结合,提供更加便捷的应用实践。
-
-## ERNIE-CTM特点
-
-- 全面的中文汉字字表扩充
- - ERNIE-CTM的字符集包含2万+汉字,以及中文常用符号(常用标点、汉语拼音、编号)、部分外语符号(假名、单位)等,大幅减少中文解析挖掘任务中UNK(未识别字符)引发的标注问题。同时,ERNIE-CTM使用了embedding分解,可以更加灵活地扩充应用字表。
-- 更加适配中文文本挖掘任务
- - ERNIE-CTM中在每个表示后面添加了全局信息,在序列特征上叠加了全局的信息,使得在文本挖掘任务上有更加强力的表现。
-- 支持多种特征训练的模型结构
- - ERNIE-CTM的模型结构中,支持多种特征训练,用户可按照自己的需求任意添加任务及对应特征训练模型,而无需考虑任务之间的冲突所造成的灾难性遗忘。
-
-
-
-## ERNIE-CTM模型介绍
-
-### 模型结构
-
-ERNIE-CTM的模型结构大体与BERT相同,都是双向transformer结构。区别是,ERNIE-CTM为能灵活扩充字表,采用了ALBERT的embedding分解,将embedding层分解为128维,参数列表如下:
-
-| 模型 | embedding size | hidden size | hidden layers | vocab size |
-| -------------- | -------------- | ----------- | ------------- | ---------- |
-| ERNIE-CTM-base | 128 | 768 | 12 | 23000 |
-
-ERNIE-CTM以字粒度建模,英文区分大小写,其输入表示如下:
-
-
-
-其中,`[CLS{n}]`是ERNIE-CTM预留出的全局观察位,其中`n`从0开始计数,该全局观察位用于不同的训练任务,建模不同的语义特征,在下游任务中,可以结合使用,如使用attention筛选/融合特征,以达到更好的效果。而在灵活使用`[CLS{n}]`的时候,为中途增减任务token时不影响文本输入,所有的`[CLS{n}]`的位置编码均为0,且可以使用可见性矩阵(visible matrix)控制`[CLS{n}]`位置的特征对序列中其他位置,以及其他的全局观察位的可见性,以获得更加灵活、独立的特征表示。
-
-本次开源的ERNIE-CTM-base模型中,使用了两个全局观察位`[CLS0]`和`[CLS1]`,具体作用见下文预训练任务介绍。
-
-### 预训练任务
-
-ERNIE-CTM使用的预训练任务为掩码语言模型(Masked Language Model,MLM)及ALBERT所使用的句子顺序预测(Sentence Order Prediction,SOP)。
-
-其中`[CLS0]`用于训练SOP任务,训练方式如ALBERT中描述,正例为同一篇文章中的两个连续的句子,负例为用一篇文章中两个连续的句子顺序翻转。
-
-`[CLS1]`做为全局的监督信号,应用于MLM任务中。训练MLM任务前,将`[CLS1]`特征表示拼接在所有的序列表示之后,通过线性层融合,成为最终的序列表示,之后预测MLM任务。所以,ERNIE-CTM最终输出的文本序列表示中,都融合了`[CLS1]`的特征表示。最终的序列表示中,带有全句的特征,一定程度可避免序列中全局特征捕捉不足,同时,`[CLS1]`最终的表示中也充分融合了句子内容的信息,弥补了SOP任务对文本主题信息捕捉不足的缺陷。
-
-
-
-### WordTag增量训练
-
-在Ernie-Ctm微调任务中我们提供了一个基于[WordTag](../wordtag)的百科知识标注任务,该任务旨在解析中文词汇的知识标注,在该词性体系中覆盖了所有中文词汇的词类体系,包括各类实体词与非实体词(如概念、实体/专名、语法词等)。除了使用已有的WordTag工具对通用中文文本进行词类知识标注,WordTag同样支持用户使用自己的数据进行增量训练,下面是在WordTag模型上进行增量训练的具体示例流程。
-
-#### 代码结构说明
-
-```text
-wordtag/
-├── data.py # 训练数据处理脚本
-├── metric.py # 模型效果验证指标脚本
-├── predict.py # 预测脚本
-├── README.md # 使用说明
-├── train.py # 训练脚本
-└── utils.py # 工具函数
-```
-
-#### 数据准备
-
-我们提供了少数样本用以示例增量训练。执行以下命令,下载并解压示例数据集:
-
-```bash
-wget https://bj.bcebos.com/paddlenlp/datasets/wordtag_dataset_v3.tar.gz && tar -zxvf wordtag_dataset_v3.tar.gz
-```
-解压之后
-
-```text
-data/
-├── dev.txt # 验证集
-├── tags.txt # WordTag标签集合
-└── train.json # 训练数据
-```
-
-训练样本示例如下,每个单词以"/type"的形式标记其词性或实体类别,单词之间使用空格作为切分标记
-
-```text
-砚台/物体类 与/连词 笔/物体类 、/w 墨/物体类 、/w 纸/物体类 是/肯定词 中国/世界地区类 传统/修饰词 的/助词 文房四宝/词汇用语 。/w
-《/w 全球化与中国:理论与发展趋势/作品类_实体 》/w 是/肯定词 2010年/时间类 经济管理出版社/组织机构类 出版/场景事件 的/助词 图书/作品类_概念 ,/w 作者/人物类_概念 是/肯定词 余永定/人物类_实体 、/w 路爱国/人物类_实体 、/w 高海红/人物类_实体 。/w
-```
-
-#### 模型训练
-
-```shell
-python -m paddle.distributed.launch --gpus "0" train.py \
- --max_seq_len 128 \
- --batch_size 32 \
- --learning_rate 5e-5 \
- --num_train_epochs 3 \
- --logging_steps 10 \
- --save_steps 100 \
- --output_dir ./output \
- --device "gpu"
-```
-
-其中参数释义如下:
-- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
-- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `num_train_epochs` 表示训练轮数。
-- `logging_steps` 表示日志打印间隔。
-- `save_steps` 表示模型保存及评估间隔。
-- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
-
-
-
-### 模型预测
-
-```shell
-export CUDA_VISIBLE_DEVICES=0
-python -m paddle.distributed.launch --gpus "0" predict.py \
- --params_path ./output/model_300/model_state.pdparams \
- --batch_size 32 \
- --device "gpu"
-```
-
-## 自定义模型一键预测
-
-Taskflow支持加载增量训练后的模型进行一键预测,通过`task_path`定义用户自定义路径即可。
-
-文件组成:
-```text
-custom_task_path/
-├── model_state.pdparams
-├── model_config.json
-└── tags.txt
-```
-
-```python
-from paddlenlp import Taskflow
-
-my_wordtag = Taskflow("knowledge_mining", task_path="./custom_task_path/")
-
-my_wordtag("美人鱼是周星驰执导的一部电影")
-# [{'text': '美人鱼是周星驰执导的一部电影', 'items': [{'item': '美人鱼', 'offset': 0, 'wordtag_label': '作品类_实体', 'length': 3, 'termid': '作品与出版物_eb_美人鱼'}, {'item': '是', 'offset': 3, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '周星驰', 'offset': 4, 'wordtag_label': '人物类_实体', 'length': 3, 'termid': '人物_eb_周星驰'}, {'item': '执导', 'offset': 7, 'wordtag_label': '场景事件', 'length': 2, 'termid': '场景事件_cb_执导'}, {'item': '的', 'offset': 9, 'wordtag_label': '助词', 'length': 1, 'termid': '助词_cb_的'}, {'item': '一部', 'offset': 10, 'wordtag_label': '数量词', 'length': 2}, {'item': '电影', 'offset': 12, 'wordtag_label': '作品类_概念', 'length': 2, 'termid': '影视作品_cb_电影'}]}]
-```
-
-
-## ERNIE-CTM后续计划
-
-
-1. 提升预训练语料的多样性(开源版主要使用了百度百科语料),持续优化预训练模型
-2. 发布其他参数量的预训练模型(tiny、large等),便于不同场景应用
-3. 维护开源社区,探索模型优化方向,整合优秀idea
-
-
-
-## 在论文中引用ERNIE-CTM
-
-如果您的工作成果中使用了ERNIE-CTM,请增加下述引用。我们非常乐于看到ERNIE-CTM对您的工作带来帮助。
-```
-@article{zhao2020TermTree,
- title={TermTree and Knowledge Annotation Framework for Chinese Language Understanding},
- author={Zhao, Min and Qin, Huapeng and Zhang, Guoxin and Lyu, Yajuan and Zhu, Yong},
- technical report={Baidu, Inc. TR:2020-KG-TermTree},
- year={2020}
-}
-```
-
-
-
-## 问题与反馈
-
-ERNIE-CTM在持续优化中,如果您有任何建议或问题,欢迎提交issue到Github。
diff --git a/legacy/examples/torch_migration/docs/ThesisReproduction_NLP.md b/legacy/examples/torch_migration/docs/ThesisReproduction_NLP.md
deleted file mode 100644
index b944a36c893c..000000000000
--- a/legacy/examples/torch_migration/docs/ThesisReproduction_NLP.md
+++ /dev/null
@@ -1,928 +0,0 @@
-# 论文复现指南
-
-## 目录
-
-- [1. 总览](#1)
- - [1.1 背景](#1.1)
- - [1.2 前序工作](#1.2)
-- [2. 整体框图](#2)
- - [2.1 流程概览](#2.1)
- - [2.2 reprod_log whl包](#2.2)
-- [3. 论文复现理论知识及实战](#3)
- - [3.1 模型结构对齐](#3.1)
- - [3.2 验证/测试集数据读取对齐](#3.2)
- - [3.3 评估指标对齐](#3.3)
- - [3.4 损失函数对齐](#3.4)
- - [3.5 优化器对齐](#3.5)
- - [3.6 学习率对齐](#3.6)
- - [3.7 正则化策略对齐](#3.7)
- - [3.8 反向对齐](#3.8)
- - [3.9 训练集数据读取对齐](#3.9)
- - [3.10 网络初始化对齐](#3.10)
- - [3.11 模型训练对齐](#3.11)
- - [3.12 单机多卡训练](#3.12)
-- [4. 论文复现注意事项与FAQ](#4)
- - [4.0 通用注意事项](#4.0)
- - [4.1 模型结构对齐](#4.1)
- - [4.2 验证/测试集数据读取对齐](#4.2)
- - [4.3 评估指标对齐](#4.3)
- - [4.4 损失函数对齐](#4.4)
- - [4.5 优化器对齐](#4.5)
- - [4.6 学习率对齐](#4.6)
- - [4.7 正则化策略对齐](#4.7)
- - [4.8 反向对齐](#4.8)
- - [4.9 训练集数据读取对齐](#4.9)
- - [4.10 网络初始化对齐](#4.10)
- - [4.11 模型训练对齐](#4.11)
-
-
-## 1. 总览
-
-
-### 1.1 背景
-
-* 以深度学习为核心的人工智能技术仍在高速发展,通过论文复现,开发者可以获得
- * 学习成长:自我能力提升
- * 技术积累:对科研或工作有所帮助和启发
- * 社区荣誉:成果被开发者广泛使用
-
-
-### 1.2 前序工作
-
-基于本指南复现论文过程中,建议开发者准备以下内容。
-
-* 了解该模型输入输出格式。以BERT的情感分类任务为例,通过阅读论文与参考代码,了解到模型输入为`[batch_size, sequence_length]`的tensor,类型为`int64`,label为`[batch, ]`的label,类型为`int64`。
-* 准备好训练/验证数据集,用于模型训练与评估
-* 准备好fake input data以及label,与模型输入shape、type等保持一致,用于后续模型前向对齐。
- * 在对齐模型前向过程中,我们不需要考虑数据集模块等其他模块,此时使用fake data是将模型结构和数据部分解耦非常合适的一种方式。
- * 将fake data以文件的形式存储下来,也可以保证PaddlePaddle与参考代码的模型结构输入是完全一致的,更便于排查问题。
- * 在该步骤中,以BERT为例,生成fake data的脚本可以参考:[gen_fake_data.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/fake_data/gen_fake_data.py)。
-* 在特定设备(CPU/GPU)上,跑通参考代码的预测过程(前向)以及至少2轮(iteration)迭代过程,保证后续基于PaddlePaddle复现论文过程中可对比。
-* 本文档基于 `BERT-SST2-Prod` 代码以及`reprod_log` whl包进行说明与测试。如果希望体验,建议参考[BERT-SST2-Prod文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/README.md)进行安装与测试。
-* 在复现的过程中,只需要将PaddlePaddle的复现代码以及打卡日志上传至github,不能在其中添加参考代码的实现,在验收通过之后,需要删除打卡日志。建议在初期复现的时候,就将复现代码与参考代码分成2个文件夹进行管理。
-
-
-## 2. 整体框图
-
-
-### 2.1 流程概览
-
-面对一篇自然语言处理的论文,复现该论文的整体流程如下图所示。
-
-
-
-总共包含11个步骤。为了高效复现论文,设置了5个验收节点。如上图中黄色框所示。后续章节会详细介绍上述步骤和验收节点,具体内容安排如下:
-
-* 第3章:介绍11个复现步骤的理论知识、实战以及验收流程。
-* 第4章:针对复现流程过程中每个步骤可能出现的问题,本章会进行详细介绍。如果还是不能解决问题,可以提ISSUE进行讨论,提ISSUE地址:[https://github.com/PaddlePaddle/Paddle/issues/new/choose](https://github.com/PaddlePaddle/Paddle/issues/new/choose)
-
-
-### 2.2 reprod_log whl包
-
-#### 2.2.1 reprod_log工具简介
-`reprod_log`是用于论文复现赛中辅助自查和验收工具。该工具源代码地址在:[https://github.com/WenmuZhou/reprod_log](https://github.com/WenmuZhou/reprod_log)。主要功能如下:
-
-* 存取指定节点的输入输出tensor
-* 基于文件的tensor读写
-* 2个字典的对比验证
-* 对比结果的输出与记录
-
-更多API与使用方法可以参考:[reprod_log API使用说明](https://github.com/WenmuZhou/reprod_log/blob/master/README.md)。
-
-#### 2.2.2 reprod_log使用demo
-
-下面基于代码:[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/reprod_log_demo](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/reprod_log_demo),给出如何使用该工具。
-
-文件夹中包含`write_log.py`和`check_log_diff.py`文件,其中`write_log.py`中给出了`ReprodLogger`类的使用方法,`check_log_diff.py`给出了`ReprodDiffHelper`类的使用方法,依次运行两个python文件,使用下面的方式运行代码。
-
-```shell
-# 进入文件夹
-cd pipeline/reprod_log_demo
-# 随机生成矩阵,写入文件中
-python write_log.py
-# 进行文件对比,输出日志
-python check_log_diff.py
-```
-
-最终会输出以下内容
-
-```
-[2021/11/18 09:29:31] root INFO: demo_test_1:
-[2021/11/18 09:29:31] root INFO: mean diff: check passed: True, value: 0.0
-[2021/11/18 09:29:31] root INFO: demo_test_2:
-[2021/11/18 09:29:31] root INFO: mean diff: check passed: False, value: 0.33387675881385803
-[2021/11/18 09:29:31] root INFO: diff check failed
-```
-
-可以看出:对于key为`demo_test_1`的矩阵,由于diff为0,小于设置的阈值`1e-6`,核验成功;对于key为`demo_test_2`的矩阵,由于diff为0.33,大于设置的阈值`1e-6`,核验失败。
-
-#### 2.2.3 reprod_log在论文复现中应用
-
-在论文复现中,基于reprod_log的结果记录模块,产出下面若干文件
-```
-log_reprod
-├── forward_paddle.npy
-├── forward_torch.npy # 与forward_paddle.npy作为一并核查的文件对
-├── metric_paddle.npy
-├── metric_torch.npy # 与metric_paddle.npy作为一并核查的文件对
-├── loss_paddle.npy
-├── loss_torch.npy # 与loss_paddle.npy作为一并核查的文件对
-├── bp_align_paddle.npy
-├── bp_align_torch.npy # 与bp_align_paddle.npy作为一并核查的文件对
-├── train_align_paddle.npy
-├── train_align_torch.npy # pytorch运行得到的参考评估指标
-```
-
-基于reprod_log的`ReprodDiffHelper`模块,产出下面5个日志文件。
-
-```
-├── forward_diff.log # forward_paddle.npy与forward_torch.npy生成的diff结果文件
-├── metric_diff.log # metric_paddle.npy与metric_torch.npy生成的diff结果文件
-├── loss_diff.log # loss_paddle.npy与loss_torch.npy生成的diff结果文件
-├── bp_align_diff.log # bp_align_paddle.npy与bp_align_torch.npy生成的diff结果文件
-├── train_align_diff.log # train_align_paddle.train_align_torch.npy生成的diff结果文件
-```
-
-上述文件的生成代码都需要开发者进行开发,验收时需要提供上面罗列的所有文件(不需要提供产生这些文件的可运行程序)以及完整的模型训练评估程序和日志。
-BERT-SST2-Prod项目提供了基于reprod_log的5个验收点对齐验收示例,具体代码地址为:[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline),
-每个文件夹中的README.md文档提供了使用说明。
-
-
-## 3. 论文复现理论知识及实战
-
-
-### 3.1 模型结构对齐
-
-对齐模型结构时,一般有3个主要步骤:
-
-* 网络结构代码转换
-* 权重转换
-* 模型组网正确性验证
-
-下面详细介绍这3个部分。
-
-#### 3.1.1 网络结构代码转换
-
-**【基本流程】**
-
-由于PyTorch的API和PaddlePaddle的API非常相似,可以参考[PyTorch-PaddlePaddle API映射表](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/08_api_mapping/pytorch_api_mapping_cn.html)
-,组网部分代码直接进行手动转换即可。
-
-**【注意事项】**
-
-如果遇到PaddlePaddle没有的API,可以尝试用多种API来组合,也可以给PaddlePaddle团队提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues),获得支持。
-
-**【实战】**
-
-BERT网络结构的PyTorch实现: [transformers-bert](https://github.com/huggingface/transformers/blob/master/src/transformers/models/bert/modeling_bert.py)
-
-对应转换后的PaddlePaddle实现: [paddlenlp-bert](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/transformers/bert/modeling.py)
-
-
-#### 3.1.2 权重转换
-
-**【基本流程】**
-
-组网代码转换完成之后,需要对模型权重进行转换,如果PyTorch repo中已经提供权重,那么可以直接下载并进行后续的转换;如果没有提供,则可以基于PyTorch代码,随机生成一个初始化权重(定义完model以后,使用`torch.save()` API保存模型权重),然后进行权重转换。
-
-**【注意事项】**
-
-在权重转换的时候,需要注意`paddle.nn.Linear`等API的权重保存格式和名称等与PyTorch稍有diff,具体内容可以参考`4.1章节`。
-
-**【实战】**
-
-BERT的代码转换脚本可以在这里查看:[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py),
-
-注意:运行该代码需要首先下载Huggingface的BERT预训练模型到该目录下,下载地址为:[https://huggingface.co/bert-base-uncased/blob/main/pytorch_model.bin](https://huggingface.co/bert-base-uncased/blob/main/pytorch_model.bin)
-
-```python
-# https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py
-
-from collections import OrderedDict
-
-import numpy as np
-import paddle
-import torch
-from paddlenlp.transformers import BertForPretraining as PDBertForMaskedLM
-from transformers import BertForMaskedLM as PTBertForMaskedLM
-
-
-def convert_pytorch_checkpoint_to_paddle(
- pytorch_checkpoint_path="pytorch_model.bin",
- paddle_dump_path="model_state.pdparams",
- version="old", ):
- hf_to_paddle = {
- "embeddings.LayerNorm": "embeddings.layer_norm",
- "encoder.layer": "encoder.layers",
- "attention.self.query": "self_attn.q_proj",
- "attention.self.key": "self_attn.k_proj",
- "attention.self.value": "self_attn.v_proj",
- "attention.output.dense": "self_attn.out_proj",
- "intermediate.dense": "linear1",
- "output.dense": "linear2",
- "attention.output.LayerNorm": "norm1",
- "output.LayerNorm": "norm2",
- "predictions.decoder.": "predictions.decoder_",
- "predictions.transform.dense": "predictions.transform",
- "predictions.transform.LayerNorm": "predictions.layer_norm",
- }
- do_not_transpose = []
- if version == "old":
- hf_to_paddle.update({
- "predictions.bias": "predictions.decoder_bias",
- ".gamma": ".weight",
- ".beta": ".bias",
- })
- do_not_transpose = do_not_transpose + ["predictions.decoder.weight"]
-
- pytorch_state_dict = torch.load(
- pytorch_checkpoint_path, map_location="cpu")
- paddle_state_dict = OrderedDict()
- for k, v in pytorch_state_dict.items():
- is_transpose = False
- if k[-7:] == ".weight":
- # embeddings.weight and LayerNorm.weight do not transpose
- if all(d not in k for d in do_not_transpose):
- if ".embeddings." not in k and ".LayerNorm." not in k:
- if v.ndim == 2:
- v = v.transpose(0, 1)
- is_transpose = True
- oldk = k
- for hf_name, pd_name in hf_to_paddle.items():
- k = k.replace(hf_name, pd_name)
-
- # add prefix `bert.`
- if "bert." not in k and "cls." not in k and "classifier" not in k:
- k = "bert." + k
-
- print(f"Converting: {oldk} => {k} | is_transpose {is_transpose}")
- paddle_state_dict[k] = v.data.numpy()
-
- paddle.save(paddle_state_dict, paddle_dump_path)
-
-
-def compare(out_torch, out_paddle):
- out_torch = out_torch.detach().numpy()
- out_paddle = out_paddle.detach().numpy()
- assert out_torch.shape == out_paddle.shape
- abs_dif = np.abs(out_torch - out_paddle)
- mean_dif = np.mean(abs_dif)
- max_dif = np.max(abs_dif)
- min_dif = np.min(abs_dif)
- print("mean_dif:{}".format(mean_dif))
- print("max_dif:{}".format(max_dif))
- print("min_dif:{}".format(min_dif))
-
-
-def test_forward():
- paddle.set_device("cpu")
- model_torch = PTBertForMaskedLM.from_pretrained("./bert-base-uncased")
- model_paddle = PDBertForMaskedLM.from_pretrained("./bert-base-uncased")
- model_torch.eval()
- model_paddle.eval()
- np.random.seed(42)
- x = np.random.randint(
- 1, model_paddle.bert.config["vocab_size"], size=(4, 64))
- input_torch = torch.tensor(x, dtype=torch.int64)
- out_torch = model_torch(input_torch)[0]
-
- input_paddle = paddle.to_tensor(x, dtype=paddle.int64)
- out_paddle = model_paddle(input_paddle)[0]
-
- print("torch result shape:{}".format(out_torch.shape))
- print("paddle result shape:{}".format(out_paddle.shape))
- compare(out_torch, out_paddle)
-
-
-if __name__ == "__main__":
- convert_pytorch_checkpoint_to_paddle(
- "./bert-base-uncased/pytorch_model.bin",
- "./bert-base-uncased/model_state.pdparams")
- test_forward()
- # torch result shape:torch.Size([4, 64, 30522])
- # paddle result shape:[4, 64, 30522]
- # mean_dif:1.666686512180604e-05
- # max_dif:0.00015211105346679688
- # min_dif:0.0
-```
-
-运行完成之后,会在当前目录生成`model_state.pdparams`文件,即为转换后的PaddlePaddle预训练模型。
-**Tips**: 由于paddlenlp中已有转换后的bert-base-uncased模型,因此可以一键加载,程序会自动下载对应权重!
-
-
-#### 3.1.3 模型组网正确性验证
-
-**【基本流程】**
-
-1. 定义PyTorch模型,加载权重,固定seed,基于numpy生成随机数,转换为PyTorch可以处理的tensor,送入网络,获取输出,使用reprod_log保存结果。
-2. 定义PaddlePaddle模型,加载权重,固定seed,基于numpy生成随机数,转换为PaddlePaddle可以处理的tensor,送入网络,获取输出,使用reprod_log保存结果。
-3. 使用reprod_log排查diff,小于阈值,即可完成自测。
-
-**【注意事项】**
-
-* 模型在前向对齐验证时,需要调用`model.eval()`方法,保证组网中的随机量被关闭,比如BatchNorm、Dropout等。
-* 给定相同的输入数据,为保证可复现性,如果有随机数生成,固定相关的随机种子。
-* 输出diff可以使用`np.mean(np.abs(o1 - o2))`进行计算,一般小于1e-6的话,可以认为前向没有问题。如果最终输出结果diff较大,可以使用二分的方法进行排查,比如说BERT,包含1个embdding层、12个transformer-block以及最后的MLM head层,那么完成模型组网和权重转换之后,如果模型输出没有对齐,可以尝试输出中间某一个transformer-block的tensor进行对比,如果相同,则向后进行排查;如果不同,则继续向前进行排查,以此类推,直到找到导致没有对齐的操作。
-
-**【实战】**
-
-BERT模型组网正确性验证可以参考如下示例代码:
-[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/Step1](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/Step1
-
-**【验收】**
-
-对于待复现的项目,前向对齐验收流程如下。
-
-1. 准备输入:fake data
- * 使用参考代码的dataloader,生成一个batch的数据,保存下来,在前向对齐时,直接从文件中读入。
- * 固定随机数种子,生成numpy随机矩阵,转化tensor
-2. 保存输出:
- * PaddlePaddle/PyTorch:dict,key为tensor的name(自定义),value为tensor的值。最后将dict保存到文件中。建议命名为`forward_paddle.npy`和`forward_torch.npy`。
-3. 自测:使用reprod_log加载2个文件,使用report功能,记录结果到日志文件中,建议命名为`forward_diff_log.txt`,观察diff,二者diff小于特定的阈值即可。
-4. 提交内容:新建文件夹,将`forward_paddle.npy`、`forward_torch.npy`与`forward_diff_log.txt`文件放在文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
-5. 注意:
- * PaddlePaddle与PyTorch保存的dict的key需要保持相同,否则report过程可能会提示key无法对应,从而导致report失败,之后的`【验收】`环节也是如此。
- * 如果是固定随机数种子,建议将fake data保存到dict中,方便check参考代码和PaddlePaddle的输入是否一致。
-
-
-### 3.2 验证/测试集数据读取对齐
-
-**【基本流程】**
-
-对于一个数据集,一般有以下一些信息需要重点关注
-
-* 数据集名称、下载地址
-* 训练集/验证集/测试集
-
-PaddlePaddle中数据集相关的API为`paddle.io.Dataset`,PyTorch中对应为`torch.utils.data.Dataset`,二者功能一致,在绝大多数情况下,可以使用该类构建数据集。它是描述Dataset方法和行为的抽象类,在具体实现的时候,需要继承这个基类,实现其中的`__getitem__`和`__len__`方法。除了参考代码中相关实现,也可以参考待复现论文中的说明。
-
-复现完Dataset之后,可以构建Dataloader,对数据进行组batch、批处理,送进网络进行计算。
-
-`paddle.io.DataLoader`可以进行数据加载,将数据分成批数据,并提供加载过程中的采样。PyTorch对应的实现为`torch.utils.data.DataLoader`,二者在功能上一致,只是在参数方面稍有diff:(1)PaddlePaddle缺少对`pin_memory`等参数的支持;(2)PaddlePaddle增加了`use_shared_memory`参数来选择是否使用共享内存加速数据加载过程。
-
-**【注意事项】**
-
-论文中一般会提供数据集的名称以及基本信息。复现过程中,我们在下载完数据之后,建议先检查下是否和论文中描述一致,否则可能存在的问题有:
-
-* 数据集版本不同,比如论文中使用了cnn_dailymail的v3.0.0版本数据集,但是我们下载的是cnn_dailymail的v1.0.0版本数据集,如果不对其进行检查,可能会导致我们最终训练的数据量等与论文中有diff
-* 数据集使用方式不同,有些论文中,可能只是抽取了该数据集的子集进行方法验证,此时需要注意抽取方法,需要保证抽取出的子集完全相同。
-* 在评估指标对齐时,我们可以固定batch size,关闭Dataloader的shuffle操作。
-
-构建数据集时,可以使用paddlenlp中的数据集加载方式,具体可以参考:[如何自定义数据集](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_self_defined.html)。对应地,PyTorch中的数据处理api可以参考:[huggingface的datasets自定义数据集](https://huggingface.co/docs/datasets/about_dataset_load.html#building-a-dataset)。对于其中之一,可以找到另一个平台的实现。
-
-此外,
-* 有些自定义的数据处理方法,如果不涉及到深度学习框架的部分,可以直接复用。
-* 对于特定任务中的数据预处理方法,比如说Tokenizer,如果没有现成的API可以调用,可以参考官方模型套件中的一些实现方法,比如PaddleClas、PaddleDetection、PaddleSeg等。
-
-**【实战】**
-
-BERT模型复现过程中,数据预处理和Dataset、Dataloader的检查可以参考该文件:
-[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/test_data.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/test_data.py)
-
-
-使用方法可以参考[数据检查文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/README.md)。
-
-
-### 3.3 评估指标对齐
-
-**【基本流程】**
-
-PaddlePaddle提供了一系列Metric计算类,比如说`Accuracy`, `Auc`, `Precision`, `Recall`等,而PyTorch中,目前可以通过组合的方式实现metric计算,或者调用[huggingface-datasets](https://huggingface.co/docs/datasets/about_metrics.html?highlight=metric),在论文复现的过程中,需要注意保证对于该模块,给定相同的输入,二者输出完全一致。具体流程如下。
-
-1. 构建fake数据
-1. 使用PyTorch的指标获取评估结果,使用reprod_log保存结果。
-2. 使用PaddlePaddle的指标获取评估结果,使用reprod_log保存结果。
-3. 使用reprod_log排查diff,小于阈值,即可完成自测。
-
-**【注意事项】**
-
-在评估指标对齐之前,需要注意保证对于该模块,给定相同的输入,二者输出完全一致。
-
-
-**【实战】**
-
-评估指标对齐检查方法可以参考文档:[评估指标对齐检查方法文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/README.md#%E6%95%B0%E6%8D%AE%E8%AF%84%E4%BC%B0%E5%AF%B9%E9%BD%90%E6%B5%81%E7%A8%8B)
-
-
-**【验收】**
-
-对于待复现的项目,评估指标对齐验收流程如下。
-
-1. 输入:dataloader, model
-2. 输出:
- * PaddlePaddle/PyTorch:dict,key为tensor的name(自定义),value为具体评估指标的值。最后将dict使用reprod_log保存到各自的文件中,建议命名为`metric_paddle.npy`和`metric_torch.npy`。
- * 自测:使用reprod_log加载2个文件,使用report功能,记录结果到日志文件中,建议命名为`metric_diff_log.txt`,观察diff,二者diff小于特定的阈值即可。
-3. 提交内容:将`metric_paddle.npy`、`metric_torch.npy`与`metric_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
-4. 注意:
- * 数据需要是真实数据
- * 需要检查论文是否只是抽取了验证集/测试集中的部分文件,如果是的话,则需要保证PaddlePaddle和参考代码中dataset使用的数据集一致。
-
-
-
-### 3.4 损失函数对齐
-
-**【基本流程】**
-
-PaddlePaddle与PyTorch均提供了很多loss function,用于模型训练,具体的API映射表可以参考:[Loss类API映射列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/08_api_mapping/pytorch_api_mapping_cn.html#lossapi)。以CrossEntropyLoss为例,主要区别为:
-* PaddlePaddle提供了对软标签、指定softmax计算纬度的支持。
-
-如果论文中使用的loss function没有指定的API,则可以尝试通过组合API的方式,实现自定义的loss function。
-
-具体流程如下。
-
-1. 定义PyTorch模型,加载权重,加载fake data 和 fake label(或者固定seed,基于numpy生成随机数),转换为PyTorch可以处理的tensor,送入网络,获取loss结果,使用reprod_log保存结果。
-2. 定义PaddlePaddle模型,加载fake data 和 fake label(或者固定seed,基于numpy生成随机数),转换为PaddlePaddle可以处理的tensor,送入网络,获取loss结果,使用reprod_log保存结果。
-3. 使用reprod_log排查diff,小于阈值,即可完成自测。
-
-**【注意事项】**
-
-* 计算loss的时候,建议设置`model.eval()`,避免模型中随机量的问题。
-
-**【实战】**
-
-本部分可以参考文档:[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step3/README.md](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step3/README.md)。
-
-**【验收】**
-
-对于待复现的项目,损失函数对齐验收流程如下。
-
-1. 输入:fake data & label
-2. 输出:
- * PaddlePaddle/PyTorch:dict,key为tensor的name(自定义),value为具体评估指标的值。最后将dict使用reprod_log保存到各自的文件中,建议命名为`loss_paddle.npy`和`loss_torch.npy`。
-3. 自测:使用reprod_log加载2个文件,使用report功能,记录结果到日志文件中,建议命名为`loss_diff_log.txt`,观察diff,二者diff小于特定的阈值即可。
-4. 提交内容:将`loss_paddle.npy`、`loss_torch.npy`与`loss_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
-
-
-### 3.5 优化器对齐
-
-**【基本流程】**
-
-PaddlePaddle中的optimizer有`paddle.optimizer`等一系列实现,PyTorch中则有`torch.Optim`等一系列实现。
-
-**【注意事项】**
-
-以SGD等优化器为例,PaddlePaddle与Pytorch的优化器区别主要如下。
-
-* PaddlePaddle在优化器中增加了对梯度裁剪的支持,在训练GAN或者一些NLP、多模态任务中,这个用到的比较多。
-* PaddlePaddle的SGD不支持动量更新、动量衰减和Nesterov动量,这里需要使用`paddle.optimizer.Momentum` API实现这些功能。
-
-**【实战】**
-
-本部分对齐建议对照[PaddlePaddle优化器API文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html)与参考代码的优化器实现进行对齐,用之后的反向对齐统一验证该模块的正确性。
-
-
-
-### 3.6 学习率对齐
-
-**【基本流程】**
-
-* 学习率策略主要用于指定训练过程中的学习率变化曲线,这里可以将定义好的学习率策略,不断step,即可得到对应的学习率值,可以将学习率值保存在列表或者矩阵中,使用`reprod_log`工具判断二者是否对齐。
-
-**【注意事项】**
-
-PaddlePaddle中,需要首先构建学习率策略,再传入优化器对象中;对于PyTorch,如果希望使用更丰富的学习率策略,需要先构建优化器,再传入学习率策略类API。
-
-**【实战】**
-
-学习率复现对齐,可以参考代码:[学习率对齐验证文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step4/README.md#%E5%AD%A6%E4%B9%A0%E7%8E%87%E5%AF%B9%E9%BD%90%E9%AA%8C%E8%AF%81)。
-
-
-### 3.7 正则化策略对齐
-
-**【基本流程】**
-
-L2正则化策略用于模型训练,可以防止模型对训练数据过拟合,L1正则化可以用于得到稀疏化的权重矩阵,PaddlePaddle中有`paddle.regularizer.L1Decay`与`paddle.regularizer.L2Decay` API。PyTorch中,torch.optim集成的优化器只有L2正则化方法,直接在构建optimizer的时候,传入`weight_decay`参数即可。
-
-**【注意事项】**
-
-* PaddlePaddle的optimizer中支持L1Decat/L2Decay。
-* PyTorch的optimizer支持不同参数列表的学习率分别设置,params传入字典即可,而PaddlePaddle的2.1.0版本目前尚未支持这种行为,可以通过设置`ParamAttr`的`learning_rate`参数,来确定相对学习率倍数。PaddlePaddle的2.2.0版本中虽然实现该功能,但是模型收敛速度较慢,不建议使用。[优化器收敛速度慢](https://github.com/PaddlePaddle/Paddle/issues/36915)
-
-**【实战】**
-
-本部分对齐建议对照[PaddlePaddle正则化API文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/regularizer/L2Decay_cn.html)与参考代码的优化器实现进行对齐,用之后的反向对齐统一验证该模块的正确性。
-
-
-### 3.8 反向对齐
-
-**【基本流程】**
-
-此处可以通过numpy生成假的数据和label(推荐),也可以准备固定的真实数据。具体流程如下。
-
-1. 检查两个代码的训练超参数全部一致,如优化器及其超参数、学习率、LayerNorm中的eps等。
-2. 将PaddlePaddle与PyTorch网络中涉及的所有随机操作全部关闭,如dropout、drop_path等,推荐将模型设置为eval模式(`model.eval()`)
-3. 加载相同的weight dict(可以通过PyTorch来存储随机的权重),将准备好的数据分别传入网络并迭代,观察二者loss是否一致(此处batch-size要一致,如果使用多个真实数据,要保证传入网络的顺序一致)
-4. 如果经过2轮以上,loss均可以对齐,则基本可以认为反向对齐。
-
-
-**【注意事项】**
-
-* 如果第一轮loss就没有对齐,则需要仔细排查一下模型前向部分。
-* 如果第二轮开始,loss开始无法对齐,则首先需要排查下超参数的差异,没问题的话,在`loss.backward()`方法之后,使用`tensor.grad`获取梯度值,二分的方法查找diff,定位出PaddlePaddle与PyTorch梯度无法对齐的API或者操作,然后进一步验证并反馈。
-
-梯度的打印方法示例代码如下所示,注释掉的内容即为打印网络中所有参数的梯度shape。
-
-```python
- # 代码地址:https://github.com/JunnYu/BERT-SST2-Prod/blob/2c372656bb1b077b0073c50161771d9fa9d8de5a/pipeline/Step4/test_bp.py#L12
- def pd_train_some_iters(model,
- criterion,
- optimizer,
- fake_data,
- fake_label,
- max_iter=2):
- model = PDBertForSequenceClassification.from_pretrained("bert-base-uncased", num_classes=2)
- classifier_weights = paddle.load("../classifier_weights/paddle_classifier_weights.bin")
- model.load_dict(classifier_weights)
- model.eval()
- criterion = paddle.nn.CrossEntropy()
- decay_params = [
- p.name for n, p in model.named_parameters()
- if not any(nd in n for nd in ["bias", "norm"])
- ]
- optimizer = paddle.optimizer.AdamW(learning_rate=3e-5, parameters=model.parameters(),
- weight_decay=1e-2,
- epsilon=1e-6,
- apply_decay_param_fun=lambda x: x in decay_params)
- loss_list = []
- for idx in range(max_iter):
- input_ids = paddle.to_tensor(fake_data)
- labels = paddle.to_tensor(fake_label)
-
- output = model(input_ids)
- loss = criterion(output, labels)
- loss.backward()
- optimizer.step()
- optimizer.clear_grad()
- loss_list.append(loss)
- return loss_list
-```
-
-
-
-
-**【实战】**
-
-本部分可以参考文档:[反向对齐操作文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step4/README.md#%E5%8F%8D%E5%90%91%E5%AF%B9%E9%BD%90%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95)。
-
-**【验收】**
-
-对于待复现的项目,反向对齐验收流程如下。
-
-1. 输入:fake data & label
-2. 输出:
- * PaddlePaddle/PyTorch:dict,key为tensor的name(自定义),value为具体loss的值。最后将dict使用reprod_log保存到各自的文件中,建议命名为`bp_align_paddle.npy`和`bp_align_torch.npy`。
-3. 自测:使用reprod_log加载2个文件,使用report功能,记录结果到日志文件中,建议命名为`bp_align_diff_log.txt`,观察diff,二者diff小于特定的阈值即可。
-4. 提交内容:将`bp_align_paddle.npy`、`bp_align_torch.npy`与`bp_align_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
-5. 注意:
- * loss需要保存至少2轮以上。
- * 在迭代的过程中,需要保证模型的batch size等超参数完全相同
- * 在迭代的过程中,需要设置`model.eval()`,使用固定的假数据,同时加载相同权重的预训练模型。
-
-
-### 3.9 训练集数据读取对齐
-
-**【基本流程】**
-
-该部分内容与3.2节内容基本一致,参考PyTorch的代码,实现训练集数据读取与预处理模块即可。
-
-**【注意事项】**
-
-该部分内容,可以参考3.8节的自测方法,将输入的`fake data & label`替换为训练的dataloader,但是需要注意的是:
-* 在使用train dataloader的时候,建议设置random seed,对于PyTorch来说
-
-```python
-#initialize random seed
-torch.manual_seed(config.SEED)
-torch.cuda.manual_seed_all(config.SEED)
-np.random.seed(config.SEED)
-random.seed(config.SEED)
-```
-
-对于PaddlePaddle来说
-
-```python
-paddle.seed(config.SEED)
-np.random.seed(config.SEED)
-random.seed(config.SEED)
-```
-
-
-
-### 3.10 网络初始化对齐
-
-**【基本流程】**
-
-* 下面给出了部分初始化API的映射表。
-
-|PaddlePaddle API | PyTorch API |
-|---|---|
-| paddle.nn.initializer.KaimingNormal | torch.nn.init.kaiming_normal_ |
-| paddle.nn.initializer.KaimingUniform | torch.nn.init.kaiming_uniform_ |
-| paddle.nn.initializer.XavierNormal | torch.nn.init.xavier_normal_ |
-| paddle.nn.initializer.XavierUniform | torch.nn.init.xavier_uniform_ |
-
-**【注意事项】**
-
-* 更多初始化API可以参考[PyTorch初始化API文档](https://pytorch.org/docs/stable/nn.init.html)以及[PaddlePaddle初始化API文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Overview_cn.html#chushihuaxiangguan)。
-
-**【实战】**
-
-本部分对齐建议对照[PaddlePaddle 初始化API文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Overview_cn.html#chushihuaxiangguan)与参考代码的初始化实现对齐。
-
-
-### 3.11 模型训练对齐
-
-**【基本流程】**
-
-完成前面的步骤之后,就可以开始全量数据的训练对齐任务了。按照下面的步骤进行训练对齐。
-
-1. 准备train/eval data, loader, model
-2. 对model按照论文所述进行初始化(如果论文中提到加载了预训练模型,则按需加载pretrained model)
-3. 加载配置,开始训练,迭代得到最终模型与评估指标,将评估指标使用reprod_log保存到文件中。
-4. 将PaddlePaddle提供的参考指标使用reprod_log提交到另一个文件中。
-5. 使用reprod_log排查diff,小于阈值,即可完成自测。
-
-**【注意事项】**
-
-* 【强烈】建议先做完反向对齐之后再进行模型训练对齐,二者之间的不确定量包括:数据集、PaddlePaddle与参考代码在模型training mode下的区别,初始化参数。
-* 在训练对齐过程中,受到较多随机量的影响,精度有少量diff是正常的,以SST-2数据集的分类为例,diff在0.15%以内可以认为是正常的,这里可以根据不同的任务,适当调整对齐检查的阈值(`ReprodDiffHelper.report`函数中的`diff_threshold`参数)。
-* 训练过程中的波动是正常的,如果最终收敛结果不一致,可以
- * 仔细排查Dropout、BatchNorm以及其他组网模块及超参是否无误。
- * 基于参考代码随机生成一份预训练模型,转化为PaddlePaddle的模型,并使用PaddlePaddle加载训练,对比二者的收敛曲线与最终结果,排查初始化影响。
- * 使用参考代码的Dataloader生成的数据,进行模型训练,排查train dataloader的影响。
-
-**【实战】**
-
-本部分可以参考文档:[训练对齐操作文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step5/README.md)。
-
-**【验收】**
-
-对于待复现的项目,训练对齐验收流程如下。
-
-1. 输入:train/eval dataloader, model
-2. 输出:
- * PaddlePaddle:dict,key为保存值的name(自定义),value为具体评估指标的值。最后将dict使用reprod_log保存到文件中,建议命名为`train_align_paddle.npy`。
- * benchmark:dict,key为保存值的name(自定义),value为论文复现赛的评估指标要求的值。最后将dict使用reprod_log保存到文件中,建议命名为`train_align_benchmark.npy`。
-3. 自测:使用reprod_log加载2个文件,使用report功能,记录结果到日志文件中,建议命名为`train_align_diff_log.txt`,观察diff,二者diff小于特定的阈值即可。
-4. 提交内容:将`train_align_paddle.npy`、`train_align_benchmark.npy`与`train_align_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,最终一并打包上传即可。
-
-
-### 3.12 单机多卡训练
-
-如果希望使用单机多卡提升训练效率,可以从以下几个过程对代码进行修改。
-
-#### 3.12.1 数据读取
-
-对于PaddlePaddle来说,多卡数据读取这块主要的变化在sampler
-
-对于单机单卡,sampler实现方式如下所示。
-
-```python
-train_sampler = paddle.io.RandomSampler(dataset)
-train_batch_sampler = paddle.io.BatchSampler(
- sampler=train_sampler, batch_size=args.batch_size)
-```
-
-对于单机多卡任务,sampler实现方式如下所示。
-
-```python
-train_batch_sampler = paddle.io.DistributedBatchSampler(
- dataset=dataset,
- batch_size=args.batch_size,
- shuffle=True,
- drop_last=False
- )
-```
-
-注意:在这种情况下,单机多卡的代码仍然能够以单机单卡的方式运行,因此建议以这种sampler方式进行论文复现。
-
-
-#### 3.12.2 多卡模型初始化
-
-如果以多卡的方式运行,需要初始化并行训练环境,代码如下所示。
-
-```python
-if paddle.distributed.get_world_size() > 1:
- paddle.distributed.init_parallel_env()
-```
-
-在模型组网并初始化参数之后,需要使用`paddle.DataParallel()`对模型进行封装,使得模型可以通过数据并行的模式被执行。代码如下所示。
-
-```python
-if paddle.distributed.get_world_size() > 1:
- model = paddle.DataParallel(model)
-```
-
-
-#### 3.12.3 模型保存、日志保存等其他模块
-
-以模型保存为例,我们只需要在0号卡上保存即可,否则多个trainer同时保存的话,可能会造成写冲突,导致最终保存的模型不可用。
-
-
-#### 3.12.4 程序启动方式
-
-对于单机单卡,启动脚本如下所示。[单机单卡](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/benchmark/glue)
-
-```shell
-unset CUDA_VISIBLE_DEVICES
-python -m paddle.distributed.launch --gpus "0" run_glue.py \
- --model_type bert \
- --model_name_or_path bert-base-uncased \
- --task_name SST-2 \
- --max_seq_length 128 \
- --batch_size 32 \
- --learning_rate 2e-5 \
- --num_train_epochs 3 \
- --logging_steps 1 \
- --save_steps 500 \
- --output_dir ./tmp/ \
- --device gpu \
- --use_amp False
-```
-
-
-对于单机多卡(示例中为4卡训练),启动脚本如下所示。
-
-```shell
-unset CUDA_VISIBLE_DEVICES
-python -m paddle.distributed.launch --gpus "0,1,2,3" run_glue.py \
- --model_type bert \
- --model_name_or_path bert-base-uncased \
- --task_name SST-2 \
- --max_seq_length 128 \
- --batch_size 32 \
- --learning_rate 2e-5 \
- --num_train_epochs 3 \
- --logging_steps 1 \
- --save_steps 500 \
- --output_dir ./tmp/ \
- --device gpu \
- --use_amp False
-```
-
-注意:这里8卡训练时,虽然单卡的batch size没有变化(32),但是总卡的batch size相当于是单卡的8倍,因此学习率也设置为了单卡时的8倍。
-
-
-**【实战】**
-
-本部分可以参考paddlenlp库中的例子:[单机多卡训练](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/bert)。
-
-
-## 4. 论文复现注意事项与FAQ
-
-本部分主要总结大家在论文复现赛过程中遇到的问题,如果本章内容没有能够解决你的问题,欢迎给该文档提出优化建议或者给Paddle提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose)。
-
-
-### 4.0 通用注意事项
-
-* 需要仔细对照PaddlePaddle与参考代码的优化器参数实现,确保优化器参数严格对齐。
-* 如果遇到一些Paddle不支持的API操作,可以尝试使用替代实现进行复现。如下面的PyTorch代码,PaddlePaddle中可以通过slice + concat API的组合形式进行功能实现。同时,对于这个问题,建议优先给Paddle提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),列出Paddle不支持的实现,开发人员会根据优先级进行开发。
-
-```python
-torch.stack([
- per_locations[:, 0] - per_box_regression[:, 0],
- per_locations[:, 1] - per_box_regression[:, 1],
- per_locations[:, 0] + per_box_regression[:, 2],
- per_locations[:, 1] + per_box_regression[:, 3],
-], dim=1)
-```
-* 如果遇到Paddle不包含的OP或者API,比如(1) 如果是某些算法实现存在调用了外部OP,而且Paddle也不包含该OP实现;(2) 其他框架存在的API或者OP,但是Paddle中没有这些OP。此时:
- * 对于Paddle资深用户来说,可以尝试使用Paddle的自定义算子功能,存在一定的代码开发量。
- * 对于初学者来说,可以给Paddle提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),列出Paddle不支持的实现,Paddle开发人员会根据优先级进行实现。
-* PaddlePaddle与PyTorch对于不同名称的API,实现的功能可能是相同的,复现的时候注意,比如[paddle.optimizer.lr.StepDecay](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/lr/StepDecay_cn.html#stepdecay)与[torch.optim.lr_scheduler.StepLR](https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.StepLR.html#torch.optim.lr_scheduler.StepLR) 。
-* 对于PaddlePaddle来说,通过`paddle.set_device`函数(全局)来确定模型结构是运行在什么设备上,对于torch来说,是通过`model.to("device")` (局部)来确定模型结构的运行设备,这块在复现的时候需要注意。
-
-
-
-### 4.1 模型结构对齐
-
-#### 4.1.1 API
-* 对于 `paddle.nn.Linear` 层的weight参数,PaddlePaddle与PyTorch的保存方式不同,在转换时需要进行转置,示例代码可以参考[BERT权重转换脚本](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py)。
-* `torch.masked_fill`函数的功能目前可以使用`paddle.where`进行实现,可以参考:[链接](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/faq/train_cn.html#paddletorch-masked-fillapi)。
-* `pack_padded_sequence`和`pad_packed_sequence`这两个API目前PaddlePaddle中没有实现,可以直接在RNN或者LSTM的输入中传入`sequence_length`来实现等价的功能。
-
-
-#### 4.1.2 权重转换
-
-* 在权重转换的时候,不能只关注参数的名称,比如说有些`paddle.nn.Linear`层,但是定义的变量名称为`conv`,这种也是需要进行权重转置的。
-* 权重转换时,建议同时打印 Paddle 和 PyTorch 对应权重的shape,以防止名称相似但是shape不同的参数权重转换报错。
-
-#### 4.1.3 模型组网正确性验证
-
-* 在论文复现的过程中,可能会遇到一些经典的模型结构,比如Transformer等,Paddle官方也提供了Transformer的实现,但是这里建议自己根据PyTorch代码重新实现一遍,一方面是对整体的模型结构更加熟悉,另一方面也保证模型结构和权重完全对齐。
-* 在复杂的网络结构中,如果前向结果对不齐,可以按照模块排查问题,比如依次获取embedding、transformer-block、mlm-head输出等,看下问题具体出现在哪个子模块,再进到子模块详细排查。
-* 网络结构对齐后,尽量使用训练好的预训练模型和真实的数据进行前向diff计算,这样更准确。
-
-
-### 4.2 验证/测试集数据读取对齐
-
-* 需要仔细排查数据预处理,不仅包含的预处理方法相同,也需要保证预处理的流程相同,比如先padding策略不同和截断策略的不同会导致得到最终的结果是不同的。
-
-
-### 4.3 评估指标对齐
-
-* 真实数据评估时,需要注意评估时 `paddle.io.DataLoader` 的 ``drop_last`` 参数是否打开(文档[链接](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/io/DataLoader_cn.html#dataloader)),复现代码需要与参考代码保持一致,否则最后不够batch-size的数据的评估会有diff。
-* 在识别或者检索过程中,为了加速评估过程,往往会将评估函数由CPU实现改为GPU实现,由此会带来评估函数输出的不一致。这是由于sort函数对于相同值的排序结果不同带来的。在复现的过程中,如果可以接受轻微的指标不稳定,可以使用PaddlePaddle的sort函数,如果对于指标非常敏感,同时对速度性能要求很高,可以给PaddlePaddle提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),由研发人员高优开发。
-
-
-
-### 4.4 损失函数对齐
-
-* 部分算法的损失函数中会用到 bool 索引,这时候可以使用[paddle.where](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/where_cn.html#where) 代替。
-* `paddle.nn.CrossEntropyLoss` 默认是在最后一维(axis=-1)计算损失函数,而 `torch.nn.CrossEntropyLoss` 是在axis=1的地方计算损失函数,因此如果输入的维度大于2,这里需要保证计算的维(axis)相同,否则可能会出错。
-* 在生成模型中会遇到梯度损失,需要对模型中的算子求二次梯度,目前`MaxPooling`暂时不支持二次梯度,如果复现的过程中遇到了需要对`MaxPooling`求二次梯度的情况,可以和Paddle官方开发同学反馈,进一步确认解决方案。
-* 在保存损失函数值的时候,注意要使用`paddle.no_grad`,或者仅仅保存转换成 numpy 的数组,避免损失没有析构导致内存泄漏问题。
-
-```python
-# 错误示范
-loss = celoss(pred, label)
-avg_loss += loss
-# 正确示范1
-loss = celoss(pred, label)
-avg_loss += loss.numpy()
-# 正确示范2
-loss = celoss(pred, label)
-with paddle.no_grad()
- avg_loss += loss
-```
-
-
-### 4.5 优化器对齐
-
-* Paddle目前支持在 ``optimizer`` 中通过设置 ``params_groups`` 的方式设置不同参数的更新方式,可以参考[代码示例](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/optimizer/optimizer.py#L107) 。
-* 有些模型训练时,会使用梯度累加策略,即累加到一定step数量之后才进行参数更新,这时在实现上需要注意对齐。
-* 在某些任务中,比如说深度学习可视化、可解释性等任务中,一般只要求模型前向过程,不需要训练,此时优化器、学习率等用于模型训练的模块对于该类论文复现是不需要的。
-* 在文本分类领域,大多数Transformer模型都采用了AdamW优化器,并且会设置weigh decay,同时部分参数设置为no weight decay,例如位置编码的参数通常设置为no weight decay,no weight decay参数设置不正确,最终会有明显的精度损失,需要特别注意。一般可以通过分析模型权重来发现该问题,分别计算官方模型和复现模型每层参数权重的平均值、方差,对每一层依次对比,有显著差异的层可能存在问题,因为在weight decay的作用下,参数权重数值会相对较小,而未正确设置no weight decay,则会造成该层参数权重数值异常偏小。
-
-
-
-### 4.6 学习率对齐
-
-* PaddlePaddle 中参数的学习率受到优化器学习率和`ParamAttr`中设置的学习率影响,因此跟踪学习率需要将二者结合进行跟踪。
-* 对于复现代码和参考代码,学习率在整个训练过程中在相同的轮数相同的iter下应该保持一致,可以通过`reprod_log`工具、打印学习率值或者可视化二者学习率的log来查看diff。
-* 有些网络的学习率策略比较细致,比如带warmup的学习率策略,这里需要保证起始学习率等参数都完全一致。
-
-
-
-### 4.7 正则化策略对齐
-
-* 在如Transformer或者少部分CNN模型中,存在一些参数不做正则化(正则化系数为0)的情况。这里需要找到这些参数并对齐取消实施正则化策略,可以参考[这里](https://github.com/PaddlePaddle/PaddleClas/blob/release%2F2.3/ppcls/arch/backbone/model_zoo/resnest.py#L72),对特定参数进行修改。
-
-
-### 4.8 反向对齐
-
-* 反向对齐时,如果第二轮开始,loss开始无法对齐,则首先需要排查下超参数的差异,没问题的话,在`loss.backward()`方法之后,使用`tensor.grad`获取梯度值,二分的方法查找diff,定位出PaddlePaddle与PyTorch梯度无法对齐的API或者操作,然后进一步验证。第3章中给出了获取所有参数的梯度方法,如果只希望打印特定参数的梯度,可以用下面的方式。
-
-
-```python
-import paddle
-
-def print_hook_fn(grad):
- print(grad)
-
-x = paddle.to_tensor([0., 1., 2., 3.], stop_gradient=False)
-h = x.register_hook(print_hook_fn)
-w = x * 4
-w.backward()
-# backward之后会输出下面的内容
-# Tensor(shape=[4], dtype=float32, place=CPUPlace, stop_gradient=False,
-# [4., 4., 4., 4.])
-```
-
-
-
-### 4.9 训练集数据读取对齐
-
-#### 4.9.1 API
-
-* 在前向过程中,如果数据预处理过程运行出错,请先将 ``paddle.io.DataLoader`` 的 ``num_workers`` 参数设为0,然后根据单个进程下的报错日志定位出具体的bug。
-
-#### 4.9.2 数据预处理
-
-
-* 如果数据处理过程中涉及到随机数生成,建议固定seed (`np.random.seed(0)`, `random.seed(0)`),查看复现代码和参考代码处理后的数据是否有diff。
-* 对文本进行tokenizer处理时,需要确定文本的截断策略,padding策略。
-
-
-### 4.10 网络初始化对齐
-
-* 对于不同的深度学习框架,网络初始化在大多情况下,即使值的分布完全一致,也无法保证值完全一致,这里也是论文复现中不确定性比较大的地方。如果十分怀疑初始化导致的问题,建议将参考的初始化权重转成paddle模型,加载该初始化模型训练,看下收敛精度。
-* CNN对于模型初始化相对来说没有那么敏感,在迭代轮数与数据集足够的情况下,最终精度指标基本接近;而transformer系列模型对于初始化比较敏感,在transformer系列模型训练对齐过程中,建议对这一块进行重点检查。
-
-
-
-### 4.11 模型训练对齐
-
-#### 4.11.1 训练对齐通用问题
-
-* 有条件的话,复现工作之前最好先基于官方代码完成训练,保证与官方指标能够对齐,并且将训练策略和训练过程中的关键指标记录保存下来,比如每个epoch的学习率、Train Loss、Eval Loss、Eval Acc等,在复现网络的训练过程中,将关键指标保存下来,这样可以将两次训练中关键指标的变化曲线绘制出来,能够很方便的进行对比。
-* 训练过程中可以对loss或者acc进行可视化,和竞品loss或者acc进行直观的对比;如果训练较大的数据集,1次完整训练的成本比较高,此时可以隔一段时间查看一下,如果精度差异比较大,建议先停掉实验,排查原因。
-* 如果训练的过程中出nan,一般是因为除0或者log0的情况, 可以着重看下几个部分:
- * 如果有预训练模型的话,可以确认下是否加载正确
- * 模型结构中计算loss的部分是否有考虑到正样本为0的情况
- * 也可能是某个API的数值越界导致的,可以测试较小的输入是否还会出现nan。
-* 如果训练过程中如果出现不收敛的情况,可以
- * 简化网络和数据,实验是否收敛;
- * 如果是基于原有实现进行改动,可以尝试控制变量法,每次做一个改动,逐个排查;
- * 检查学习率是否过大、优化器设置是否合理,排查下weight decay是否设置正确;
- * 保存不同step之间的模型参数,观察模型参数是否更新。
diff --git a/legacy/model_zoo/electra/README.md b/legacy/model_zoo/electra/README.md
deleted file mode 100644
index 7a009a28b542..000000000000
--- a/legacy/model_zoo/electra/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# ELECTRA with PaddleNLP
-
-[ELECTRA](https://openreview.net/pdf?id=r1xMH1BtvB) 在[BERT](https://arxiv.org/abs/1810.04805)的基础上对其预训练过程进行了改进:预训练由两部分模型网络组成,称为Generator和Discriminator,各自包含1个BERT模型。Generator的预训练使用和BERT一样的Masked Language Model(MLM)任务,但Discriminator的预训练使用Replaced Token Detection(RTD)任务(主要改进点)。预训练完成后,使用Discriminator作为精调模型,后续的Fine-tuning不再使用Generator。
-
-图片来源:来自[electra论文](https://openreview.net/pdf?id=r1xMH1BtvB)
-
-详细请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/model_zoo/electra).
diff --git a/legacy/model_zoo/ernie-3.0-tiny/deploy/README.md b/legacy/model_zoo/ernie-3.0-tiny/deploy/README.md
deleted file mode 100644
index 0946cd900482..000000000000
--- a/legacy/model_zoo/ernie-3.0-tiny/deploy/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# FastDeploy ERNIE 3.0 Tiny 模型高性能部署
-
-**目录**
- * [FastDeploy部署介绍](#FastDeploy部署介绍)
- * [代码结构](#代码结构)
- * [环境要求](#环境要求)
- * [详细部署文档](#详细部署文档)
-
-
-
-## FastDeploy部署介绍
-
-**⚡️FastDeploy**是一款**全场景**、**易用灵活**、**极致高效**的AI推理部署工具,满足开发者**多硬件、多平台**的产业部署需求。开发者可以基于FastDeploy将训练好的预测模型在不同的硬件、不同的操作系统以及不同的推理引擎后端上进行部署。目前FastDeploy提供多种编程语言的 SDK,包括 C++、Python 以及 Java SDK。
-
-目前 ERNIE 3.0 Tiny 模型已提供基于 FastDeploy 的云边端的部署示例,在服务端上的 GPU 硬件上,支持`Paddle Inference`、`ONNX Runtime`、`Paddle TensorRT`以及`TensorRT`后端,在CPU上支持`Paddle Inference`、`ONNX Runtime`以及`OpenVINO`后端;在移动端上支持`Paddle Lite`后端。多硬件、多推理引擎后端的支持可以满足开发者不同的部署需求。
-
-本部署示例是车载语音场景下的口语理解(Spoken Language Understanding,SLU)任务,详细可看[ERNIE 3.0 Tiny介绍](../README.md)。
-
-
-
-
-## 代码结构
-
-```text
-
-├── python
-│ ├── infer_demo.py # Python 部署示例代码
-│ └── README.md # Python 部署示例文档
-└── README.md # 文档
-
-```
-
-
-
-## 环境要求
-
-在部署ERNIE 3.0 Tiny模型前,需要安装FastDeploy SDK,可参考[FastDeploy SDK安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)确认部署环境是否满足FastDeploy环境要求,并按照介绍安装相应的SDK。
-
-
-
-## 详细部署文档
-
-- [Python部署](python/README.md)
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md b/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
deleted file mode 100644
index b3ce2c1ae200..000000000000
--- a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
+++ /dev/null
@@ -1 +0,0 @@
-本目录存放ERNIE 3.0模型
diff --git a/legacy/model_zoo/ernie-doc/README.md b/legacy/model_zoo/ernie-doc/README.md
deleted file mode 100644
index 6669d77fd2b1..000000000000
--- a/legacy/model_zoo/ernie-doc/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# ERNIE-Doc: A Retrospective Long-Document Modeling Transformer
-
-## 模型简介
-[ERNIE-Doc](https://arxiv.org/abs/2012.15688)是百度NLP提出的针对长文本的预训练模型。在循环Transformer机制之上,创新性地提出两阶段重复学习以及增强的循环机制,以此提高模型感受野,加强模型对长文本的理解能力。
-
-详细参考这里: https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/model_zoo/ernie-doc
diff --git a/legacy/model_zoo/luke/README.md b/legacy/model_zoo/luke/README.md
deleted file mode 100644
index a66f93035b52..000000000000
--- a/legacy/model_zoo/luke/README.md
+++ /dev/null
@@ -1,91 +0,0 @@
-# LUKE with PaddleNLP
-
-[LUKE: Deep Contextualized Entity Representations with Entity-aware Self-attention](https://arxiv.org/abs/2010.01057)
-
-**模型简介:**
-许多NLP任务都涉及实体,例如:关系分类、实体类型、命名实体识别(NER)和问答(QA)。解决此类实体相关任务的关键是学习实体有效表示。传统的实体表示为每个实体分配一个固定的Embedding向量,该向量将有关实体的信息存储在知识库(KB)中。它们需要实体链接(entity linking)来表示文本中的实体,而不能表示KB中不存在的实体。
-
-相比之下,基于contextualized word representations(CWRs) transformer的大型预训练模型,如BERT和RoBERTa,提供了基于语言建模的有效通用词语表征。然而,由于以下两个原因,CWRs的体系结构不适合表示实体:
-
-- 由于CWR不输出实体的跨级(span-level)表示,因此它们通常需要学习如何基于通常较小的下游数据集计算此类表征。
-
-- 许多与实体相关的任务,如关系分类和问答(QA)涉及实体之间关系的推理。尽管transformer可以通过使用self-attention机制将单词相互关联来捕捉单词之间的复杂关系。在实体之间执行关系推理是困难的,因为许多实体在模型中被分割成多个词。此外,基于单词的CWRs预训练任务不适合学习实体的表征,因为在实体中预测一个被MASK的单词,例如预测“Rings”, 给予句子“The Lord of the [MASK]”,一个完整的实体就这样被拆分。
-
-LUKE和现有CWRs之间的一个重要区别在于,它不仅将单词视为独立的token,还将实体视为独立的token,并使用transformer计算所有token的中间表征和输出表征。由于实体被视为token,LUKE可以直接建模实体之间的关系。
-本项目是 LUKE 在 Paddle 2.x上的开源实现。
-
-## 快速开始
-
-### 下游任务微调
-
-数据集
-下载Open Entity数据集
-[下载地址](https://cloud.tsinghua.edu.cn/f/6ec98dbd931b4da9a7f0/)
-把下载好的文件解压,并把解压后的Open Entity目录下的`train.json`、`test.json`和`dev.json`分别为训练集、验证集和测试集
-
-下载SQuAD1.1数据集,主流机器阅读理解数据集
-[下载地址](https://data.deepai.org/squad1.1.zip)
-
-#### 1、SQuAD1.1
-以SQuAD1.1数据集为例
-
-运行以下两个命令即可训练并评估LUKE在SQuAD1.1数据集的精度
-
-```shell
-python -m paddle.distributed.launch examples/language_model/luke/run_squad.py
- --model_type luke \
- --device gpu \
- --learning_rate 15e-6 \
- --num_train_epochs 2 \
- --batch_size 8 \
- --do_predict \
- --do_train \
- --model_name_or_path luke-large
-```
-其中参数释义如下:
-- `model_type` 指示了模型类型,当前支持`luke`
-- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
-- `num_train_epochs` 表示需要训练的epoch数量
-- `do_train` 表示是否开启训练
-- `do_predict` 表示是否开启评估
-- `model_name_or_path` 模型的名称和路径,支持`luke-base` 和 `luke-large`
-
-训练结束后模型会对模型进行评估,其评估在验证集上完成, 训练完成后你将看到如下结果:
-```text
-{"exact_match": 89.75691579943235, "f1": 94.95702001984502}
-```
-
-#### 2、Open Entity
-
-```shell
-python -m paddle.distributed.launch examples/language_model/luke/run_open_entity.py \
- --model_type luke-large \
- --data_dir data/ \
- --output_dir output/ \
- --device gpu \
- --learning_rate 1e-5 \
- --num_train_epochs 3 \
- --train_batch_size 2
-```
-训练结束后模型会对模型进行评估,其评估在测试集上完成, 训练完成后你将看到如下结果:
-```text
-Results: {
- "test_f1": 0.7815726767275616,
- "test_precision": 0.7880405766150561,
- "test_recall": 0.7752100840336135
-}
-```
-
-
-# Reference
-
-```bibtex
-@inproceedings{yamada2020luke,
- title={LUKE: Deep Contextualized Entity Representations with Entity-aware Self-attention},
- author={Ikuya Yamada and Akari Asai and Hiroyuki Shindo and Hideaki Takeda and Yuji Matsumoto},
- booktitle={EMNLP},
- year={2020}
-}
-```
diff --git a/legacy/model_zoo/xlnet/README.md b/legacy/model_zoo/xlnet/README.md
deleted file mode 100644
index 06a0c30331bb..000000000000
--- a/legacy/model_zoo/xlnet/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# XLNet
-
-## 模型简介
-
-[XLNet: Generalized Autoregressive Pretraining for Language Understanding](https://arxiv.org/abs/1906.08237) 是一款无监督的自回归预训练语言模型。 有别于传统的单向自回归模型,XLNet通过最大化输入序列所有排列的期望来进行语言建模,这使得它可以同时关注到上下文的信息。 另外,XLNet在预训练阶段集成了 [Transformer-XL](https://arxiv.org/abs/1901.02860) 模型,Transformer-XL中的片段循环机制(Segment Recurrent Mechanism)和 相对位置编码(Relative Positional Encoding)机制能够支持XLNet接受更长的输入序列,这使得XLNet在长文本序列的语言任务上有着优秀的表现。
-
-详细请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/language_model/xlnet).
diff --git a/llm/README.md b/llm/README.md
index 24a498e116df..307deec0f8f6 100644
--- a/llm/README.md
+++ b/llm/README.md
@@ -76,7 +76,7 @@ mv llama_openwebtext_100k.idx ./data
```shell
# 编译自定义算子,可选
-cd ../legacy/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
+cd ../slm/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
# 模型预训练参考
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./config/llama/pretrain_argument.json
diff --git a/llm/auto_parallel/llama/README.md b/llm/auto_parallel/llama/README.md
index c8efdb1b870c..4786269891e1 100644
--- a/llm/auto_parallel/llama/README.md
+++ b/llm/auto_parallel/llama/README.md
@@ -19,7 +19,7 @@ mv llama_openwebtext_100k.idx ./data
安装自定义算子:
```shell
# 编译自定义算子,可选
-cd ../../../legacy/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
+cd ../../../slm/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
```
## 3. 预训练
diff --git a/llm/docs/pretrain.rst b/llm/docs/pretrain.rst
index 788b99b660b1..bf9fc6c08dcf 100644
--- a/llm/docs/pretrain.rst
+++ b/llm/docs/pretrain.rst
@@ -65,7 +65,7 @@ git clone 代码到本地,即可开始。
.. code-block:: bash
# 编译自定义算子,可选
- cd ../legacy/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
+ cd ../slm/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
# llama 模型预训练
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./config/llama/pretrain_argument.json
@@ -78,7 +78,7 @@ git clone 代码到本地,即可开始。
1. 建议使用paddle develop版本训练,需要安装 ``pip install fast_dataindex visualdl==2.5.3`` 等相关缺失whl包。
2. ``use_flash_attention`` 需要在A100机器开启,建议使用cuda11.8环境。
-3. ``use_fused_rms_norm`` 需要安装 `此目录 `_ 下的自定义OP, `python setup.py install`。如果安装后仍然找不到算子,需要额外设置 ``PYTHONPATH``。
+3. ``use_fused_rms_norm`` 需要安装 `此目录 `_ 下的自定义OP, `python setup.py install`。如果安装后仍然找不到算子,需要额外设置 ``PYTHONPATH``。
4. ``continue_training`` 表示从现有的预训练模型加载训练。7b模型初始loss大概为2.xx, 随机初始化模型loss从11.x左右下降。
5. 当前脚本为sharding版本,需要4D并行训练(数据、sharding、张量、流水线并行)的用户,请参考 ``run_trainer_tp4pp2.sh`` 脚本。
6. 多机训练时,若各机器使用的训练数据文件位置相同(例如挂载共享硬盘情况),请指定 ``--share_folder true`` 使全局0号卡制作缓存数据。否则默认各台机器的0号卡独立制作缓存数据,
diff --git a/llm/experimental/ernie-3.5-se/README.md b/llm/experimental/ernie-3.5-se/README.md
index 60d509971a04..c2254d1479e6 100644
--- a/llm/experimental/ernie-3.5-se/README.md
+++ b/llm/experimental/ernie-3.5-se/README.md
@@ -89,7 +89,7 @@ python -u -m paddle.distributed.launch \
1. 需要 paddle develop 版本训练,需要安装`pip install fast_dataindex visualdl==2.5.3`等相关缺失 whl 包
2. `use_flash_attention` 需要在 A100机器开启,否则 loss 可能不正常(很快变成0.00x,非常小不正常)。建议使用 cuda11.8环境。
3. `continue_training` 表示从现有的预训练模型加载训练,如果需要从头开始预训练模型,则设置为0。
-4. `use_fused_ln` 需要安装[此目录](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/model_zoo/gpt-3/external_ops)下的自定义 OP, `python setup.py install`。如果安装后仍然找不到算子,需要额外设置 PYTHONPATH
+4. `use_fused_ln` 需要安装[此目录](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/gpt-3/external_ops)下的自定义 OP, `python setup.py install`。如果安装后仍然找不到算子,需要额外设置 PYTHONPATH
5. 当前脚本为 sharding 版本,需要4D 并行训练(数据、sharding、张量、流水线并行)的用户,可另外调整相关参数。
diff --git a/llm/gcu/llama/predict_llama_gcu.sh b/llm/gcu/llama/predict_llama_gcu.sh
index 689baa84660c..f1650526c956 100644
--- a/llm/gcu/llama/predict_llama_gcu.sh
+++ b/llm/gcu/llama/predict_llama_gcu.sh
@@ -21,7 +21,7 @@ export CUSTOM_DEVICE_BLACK_LIST="softmax_with_cross_entropy"
export PYTHONPATH=../../:$PYTHONPATH
echo 'run llama wiki_text eval, log: wikitext_eval_gcu.log'
-python ../../../legacy/examples/benchmark/wiki_lambada/eval.py \
+python ../../../slm/examples/benchmark/wiki_lambada/eval.py \
--model_name_or_path "__internal_testing__/sci-benchmark-llama-13b-5k" \
--device gcu \
--batch_size 4 \
diff --git a/llm/tools/preprocess/README.md b/llm/tools/preprocess/README.md
index f49af0ddf209..a44cd8884aab 100644
--- a/llm/tools/preprocess/README.md
+++ b/llm/tools/preprocess/README.md
@@ -246,7 +246,7 @@ mv ./preprocess/baike_sample* ./data
```
* llama 预训练请参考[预训练](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm)。
-* ernie 预训练请参考[预训练](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/model_zoo/ernie-1.0/pretraining_introduction.md)。
+* ernie 预训练请参考[预训练](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/model_zoo/ernie-1.0/pretraining_introduction.md)。
代码说明:
diff --git a/scripts/distribute/ci_case_auto.sh b/scripts/distribute/ci_case_auto.sh
index 7387c13b35f0..33ad38295e1c 100755
--- a/scripts/distribute/ci_case_auto.sh
+++ b/scripts/distribute/ci_case_auto.sh
@@ -19,7 +19,7 @@ set -e
export log_path=/workspace/case_logs
export root_path=/workspace/PaddleNLP
-export gpt_case_path=$root_path/legacy/model_zoo/gpt-3
+export gpt_case_path=$root_path/slm/model_zoo/gpt-3
export gpt_data_path=/fleetx_data
export llama_case_path=$root_path/llm/auto_parallel/llama
diff --git a/scripts/distribute/ci_case_dy.sh b/scripts/distribute/ci_case_dy.sh
index a22abba53fee..87f07e2c9ce4 100644
--- a/scripts/distribute/ci_case_dy.sh
+++ b/scripts/distribute/ci_case_dy.sh
@@ -19,7 +19,7 @@ set -e
export log_path=/workspace/case_logs
export root_path=/workspace/PaddleNLP
-export gpt_case_path=$root_path/legacy/model_zoo/gpt-3
+export gpt_case_path=$root_path/slm/model_zoo/gpt-3
export gpt_data_path=/fleetx_data
export llm_gpt_case_path=$root_path/llm
@@ -273,7 +273,7 @@ function gpt_export_345M_mp1() {
rm -rf $log_dir
rm -rf output
- export PYTHONPATH=$root_path/legacy/model_zoo/gpt-3:$PYTHONPATH
+ export PYTHONPATH=$root_path/slm/model_zoo/gpt-3:$PYTHONPATH
export CUDA_VISIBLE_DEVICES=1
python -m paddle.distributed.launch --log_dir $log_dir --devices "1" \
./tools/auto_export.py \
@@ -294,7 +294,7 @@ function gpt_export_345M_mp2() {
rm -rf $log_dir
rm -rf output
- export PYTHONPATH=$root_path/legacy/model_zoo/gpt-3:$PYTHONPATH
+ export PYTHONPATH=$root_path/slm/model_zoo/gpt-3:$PYTHONPATH
export CUDA_VISIBLE_DEVICES=0,1
python -m paddle.distributed.launch --devices "0,1" \
./tools/auto_export.py \
diff --git a/scripts/distribute/run_ci.sh b/scripts/distribute/run_ci.sh
index dfd0c702c1d1..6a7151553945 100644
--- a/scripts/distribute/run_ci.sh
+++ b/scripts/distribute/run_ci.sh
@@ -21,7 +21,7 @@ export log_path=/workspace/case_logs
export case_list=()
target_lists_for_gpt=(
- "legacy/model_zoo/gpt-3"
+ "slm/model_zoo/gpt-3"
"llm/auto_parallel/gpt-3"
"paddlenlp/transformers/gpt/modeling.py"
"paddlenlp/transformers/gpt/modeling_pp.py"
@@ -67,7 +67,7 @@ install_paddlenlp(){
install_external_ops(){
echo -e "\033[31m ---- Install extern_ops \033"
export PYTHONPATH=${nlp_dir}:$PYTHONPATH
- cd ${nlp_dir}/legacy/model_zoo/gpt-3/external_ops
+ cd ${nlp_dir}/slm/model_zoo/gpt-3/external_ops
python setup.py install
python -c "import fused_ln;";
}
diff --git a/scripts/regression/ci_case.sh b/scripts/regression/ci_case.sh
index 15de189362d1..d9c233c31a1f 100644
--- a/scripts/regression/ci_case.sh
+++ b/scripts/regression/ci_case.sh
@@ -49,7 +49,7 @@ print_info() {
# case list
# 2 msra_ner (不可控,内置)
msra_ner() {
- cd ${nlp_dir}/legacy/examples/information_extraction/msra_ner/
+ cd ${nlp_dir}/slm/examples/information_extraction/msra_ner/
export CUDA_VISIBLE_DEVICES=${cudaid2}
## train
time (python -m paddle.distributed.launch ./train.py \
@@ -85,7 +85,7 @@ msra_ner() {
}
# 3 glue
glue() {
- cd ${nlp_dir}/legacy/examples/benchmark/glue/
+ cd ${nlp_dir}/slm/examples/benchmark/glue/
export CUDA_VISIBLE_DEVICES=${cudaid2}
## TASK_SST-2
export TASK_NAME=SST-2
@@ -106,11 +106,11 @@ glue() {
# 4 bert
bert() {
export CUDA_VISIBLE_DEVICES=${cudaid2}
- # cd ${nlp_dir}/legacy/model_zoo/bert/
+ # cd ${nlp_dir}/slm/model_zoo/bert/
# wget -q https://paddle-qa.bj.bcebos.com/paddlenlp/bert.tar.gz
# tar -xzvf bert.tar.gz
python -c "import datasets;from datasets import load_dataset; train_dataset=load_dataset('glue', 'sst2', split='train')"
- cd ${nlp_dir}/legacy/model_zoo/bert/data/
+ cd ${nlp_dir}/slm/model_zoo/bert/data/
wget -q https://bj.bcebos.com/paddlenlp/models/transformers/bert/data/training_data.hdf5
cd ../
# pretrain
@@ -156,7 +156,7 @@ bert() {
}
# 5 skep (max save 不可控 内置)
skep() {
- cd ${nlp_dir}/legacy/examples/sentiment_analysis/skep/
+ cd ${nlp_dir}/slm/examples/sentiment_analysis/skep/
export CUDA_VISIBLE_DEVICES=${cudaid2}
## train_sentence
time (python -m paddle.distributed.launch train_sentence.py --batch_size 16 --epochs 1 --model_name "skep_ernie_1.0_large_ch" --device gpu --save_dir ./checkpoints >${log_path}/skep_train_sentence) >>${log_path}/skep_train_sentence 2>&1
@@ -179,7 +179,7 @@ skep() {
}
# 6 bigbird
bigbird(){
- cd ${nlp_dir}/legacy/model_zoo/bigbird/
+ cd ${nlp_dir}/slm/model_zoo/bigbird/
export CUDA_VISIBLE_DEVICES=${cudaid2}
time (python -m paddle.distributed.launch --log_dir log run_pretrain.py --model_name_or_path bigbird-base-uncased \
--input_dir "./data" \
@@ -197,7 +197,7 @@ bigbird(){
# 9 ernie
ernie(){
#data process
- cd ${nlp_dir}/legacy/model_zoo/ernie-1.0/
+ cd ${nlp_dir}/slm/model_zoo/ernie-1.0/
if [ -d "data_ernie_3.0" ];then
rm -rf data_ernie_3.0
@@ -242,7 +242,7 @@ ernie(){
}
# 11 ofa
ofa(){
- cd ${nlp_dir}/legacy/examples/model_compression/ofa/
+ cd ${nlp_dir}/slm/examples/model_compression/ofa/
cd ../../benchmark/glue/
export CUDA_VISIBLE_DEVICES=${cudaid2}
# finetuing
@@ -260,7 +260,7 @@ ofa(){
--output_dir ./ \
--device gpu >${log_path}/ofa_pretrain) >>${log_path}/ofa_pretrain 2>&1
print_info $? ofa_pretrain
- mv sst-2_ft_model_1.pdparams/ ${nlp_dir}/legacy/examples/model_compression/ofa/
+ mv sst-2_ft_model_1.pdparams/ ${nlp_dir}/slm/examples/model_compression/ofa/
cd -
#model slim
# export CUDA_VISIBLE_DEVICES=${cudaid2}
@@ -281,7 +281,7 @@ ofa(){
}
# 12 albert
albert() {
- cd ${nlp_dir}/legacy/examples/benchmark/glue/
+ cd ${nlp_dir}/slm/examples/benchmark/glue/
export CUDA_VISIBLE_DEVICES=${cudaid2}
time (python -m paddle.distributed.launch run_glue.py \
--model_type albert \
@@ -300,7 +300,7 @@ albert() {
}
# 13 squad
# squad() {
-# cd ${nlp_dir}/legacy/examples/machine_reading_comprehension/SQuAD/
+# cd ${nlp_dir}/slm/examples/machine_reading_comprehension/SQuAD/
# export CUDA_VISIBLE_DEVICES=${cudaid1}
# # finetune
# time (python -m paddle.distributed.launch run_squad.py \
@@ -337,7 +337,7 @@ albert() {
# 15 lexical_analysis
lexical_analysis(){
export CUDA_VISIBLE_DEVICES=${cudaid2}
- cd ${nlp_dir}/legacy/examples/lexical_analysis/
+ cd ${nlp_dir}/slm/examples/lexical_analysis/
#train
time (python download.py --data_dir ./ )
time (python -m paddle.distributed.launch train.py \
@@ -371,7 +371,7 @@ lexical_analysis(){
# 22 transformer
transformer() {
- cd ${nlp_dir}/legacy/examples/machine_translation/transformer/
+ cd ${nlp_dir}/slm/examples/machine_translation/transformer/
wget -q https://paddle-qa.bj.bcebos.com/paddlenlp/WMT14.en-de.partial.tar.gz
tar -xzvf WMT14.en-de.partial.tar.gz
time (
@@ -419,7 +419,7 @@ transformer() {
}
#28 question_matching
question_matching() {
- cd ${nlp_dir}/legacy/examples/text_matching/question_matching/
+ cd ${nlp_dir}/slm/examples/text_matching/question_matching/
wget -q https://paddle-qa.bj.bcebos.com/paddlenlp/data_v4.tar.gz
tar -xvzf data_v4.tar.gz
export CUDA_VISIBLE_DEVICES=${cudaid2}
@@ -452,7 +452,7 @@ question_matching() {
# 29 ernie-csc
ernie-csc() {
export CUDA_VISIBLE_DEVICES=${cudaid2}
- cd ${nlp_dir}/legacy/examples/text_correction/ernie-csc
+ cd ${nlp_dir}/slm/examples/text_correction/ernie-csc
#dowdnload data
python download.py --data_dir ./extra_train_ds/ --url https://github.com/wdimmy/Automatic-Corpus-Generation/raw/master/corpus/train.sgml
#trans xml txt
@@ -472,7 +472,7 @@ ernie-csc() {
}
clue() {
- cd ${nlp_dir}/legacy/examples/benchmark/clue/classification
+ cd ${nlp_dir}/slm/examples/benchmark/clue/classification
python -u ./run_clue_classifier_trainer.py \
--model_name_or_path ernie-3.0-base-zh \
--dataset "clue afqmc" \
@@ -514,7 +514,7 @@ clue() {
--max_steps 1 \
--do_train >${log_path}/clue-class >>${log_path}/clue-class 2>&1
print_info $? clue-class
- cd ${nlp_dir}/legacy/examples/benchmark/clue/mrc
+ cd ${nlp_dir}/slm/examples/benchmark/clue/mrc
export CUDA_VISIBLE_DEVICES=${cudaid1}
# python -m paddle.distributed.launch run_cmrc2018.py \
# --model_name_or_path ernie-3.0-base-zh \
@@ -553,7 +553,7 @@ llm(){
}
ernie-3.0(){
- cd ${nlp_dir}/legacy/model_zoo/ernie-3.0/
+ cd ${nlp_dir}/slm/model_zoo/ernie-3.0/
#训练
python run_seq_cls.py --model_name_or_path ernie-3.0-medium-zh --dataset afqmc --output_dir ./best_models --export_model_dir best_models/ --do_train --do_eval --do_export --config=configs/default.yml --max_steps=2 --save_step=2 >${log_path}/ernie-3.0_train_seq_cls >>${log_path}/ernie-3.0_train_seq_cls 2>&1
print_info $? ernie-3.0_train_seq_cls
@@ -577,7 +577,7 @@ ernie-3.0(){
# print_info $? ernie-3.0_compress_qa
}
uie(){
- cd ${nlp_dir}/legacy/model_zoo/uie/
+ cd ${nlp_dir}/slm/model_zoo/uie/
mkdir data && cd data && wget https://bj.bcebos.com/paddlenlp/datasets/uie/doccano_ext.json && cd ../
python doccano.py --doccano_file ./data/doccano_ext.json --task_type ext --save_dir ./data --splits 0.8 0.2 0 --schema_lang ch >${log_path}/uie_doccano>>${log_path}/uie_doccano 2>&1
print_info $? uie_doccano
@@ -592,7 +592,7 @@ uie(){
print_info $? uie_eval
}
ernie-layout(){
- cd ${nlp_dir}/legacy/model_zoo/ernie-layout/
+ cd ${nlp_dir}/slm/model_zoo/ernie-layout/
# train ner
python -u run_ner.py --model_name_or_path ernie-layoutx-base-uncased --output_dir ./ernie-layoutx-base-uncased/models/funsd/ \
--dataset_name funsd --do_train --do_eval --max_steps 2 --eval_steps 2 --save_steps 2 --save_total_limit 1 --seed 1000 --overwrite_output_dir \
@@ -604,7 +604,7 @@ ernie-layout(){
python export_model.py --task_type ner --model_path ./ernie-layoutx-base-uncased/models/funsd/ --output_path ./ner_export >${log_path}/ernie-layout_export>>${log_path}/ernie-layout_export2>&1
print_info $? ernie-layout_export
# deploy ner
- cd ${nlp_dir}/legacy/model_zoo/ernie-layout/deploy/python
+ cd ${nlp_dir}/slm/model_zoo/ernie-layout/deploy/python
wget https://bj.bcebos.com/paddlenlp/datasets/document_intelligence/images.zip && unzip images.zip
python infer.py --model_path_prefix ../../ner_export/inference --task_type ner --lang "en" --batch_size 8 >${log_path}/ernie-layout_deploy>>${log_path}/ernie-layout_deploy 2>&1
print_info $? ernie-layout_deploy
diff --git a/scripts/regression/get_model_list.py b/scripts/regression/get_model_list.py
index 4ebe373c43ff..45d196ea4033 100644
--- a/scripts/regression/get_model_list.py
+++ b/scripts/regression/get_model_list.py
@@ -20,7 +20,7 @@ def get_model_list():
"""
get model list from
-
+
"""
CI_MODEL_LIST = [
@@ -72,9 +72,9 @@ def get_model_list():
]
examples_second_list = ["model_interpretation", "semantic_indexing", "lexical_analysis", "word_embedding"]
- model_list = os.listdir("legacy/model_zoo")
+ model_list = os.listdir("slm/model_zoo")
model_list = os.listdir("model_zoo")
- examples_list = os.listdir("legacy/examples/")
+ examples_list = os.listdir("slm/examples/")
app_list = os.listdir("applications/")
# remove model_list README
diff --git a/legacy/applications/README.md b/slm/applications/README.md
similarity index 76%
rename from legacy/applications/README.md
rename to slm/applications/README.md
index d75461dda949..a44bce02be21 100644
--- a/legacy/applications/README.md
+++ b/slm/applications/README.md
@@ -13,10 +13,10 @@ PaddleNLP 从预训练模型库出发,提供了经典预训练模型在主流
在面向不同场景任务建设一系列产业方案的过程中,不难发现,从技术基础设施角度看:
-(1)NLP系统都可以抽象为由多个基础组件串接而成的流水线系统;
-(2)多个NLP流水线系统可共享使用相同的基础组件。
+(1)NLP 系统都可以抽象为由多个基础组件串接而成的流水线系统;
+(2)多个 NLP 流水线系统可共享使用相同的基础组件。
-因此,PaddleNLP 逐渐孵化出了一套 NLP 流水线系统 [Pipelines](../pipelines),将各个 NLP 复杂系统的通用模块抽象封装为标准组件,支持开发者通过配置文件对标准组件进行组合,仅需几分钟即可定制化构建智能系统,让解决NLP任务像搭积木一样便捷、灵活、高效。同时,Pipelines 中预置了前沿的预训练模型和算法,在研发效率、模型效果和性能方面提供多重保障。因此,Pipelines 能够大幅加快开发者使用飞桨落地的效率。
+因此,PaddleNLP 逐渐孵化出了一套 NLP 流水线系统 [Pipelines](../pipelines),将各个 NLP 复杂系统的通用模块抽象封装为标准组件,支持开发者通过配置文件对标准组件进行组合,仅需几分钟即可定制化构建智能系统,让解决 NLP 任务像搭积木一样便捷、灵活、高效。同时,Pipelines 中预置了前沿的预训练模型和算法,在研发效率、模型效果和性能方面提供多重保障。因此,Pipelines 能够大幅加快开发者使用飞桨落地的效率。
@@ -31,13 +31,13 @@ PaddleNLP 从预训练模型库出发,提供了经典预训练模型在主流
- 如果你希望使用自己的业务数据进行二次开发,推荐使用`./applications`目录下的**可定制版本**,训练好的模型可以直接集成进 Pipelines 中进行使用。
- 也可以使用 [AI Studio](https://aistudio.baidu.com/aistudio/index) 在线 Jupyter Notebook 快速体验,有 GPU 算力哦。
-| 场景任务 | Pipelines版本地址 | 可定制版本地址 | Notebook |
+| 场景任务 | Pipelines 版本地址 | 可定制版本地址 | Notebook |
| :--------------- | ------- | ------- | ------- |
-| **检索**| [字面+语义检索](../pipelines/examples/semantic-search) | [语义检索](./neural_search) | [基于Pipelines搭建检索系统](https://aistudio.baidu.com/aistudio/projectdetail/4442670)
[二次开发语义检索](https://aistudio.baidu.com/aistudio/projectdetail/3351784) |
-| **问答** | [FAQ问答](../pipelines/examples/FAQ/)
[无监督检索式问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/unsupervised-question-answering)
[有监督检索式问答](../pipelines/examples/question-answering) | [FAQ问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa)
[无监督检索式问答](./question_answering/unsupervised_qa) | [基于Pipelines搭建FAQ问答系统](https://aistudio.baidu.com/aistudio/projectdetail/4465498)
[基于Pipelines搭建抽取式问答系统](https://aistudio.baidu.com/aistudio/projectdetail/4442857)
[FAQ政务问答](https://aistudio.baidu.com/aistudio/projectdetail/3678873)
[FAQ保险问答](https://aistudio.baidu.com/aistudio/projectdetail/3882519) |
+| **检索**| [字面+语义检索](../pipelines/examples/semantic-search) | [语义检索](./neural_search) | [基于 Pipelines 搭建检索系统](https://aistudio.baidu.com/aistudio/projectdetail/4442670)
[二次开发语义检索](https://aistudio.baidu.com/aistudio/projectdetail/3351784) |
+| **问答** | [FAQ 问答](../pipelines/examples/FAQ/)
[无监督检索式问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/unsupervised-question-answering)
[有监督检索式问答](../pipelines/examples/question-answering) | [FAQ 问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa)
[无监督检索式问答](./question_answering/unsupervised_qa) | [基于 Pipelines 搭建 FAQ 问答系统](https://aistudio.baidu.com/aistudio/projectdetail/4465498)
[基于 Pipelines 搭建抽取式问答系统](https://aistudio.baidu.com/aistudio/projectdetail/4442857)
[FAQ 政务问答](https://aistudio.baidu.com/aistudio/projectdetail/3678873)
[FAQ 保险问答](https://aistudio.baidu.com/aistudio/projectdetail/3882519) |
| **文本分类**| 暂无 | [文本分类](./text_classification) | [对话意图识别](https://aistudio.baidu.com/aistudio/projectdetail/2017202)
[法律文本多标签分类](https://aistudio.baidu.com/aistudio/projectdetail/3996601)
[层次分类](https://aistudio.baidu.com/aistudio/projectdetail/4568985) |
| **通用文本分类** | 暂无 | [通用文本分类](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/zero_shot_text_classification) | |
-| **通用信息抽取** | 暂无 | [通用信息抽取](./information_extraction) | [UIE快速体验](https://aistudio.baidu.com/aistudio/projectdetail/3914778)
[UIE微调实体抽取](https://aistudio.baidu.com/aistudio/projectdetail/4038499)
[UIE微调关系抽取](https://aistudio.baidu.com/aistudio/projectdetail/4371345)
[UIE-X快速体验](https://aistudio.baidu.com/aistudio/projectdetail/5017442)
[UIE-X微调](https://aistudio.baidu.com/aistudio/projectdetail/5261592) |
+| **通用信息抽取** | 暂无 | [通用信息抽取](./information_extraction) | [UIE 快速体验](https://aistudio.baidu.com/aistudio/projectdetail/3914778)
[UIE 微调实体抽取](https://aistudio.baidu.com/aistudio/projectdetail/4038499)
[UIE 微调关系抽取](https://aistudio.baidu.com/aistudio/projectdetail/4371345)
[UIE-X 快速体验](https://aistudio.baidu.com/aistudio/projectdetail/5017442)
[UIE-X 微调](https://aistudio.baidu.com/aistudio/projectdetail/5261592) |
| **情感分析** | [情感分析](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/sentiment_analysis) | [情感分析](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/sentiment_analysis) | [情感分析](https://aistudio.baidu.com/aistudio/projectdetail/5318177)|
| **文档智能** | [文档抽取问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/document-intelligence) | [跨模态文档问答](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/document_intelligence/doc_vqa)| [文档抽取问答](https://aistudio.baidu.com/aistudio/projectdetail/4881278)
[汽车说明书问答](https://aistudio.baidu.com/aistudio/projectdetail/4049663) |
| **文生图** | [文生图系统](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/text_to_image) | 可参考[PaddleMIX](https://github.com/PaddlePaddle/PaddleMIX) | |
@@ -70,7 +70,7 @@ PaddleNLP 从预训练模型库出发,提供了经典预训练模型在主流
#### ❓ 智能问答系统
-- 端到端问答技术 [🚀RocketQA](https://github.com/PaddlePaddle/RocketQA),首个中文端到端问答模型,基于知识增强的预训练模型ERNIE和百万量级的人工标注数据集DuReader训练得到,效果优异;
+- 端到端问答技术 [🚀RocketQA](https://github.com/PaddlePaddle/RocketQA),首个中文端到端问答模型,基于知识增强的预训练模型 ERNIE 和百万量级的人工标注数据集 DuReader 训练得到,效果优异;
- 覆盖有监督(如 FAQ 问答)、无监督(自动生成 QA 对,生成的问答对语料可以通过无监督的方式构建检索式问答系统)等多种情况,适用各类业务场景。
@@ -108,8 +108,8 @@ PaddleNLP 从预训练模型库出发,提供了经典预训练模型在主流
#### 💌 评论观点抽取与情感分析
-- 经典方案:基于情感知识增强预训练模型SKEP,两阶段式抽取和分类,首先通过序列标注的方式定位属性词和观点词,然后进行属性集情感分类;
-- 前沿方案:基于UIE的情感分析方案采用 Prompt Learning 的方式进行情感信息抽取,精度更高。支持语句级和属性级情感分析,解决同义属性聚合、隐性观点抽取难点,并提供可视化分析能力。
+- 经典方案:基于情感知识增强预训练模型 SKEP,两阶段式抽取和分类,首先通过序列标注的方式定位属性词和观点词,然后进行属性集情感分类;
+- 前沿方案:基于 UIE 的情感分析方案采用 Prompt Learning 的方式进行情感信息抽取,精度更高。支持语句级和属性级情感分析,解决同义属性聚合、隐性观点抽取难点,并提供可视化分析能力。

diff --git a/legacy/applications/information_extraction/README.md b/slm/applications/information_extraction/README.md
similarity index 70%
rename from legacy/applications/information_extraction/README.md
rename to slm/applications/information_extraction/README.md
index c85a0912cae4..e0433d1305f0 100644
--- a/legacy/applications/information_extraction/README.md
+++ b/slm/applications/information_extraction/README.md
@@ -10,7 +10,7 @@
- [2.3 产业级全流程方案](#23)
- [2.4 效果展示](#24)
- [3. 快速开始](#快速开始)
- - [3.1 Taskflow开箱即用](#31)
+ - [3.1 Taskflow 开箱即用](#31)
- [3.2 文本信息抽取](#32)
- [3.3 文档信息抽取](#33)
@@ -20,13 +20,13 @@
信息抽取应用针对信息抽取一系列高频场景开源了产业级解决方案,**具备多领域、多任务、跨模态的能力**,打通**数据标注-模型训练-模型调优-预测部署全流程**,可快速实现信息抽取产品落地。
-信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP信息抽取应用**基于UIE统一建模的思想**,提供了信息抽取产业级应用方案,**除支持纯文本场景实体、关系、事件、观点等不同任务抽取外,还支持文档/图片/表格的端到端信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务POC阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
+信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP 信息抽取应用**基于 UIE 统一建模的思想**,提供了信息抽取产业级应用方案,**除支持纯文本场景实体、关系、事件、观点等不同任务抽取外,还支持文档/图片/表格的端到端信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务 POC 阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
**信息抽取应用亮点:**
- **覆盖场景全面🎓:** 覆盖信息抽取各类主流任务,面向纯文本和文档场景,支持多语言,满足开发者多样信息抽取落地需求。
-- **效果领先🏃:** 以在纯文本、多模态上均有突出效果的UIE系列模型作为训练基座,提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **简单易用⚡:** 通过Taskflow实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
+- **效果领先🏃:** 以在纯文本、多模态上均有突出效果的 UIE 系列模型作为训练基座,提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **简单易用⚡:** 通过 Taskflow 实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
- **高效调优✊:** 开发者无需机器学习背景知识,即可轻松上手数据标注及模型训练流程。
@@ -50,7 +50,7 @@
### 2.2 强大的训练基座
-信息抽取应用使用ERNIE 3.0轻量级模型作为预训练模型,同时在大量信息抽取数据上进行了二次预训练,从而让模型适配固定prompt。
+信息抽取应用使用 ERNIE 3.0轻量级模型作为预训练模型,同时在大量信息抽取数据上进行了二次预训练,从而让模型适配固定 prompt。
- 中文文本数据集实验效果
@@ -69,11 +69,11 @@
🧾 🎓uie-x-base (12L768H) | 48.84 | 73.87 | 65.60 | 88.81 | 79.36 | 81.65
|
-0-shot表示无训练数据直接通过```paddlenlp.Taskflow```进行预测,5-shot表示每个类别包含5条标注数据进行模型微调。**实验表明UIE在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
+0-shot 表示无训练数据直接通过 ```paddlenlp.Taskflow```进行预测,5-shot 表示每个类别包含5条标注数据进行模型微调。**实验表明 UIE 在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
- 多模态数据集实验效果
-我们在通用、金融、医疗三大场景自建多模态测试集上对UIE-X的零样本效果进行了实验:
+我们在通用、金融、医疗三大场景自建多模态测试集上对 UIE-X 的零样本效果进行了实验:
| 通用 | 金融 | 医疗
@@ -88,39 +88,39 @@
**调研阶段**
-- 该阶段目标需求开放且缺少数据积累。我们提供Taskflow三行代码极简调用的方式,无需标注数据即可在业务场景上快速验证效果。
- - [文本抽取 Taskflow使用指南](./taskflow_text.md)
- - [文档抽取 Taskflow使用指南](./taskflow_doc.md)
+- 该阶段目标需求开放且缺少数据积累。我们提供 Taskflow 三行代码极简调用的方式,无需标注数据即可在业务场景上快速验证效果。
+ - [文本抽取 Taskflow 使用指南](./taskflow_text.md)
+ - [文档抽取 Taskflow 使用指南](./taskflow_doc.md)
**数据准备阶段**
-- 我们推荐在实际的业务场景中定制自己的信息抽取模型。我们提供了不同抽取场景的Label Studio标注解决方案,可基于该方案实现从数据标注到训练数据构造的无缝衔接,大大降低了数据标注、模型定制的时间成本。
+- 我们推荐在实际的业务场景中定制自己的信息抽取模型。我们提供了不同抽取场景的 Label Studio 标注解决方案,可基于该方案实现从数据标注到训练数据构造的无缝衔接,大大降低了数据标注、模型定制的时间成本。
- [文本抽取标注指南](./label_studio_text.md)
- [文档抽取标注指南](./label_studio_doc.md)。
**模型微调及封闭域蒸馏**
-- 基于UIE优秀的小样本微调能力,实现低成本模型定制适配。同时提供封闭域蒸馏的加速方案,解决抽取速度慢的问题。
+- 基于 UIE 优秀的小样本微调能力,实现低成本模型定制适配。同时提供封闭域蒸馏的加速方案,解决抽取速度慢的问题。
- [文本信息抽取全流程示例](./text/README.md)
- [文档信息抽取全流程示例](./document/README.md)
**模型部署**
-- 提供HTTP部署方案,快速实现定制模型的部署上线。
- - [文本抽取HTTP部署指南](./text/deploy/simple_serving/README.md)
- - [文档抽取HTTP部署指南](./document/deploy/simple_serving/README.md)
+- 提供 HTTP 部署方案,快速实现定制模型的部署上线。
+ - [文本抽取 HTTP 部署指南](./text/deploy/simple_serving/README.md)
+ - [文档抽取 HTTP 部署指南](./document/deploy/simple_serving/README.md)
### 2.4 效果展示
-- 🧾 通过[Huggingface网页](https://huggingface.co/spaces/PaddlePaddle/UIE-X)体验UIE-X功能:
+- 🧾 通过[Huggingface 网页](https://huggingface.co/spaces/PaddlePaddle/UIE-X)体验 UIE-X 功能:
-- UIE-X端到端文档抽取产业应用示例
+- UIE-X 端到端文档抽取产业应用示例
- 报关单
@@ -152,11 +152,11 @@
-### 3.1 Taskflow开箱即用
+### 3.1 Taskflow 开箱即用
-- 通过Taskflow实现开箱即用
- 👉 [文本抽取 Taskflow使用指南](./taskflow_text.md)
- 👉 [文档抽取 Taskflow使用指南](./taskflow_doc.md)
+- 通过 Taskflow 实现开箱即用
+ 👉 [文本抽取 Taskflow 使用指南](./taskflow_text.md)
+ 👉 [文档抽取 Taskflow 使用指南](./taskflow_doc.md)
diff --git a/legacy/applications/information_extraction/README_en.md b/slm/applications/information_extraction/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/README_en.md
rename to slm/applications/information_extraction/README_en.md
diff --git a/legacy/applications/information_extraction/document/README.md b/slm/applications/information_extraction/document/README.md
similarity index 79%
rename from legacy/applications/information_extraction/document/README.md
rename to slm/applications/information_extraction/document/README.md
index 30f4670e954f..b65d260d6a59 100644
--- a/legacy/applications/information_extraction/document/README.md
+++ b/slm/applications/information_extraction/document/README.md
@@ -16,22 +16,22 @@
## 1. 文档信息抽取应用
-本项目提供基于UIE微调的文档抽取端到端应用方案,打通**数据标注-模型训练-模型调优-预测部署全流程**,可快速实现文档信息抽取产品落地。
+本项目提供基于 UIE 微调的文档抽取端到端应用方案,打通**数据标注-模型训练-模型调优-预测部署全流程**,可快速实现文档信息抽取产品落地。
-信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP信息抽取应用UIE统一建模的思想,提供了文档信息抽取产业级应用方案,支持**文档/图片/表格和纯文本场景下实体、关系、事件、观点等不同任务信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务POC阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
+信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP 信息抽取应用 UIE 统一建模的思想,提供了文档信息抽取产业级应用方案,支持**文档/图片/表格和纯文本场景下实体、关系、事件、观点等不同任务信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务 POC 阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
**文档信息抽取应用亮点:**
- **覆盖场景全面🎓:** 覆盖文档信息抽取各类主流任务,支持多语言,满足开发者多样信息抽取落地需求。
-- **效果领先🏃:** 以在多模态信息抽取上有突出效果的模型UIE-X作为训练基座,具有广泛成熟的实践应用性。
-- **简单易用⚡:** 通过Taskflow实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
+- **效果领先🏃:** 以在多模态信息抽取上有突出效果的模型 UIE-X 作为训练基座,具有广泛成熟的实践应用性。
+- **简单易用⚡:** 通过 Taskflow 实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
- **高效调优✊:** 开发者无需机器学习背景知识,即可轻松上手数据标注及模型训练流程。
## 2. 快速开始
-对于简单的抽取目标可以直接使用```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用定制功能(标注少量数据进行模型微调)以进一步提升效果。
+对于简单的抽取目标可以直接使用 ```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用定制功能(标注少量数据进行模型微调)以进一步提升效果。
@@ -50,9 +50,9 @@
### 2.2 数据标注
-我们推荐使用 [Label Studio](https://labelstud.io/) 进行文档信息抽取数据标注,本项目打通了从数据标注到训练的通道,也即Label Studio导出数据可以通过 [label_studio.py](../label_studio.py) 脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考 [Label Studio数据标注指南](../label_studio_doc.md)。
+我们推荐使用 [Label Studio](https://labelstud.io/) 进行文档信息抽取数据标注,本项目打通了从数据标注到训练的通道,也即 Label Studio 导出数据可以通过 [label_studio.py](../label_studio.py) 脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考 [Label Studio 数据标注指南](../label_studio_doc.md)。
-这里我们提供预先标注好的`增值税发票数据集`的文件,可以运行下面的命令行下载数据集,我们将展示如何使用数据转化脚本生成训练/验证/测试集文件,并使用UIE-X模型进行微调。
+这里我们提供预先标注好的`增值税发票数据集`的文件,可以运行下面的命令行下载数据集,我们将展示如何使用数据转化脚本生成训练/验证/测试集文件,并使用 UIE-X 模型进行微调。
下载增值税发票数据集:
```shell
@@ -71,7 +71,7 @@ python ../label_studio.py \
--task_type ext
```
-生成训练/验证集文件,可以使用PP-Structure的布局分析优化OCR结果的排序:
+生成训练/验证集文件,可以使用 PP-Structure 的布局分析优化 OCR 结果的排序:
```shell
python ../label_studio.py \
--label_studio_file ./data/label_studio.json \
@@ -81,7 +81,7 @@ python ../label_studio.py \
--layout_analysis True
```
-更多不同类型任务(含实体抽取、关系抽取、文档分类等)的标注规则及参数说明,请参考[Label Studio数据标注指南](../label_studio_doc.md)。
+更多不同类型任务(含实体抽取、关系抽取、文档分类等)的标注规则及参数说明,请参考[Label Studio 数据标注指南](../label_studio_doc.md)。
@@ -120,7 +120,7 @@ python finetune.py \
--save_total_limit 1
```
-如果在GPU环境中使用,可以指定gpus参数进行多卡训练:
+如果在 GPU 环境中使用,可以指定 gpus 参数进行多卡训练:
```shell
python -u -m paddle.distributed.launch --gpus "0" finetune.py \
@@ -162,20 +162,20 @@ python -u -m paddle.distributed.launch --gpus "0" finetune.py \
* `train_path`:训练集路径;默认为 `None` 。
* `dev_path`:开发集路径;默认为 `None` 。
* `max_seq_len`:文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
-* `per_device_train_batch_size`:用于训练的每个 GPU 核心/NPU 核心/CPU 的batch大小,默认为8。
-* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/NPU 核心/CPU 的batch大小,默认为8。
+* `per_device_train_batch_size`:用于训练的每个 GPU 核心/NPU 核心/CPU 的 batch 大小,默认为8。
+* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/NPU 核心/CPU 的 batch 大小,默认为8。
* `num_train_epochs`: 训练轮次,使用早停法时可以选择 100;默认为10。
* `learning_rate`:训练最大学习率,UIE-X 推荐设置为 1e-5;默认值为3e-5。
-* `label_names`:训练数据标签label的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为None。
+* `label_names`:训练数据标签 label 的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为 None。
* `do_train`:是否进行微调训练,设置该参数表示进行微调训练,默认不设置。
* `do_eval`:是否进行评估,设置该参数表示进行评估,默认不设置。
* `do_export`:是否进行导出,设置该参数表示进行静态图导出,默认不设置。
-* `export_model_dir`:静态图导出地址,默认为None。
+* `export_model_dir`:静态图导出地址,默认为 None。
* `overwrite_output_dir`: 如果 `True`,覆盖输出目录的内容。如果 `output_dir` 指向检查点目录,则使用它继续训练。
-* `disable_tqdm`: 是否使用tqdm进度条。
-* `metric_for_best_model`:最优模型指标,UIE-X 推荐设置为 `eval_f1`,默认为None。
-* `load_best_model_at_end`:训练结束后是否加载最优模型,通常与`metric_for_best_model`配合使用,默认为False。
-* `save_total_limit`:如果设置次参数,将限制checkpoint的总数。删除旧的checkpoints `输出目录`,默认为None。
+* `disable_tqdm`: 是否使用 tqdm 进度条。
+* `metric_for_best_model`:最优模型指标,UIE-X 推荐设置为 `eval_f1`,默认为 None。
+* `load_best_model_at_end`:训练结束后是否加载最优模型,通常与`metric_for_best_model`配合使用,默认为 False。
+* `save_total_limit`:如果设置次参数,将限制 checkpoint 的总数。删除旧的 checkpoints `输出目录`,默认为 None。
@@ -241,12 +241,12 @@ python evaluate.py \
* `device`: 评估设备,可选择 'cpu'、'gpu'、'npu' 其中的一种;默认为 GPU 评估。
* `model_path`: 进行评估的模型文件夹路径,路径下需包含模型权重文件`model_state.pdparams`及配置文件`model_config.json`。
* `test_path`: 进行评估的测试集文件。
-* `label_names`:训练数据标签label的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为None。
+* `label_names`:训练数据标签 label 的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为 None。
* `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
* `max_seq_len`: 文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
-* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/NPU 核心/CPU 的batch大小,默认为8。
-* `debug`: 是否开启debug模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
-* `schema_lang`: 选择schema的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
+* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/NPU 核心/CPU 的 batch 大小,默认为8。
+* `debug`: 是否开启 debug 模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
+* `schema_lang`: 选择 schema 的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
@@ -298,4 +298,4 @@ DocParser.write_image_with_results(
| 30-shot+PP-Structure| 1.0 | 0.9625 | 0.9809 |
-n-shot表示训练集包含n张标注图片数据进行模型微调,实验表明UIE-X可以通过少量数据(few-shot)和PP-Structure的布局分析进一步提升结果。
+n-shot 表示训练集包含 n 张标注图片数据进行模型微调,实验表明 UIE-X 可以通过少量数据(few-shot)和 PP-Structure 的布局分析进一步提升结果。
diff --git a/legacy/applications/information_extraction/document/README_en.md b/slm/applications/information_extraction/document/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/document/README_en.md
rename to slm/applications/information_extraction/document/README_en.md
diff --git a/legacy/applications/information_extraction/document/deploy/simple_serving/README.md b/slm/applications/information_extraction/document/deploy/simple_serving/README.md
similarity index 75%
rename from legacy/applications/information_extraction/document/deploy/simple_serving/README.md
rename to slm/applications/information_extraction/document/deploy/simple_serving/README.md
index e98fc150228a..583318a1f343 100644
--- a/legacy/applications/information_extraction/document/deploy/simple_serving/README.md
+++ b/slm/applications/information_extraction/document/deploy/simple_serving/README.md
@@ -1,26 +1,26 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server服务启动](#Server服务启动)
-- [Client请求启动](#Client请求启动)
+- [Server 服务启动](#Server 服务启动)
+- [Client 请求启动](#Client 请求启动)
- [服务化自定义参数](#服务化自定义参数)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本(或者最新的develop版本)
+使用有 SimpleServing 功能的 PaddleNLP 版本(或者最新的 develop 版本)
```shell
pip install paddlenlp >= 2.4.4
```
-## Server服务启动
+## Server 服务启动
```bash
paddlenlp server server:app --workers 1 --host 0.0.0.0 --port 8189
```
-## Client请求启动
+## Client 请求启动
```bash
python client.py
@@ -29,7 +29,7 @@ python client.py
## 服务化自定义参数
### Server 自定义参数
-#### schema替换
+#### schema 替换
```python
# Default schema
schema = ['开票日期', '名称', '纳税人识别号', '开户行及账号', '金额', '价税合计', 'No', '税率', '地址、电话', '税额']
@@ -42,7 +42,7 @@ uie = Taskflow('information_extraction', task_path='../../checkpoint/model_best/
```
#### 多卡服务化预测
-PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个Taskflow的task即可,下面是示例代码
+PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个 Taskflow 的 task 即可,下面是示例代码
```
uie1 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=0)
uie2 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=1)
diff --git a/legacy/applications/information_extraction/document/deploy/simple_serving/README_en.md b/slm/applications/information_extraction/document/deploy/simple_serving/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/document/deploy/simple_serving/README_en.md
rename to slm/applications/information_extraction/document/deploy/simple_serving/README_en.md
diff --git a/legacy/applications/information_extraction/document/deploy/simple_serving/client.py b/slm/applications/information_extraction/document/deploy/simple_serving/client.py
similarity index 100%
rename from legacy/applications/information_extraction/document/deploy/simple_serving/client.py
rename to slm/applications/information_extraction/document/deploy/simple_serving/client.py
diff --git a/legacy/applications/information_extraction/document/deploy/simple_serving/server.py b/slm/applications/information_extraction/document/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/information_extraction/document/deploy/simple_serving/server.py
rename to slm/applications/information_extraction/document/deploy/simple_serving/server.py
diff --git a/legacy/applications/information_extraction/document/evaluate.py b/slm/applications/information_extraction/document/evaluate.py
similarity index 100%
rename from legacy/applications/information_extraction/document/evaluate.py
rename to slm/applications/information_extraction/document/evaluate.py
diff --git a/legacy/applications/information_extraction/document/finetune.py b/slm/applications/information_extraction/document/finetune.py
similarity index 100%
rename from legacy/applications/information_extraction/document/finetune.py
rename to slm/applications/information_extraction/document/finetune.py
diff --git a/legacy/applications/information_extraction/document/utils.py b/slm/applications/information_extraction/document/utils.py
similarity index 100%
rename from legacy/applications/information_extraction/document/utils.py
rename to slm/applications/information_extraction/document/utils.py
diff --git a/legacy/applications/information_extraction/label_studio.py b/slm/applications/information_extraction/label_studio.py
similarity index 100%
rename from legacy/applications/information_extraction/label_studio.py
rename to slm/applications/information_extraction/label_studio.py
diff --git a/legacy/applications/information_extraction/label_studio_doc.md b/slm/applications/information_extraction/label_studio_doc.md
similarity index 83%
rename from legacy/applications/information_extraction/label_studio_doc.md
rename to slm/applications/information_extraction/label_studio_doc.md
index 57be7dc327b2..5be9dc317736 100644
--- a/legacy/applications/information_extraction/label_studio_doc.md
+++ b/slm/applications/information_extraction/label_studio_doc.md
@@ -1,4 +1,4 @@
-# 文档抽取任务Label Studio使用指南
+# 文档抽取任务 Label Studio 使用指南
**目录**
@@ -21,7 +21,7 @@
- label-studio == 1.6.0
- paddleocr >= 2.6.0.1
-在终端(terminal)使用pip安装label-studio:
+在终端(terminal)使用 pip 安装 label-studio:
```shell
pip install label-studio==1.6.0
@@ -32,7 +32,7 @@ pip install label-studio==1.6.0
label-studio start
```
-在浏览器打开[http://localhost:8080/](http://127.0.0.1:8080/),输入用户名和密码登录,开始使用label-studio进行标注。
+在浏览器打开[http://localhost:8080/](http://127.0.0.1:8080/),输入用户名和密码登录,开始使用 label-studio 进行标注。
@@ -63,19 +63,19 @@ label-studio start
-- 添加标签(也可跳过后续在Setting/Labeling Interface中添加)
+- 添加标签(也可跳过后续在 Setting/Labeling Interface 中添加)
-图中展示了Span实体类型标签的构建,其他类型标签的构建可参考[2.3标签构建](#23)
+图中展示了 Span 实体类型标签的构建,其他类型标签的构建可参考[2.3标签构建](#23)
#### 2.2 数据上传
-先从本地或HTTP链接上传图片,然后选择导入本项目。
+先从本地或 HTTP 链接上传图片,然后选择导入本项目。

@@ -85,20 +85,20 @@ label-studio start
#### 2.3 标签构建
-- Span实体类型标签
+- Span 实体类型标签
-- Relation关系类型标签
+- Relation 关系类型标签
-Relation XML模板:
+Relation XML 模板:
```xml
@@ -127,7 +127,7 @@ Relation XML模板:
- - 该标注示例对应的schema为:
+ - 该标注示例对应的 schema 为:
```text
schema = ['开票日期', '名称', '纳税人识别号', '地址、电话', '开户行及账号', '金额', '税额', '价税合计', 'No', '税率']
@@ -168,7 +168,7 @@ Relation XML模板:
- - 该标注示例对应的schema为:
+ - 该标注示例对应的 schema 为:
```text
schema = {
@@ -188,7 +188,7 @@ Relation XML模板:
- - 该标注示例对应的schema为:
+ - 该标注示例对应的 schema 为:
```text
schema = '文档类别[发票,报关单]'
@@ -199,7 +199,7 @@ Relation XML模板:
#### 2.5 数据导出
-勾选已标注图片ID,选择导出的文件类型为``JSON``,导出数据:
+勾选已标注图片 ID,选择导出的文件类型为``JSON``,导出数据:

@@ -209,7 +209,7 @@ Relation XML模板:
#### 2.6 数据转换
-将导出的文件重命名为``label_studio.json``后,放入``./document/data``目录下,并将对应的标注图片放入``./document/data/images``目录下(图片的文件名需与上传到label studio时的命名一致)。通过[label_studio.py](./label_studio.py)脚本可转为UIE的数据格式。
+将导出的文件重命名为``label_studio.json``后,放入``./document/data``目录下,并将对应的标注图片放入``./document/data/images``目录下(图片的文件名需与上传到 label studio 时的命名一致)。通过[label_studio.py](./label_studio.py)脚本可转为 UIE 的数据格式。
- 路径示例
@@ -247,25 +247,25 @@ python label_studio.py \
#### 2.7 更多配置
-- ``label_studio_file``: 从label studio导出的数据标注文件。
+- ``label_studio_file``: 从 label studio 导出的数据标注文件。
- ``save_dir``: 训练数据的保存目录,默认存储在``data``目录下。
- ``negative_ratio``: 最大负例比例,该参数只对抽取类型任务有效,适当构造负例可提升模型效果。负例数量和实际的标签数量有关,最大负例数量 = negative_ratio * 正例数量。该参数只对训练集有效,默认为5。为了保证评估指标的准确性,验证集和测试集默认构造全负例。
- ``splits``: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.1, 0.1]表示按照``8:1:1``的比例将数据划分为训练集、验证集和测试集。
- ``task_type``: 选择任务类型,可选有抽取和分类两种类型的任务。
- ``options``: 指定分类任务的类别标签,该参数只对分类类型任务有效。默认为["正向", "负向"]。
-- ``prompt_prefix``: 声明分类任务的prompt前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
-- ``is_shuffle``: 是否对数据集进行随机打散,默认为True。
+- ``prompt_prefix``: 声明分类任务的 prompt 前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
+- ``is_shuffle``: 是否对数据集进行随机打散,默认为 True。
- ``seed``: 随机种子,默认为1000.
- ``separator``: 实体类别/评价维度与分类标签的分隔符,该参数只对实体/评价维度分类任务有效。默认为"##"。
-- ``schema_lang``:选择schema的语言,将会应该训练数据prompt的构造方式,可选有`ch`和`en`。默认为`ch`。
-- ``ocr_lang``:选择OCR的语言,可选有`ch`和`en`。默认为`ch`。
-- ``layout_analysis``:是否使用PPStructure对文档进行布局分析,该参数只对文档类型标注任务有效。默认为False。
+- ``schema_lang``:选择 schema 的语言,将会应该训练数据 prompt 的构造方式,可选有`ch`和`en`。默认为`ch`。
+- ``ocr_lang``:选择 OCR 的语言,可选有`ch`和`en`。默认为`ch`。
+- ``layout_analysis``:是否使用 PPStructure 对文档进行布局分析,该参数只对文档类型标注任务有效。默认为 False。
备注:
- 默认情况下 [label_studio.py](./label_studio.py) 脚本会按照比例将数据划分为 train/dev/test 数据集
- 每次执行 [label_studio.py](./label_studio.py) 脚本,将会覆盖已有的同名数据文件
- 在模型训练阶段我们推荐构造一些负例以提升模型效果,在数据转换阶段我们内置了这一功能。可通过`negative_ratio`控制自动构造的负样本比例;负样本数量 = negative_ratio * 正样本数量。
-- 对于从label_studio导出的文件,默认文件中的每条数据都是经过人工正确标注的。
+- 对于从 label_studio 导出的文件,默认文件中的每条数据都是经过人工正确标注的。
## References
diff --git a/legacy/applications/information_extraction/label_studio_doc_en.md b/slm/applications/information_extraction/label_studio_doc_en.md
similarity index 100%
rename from legacy/applications/information_extraction/label_studio_doc_en.md
rename to slm/applications/information_extraction/label_studio_doc_en.md
diff --git a/legacy/applications/information_extraction/label_studio_text.md b/slm/applications/information_extraction/label_studio_text.md
similarity index 79%
rename from legacy/applications/information_extraction/label_studio_text.md
rename to slm/applications/information_extraction/label_studio_text.md
index 6596940a24e9..c6d3f3d93b4d 100644
--- a/legacy/applications/information_extraction/label_studio_text.md
+++ b/slm/applications/information_extraction/label_studio_text.md
@@ -1,4 +1,4 @@
-# 文本抽取任务Label Studio使用指南
+# 文本抽取任务 Label Studio 使用指南
**目录**
@@ -21,7 +21,7 @@
- label-studio == 1.6.0
- paddleocr >= 2.6.0.1
-在终端(terminal)使用pip安装label-studio:
+在终端(terminal)使用 pip 安装 label-studio:
```shell
pip install label-studio==1.6.0
@@ -32,7 +32,7 @@ pip install label-studio==1.6.0
label-studio start
```
-在浏览器打开[http://localhost:8080/](http://127.0.0.1:8080/),输入用户名和密码登录,开始使用label-studio进行标注。
+在浏览器打开[http://localhost:8080/](http://127.0.0.1:8080/),输入用户名和密码登录,开始使用 label-studio 进行标注。
@@ -62,7 +62,7 @@ label-studio start
-- 添加标签(也可跳过后续在Setting/Labeling Interface中配置)
+- 添加标签(也可跳过后续在 Setting/Labeling Interface 中配置)

@@ -74,7 +74,7 @@ label-studio start
#### 2.2 数据上传
-先从本地上传txt格式文件,选择``List of tasks``,然后选择导入本项目。
+先从本地上传 txt 格式文件,选择``List of tasks``,然后选择导入本项目。

@@ -84,19 +84,19 @@ label-studio start
#### 2.3 标签构建
-- Span类型标签
+- Span 类型标签
-- Relation类型标签
+- Relation 类型标签
-Relation XML模板:
+Relation XML 模板:
```xml
@@ -125,7 +125,7 @@ Relation XML模板:
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = [
@@ -142,11 +142,11 @@ schema = [
-对于关系抽取,其P的类型设置十分重要,需要遵循以下原则
+对于关系抽取,其 P 的类型设置十分重要,需要遵循以下原则
-“{S}的{P}为{O}”需要能够构成语义合理的短语。比如对于三元组(S, 父子, O),关系类别为父子是没有问题的。但按照UIE当前关系类型prompt的构造方式,“S的父子为O”这个表达不是很通顺,因此P改成孩子更好,即“S的孩子为O”。**合理的P类型设置,将显著提升零样本效果**。
+“{S}的{P}为{O}”需要能够构成语义合理的短语。比如对于三元组(S, 父子, O),关系类别为父子是没有问题的。但按照 UIE 当前关系类型 prompt 的构造方式,“S 的父子为 O”这个表达不是很通顺,因此 P 改成孩子更好,即“S 的孩子为 O”。**合理的 P 类型设置,将显著提升零样本效果**。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -164,7 +164,7 @@ schema = {
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -182,7 +182,7 @@ schema = {
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = '情感倾向[正向,负向]'
@@ -194,7 +194,7 @@ schema = '情感倾向[正向,负向]'
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -209,7 +209,7 @@ schema = {
#### 2.5 数据导出
-勾选已标注文本ID,选择导出的文件类型为``JSON``,导出数据:
+勾选已标注文本 ID,选择导出的文件类型为``JSON``,导出数据:

@@ -219,7 +219,7 @@ schema = {
#### 2.6 数据转换
-将导出的文件重命名为``label_studio.json``后,放入``./data``目录下。通过[label_studio.py](./label_studio.py)脚本可转为UIE的数据格式。
+将导出的文件重命名为``label_studio.json``后,放入``./data``目录下。通过[label_studio.py](./label_studio.py)脚本可转为 UIE 的数据格式。
- 抽取式任务
@@ -233,7 +233,7 @@ python label_studio.py \
- 句子级分类任务
-在数据转换阶段,我们会自动构造用于模型训练的prompt信息。例如句子级情感分类中,prompt为``情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行配置。
+在数据转换阶段,我们会自动构造用于模型训练的 prompt 信息。例如句子级情感分类中,prompt 为``情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行配置。
```shell
python label_studio.py \
@@ -247,7 +247,7 @@ python label_studio.py \
- 实体/评价维度分类任务
-在数据转换阶段,我们会自动构造用于模型训练的prompt信息。例如评价维度情感分类中,prompt为``XXX的情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
+在数据转换阶段,我们会自动构造用于模型训练的 prompt 信息。例如评价维度情感分类中,prompt 为``XXX 的情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
```shell
python label_studio.py \
@@ -264,23 +264,23 @@ python label_studio.py \
#### 2.7 更多配置
-- ``label_studio_file``: 从label studio导出的数据标注文件。
+- ``label_studio_file``: 从 label studio 导出的数据标注文件。
- ``save_dir``: 训练数据的保存目录,默认存储在``data``目录下。
- ``negative_ratio``: 最大负例比例,该参数只对抽取类型任务有效,适当构造负例可提升模型效果。负例数量和实际的标签数量有关,最大负例数量 = negative_ratio * 正例数量。该参数只对训练集有效,默认为5。为了保证评估指标的准确性,验证集和测试集默认构造全负例。
- ``splits``: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.1, 0.1]表示按照``8:1:1``的比例将数据划分为训练集、验证集和测试集。
- ``task_type``: 选择任务类型,可选有抽取和分类两种类型的任务。
- ``options``: 指定分类任务的类别标签,该参数只对分类类型任务有效。默认为["正向", "负向"]。
-- ``prompt_prefix``: 声明分类任务的prompt前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
-- ``is_shuffle``: 是否对数据集进行随机打散,默认为True。
+- ``prompt_prefix``: 声明分类任务的 prompt 前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
+- ``is_shuffle``: 是否对数据集进行随机打散,默认为 True。
- ``seed``: 随机种子,默认为1000.
-- ``schema_lang``:选择schema的语言,将会应该训练数据prompt的构造方式,可选有`ch`和`en`。默认为`ch`。
+- ``schema_lang``:选择 schema 的语言,将会应该训练数据 prompt 的构造方式,可选有`ch`和`en`。默认为`ch`。
- ``separator``: 实体类别/评价维度与分类标签的分隔符,该参数只对实体/评价维度分类任务有效。默认为"##"。
备注:
- 默认情况下 [label_studio.py](./label_studio.py) 脚本会按照比例将数据划分为 train/dev/test 数据集
- 每次执行 [label_studio.py](./label_studio.py) 脚本,将会覆盖已有的同名数据文件
- 在模型训练阶段我们推荐构造一些负例以提升模型效果,在数据转换阶段我们内置了这一功能。可通过`negative_ratio`控制自动构造的负样本比例;负样本数量 = negative_ratio * 正样本数量。
-- 对于从label_studio导出的文件,默认文件中的每条数据都是经过人工正确标注的。
+- 对于从 label_studio 导出的文件,默认文件中的每条数据都是经过人工正确标注的。
## References
diff --git a/legacy/applications/information_extraction/label_studio_text_en.md b/slm/applications/information_extraction/label_studio_text_en.md
similarity index 100%
rename from legacy/applications/information_extraction/label_studio_text_en.md
rename to slm/applications/information_extraction/label_studio_text_en.md
diff --git a/legacy/applications/information_extraction/taskflow_doc.md b/slm/applications/information_extraction/taskflow_doc.md
similarity index 77%
rename from legacy/applications/information_extraction/taskflow_doc.md
rename to slm/applications/information_extraction/taskflow_doc.md
index ef9694d916db..491b304a9a9c 100644
--- a/legacy/applications/information_extraction/taskflow_doc.md
+++ b/slm/applications/information_extraction/taskflow_doc.md
@@ -1,4 +1,4 @@
-# UIE Taskflow使用指南
+# UIE Taskflow 使用指南
**目录**
- [1. 功能简介](#1)
@@ -21,13 +21,13 @@
## 2. 文档信息抽取
-本章节主要介绍Taskflow的文档抽取功能,以下示例图片[下载链接](https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/cases.zip)。
+本章节主要介绍 Taskflow 的文档抽取功能,以下示例图片[下载链接](https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/cases.zip)。
#### 2.1 实体抽取
-实体抽取,又称命名实体识别(Named Entity Recognition,简称NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
+实体抽取,又称命名实体识别(Named Entity Recognition,简称 NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
- 报关单
@@ -117,7 +117,7 @@
#### 2.2 关系抽取
-关系抽取(Relation Extraction,简称RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
+关系抽取(Relation Extraction,简称 RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
- 表格
@@ -139,7 +139,7 @@
- 实体、关系多任务抽取
-对文档进行实体+关系抽取,schema构造如下:
+对文档进行实体+关系抽取,schema 构造如下:
```text
schema = [
@@ -176,7 +176,7 @@ schema = [
- 输入格式
-文档抽取UIE-X支持图片路径、http图片链接、base64的输入形式,支持图片和PDF两种文档格式。文本抽取可以通过`text`指定输入文本。
+文档抽取 UIE-X 支持图片路径、http 图片链接、base64的输入形式,支持图片和 PDF 两种文档格式。文本抽取可以通过`text`指定输入文本。
```python
[
@@ -186,9 +186,9 @@ schema = [
]
```
-**NOTE**: 多页PDF输入目前只抽取第一页的结果,UIE-X比较适合单证文档(如票据、单据等)的信息提取,目前还不适合过长或多页的文档。
+**NOTE**: 多页 PDF 输入目前只抽取第一页的结果,UIE-X 比较适合单证文档(如票据、单据等)的信息提取,目前还不适合过长或多页的文档。
-- 使用自己的layout / OCR作为输入
+- 使用自己的 layout / OCR 作为输入
```python
layout = [
@@ -204,9 +204,9 @@ ie({"doc": doc_path, 'layout': layout})
#### 2.5 使用技巧
-- 使用PP-Structure版面分析功能
+- 使用 PP-Structure 版面分析功能
-OCR中识别出来的文字会按照左上到右下进行排序,对于分栏、表格内有多行文本等情况我们推荐使用版面分析功能``layout_analysis=True``以优化文字排序并增强抽取效果。以下例子仅举例版面分析功能的使用场景,实际场景一般需要标注微调。
+OCR 中识别出来的文字会按照左上到右下进行排序,对于分栏、表格内有多行文本等情况我们推荐使用版面分析功能``layout_analysis=True``以优化文字排序并增强抽取效果。以下例子仅举例版面分析功能的使用场景,实际场景一般需要标注微调。

@@ -235,7 +235,7 @@ OCR中识别出来的文字会按照左上到右下进行排序,对于分栏
#### 2.6 结果可视化
-- OCR识别结果可视化:
+- OCR 识别结果可视化:
```python
>>> from paddlenlp.utils.doc_parser import DocParser
@@ -296,13 +296,13 @@ OCR中识别出来的文字会按照左上到右下进行排序,对于分栏
```
* `schema`:定义任务抽取目标,可参考开箱即用中不同任务的调用示例进行配置。
-* `schema_lang`:设置schema的语言,默认为`ch`, 可选有`ch`和`en`。因为中英schema的构造有所不同,因此需要指定schema的语言。
-* `ocr_lang`:选择PaddleOCR的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
+* `schema_lang`:设置 schema 的语言,默认为`ch`, 可选有`ch`和`en`。因为中英 schema 的构造有所不同,因此需要指定 schema 的语言。
+* `ocr_lang`:选择 PaddleOCR 的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为16。
* `model`:选择任务使用的模型,默认为`uie-base`,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`, `uie-nano`和`uie-medical-base`, `uie-base-en`,`uie-x-base`。
-* `layout_analysis`:是否使用PP-Structure对文档进行布局分析以优化布局信息的排序,默认为False。
-* `position_prob`:模型对于span的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span的最终概率输出为起始位置概率和终止位置概率的乘积。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持GPU和NPU硬件环境。如果选择`fp16`,在GPU硬件环境下,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `layout_analysis`:是否使用 PP-Structure 对文档进行布局分析以优化布局信息的排序,默认为 False。
+* `position_prob`:模型对于 span 的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span 的最终概率输出为起始位置概率和终止位置概率的乘积。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持 GPU 和 NPU 硬件环境。如果选择`fp16`,在 GPU 硬件环境下,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
## References
- **[PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)**
diff --git a/legacy/applications/information_extraction/taskflow_doc_en.md b/slm/applications/information_extraction/taskflow_doc_en.md
similarity index 100%
rename from legacy/applications/information_extraction/taskflow_doc_en.md
rename to slm/applications/information_extraction/taskflow_doc_en.md
diff --git a/legacy/applications/information_extraction/taskflow_text.md b/slm/applications/information_extraction/taskflow_text.md
similarity index 88%
rename from legacy/applications/information_extraction/taskflow_text.md
rename to slm/applications/information_extraction/taskflow_text.md
index aa9da3b388e4..612c38e35357 100644
--- a/legacy/applications/information_extraction/taskflow_text.md
+++ b/slm/applications/information_extraction/taskflow_text.md
@@ -1,4 +1,4 @@
-# 文本抽取任务UIE Taskflow使用指南
+# 文本抽取任务 UIE Taskflow 使用指南
**目录**
- [1. 功能简介](#1)
@@ -23,7 +23,7 @@
## 2. 应用示例
-UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开箱即用的行业示例:
+UIE 不限定行业领域和抽取目标,以下是一些通过 Taskflow 实现开箱即用的行业示例:
- 医疗场景-专病结构化
@@ -53,9 +53,9 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
#### 3.1 实体抽取
- 实体抽取,又称命名实体识别(Named Entity Recognition,简称NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
+ 实体抽取,又称命名实体识别(Named Entity Recognition,简称 NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
- - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema构造如下:
+ - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema 构造如下:
```text
['时间', '选手', '赛事名称']
@@ -84,7 +84,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
'text': '谷爱凌'}]}]
```
- - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema构造如下:
+ - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema 构造如下:
```text
['肿瘤的大小', '肿瘤的个数', '肝癌级别', '脉管内癌栓分级']
@@ -116,7 +116,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
'text': 'M0级'}]}]
```
- - 例如抽取的目标实体类型是"person"和"organization",schema构造如下:
+ - 例如抽取的目标实体类型是"person"和"organization",schema 构造如下:
```text
['person', 'organization']
@@ -144,9 +144,9 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
#### 3.2 关系抽取
- 关系抽取(Relation Extraction,简称RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
+ 关系抽取(Relation Extraction,简称 RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
- - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema构造如下:
+ - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema 构造如下:
```text
{
@@ -194,7 +194,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
'text': '2022语言与智能技术竞赛'}]}]
```
- - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema构造如下:
+ - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema 构造如下:
```text
{
@@ -229,9 +229,9 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
#### 3.3 事件抽取
- 事件抽取 (Event Extraction, 简称EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
+ 事件抽取 (Event Extraction, 简称 EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
- - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema构造如下:
+ - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema 构造如下:
```text
{
@@ -244,7 +244,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
}
```
- 触发词的格式统一为`触发词`或``XX触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
+ 触发词的格式统一为`触发词`或``XX 触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
调用示例:
@@ -263,7 +263,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
评论观点抽取,是指抽取文本中包含的评价维度、观点词。
- - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema构造如下:
+ - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema 构造如下:
```text
{
@@ -302,7 +302,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
'text': '店面'}]}]
```
- - 英文模型schema构造如下:
+ - 英文模型 schema 构造如下:
```text
{
@@ -335,7 +335,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
#### 3.5 情感分类
- - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema构造如下:
+ - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema 构造如下:
```text
'情感倾向[正向,负向]'
@@ -350,7 +350,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
[{'情感倾向[正向,负向]': [{'text': '正向', 'probability': 0.9988661643929895}]}]
```
- 英文模型schema构造如下:
+ 英文模型 schema 构造如下:
```text
'Sentiment classification [negative, positive]'
@@ -369,7 +369,7 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
#### 3.6 跨任务抽取
- - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema可按照如下方式进行构造:
+ - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema 可按照如下方式进行构造:
```text
[
@@ -493,8 +493,8 @@ UIE不限定行业领域和抽取目标,以下是一些通过Taskflow实现开
```
* `schema`:定义任务抽取目标,可参考开箱即用中不同任务的调用示例进行配置。
-* `schema_lang`:设置schema的语言,默认为`ch`, 可选有`ch`和`en`。因为中英schema的构造有所不同,因此需要指定schema的语言。该参数只对`uie-x-base`,`uie-m-base`和`uie-m-large`模型有效。
+* `schema_lang`:设置 schema 的语言,默认为`ch`, 可选有`ch`和`en`。因为中英 schema 的构造有所不同,因此需要指定 schema 的语言。该参数只对`uie-x-base`,`uie-m-base`和`uie-m-large`模型有效。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为16。
* `model`:选择任务使用的模型,默认为`uie-base`,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`, `uie-nano`和`uie-medical-base`, `uie-base-en`,`uie-x-base`。
-* `position_prob`:模型对于span的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span的最终概率输出为起始位置概率和终止位置概率的乘积。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持GPU和NPU硬件环境。如果选择`fp16`,在GPU硬件环境下,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `position_prob`:模型对于 span 的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span 的最终概率输出为起始位置概率和终止位置概率的乘积。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持 GPU 和 NPU 硬件环境。如果选择`fp16`,在 GPU 硬件环境下,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
diff --git a/legacy/applications/information_extraction/taskflow_text_en.md b/slm/applications/information_extraction/taskflow_text_en.md
similarity index 100%
rename from legacy/applications/information_extraction/taskflow_text_en.md
rename to slm/applications/information_extraction/taskflow_text_en.md
diff --git a/legacy/applications/information_extraction/text/README.md b/slm/applications/information_extraction/text/README.md
similarity index 79%
rename from legacy/applications/information_extraction/text/README.md
rename to slm/applications/information_extraction/text/README.md
index 84cd77fd288c..32d3bc6f4c26 100644
--- a/legacy/applications/information_extraction/text/README.md
+++ b/slm/applications/information_extraction/text/README.md
@@ -17,22 +17,22 @@
## 1. 文本信息抽取应用
-本项目提供基于UIE微调的纯文本抽取端到端应用方案,打通**数据标注-模型训练-模型调优-预测部署全流程**,可快速实现文档信息抽取产品落地。
+本项目提供基于 UIE 微调的纯文本抽取端到端应用方案,打通**数据标注-模型训练-模型调优-预测部署全流程**,可快速实现文档信息抽取产品落地。
-信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP信息抽取应用UIE统一建模的思想,提供了文档信息抽取产业级应用方案,支持**文档/图片/表格和纯文本场景下实体、关系、事件、观点等不同任务信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务POC阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
+信息抽取通俗地说就是从给定的文本/图片等输入数据中抽取出结构化信息的过程。在信息抽取的落地过程中通常面临领域多变、任务多样、数据稀缺等许多挑战。针对信息抽取领域的难点和痛点,PaddleNLP 信息抽取应用 UIE 统一建模的思想,提供了文档信息抽取产业级应用方案,支持**文档/图片/表格和纯文本场景下实体、关系、事件、观点等不同任务信息抽取**。该应用**不限定行业领域和抽取目标**,可实现从产品原型研发、业务 POC 阶段到业务落地、迭代阶段的无缝衔接,助力开发者实现特定领域抽取场景的快速适配与落地。
**文本信息抽取应用亮点:**
- **覆盖场景全面🎓:** 覆盖文本信息抽取各类主流任务,支持多语言,满足开发者多样信息抽取落地需求。
-- **效果领先🏃:** 以在纯文本具有突出效果的UIE系列模型作为训练基座,提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **简单易用⚡:** 通过Taskflow实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
+- **效果领先🏃:** 以在纯文本具有突出效果的 UIE 系列模型作为训练基座,提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **简单易用⚡:** 通过 Taskflow 实现三行代码可实现无标注数据的情况下进行快速调用,一行命令即可开启信息抽取训练,轻松完成部署上线,降低信息抽取技术落地门槛。
- **高效调优✊:** 开发者无需机器学习背景知识,即可轻松上手数据标注及模型训练流程。
## 2. 快速开始
-对于简单的抽取目标可以直接使用```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用定制功能(标注少量数据进行模型微调)以进一步提升效果。
+对于简单的抽取目标可以直接使用 ```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用定制功能(标注少量数据进行模型微调)以进一步提升效果。
@@ -50,9 +50,9 @@
### 2.2 数据标注
-我们推荐使用 [Label Studio](https://labelstud.io/) 进行文本信息抽取数据标注,本项目打通了从数据标注到训练的通道,也即Label Studio导出数据可以通过 [label_studio.py](../label_studio.py) 脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考 [Label Studio数据标注指南](../label_studio_text.md)。
+我们推荐使用 [Label Studio](https://labelstud.io/) 进行文本信息抽取数据标注,本项目打通了从数据标注到训练的通道,也即 Label Studio 导出数据可以通过 [label_studio.py](../label_studio.py) 脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考 [Label Studio 数据标注指南](../label_studio_text.md)。
-这里我们提供预先标注好的`军事关系抽取数据集`的文件,可以运行下面的命令行下载数据集,我们将展示如何使用数据转化脚本生成训练/验证/测试集文件,并使用UIE模型进行微调。
+这里我们提供预先标注好的`军事关系抽取数据集`的文件,可以运行下面的命令行下载数据集,我们将展示如何使用数据转化脚本生成训练/验证/测试集文件,并使用 UIE 模型进行微调。
下载军事关系抽取数据集:
@@ -73,7 +73,7 @@ python ../label_studio.py \
--task_type ext
```
-更多不同类型任务(含实体抽取、关系抽取、文档分类等)的标注规则及参数说明,请参考[Label Studio数据标注指南](../label_studio_text.md)。
+更多不同类型任务(含实体抽取、关系抽取、文档分类等)的标注规则及参数说明,请参考[Label Studio 数据标注指南](../label_studio_text.md)。
@@ -113,7 +113,7 @@ python finetune.py \
--save_total_limit 1
```
-如果在GPU环境中使用,可以指定gpus参数进行多卡训练:
+如果在 GPU 环境中使用,可以指定 gpus 参数进行多卡训练:
```shell
python -u -m paddle.distributed.launch --gpus "0,1" finetune.py \
@@ -155,20 +155,20 @@ python -u -m paddle.distributed.launch --gpus "0,1" finetune.py \
* `train_path`:训练集路径;默认为 `None` 。
* `dev_path`:开发集路径;默认为 `None` 。
* `max_seq_len`:文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
-* `per_device_train_batch_size`:用于训练的每个 GPU 核心/CPU 的batch大小,默认为8。
-* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/CPU 的batch大小,默认为8。
+* `per_device_train_batch_size`:用于训练的每个 GPU 核心/CPU 的 batch 大小,默认为8。
+* `per_device_eval_batch_size`:用于评估的每个 GPU 核心/CPU 的 batch 大小,默认为8。
* `num_train_epochs`: 训练轮次,使用早停法时可以选择 100;默认为10。
* `learning_rate`:训练最大学习率,UIE-X 推荐设置为 1e-5;默认值为3e-5。
-* `label_names`:训练数据标签label的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为None。
+* `label_names`:训练数据标签 label 的名称,UIE-X 设置为'start_positions' 'end_positions';默认值为 None。
* `do_train`:是否进行微调训练,设置该参数表示进行微调训练,默认不设置。
* `do_eval`:是否进行评估,设置该参数表示进行评估,默认不设置。
* `do_export`:是否进行导出,设置该参数表示进行静态图导出,默认不设置。
-* `export_model_dir`:静态图导出地址,默认为None。
+* `export_model_dir`:静态图导出地址,默认为 None。
* `overwrite_output_dir`: 如果 `True`,覆盖输出目录的内容。如果 `output_dir` 指向检查点目录,则使用它继续训练。
-* `disable_tqdm`: 是否使用tqdm进度条。
-* `metric_for_best_model`:最优模型指标,UIE-X 推荐设置为 `eval_f1`,默认为None。
-* `load_best_model_at_end`:训练结束后是否加载最优模型,通常与`metric_for_best_model`配合使用,默认为False。
-* `save_total_limit`:如果设置次参数,将限制checkpoint的总数。删除旧的checkpoints `输出目录`,默认为None。
+* `disable_tqdm`: 是否使用 tqdm 进度条。
+* `metric_for_best_model`:最优模型指标,UIE-X 推荐设置为 `eval_f1`,默认为 None。
+* `load_best_model_at_end`:训练结束后是否加载最优模型,通常与`metric_for_best_model`配合使用,默认为 False。
+* `save_total_limit`:如果设置次参数,将限制 checkpoint 的总数。删除旧的 checkpoints `输出目录`,默认为 None。
@@ -232,9 +232,9 @@ python evaluate.py \
- `test_path`: 进行评估的测试集文件。
- `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
- `max_seq_len`: 文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
-- `debug`: 是否开启debug模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
+- `debug`: 是否开启 debug 模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
- `multilingual`: 是否是跨语言模型,默认关闭。
-- `schema_lang`: 选择schema的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
+- `schema_lang`: 选择 schema 的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
@@ -286,4 +286,4 @@ python evaluate.py \
### 2.7 封闭域蒸馏
-在一些工业应用场景中对性能的要求较高,模型若不能有效压缩则无法实际应用。因此,我们基于数据蒸馏技术构建了UIE Slim数据蒸馏系统。其原理是通过数据作为桥梁,将UIE模型的知识迁移到封闭域信息抽取小模型,以达到精度损失较小的情况下却能达到大幅度预测速度提升的效果。详细介绍请参考[UIE Slim 数据蒸馏](./data_distill/README.md)
+在一些工业应用场景中对性能的要求较高,模型若不能有效压缩则无法实际应用。因此,我们基于数据蒸馏技术构建了 UIE Slim 数据蒸馏系统。其原理是通过数据作为桥梁,将 UIE 模型的知识迁移到封闭域信息抽取小模型,以达到精度损失较小的情况下却能达到大幅度预测速度提升的效果。详细介绍请参考[UIE Slim 数据蒸馏](./data_distill/README.md)
diff --git a/legacy/applications/information_extraction/text/README_en.md b/slm/applications/information_extraction/text/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/text/README_en.md
rename to slm/applications/information_extraction/text/README_en.md
diff --git a/legacy/applications/information_extraction/text/data_distill/README.md b/slm/applications/information_extraction/text/data_distill/README.md
similarity index 73%
rename from legacy/applications/information_extraction/text/data_distill/README.md
rename to slm/applications/information_extraction/text/data_distill/README.md
index 6886f591e10d..863c80b61786 100644
--- a/legacy/applications/information_extraction/text/data_distill/README.md
+++ b/slm/applications/information_extraction/text/data_distill/README.md
@@ -1,22 +1,22 @@
# UIE Slim 数据蒸馏
-在UIE强大的抽取能力背后,同样需要较大的算力支持计算。在一些工业应用场景中对性能的要求较高,若不能有效压缩则无法实际应用。因此,我们基于数据蒸馏技术构建了UIE Slim数据蒸馏系统。其原理是通过数据作为桥梁,将UIE模型的知识迁移到封闭域信息抽取小模型,以达到精度损失较小的情况下却能达到大幅度预测速度提升的效果。
+在 UIE 强大的抽取能力背后,同样需要较大的算力支持计算。在一些工业应用场景中对性能的要求较高,若不能有效压缩则无法实际应用。因此,我们基于数据蒸馏技术构建了 UIE Slim 数据蒸馏系统。其原理是通过数据作为桥梁,将 UIE 模型的知识迁移到封闭域信息抽取小模型,以达到精度损失较小的情况下却能达到大幅度预测速度提升的效果。
-#### UIE数据蒸馏三步
+#### UIE 数据蒸馏三步
-- **Step 1**: 使用UIE模型对标注数据进行finetune,得到Teacher Model。
+- **Step 1**: 使用 UIE 模型对标注数据进行 finetune,得到 Teacher Model。
-- **Step 2**: 用户提供大规模无标注数据,需与标注数据同源。使用Taskflow UIE对无监督数据进行预测。
+- **Step 2**: 用户提供大规模无标注数据,需与标注数据同源。使用 Taskflow UIE 对无监督数据进行预测。
-- **Step 3**: 使用标注数据以及步骤2得到的合成数据训练出封闭域Student Model。
+- **Step 3**: 使用标注数据以及步骤2得到的合成数据训练出封闭域 Student Model。
## UIE Finetune
-参考[UIE关系抽取微调](../README.md)完成模型微调,得到``../checkpoint/model_best``。
+参考[UIE 关系抽取微调](../README.md)完成模型微调,得到``../checkpoint/model_best``。
## 离线蒸馏
-#### 通过训练好的UIE定制模型预测无监督数据的标签
+#### 通过训练好的 UIE 定制模型预测无监督数据的标签
```shell
python data_distill.py \
@@ -27,12 +27,12 @@ python data_distill.py \
--model_path ../checkpoint/model_best
```
-**NOTE**:schema需要根据标注数据在`data_distill.py`中进行配置,且schema需要包含标注数据中的所有标签类型。
+**NOTE**:schema 需要根据标注数据在`data_distill.py`中进行配置,且 schema 需要包含标注数据中的所有标签类型。
可配置参数说明:
- `data_path`: 标注数据(`doccano_ext.json`)及无监督文本(`unlabeled_data.txt`)路径。
-- `model_path`: 训练好的UIE定制模型路径。
+- `model_path`: 训练好的 UIE 定制模型路径。
- `save_dir`: 学生模型训练数据保存路径。
- `synthetic_ratio`: 控制合成数据的比例。最大合成数据数量=synthetic_ratio*标注数据数量。
- `platform`: 标注数据的所使用的标注平台,可选有`doccano`,`label_studio`,默认为`label_studio`。
@@ -41,7 +41,7 @@ python data_distill.py \
#### 老师模型评估
-UIE微调阶段针对UIE训练格式数据评估模型效果(该评估方式非端到端评估,非关系抽取或事件抽取的标准评估方式),可通过以下评估脚本进行端到端评估。
+UIE 微调阶段针对 UIE 训练格式数据评估模型效果(该评估方式非端到端评估,非关系抽取或事件抽取的标准评估方式),可通过以下评估脚本进行端到端评估。
```shell
python evaluate_teacher.py \
@@ -53,7 +53,7 @@ python evaluate_teacher.py \
可配置参数说明:
-- `model_path`: 训练好的UIE定制模型路径。
+- `model_path`: 训练好的 UIE 定制模型路径。
- `test_path`: 测试数据集路径。
- `label_maps_path`: 学生模型标签字典。
- `batch_size`: 批处理大小,默认为8。
@@ -81,16 +81,16 @@ python train.py \
- `learning_rate`: 学习率,默认为3e-5。
- `save_dir`: 模型存储路径,默认为`./checkpoint`。
- `max_seq_len`: 最大文本长度,默认为256。
-- `weight_decay`: 表示AdamW优化器中使用的 weight_decay 的系数。
-- `warmup_proportion`: 学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.0。
+- `weight_decay`: 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_proportion`: 学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.0。
- `num_epochs`: 训练轮数,默认为100。
- `seed`: 随机种子,默认为1000。
- `encoder`: 选择学生模型的模型底座,默认为`ernie-3.0-mini-zh`。
- `task_type`: 选择任务类型,可选有`entity_extraction`,`relation_extraction`,`event_extraction`和`opinion_extraction`。因为是封闭域信息抽取,需指定任务类型。
-- `logging_steps`: 日志打印的间隔steps数,默认10。
-- `eval_steps`: evaluate的间隔steps数,默认200。
-- `device`: 选用什么设备进行训练,可选cpu或gpu。
-- `init_from_ckpt`: 可选,模型参数路径,热启动模型训练;默认为None。
+- `logging_steps`: 日志打印的间隔 steps 数,默认10。
+- `eval_steps`: evaluate 的间隔 steps 数,默认200。
+- `device`: 选用什么设备进行训练,可选 cpu 或 gpu。
+- `init_from_ckpt`: 可选,模型参数路径,热启动模型训练;默认为 None。
#### 学生模型评估
@@ -105,7 +105,7 @@ python evaluate.py \
可配置参数说明:
-- `model_path`: 训练好的UIE定制模型路径。
+- `model_path`: 训练好的 UIE 定制模型路径。
- `test_path`: 测试数据集路径。
- `label_maps_path`: 学生模型标签字典。
- `batch_size`: 批处理大小,默认为8。
@@ -113,9 +113,9 @@ python evaluate.py \
- `encoder`: 选择学生模型的模型底座,默认为`ernie-3.0-mini-zh`。
- `task_type`: 选择任务类型,可选有`entity_extraction`,`relation_extraction`,`event_extraction`和`opinion_extraction`。因为是封闭域信息抽取的评估,需指定任务类型。
-## Taskflow部署学生模型
+## Taskflow 部署学生模型
-- 通过Taskflow一键部署封闭域信息抽取模型,`task_path`为学生模型路径。
+- 通过 Taskflow 一键部署封闭域信息抽取模型,`task_path`为学生模型路径。
```python
>>> from pprint import pprint
diff --git a/legacy/applications/information_extraction/text/data_distill/README_en.md b/slm/applications/information_extraction/text/data_distill/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/README_en.md
rename to slm/applications/information_extraction/text/data_distill/README_en.md
diff --git a/legacy/applications/information_extraction/text/data_distill/criterion.py b/slm/applications/information_extraction/text/data_distill/criterion.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/criterion.py
rename to slm/applications/information_extraction/text/data_distill/criterion.py
diff --git a/legacy/applications/information_extraction/text/data_distill/data_collator.py b/slm/applications/information_extraction/text/data_distill/data_collator.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/data_collator.py
rename to slm/applications/information_extraction/text/data_distill/data_collator.py
diff --git a/legacy/applications/information_extraction/text/data_distill/data_distill.py b/slm/applications/information_extraction/text/data_distill/data_distill.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/data_distill.py
rename to slm/applications/information_extraction/text/data_distill/data_distill.py
diff --git a/legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md b/slm/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md
similarity index 79%
rename from legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md
rename to slm/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md
index 22b478324275..5e7636eb3951 100644
--- a/legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md
+++ b/slm/applications/information_extraction/text/data_distill/deploy/simple_serving/README.md
@@ -1,26 +1,26 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server服务启动](#Server服务启动)
-- [Client请求启动](#Client请求启动)
+- [Server 服务启动](#Server 服务启动)
+- [Client 请求启动](#Client 请求启动)
- [服务化自定义参数](#服务化自定义参数)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本(或者最新的develop版本)
+使用有 SimpleServing 功能的 PaddleNLP 版本(或者最新的 develop 版本)
```shell
pip install paddlenlp >= 2.4.4
```
-## Server服务启动
+## Server 服务启动
```bash
paddlenlp server server:app --workers 1 --host 0.0.0.0 --port 8189
```
-## Client请求启动
+## Client 请求启动
```bash
python client.py
@@ -29,7 +29,7 @@ python client.py
## 服务化自定义参数
### Server 自定义参数
-#### schema替换
+#### schema 替换
```python
# Default schema
schema = {"武器名称": ["产国", "类型", "研发单位"]}
@@ -42,7 +42,7 @@ uie = Taskflow('information_extraction', model='uie-data-distill-gp', task_path=
```
#### 多卡服务化预测
-PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个Taskflow的task即可,下面是示例代码
+PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个 Taskflow 的 task 即可,下面是示例代码
```
uie1 = Taskflow('information_extraction', model='uie-data-distill-gp', task_path='../../checkpoint/model_best/', schema=schema, device_id=0)
uie2 = Taskflow('information_extraction', model='uie-data-distill-gp', task_path='../../checkpoint/model_best/', schema=schema, device_id=1)
diff --git a/legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/README_en.md b/slm/applications/information_extraction/text/data_distill/deploy/simple_serving/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/README_en.md
rename to slm/applications/information_extraction/text/data_distill/deploy/simple_serving/README_en.md
diff --git a/legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/client.py b/slm/applications/information_extraction/text/data_distill/deploy/simple_serving/client.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/client.py
rename to slm/applications/information_extraction/text/data_distill/deploy/simple_serving/client.py
diff --git a/legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/server.py b/slm/applications/information_extraction/text/data_distill/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/deploy/simple_serving/server.py
rename to slm/applications/information_extraction/text/data_distill/deploy/simple_serving/server.py
diff --git a/legacy/applications/information_extraction/text/data_distill/evaluate.py b/slm/applications/information_extraction/text/data_distill/evaluate.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/evaluate.py
rename to slm/applications/information_extraction/text/data_distill/evaluate.py
diff --git a/legacy/applications/information_extraction/text/data_distill/evaluate_teacher.py b/slm/applications/information_extraction/text/data_distill/evaluate_teacher.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/evaluate_teacher.py
rename to slm/applications/information_extraction/text/data_distill/evaluate_teacher.py
diff --git a/legacy/applications/information_extraction/text/data_distill/metric.py b/slm/applications/information_extraction/text/data_distill/metric.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/metric.py
rename to slm/applications/information_extraction/text/data_distill/metric.py
diff --git a/legacy/applications/information_extraction/text/data_distill/train.py b/slm/applications/information_extraction/text/data_distill/train.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/train.py
rename to slm/applications/information_extraction/text/data_distill/train.py
diff --git a/legacy/applications/information_extraction/text/data_distill/utils.py b/slm/applications/information_extraction/text/data_distill/utils.py
similarity index 100%
rename from legacy/applications/information_extraction/text/data_distill/utils.py
rename to slm/applications/information_extraction/text/data_distill/utils.py
diff --git a/legacy/applications/information_extraction/text/deploy/simple_serving/README.md b/slm/applications/information_extraction/text/deploy/simple_serving/README.md
similarity index 78%
rename from legacy/applications/information_extraction/text/deploy/simple_serving/README.md
rename to slm/applications/information_extraction/text/deploy/simple_serving/README.md
index 0624a674e947..c72cfa5c4e31 100644
--- a/legacy/applications/information_extraction/text/deploy/simple_serving/README.md
+++ b/slm/applications/information_extraction/text/deploy/simple_serving/README.md
@@ -1,26 +1,26 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server服务启动](#Server服务启动)
-- [Client请求启动](#Client请求启动)
+- [Server 服务启动](#Server 服务启动)
+- [Client 请求启动](#Client 请求启动)
- [服务化自定义参数](#服务化自定义参数)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本(或者最新的develop版本)
+使用有 SimpleServing 功能的 PaddleNLP 版本(或者最新的 develop 版本)
```shell
pip install paddlenlp >= 2.4.4
```
-## Server服务启动
+## Server 服务启动
```bash
paddlenlp server server:app --workers 1 --host 0.0.0.0 --port 8189
```
-## Client请求启动
+## Client 请求启动
```bash
python client.py
@@ -29,7 +29,7 @@ python client.py
## 服务化自定义参数
### Server 自定义参数
-#### schema替换
+#### schema 替换
```python
# Default schema
schema = {"武器名称": ["产国", "类型", "研发单位"]}
@@ -42,7 +42,7 @@ uie = Taskflow('information_extraction', task_path='../../checkpoint/model_best/
```
#### 多卡服务化预测
-PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个Taskflow的task即可,下面是示例代码
+PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个 Taskflow 的 task 即可,下面是示例代码
```
uie1 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=0)
uie2 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=1)
diff --git a/legacy/applications/information_extraction/text/deploy/simple_serving/README_en.md b/slm/applications/information_extraction/text/deploy/simple_serving/README_en.md
similarity index 100%
rename from legacy/applications/information_extraction/text/deploy/simple_serving/README_en.md
rename to slm/applications/information_extraction/text/deploy/simple_serving/README_en.md
diff --git a/legacy/applications/information_extraction/text/deploy/simple_serving/client.py b/slm/applications/information_extraction/text/deploy/simple_serving/client.py
similarity index 100%
rename from legacy/applications/information_extraction/text/deploy/simple_serving/client.py
rename to slm/applications/information_extraction/text/deploy/simple_serving/client.py
diff --git a/legacy/applications/information_extraction/text/deploy/simple_serving/server.py b/slm/applications/information_extraction/text/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/information_extraction/text/deploy/simple_serving/server.py
rename to slm/applications/information_extraction/text/deploy/simple_serving/server.py
diff --git a/legacy/applications/information_extraction/text/evaluate.py b/slm/applications/information_extraction/text/evaluate.py
similarity index 100%
rename from legacy/applications/information_extraction/text/evaluate.py
rename to slm/applications/information_extraction/text/evaluate.py
diff --git a/legacy/applications/information_extraction/text/finetune.py b/slm/applications/information_extraction/text/finetune.py
similarity index 100%
rename from legacy/applications/information_extraction/text/finetune.py
rename to slm/applications/information_extraction/text/finetune.py
diff --git a/legacy/applications/information_extraction/text/utils.py b/slm/applications/information_extraction/text/utils.py
similarity index 100%
rename from legacy/applications/information_extraction/text/utils.py
rename to slm/applications/information_extraction/text/utils.py
diff --git a/legacy/applications/neural_search/README.md b/slm/applications/neural_search/README.md
similarity index 82%
rename from legacy/applications/neural_search/README.md
rename to slm/applications/neural_search/README.md
index 8786fc2a73d3..b86ac708036a 100644
--- a/legacy/applications/neural_search/README.md
+++ b/slm/applications/neural_search/README.md
@@ -16,7 +16,7 @@
车头如何放置车牌 后牌照怎么装
```
-语义检索系统的关键就在于,采用语义而非关键词方式进行召回,达到更精准、更广泛得召回相似结果的目的。想快速体验搜索的效果,请参考[Pipelines的语义检索实现](../../pipelines/examples/semantic-search)
+语义检索系统的关键就在于,采用语义而非关键词方式进行召回,达到更精准、更广泛得召回相似结果的目的。想快速体验搜索的效果,请参考[Pipelines 的语义检索实现](../../pipelines/examples/semantic-search)

@@ -44,7 +44,7 @@
+ 性能快
+ Paddle Inference 快速抽取向量
+ Milvus 快速查询和高性能建库
- + Paddle Serving服务化部署
+ + Paddle Serving 服务化部署
### 2.2 功能架构
@@ -57,7 +57,7 @@
-以上是nerual_search的系统流程图,其中左侧为召回环节,核心是语义向量抽取模块;右侧是排序环节,核心是排序模型。召回环节需要用户通过自己的语料构建向量索引库,用户发起query了之后,就可以检索出相似度最高的向量,然后找出该向量对应的文本;排序环节主要是对召回的文本进行重新排序。下面我们分别介绍召回中的语义向量抽取模块,以及排序模型。
+以上是 nerual_search 的系统流程图,其中左侧为召回环节,核心是语义向量抽取模块;右侧是排序环节,核心是排序模型。召回环节需要用户通过自己的语料构建向量索引库,用户发起 query 了之后,就可以检索出相似度最高的向量,然后找出该向量对应的文本;排序环节主要是对召回的文本进行重新排序。下面我们分别介绍召回中的语义向量抽取模块,以及排序模型。
#### 2.2.2 召回模块
@@ -82,7 +82,7 @@
召回模型负责从海量(千万级)候选文本中快速(毫秒级)筛选出与 Query 相关性较高的 TopK Doc,排序模型会在召回模型筛选出的 TopK Doc 结果基础之上针对每一个 (Query, Doc) Pair 对进行两两匹配计算相关性,排序效果更精准。
-排序模块有2种选择,第一种基于前沿的预训练模型 ERNIE,训练 Pair-wise 语义匹配模型;第二种是基于RocketQA模型训练的Cross Encoder模形。第一种是Pair-wise的排序算法,基本思路是对样本构建偏序文档对,两两比较,从比较中学习顺序,第二种是Poinet-Wise的算法,只考虑当前Query和每个文档的绝对相关度,并没有考虑其他文档与Query的相关度,但是建模方式比较简单。第一种Pair-wise模型可以说是第二种point-wise模型的改进版本,但对于噪声数据更为敏感,即一个错误的标注会导致多个pair对的错误,用户可以先使用基于Point-wise的Cross Encoder构建一个基础模型,需要进一步优化可以使用Pair-wise的方法优化。
+排序模块有2种选择,第一种基于前沿的预训练模型 ERNIE,训练 Pair-wise 语义匹配模型;第二种是基于 RocketQA 模型训练的 Cross Encoder 模形。第一种是 Pair-wise 的排序算法,基本思路是对样本构建偏序文档对,两两比较,从比较中学习顺序,第二种是 Poinet-Wise 的算法,只考虑当前 Query 和每个文档的绝对相关度,并没有考虑其他文档与 Query 的相关度,但是建模方式比较简单。第一种 Pair-wise 模型可以说是第二种 point-wise 模型的改进版本,但对于噪声数据更为敏感,即一个错误的标注会导致多个 pair 对的错误,用户可以先使用基于 Point-wise 的 Cross Encoder 构建一个基础模型,需要进一步优化可以使用 Pair-wise 的方法优化。
## 3. 文献检索实践
@@ -92,16 +92,16 @@
**语义索引**:由于我们既有无监督数据,又有有监督数据,所以结合 SimCSE 和 In-batch Negatives 方案,并采取 Domain-adaptive Pretraining 优化模型效果。
-首先是利用 ERNIE模型进行 Domain-adaptive Pretraining,在得到的预训练模型基础上,进行无监督的 SimCSE 训练,最后利用 In-batch Negatives 方法进行微调,得到最终的语义索引模型,把建库的文本放入模型中抽取特征向量,然后把抽取后的向量放到语义索引引擎 milvus 中,利用 milvus 就可以很方便得实现召回了。
+首先是利用 ERNIE 模型进行 Domain-adaptive Pretraining,在得到的预训练模型基础上,进行无监督的 SimCSE 训练,最后利用 In-batch Negatives 方法进行微调,得到最终的语义索引模型,把建库的文本放入模型中抽取特征向量,然后把抽取后的向量放到语义索引引擎 milvus 中,利用 milvus 就可以很方便得实现召回了。
-**排序**:使用 ERNIE-Gram 的单塔结构/RocketQA的Cross Encoder对召回后的数据精排序。
+**排序**:使用 ERNIE-Gram 的单塔结构/RocketQA 的 Cross Encoder 对召回后的数据精排序。
#### 3.1.2 评估指标
**模型效果指标**
-* 在语义索引召回阶段使用的指标是 Recall@K,表示的是预测的前topK(从最后的按得分排序的召回列表中返回前K个结果)结果和语料库中真实的前 K 个相关结果的重叠率,衡量的是检索系统的查全率。
+* 在语义索引召回阶段使用的指标是 Recall@K,表示的是预测的前 topK(从最后的按得分排序的召回列表中返回前 K 个结果)结果和语料库中真实的前 K 个相关结果的重叠率,衡量的是检索系统的查全率。
-* 在排序阶段使用的指标为AUC,AUC反映的是分类器对样本的排序能力,如果完全随机得对样本分类,那么AUC应该接近0.5。分类器越可能把真正的正样本排在前面,AUC越大,分类性能越好。
+* 在排序阶段使用的指标为 AUC,AUC 反映的是分类器对样本的排序能力,如果完全随机得对样本分类,那么 AUC 应该接近0.5。分类器越可能把真正的正样本排在前面,AUC 越大,分类性能越好。
**性能指标**
* 基于 Paddle Inference 快速抽取向量
@@ -114,9 +114,9 @@
(1)采用文献的 query, title,keywords,abstract 四个字段内容,构建无标签数据集进行 Domain-adaptive Pretraining;
-(2)采用文献的 query,title,keywords 三个字段内容,构造无标签数据集,进行无监督召回训练SimCSE;
+(2)采用文献的 query,title,keywords 三个字段内容,构造无标签数据集,进行无监督召回训练 SimCSE;
-(3)使用文献的query, title, keywords,构造带正标签的数据集,不包含负标签样本,基于 In-batch Negatives 策略进行训练;
+(3)使用文献的 query, title, keywords,构造带正标签的数据集,不包含负标签样本,基于 In-batch Negatives 策略进行训练;
(4)在排序阶段,使用点击(作为正样本)和展现未点击(作为负样本)数据构造排序阶段的训练集,进行精排训练。
@@ -125,7 +125,7 @@
| 召回 | Domain-adaptive Pretraining | 2kw | - | - | - |
| 召回 | 无监督预训练 - SimCSE | 798w | 20000 | 300000 | 1000 |
| 召回 | 有监督训练 - In-batch Negatives | 3998 | 20000 | 300000 | 1000 |
-| 排序 | 有监督训练 - ERNIE-Gram单塔 Pairwise/RocketQA Cross Encoder | 1973538 | 57811 | - | 1000 |
+| 排序 | 有监督训练 - ERNIE-Gram 单塔 Pairwise/RocketQA Cross Encoder | 1973538 | 57811 | - | 1000 |
我们将除 Domain-adaptive Pretraining 之外的其他数据集全部开源,下载地址:
@@ -154,7 +154,7 @@
### 3.3 数据格式
-1. 对于无监督SimCSE的训练方法,格式参考`train_unsupervised.csv`,即一行条文本即可,无需任何标注。对于召回模型训练需要规定格式的本地数据集,需要准备训练集文件`train.csv`,验证集`dev.csv`,召回集文件`corpus.csv`。
+1. 对于无监督 SimCSE 的训练方法,格式参考`train_unsupervised.csv`,即一行条文本即可,无需任何标注。对于召回模型训练需要规定格式的本地数据集,需要准备训练集文件`train.csv`,验证集`dev.csv`,召回集文件`corpus.csv`。
训练数据集`train.csv`的格式如下:
@@ -195,7 +195,7 @@ query2 \t 用户点击的title2
......
```
-2. 对于排序模型的训练,排序模型目前提供了2种,第一种是Pairwise训练的方式,第二种是RocketQA的排序模型,对于第一种排序模型,需要准备训练集`train_pairwise.csv`,验证集`dev_pairwise.csv`两个文件,除此之外还可以准备测试集文件`test.csv`或者`test_pairwise.csv`。
+2. 对于排序模型的训练,排序模型目前提供了2种,第一种是 Pairwise 训练的方式,第二种是 RocketQA 的排序模型,对于第一种排序模型,需要准备训练集`train_pairwise.csv`,验证集`dev_pairwise.csv`两个文件,除此之外还可以准备测试集文件`test.csv`或者`test_pairwise.csv`。
训练数据集`train_pairwise.csv`的格式如下:
@@ -229,7 +229,7 @@ DAA髋关节置换 DAA全髋关节置换术治疗髋关节病变对患者髋
DAA髋关节置换 护患沟通技巧在急诊输液护理中的应用分析急诊科,输液护理,护理沟通技巧,应用 0
.......
```
-训练数据集`test_pairwise.csv`的格式如下,其中这个score得分是召回算出来的相似度或者距离,仅供参考,可以忽略:
+训练数据集`test_pairwise.csv`的格式如下,其中这个 score 得分是召回算出来的相似度或者距离,仅供参考,可以忽略:
```
query1 \t title1 \t score
@@ -245,7 +245,7 @@ query2 \t title2 \t score
.......
```
-对于第二种基于RocketQA的排序模型。
+对于第二种基于 RocketQA 的排序模型。
训练数据集`train.csv`,验证集`dev_pairwise.csv`的格式如下:
@@ -264,7 +264,7 @@ query2 \t title2 \t label
.......
```
-训练数据集`test.csv`的格式如下,其中这个score得分是召回算出来的相似度或者距离,仅供参考,可以忽略:
+训练数据集`test.csv`的格式如下,其中这个 score 得分是召回算出来的相似度或者距离,仅供参考,可以忽略:
```
query1 \t title1 \t score
@@ -314,26 +314,26 @@ pip install -r requirements.txt
## 4. Neural Search 快速体验实践
-PaddleNLP已经基于ERNIE 1.0训练了一个基线模型,如果想快速搭建Neural Search的完整系统,有两种方法,第一种是请参考下面的实现,包含了服务化的完整流程,另一种是使用Pipelines加载,Pipelines已经支持Neural Search训练的模型的载入,可以使用Pipelines的快速的基于Neural Search模型实现检索系统,详情请参考文档[Pipelines-Neural-Search](../../pipelines/examples/semantic-search/Neural_Search.md)。
+PaddleNLP 已经基于 ERNIE 1.0训练了一个基线模型,如果想快速搭建 Neural Search 的完整系统,有两种方法,第一种是请参考下面的实现,包含了服务化的完整流程,另一种是使用 Pipelines 加载,Pipelines 已经支持 Neural Search 训练的模型的载入,可以使用 Pipelines 的快速的基于 Neural Search 模型实现检索系统,详情请参考文档[Pipelines-Neural-Search](../../pipelines/examples/semantic-search/Neural_Search.md)。
### 4.1. 召回
-- 召回向量抽取服务的搭建请参考:[In-batch Negatives](./recall/in_batch_negative/), 只需要下载基于ERNIE 1.0的预训练模型,导出成Paddle Serving的格式,然后启动Pipeline Server服务即可
+- 召回向量抽取服务的搭建请参考:[In-batch Negatives](./recall/in_batch_negative/), 只需要下载基于 ERNIE 1.0的预训练模型,导出成 Paddle Serving 的格式,然后启动 Pipeline Server 服务即可
-- 召回向量检索服务的搭建请参考:[Milvus](./recall/milvus/), 需要搭建Milvus并且插入检索数据的向量
+- 召回向量检索服务的搭建请参考:[Milvus](./recall/milvus/), 需要搭建 Milvus 并且插入检索数据的向量
-【注意】如果使用Neural Search训练好的模型,由于该模型是基于ERNIE 1.0训练的,所以需要把 `model_name_or_path`指定为`ernie 1.0`,向量抽取结果才能正常。
+【注意】如果使用 Neural Search 训练好的模型,由于该模型是基于 ERNIE 1.0训练的,所以需要把 `model_name_or_path`指定为`ernie 1.0`,向量抽取结果才能正常。
### 4.2. 排序
-排序服务的搭建请参考 [ernie_matching](./ranking/ernie_matching/),只需要下载基于ERNIE Gram的预训练模型,导出成Paddle Serving的格式,最后需要启动 Pipeline Serving服务
+排序服务的搭建请参考 [ernie_matching](./ranking/ernie_matching/),只需要下载基于 ERNIE Gram 的预训练模型,导出成 Paddle Serving 的格式,最后需要启动 Pipeline Serving 服务
-【注意】如果使用Neural Search训练好的模型,由于该模型是基于ERNIE Gram训练的,所以需要把 `model_name_or_path`指定为`ernie-gram-zh`,向量抽取结果才能正常。
+【注意】如果使用 Neural Search 训练好的模型,由于该模型是基于 ERNIE Gram 训练的,所以需要把 `model_name_or_path`指定为`ernie-gram-zh`,向量抽取结果才能正常。
### 4.3. 系统运行
-以上召回和排序模型都经过Paddle Serving服务化以后,就可以直接使用下面的命令运行体验:
+以上召回和排序模型都经过 Paddle Serving 服务化以后,就可以直接使用下面的命令运行体验:
```
python3 run_system.py
@@ -349,7 +349,7 @@ PipelineClient::predict pack_data time:1656991376.3981335
PipelineClient::predict before time:1656991376.3983877
time to cost :0.05616641044616699 seconds
```
-会输出2个文件 `recall_result.csv` 是召回检索的结果,`rank_result.csv` 是排序的结果。csv的示例输出下。
+会输出2个文件 `recall_result.csv` 是召回检索的结果,`rank_result.csv` 是排序的结果。csv 的示例输出下。
召回的结果:
@@ -390,7 +390,7 @@ time to cost :0.05616641044616699 seconds
| 有监督训练 Baseline | 30.077 | 43.513 | 48.633 | 53.448 | 59.632 | 标准 pair-wise 训练范式,通过随机采样产生负样本 |
| 有监督训练 In-batch Negatives | 51.301 | 65.309 | 69.878 | 73.996 | 78.881 | In-batch Negatives 有监督训练 |
| 无监督训练 SimCSE | 42.374 | 57.505 | 62.641 | 67.09 | 72.331 | SimCSE 无监督训练 |
-| 无监督 + 有监督训练 SimCSE + In-batch Negatives | 55.976 | 71.849 | 76.363 | 80.49 | 84.809 | SimCSE无监督训练,In-batch Negatives 有监督训练 |
+| 无监督 + 有监督训练 SimCSE + In-batch Negatives | 55.976 | 71.849 | 76.363 | 80.49 | 84.809 | SimCSE 无监督训练,In-batch Negatives 有监督训练 |
| Domain-adaptive Pretraining + SimCSE | 51.031 | 66.648 | 71.338 | 75.676 | 80.144 | ERNIE 预训练,SimCSE 无监督训练 |
| Domain-adaptive Pretraining + SimCSE + In-batch Negatives | **58.248** | **75.099** | **79.813** | **83.801** | **87.733** | ERNIE 预训练,SimCSE 无监督训训练,In-batch Negatives 有监督训练 |
@@ -421,7 +421,7 @@ time to cost :0.05616641044616699 seconds
中西方语言与文化的差异
```
-下面是召回的部分结果,第一个是召回的title,第二个数字是计算的相似度距离
+下面是召回的部分结果,第一个是召回的 title,第二个数字是计算的相似度距离
```
跨文化中的文化习俗对翻译的影响翻译,跨文化,文化习俗 0.615584135055542
@@ -448,7 +448,7 @@ time to cost :0.05616641044616699 seconds
### 5.2 排序阶段
-排序阶段有2种方案,第一种是[ernie_matching](./ranking/ernie_matching/)使用的模型是 ERNIE-3.0-Medium-zh,用时 20h;第二种是基于RocketQA的排序模型[cross_encoder](./ranking/cross_encoder/),训练用时也是20h左右。
+排序阶段有2种方案,第一种是[ernie_matching](./ranking/ernie_matching/)使用的模型是 ERNIE-3.0-Medium-zh,用时 20h;第二种是基于 RocketQA 的排序模型[cross_encoder](./ranking/cross_encoder/),训练用时也是20h 左右。
排序阶段的效果评估:
diff --git a/legacy/applications/neural_search/img/attu.png b/slm/applications/neural_search/img/attu.png
similarity index 100%
rename from legacy/applications/neural_search/img/attu.png
rename to slm/applications/neural_search/img/attu.png
diff --git a/legacy/applications/neural_search/img/system_pipeline.png b/slm/applications/neural_search/img/system_pipeline.png
similarity index 100%
rename from legacy/applications/neural_search/img/system_pipeline.png
rename to slm/applications/neural_search/img/system_pipeline.png
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/README.md b/slm/applications/neural_search/ranking/cross_encoder/README.md
similarity index 92%
rename from legacy/applications/neural_search/ranking/cross_encoder/README.md
rename to slm/applications/neural_search/ranking/cross_encoder/README.md
index b5dd873b4313..dfdb189960a9 100644
--- a/legacy/applications/neural_search/ranking/cross_encoder/README.md
+++ b/slm/applications/neural_search/ranking/cross_encoder/README.md
@@ -16,7 +16,7 @@
# 背景介绍
-基于RocketQA的CrossEncoder训练的单塔模型,该模型用于搜索的排序阶段,对召回的结果进行重新排序的作用。
+基于 RocketQA 的 CrossEncoder 训练的单塔模型,该模型用于搜索的排序阶段,对召回的结果进行重新排序的作用。
@@ -29,7 +29,7 @@
### 技术方案
-加载基于ERNIE 3.0训练过的RocketQA单塔CrossEncoder模型。
+加载基于 ERNIE 3.0训练过的 RocketQA 单塔 CrossEncoder 模型。
### 评估指标
@@ -165,7 +165,7 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3" --log_dir="logs" train_c
--epochs 3 \
--eval_step 1000
```
-也可以运行bash脚本:
+也可以运行 bash 脚本:
```
sh scripts/train_ce.sh
@@ -181,7 +181,7 @@ python evaluate.py --model_name_or_path rocketqa-base-cross-encoder \
--init_from_ckpt checkpoints/model_80000/model_state.pdparams \
--test_file data/dev_pairwise.csv
```
-也可以运行bash脚本:
+也可以运行 bash 脚本:
```
sh scripts/evaluate_ce.sh
@@ -200,7 +200,7 @@ eval_dev auc:0.829
### 准备预测数据
-待预测数据为 tab 分隔的 tsv 文件,每一行为 1 个文本 Pair,和文本pair的语义索引相似度,(该相似度由召回模型算出,仅供参考),部分示例如下:
+待预测数据为 tab 分隔的 tsv 文件,每一行为 1 个文本 Pair,和文本 pair 的语义索引相似度,(该相似度由召回模型算出,仅供参考),部分示例如下:
```
中西方语言与文化的差异 第二语言习得的一大障碍就是文化差异。 0.5160342454910278
@@ -214,7 +214,7 @@ eval_dev auc:0.829
### 开始预测
-以上述 demo 数据为例,运行如下命令基于我们开源的rocketqa模型开始计算文本 Pair 的语义相似度:
+以上述 demo 数据为例,运行如下命令基于我们开源的 rocketqa 模型开始计算文本 Pair 的语义相似度:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -232,7 +232,7 @@ python predict.py \
```
sh scripts/predict_ce.sh
```
-得到下面的输出,分别是query,title和对应的预测概率:
+得到下面的输出,分别是 query,title 和对应的预测概率:
```
{'text_a': '加强科研项目管理有效促进医学科研工作', 'text_b': '高校\\十四五\\规划中学科建设要处理好五对关系\\十四五\\规划,学科建设,科技创新,人才培养', 'pred_prob': 0.7076062}
@@ -257,7 +257,7 @@ python export_model.py \
--model_name_or_path rocketqa-base-cross-encoder \
--output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
@@ -265,19 +265,19 @@ sh scripts/export_model.sh
### Paddle Inference
-使用PaddleInference
+使用 PaddleInference
```
python deploy/python/predict.py --model_dir ./output \
--input_file data/test.csv \
--model_name_or_path rocketqa-base-cross-encoder
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy/python/deploy.sh
```
-得到下面的输出,输出的是样本的query,title以及对应的概率:
+得到下面的输出,输出的是样本的 query,title 以及对应的概率:
```
Data: {'query': '加强科研项目管理有效促进医学科研工作', 'title': '科研项目管理策略科研项目,项目管理,实施,必要性,策略'} prob: 0.5479063987731934
@@ -286,9 +286,9 @@ Data: {'query': '加强科研项目管理有效促进医学科研工作', 'title
Data: {'query': '加强科研项目管理有效促进医学科研工作', 'title': '普通高校科研管理模式的优化与创新普通高校,科研,科研管理'} prob: 0.465454638004303
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成Serving的格式:
+Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成 Serving 的格式:
```
python export_to_serving.py \
@@ -314,9 +314,9 @@ python export_to_serving.py \
```
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署有两种方式,第一种方式是Pipeline的方式,第二种是C++的方式,下面分别介绍这两种方式的用法:
+Paddle Serving 的部署有两种方式,第一种方式是 Pipeline 的方式,第二种是 C++的方式,下面分别介绍这两种方式的用法:
-#### Pipeline方式
+#### Pipeline 方式
修改对应预训练模型的`Tokenizer`:
@@ -332,7 +332,7 @@ python web_service.py
启动客户端调用 Server。
-首先修改rpc_client.py中需要预测的样本:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [{"query":"加强科研项目管理有效促进医学科研工作","title":"科研项目管理策略科研项目,项目管理,实施,必要性,策略"}]`
@@ -354,7 +354,7 @@ time to cost :0.016808509826660156 seconds
#### C++的方式
-启动C++的Serving:
+启动 C++的 Serving:
```
python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/data.py b/slm/applications/neural_search/ranking/cross_encoder/data.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/data.py
rename to slm/applications/neural_search/ranking/cross_encoder/data.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/http_client.py b/slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/http_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/http_client.py
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/http_client.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/rpc_client.py b/slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/cpp/rpc_client.py
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/rpc_client.py
diff --git a/slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh b/slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
new file mode 100644
index 000000000000..56b05455acf1
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/deploy/cpp/start_server.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/config_nlp.yml b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/python/config_nlp.yml
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/python/config_nlp.yml
diff --git a/slm/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
new file mode 100644
index 000000000000..2099842e760c
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/deploy.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python deploy/python/predict.py --model_dir ./output \
+ --input_file data/test.csv \
+ --model_name_or_path rocketqa-base-cross-encoder
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/predict.py b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/python/predict.py
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/python/predict.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py
index 27c3d6e06976..567fb6e2b3b6 100644
--- a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py
+++ b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/rpc_client.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
-import numpy as np
+import numpy as np
from paddle_serving_server.pipeline import PipelineClient
client = PipelineClient()
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/deploy/python/web_service.py b/slm/applications/neural_search/ranking/cross_encoder/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/deploy/python/web_service.py
rename to slm/applications/neural_search/ranking/cross_encoder/deploy/python/web_service.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/evaluate.py b/slm/applications/neural_search/ranking/cross_encoder/evaluate.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/evaluate.py
rename to slm/applications/neural_search/ranking/cross_encoder/evaluate.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/export_model.py b/slm/applications/neural_search/ranking/cross_encoder/export_model.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/export_model.py
rename to slm/applications/neural_search/ranking/cross_encoder/export_model.py
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/export_to_serving.py b/slm/applications/neural_search/ranking/cross_encoder/export_to_serving.py
similarity index 99%
rename from legacy/applications/neural_search/ranking/cross_encoder/export_to_serving.py
rename to slm/applications/neural_search/ranking/cross_encoder/export_to_serving.py
index e10cd5616a4e..4fdaaaee6e6e 100644
--- a/legacy/applications/neural_search/ranking/cross_encoder/export_to_serving.py
+++ b/slm/applications/neural_search/ranking/cross_encoder/export_to_serving.py
@@ -13,6 +13,7 @@
# limitations under the License.
import argparse
+
import paddle_serving_client.io as serving_io
# yapf: disable
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/predict.py b/slm/applications/neural_search/ranking/cross_encoder/predict.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/predict.py
rename to slm/applications/neural_search/ranking/cross_encoder/predict.py
diff --git a/slm/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh b/slm/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
new file mode 100644
index 000000000000..4c762a7c9ed8
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/scripts/evaluate_ce.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python evaluate.py --model_name_or_path rocketqa-base-cross-encoder \
+ --init_from_ckpt checkpoints/model_80000/model_state.pdparams \
+ --test_file data/dev_pairwise.csv
\ No newline at end of file
diff --git a/slm/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh b/slm/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
new file mode 100644
index 000000000000..1f9dad53ef4c
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/scripts/export_model.sh
@@ -0,0 +1,18 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_model.py \
+ --params_path checkpoints/model_80000/model_state.pdparams \
+ --model_name_or_path rocketqa-base-cross-encoder \
+ --output_path=./output
\ No newline at end of file
diff --git a/slm/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh b/slm/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
new file mode 100644
index 000000000000..a7e29fa741ad
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/scripts/export_to_serving.sh
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_to_serving.py \
+ --dirname "output" \
+ --model_filename "inference.pdmodel" \
+ --params_filename "inference.pdiparams" \
+ --server_path "serving_server" \
+ --client_path "serving_client" \
+ --fetch_alias_names "predict"
diff --git a/slm/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh b/slm/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
new file mode 100644
index 000000000000..15b0fcd45345
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/scripts/predict_ce.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+unset CUDA_VISIBLE_DEVICES
+export CUDA_VISIBLE_DEVICES=0
+python predict.py \
+ --device 'gpu' \
+ --params_path checkpoints/model_80000/model_state.pdparams \
+ --model_name_or_path rocketqa-base-cross-encoder \
+ --test_set data/test.csv \
+ --topk 10 \
+ --batch_size 128 \
+ --max_seq_length 384
\ No newline at end of file
diff --git a/slm/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh b/slm/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
new file mode 100644
index 000000000000..3fcbb3b47d56
--- /dev/null
+++ b/slm/applications/neural_search/ranking/cross_encoder/scripts/train_ce.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+unset CUDA_VISIBLE_DEVICES
+python -u -m paddle.distributed.launch --gpus "0,1,2,3" --log_dir="logs" train_ce.py \
+ --device gpu \
+ --train_set data/train.csv \
+ --test_file data/dev_pairwise.csv \
+ --save_dir ./checkpoints \
+ --model_name_or_path rocketqa-base-cross-encoder \
+ --batch_size 32 \
+ --save_steps 10000 \
+ --max_seq_len 384 \
+ --learning_rate 1E-5 \
+ --weight_decay 0.01 \
+ --warmup_proportion 0.0 \
+ --logging_steps 10 \
+ --seed 1 \
+ --epochs 3 \
+ --eval_step 1000
diff --git a/legacy/applications/neural_search/ranking/cross_encoder/train_ce.py b/slm/applications/neural_search/ranking/cross_encoder/train_ce.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/cross_encoder/train_ce.py
rename to slm/applications/neural_search/ranking/cross_encoder/train_ce.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/README.md b/slm/applications/neural_search/ranking/ernie_matching/README.md
similarity index 91%
rename from legacy/applications/neural_search/ranking/ernie_matching/README.md
rename to slm/applications/neural_search/ranking/ernie_matching/README.md
index 6f912ad680a1..8f5c09c91758 100644
--- a/legacy/applications/neural_search/ranking/ernie_matching/README.md
+++ b/slm/applications/neural_search/ranking/ernie_matching/README.md
@@ -16,7 +16,7 @@
# 背景介绍
-基于ERNIE-Gram训练Pair-wise模型。Pair-wise 匹配模型适合将文本对相似度作为特征之一输入到上层排序模块进行排序的应用场景。
+基于 ERNIE-Gram 训练 Pair-wise 模型。Pair-wise 匹配模型适合将文本对相似度作为特征之一输入到上层排序模块进行排序的应用场景。
@@ -29,7 +29,7 @@
### 技术方案
-双塔模型,使用ERNIE-Gram预训练模型,使用margin_ranking_loss训练模型。
+双塔模型,使用 ERNIE-Gram 预训练模型,使用 margin_ranking_loss 训练模型。
### 评估指标
@@ -147,7 +147,7 @@ ernie_matching/
### 单机单卡训练/单机多卡训练
-这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1,2,3 卡, 基于ERNIE-Gram训练模型,数据量比较大,需要20小时10分钟左右。如果采用单机单卡训练,只需要把`--gpu`参数设置成单卡的卡号即可
+这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1,2,3 卡, 基于 ERNIE-Gram 训练模型,数据量比较大,需要20小时10分钟左右。如果采用单机单卡训练,只需要把`--gpu`参数设置成单卡的卡号即可
训练的命令如下:
@@ -162,7 +162,7 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3" train_pairwise.py \
--train_file data/train_pairwise.csv \
--test_file data/dev_pairwise.csv
```
-也可以运行bash脚本:
+也可以运行 bash 脚本:
```
sh scripts/train_pairwise.sh
@@ -182,7 +182,7 @@ python -u -m paddle.distributed.launch --gpus "0" evaluate.py \
--init_from_ckpt "./checkpoints/model_30000/model_state.pdparams" \
--test_file data/dev_pairwise.csv
```
-也可以运行bash脚本:
+也可以运行 bash 脚本:
```
sh scripts/evaluate.sh
@@ -201,7 +201,7 @@ eval_dev auc:0.796
### 准备预测数据
-待预测数据为 tab 分隔的 tsv 文件,每一行为 1 个文本 Pair,和文本pair的语义索引相似度,部分示例如下:
+待预测数据为 tab 分隔的 tsv 文件,每一行为 1 个文本 Pair,和文本 pair 的语义索引相似度,部分示例如下:
```
中西方语言与文化的差异 第二语言习得的一大障碍就是文化差异。 0.5160342454910278
@@ -215,7 +215,7 @@ eval_dev auc:0.796
### 开始预测
-以上述 demo 数据为例,运行如下命令基于我们开源的 ERNIE-Gram模型开始计算文本 Pair 的语义相似度:
+以上述 demo 数据为例,运行如下命令基于我们开源的 ERNIE-Gram 模型开始计算文本 Pair 的语义相似度:
```shell
python -u -m paddle.distributed.launch --gpus "0" \
@@ -231,7 +231,7 @@ python -u -m paddle.distributed.launch --gpus "0" \
```
sh scripts/predict_pairwise.sh
```
-得到下面的输出,分别是query,title和对应的预测概率:
+得到下面的输出,分别是 query,title 和对应的预测概率:
```
{'query': '中西方语言与文化的差异', 'title': '第二语言习得的一大障碍就是文化差异。', 'pred_prob': 0.85112214}
@@ -254,7 +254,7 @@ python export_model.py --params_path checkpoints/model_30000/model_state.pdparam
--output_path=./output \
--model_name_or_path ernie-3.0-medium-zh
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
@@ -262,19 +262,19 @@ sh scripts/export_model.sh
### Paddle Inference
-使用PaddleInference:
+使用 PaddleInference:
```
python deploy/python/predict.py --model_dir ./output \
--input_file sort/test_pairwise.csv \
--model_name_or_path ernie-3.0-medium-zh
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy/python/deploy.sh
```
-得到下面的输出,输出的是样本的query,title以及对应的概率:
+得到下面的输出,输出的是样本的 query,title 以及对应的概率:
```
Data: {'query': '中西方语言与文化的差异', 'title': '第二语言习得的一大障碍就是文化差异。'} prob: [0.8511221]
@@ -284,9 +284,9 @@ Data: {'query': '中西方语言与文化的差异', 'title': '中英文化差
Data: {'query': '中西方语言与文化的差异', 'title': '浅谈文化与语言习得文化,语言,文化与语言的关系,文化与语言习得意识,跨文化交际'} prob: [0.8944413]
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成Serving的格式:
+Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成 Serving 的格式:
```
python export_to_serving.py \
@@ -312,9 +312,9 @@ python export_to_serving.py \
```
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署有两种方式,第一种方式是Pipeline的方式,第二种是C++的方式,下面分别介绍这两种方式的用法:
+Paddle Serving 的部署有两种方式,第一种方式是 Pipeline 的方式,第二种是 C++的方式,下面分别介绍这两种方式的用法:
-#### Pipeline方式
+#### Pipeline 方式
修改`Tokenizer`
@@ -330,7 +330,7 @@ python web_service.py
启动客户端调用 Server。
-首先修改rpc_client.py中需要预测的样本:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [{"query":"中西方语言与文化的差异","title":"第二语言习得的一大障碍就是文化差异。"}]`
@@ -352,7 +352,7 @@ time to cost :0.012039899826049805 seconds
#### C++的方式
-启动C++的Serving:
+启动 C++的 Serving:
```
python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
@@ -388,7 +388,7 @@ time to cost :0.006819009780883789 seconds
```
可以看到服务端返回了相似度结果
-也可以使用curl方式发送Http请求:
+也可以使用 curl 方式发送 Http 请求:
```
curl -XPOST http://0.0.0.0:8600/GeneralModelService/inference -d ' {"tensor":[{"int64_data":[ 1, 12, 213, 58, 405, 545, 54, 68, 73,
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/data.py b/slm/applications/neural_search/ranking/ernie_matching/data.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/data.py
rename to slm/applications/neural_search/ranking/ernie_matching/data.py
index d7fdd67cc36f..8f1ccbe5d14c 100644
--- a/legacy/applications/neural_search/ranking/ernie_matching/data.py
+++ b/slm/applications/neural_search/ranking/ernie_matching/data.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import paddle
import numpy as np
+import paddle
from paddlenlp.datasets import MapDataset
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/http_client.py b/slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/http_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/http_client.py
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/http_client.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/rpc_client.py b/slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/cpp/rpc_client.py
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/rpc_client.py
diff --git a/slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh b/slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
new file mode 100644
index 000000000000..56b05455acf1
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/deploy/cpp/start_server.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -m paddle_serving_server.serve --model serving_server --port 8600 --gpu_id 0 --thread 5 --ir_optim True
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/config_nlp.yml b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/python/config_nlp.yml
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/python/config_nlp.yml
diff --git a/slm/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
new file mode 100644
index 000000000000..d89cd97bd5fd
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/deploy.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python deploy/python/predict.py --model_dir ./output \
+ --input_file sort/test_pairwise.csv \
+ --model_name_or_path ernie-3.0-medium-zh
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/predict.py b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/python/predict.py
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/python/predict.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py
index 613fe9b9aa3c..704cee13d1d4 100644
--- a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py
+++ b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/rpc_client.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
-import numpy as np
+import numpy as np
from paddle_serving_server.pipeline import PipelineClient
client = PipelineClient()
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/deploy/python/web_service.py b/slm/applications/neural_search/ranking/ernie_matching/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/deploy/python/web_service.py
rename to slm/applications/neural_search/ranking/ernie_matching/deploy/python/web_service.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/evaluate.py b/slm/applications/neural_search/ranking/ernie_matching/evaluate.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/evaluate.py
rename to slm/applications/neural_search/ranking/ernie_matching/evaluate.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/export_model.py b/slm/applications/neural_search/ranking/ernie_matching/export_model.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/export_model.py
rename to slm/applications/neural_search/ranking/ernie_matching/export_model.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/export_to_serving.py b/slm/applications/neural_search/ranking/ernie_matching/export_to_serving.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/export_to_serving.py
rename to slm/applications/neural_search/ranking/ernie_matching/export_to_serving.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/model.py b/slm/applications/neural_search/ranking/ernie_matching/model.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/model.py
rename to slm/applications/neural_search/ranking/ernie_matching/model.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/predict_pairwise.py b/slm/applications/neural_search/ranking/ernie_matching/predict_pairwise.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/predict_pairwise.py
rename to slm/applications/neural_search/ranking/ernie_matching/predict_pairwise.py
diff --git a/slm/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh b/slm/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
new file mode 100644
index 000000000000..c01b91181d1e
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/scripts/evaluate.sh
@@ -0,0 +1,30 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+unset CUDA_VISIBLE_DEVICES
+# gpu
+python -u -m paddle.distributed.launch --gpus "0" evaluate.py \
+ --device gpu \
+ --batch_size 32 \
+ --learning_rate 2E-5 \
+ --init_from_ckpt "./checkpoints/model_30000/model_state.pdparams" \
+ --test_file sort/dev_pairwise.csv
+
+# cpu
+# python evaluate.py \
+# --device cpu \
+# --batch_size 32 \
+# --learning_rate 2E-5 \
+# --init_from_ckpt "./checkpoints/model_30000/model_state.pdparams" \
+# --test_file sort/dev_pairwise.csv
\ No newline at end of file
diff --git a/slm/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh b/slm/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
new file mode 100644
index 000000000000..8dbfb1d3fe42
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/scripts/export_model.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_model.py --params_path checkpoints/model_30000/model_state.pdparams \
+ --output_path=./output \
+ --model_name_or_path ernie-3.0-medium-zh
\ No newline at end of file
diff --git a/slm/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh b/slm/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
new file mode 100644
index 000000000000..7358d1480879
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/scripts/export_to_serving.sh
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_to_serving.py \
+ --dirname "output" \
+ --model_filename "inference.predict.pdmodel" \
+ --params_filename "inference.predict.pdiparams" \
+ --server_path "serving_server" \
+ --client_path "serving_client" \
+ --fetch_alias_names "predict"
diff --git a/slm/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh b/slm/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
new file mode 100644
index 000000000000..6e623d9384d7
--- /dev/null
+++ b/slm/applications/neural_search/ranking/ernie_matching/scripts/predict_pairwise.sh
@@ -0,0 +1,29 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# gpu
+python -u -m paddle.distributed.launch --gpus "0" \
+ predict_pairwise.py \
+ --device gpu \
+ --params_path "./checkpoints/model_30000/model_state.pdparams"\
+ --batch_size 128 \
+ --max_seq_length 64 \
+ --input_file 'sort/test_pairwise.csv'
+# cpu
+# python predict_pairwise.py \
+# --device gpu \
+# --params_path "./checkpoints/model_30000/model_state.pdparams"\
+# --batch_size 128 \
+# --max_seq_length 64 \
+# --input_file 'sort/test_pairwise.csv'
\ No newline at end of file
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh b/slm/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh
similarity index 50%
rename from legacy/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh
rename to slm/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh
index a95169e5b155..da11605c04bd 100644
--- a/legacy/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh
+++ b/slm/applications/neural_search/ranking/ernie_matching/scripts/train_pairwise.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# gpu
python -u -m paddle.distributed.launch --gpus="0,1,2,3" train_pairwise.py \
--device gpu \
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/train_pairwise.py b/slm/applications/neural_search/ranking/ernie_matching/train_pairwise.py
similarity index 100%
rename from legacy/applications/neural_search/ranking/ernie_matching/train_pairwise.py
rename to slm/applications/neural_search/ranking/ernie_matching/train_pairwise.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/README.md b/slm/applications/neural_search/recall/in_batch_negative/README.md
similarity index 85%
rename from legacy/applications/neural_search/recall/in_batch_negative/README.md
rename to slm/applications/neural_search/recall/in_batch_negative/README.md
index aa07d6908480..0802394b7e56 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/README.md
+++ b/slm/applications/neural_search/recall/in_batch_negative/README.md
@@ -19,7 +19,7 @@
语义索引(可通俗理解为向量索引)技术是搜索引擎、推荐系统、广告系统在召回阶段的核心技术之一。语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。语义索引模型的效果直接决定了语义相关的物料能否被成功召回进入系统参与上层排序,从基础层面影响整个系统的效果。
-在召回阶段,最常见的方式是通过双塔模型,学习Document(简写为Doc)的向量表示,对Doc端建立索引,用ANN召回。我们在这种方式的基础上,引入语义索引策略 [In-batch Negatives](https://arxiv.org/abs/2004.04906),以如下Batch size=4的训练数据为例:
+在召回阶段,最常见的方式是通过双塔模型,学习 Document(简写为 Doc)的向量表示,对 Doc 端建立索引,用 ANN 召回。我们在这种方式的基础上,引入语义索引策略 [In-batch Negatives](https://arxiv.org/abs/2004.04906),以如下 Batch size=4的训练数据为例:
```
@@ -29,7 +29,7 @@
侠盗飞车罪恶都市怎样改车 侠盗飞车罪恶都市怎么改车
```
-In-batch Negatives 策略的训练数据为语义相似的 Pair 对,策略核心是在 1 个 Batch 内同时基于 N 个负例进行梯度更新,将Batch 内除自身之外其它所有 Source Text 的相似文本 Target Text 作为负例,例如: 上例中“我手机丢了,我想换个手机” 有 1 个正例(”我想买个新手机,求推荐“),3 个负例(1.求秋色之空全集漫画,2.手机学日语的软件,3.侠盗飞车罪恶都市怎么改车)。
+In-batch Negatives 策略的训练数据为语义相似的 Pair 对,策略核心是在 1 个 Batch 内同时基于 N 个负例进行梯度更新,将 Batch 内除自身之外其它所有 Source Text 的相似文本 Target Text 作为负例,例如: 上例中“我手机丢了,我想换个手机” 有 1 个正例(”我想买个新手机,求推荐“),3 个负例(1.求秋色之空全集漫画,2.手机学日语的软件,3.侠盗飞车罪恶都市怎么改车)。
@@ -42,14 +42,14 @@ In-batch Negatives 策略的训练数据为语义相似的 Pair 对,策略核
### 技术方案
-双塔模型,在召回训练阶段引入In-batch Negatives 策略,使用hnswlib建立索引库,进行召回测试。
+双塔模型,在召回训练阶段引入 In-batch Negatives 策略,使用 hnswlib 建立索引库,进行召回测试。
### 评估指标
采用 Recall@1,Recall@5 ,Recall@10 ,Recall@20 和 Recall@50 指标来评估语义索引模型的召回效果。
-Recall@K召回率是指预测的前topK(top-k是指从最后的按得分排序的召回列表中返回前k个结果)结果中检索出的相关结果数和库中所有的相关结果数的比率,衡量的是检索系统的查全率。
+Recall@K 召回率是指预测的前 topK(top-k 是指从最后的按得分排序的召回列表中返回前 k 个结果)结果中检索出的相关结果数和库中所有的相关结果数的比率,衡量的是检索系统的查全率。
**效果评估**
@@ -63,7 +63,7 @@ Recall@K召回率是指预测的前topK(top-k是指从最后的按得分排序
## 2. 环境依赖
-推荐使用GPU进行训练,在预测阶段使用CPU或者GPU均可。
+推荐使用 GPU 进行训练,在预测阶段使用 CPU 或者 GPU 均可。
**环境依赖**
* python >= 3.6.2
@@ -116,7 +116,7 @@ Recall@K召回率是指预测的前topK(top-k是指从最后的按得分排序
我们基于某文献检索平台数据,构造面向语义索引的训练集、测试集、召回库。
-**训练集** 和 **验证集** 格式一致,训练集4k条,测试集2w条,每行由一对语义相似的文本Pair构成,以tab符分割,第一列是检索query,第二列由相关文献标题(+关键词)构成。样例数据如下:
+**训练集** 和 **验证集** 格式一致,训练集4k 条,测试集2w 条,每行由一对语义相似的文本 Pair 构成,以 tab 符分割,第一列是检索 query,第二列由相关文献标题(+关键词)构成。样例数据如下:
```
宁夏社区图书馆服务体系布局现状分析 宁夏社区图书馆服务体系布局现状分析社区图书馆,社区图书馆服务,社区图书馆服务体系
@@ -125,7 +125,7 @@ Recall@K召回率是指预测的前topK(top-k是指从最后的按得分排序
甘氨酸二肽的合成 甘氨酸二肽合成中缩合剂的选择甘氨酸,缩合剂,二肽
```
-**召回库** 用于模拟业务线上的全量语料库,评估模型的召回效果,计算相应的Recall指标。召回库总共30万条样本,每行由一列构成,文献标题(+关键词),样例数据如下:
+**召回库** 用于模拟业务线上的全量语料库,评估模型的召回效果,计算相应的 Recall 指标。召回库总共30万条样本,每行由一列构成,文献标题(+关键词),样例数据如下:
```
陕西省贫困地区城乡青春期少女生长发育调查青春期,生长发育,贫困地区
五丈岩水库溢洪道加固工程中的新材料应用碳纤维布,粘钢加固技术,超细水泥,灌浆技术
@@ -180,9 +180,9 @@ Recall@K召回率是指预测的前topK(top-k是指从最后的按得分排序
这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1,2,3 卡, 基于 In-batch Negatives 策略训练模型,数据量比较小,几分钟就可以完成。如果采用单机单卡训练,只需要把`--gpus`参数设置成单卡的卡号即可。
-如果使用CPU进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成cpu即可,详细请参考train_batch_neg.sh文件的训练设置
+如果使用 CPU 进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成 cpu 即可,详细请参考 train_batch_neg.sh 文件的训练设置
-然后运行下面的命令使用GPU训练,得到语义索引模型:
+然后运行下面的命令使用 GPU 训练,得到语义索引模型:
```
root_path=inbatch
@@ -212,9 +212,9 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3" \
* `device`: 使用 cpu/gpu 进行训练
* `save_dir`: 模型存储路径
-* `batch_size`: 训练的batch size的大小
+* `batch_size`: 训练的 batch size 的大小
* `learning_rate`: 训练的学习率的大小
-* `epochs`: 训练的epoch数
+* `epochs`: 训练的 epoch 数
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `model_name_or_path`: 预训练模型,用于模型和`Tokenizer`的参数初始化
* `save_steps`: 模型存储 checkpoint 的间隔 steps 个数
@@ -229,11 +229,11 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3" \
* `recall_num`: 对 1 个文本召回的相似文本数量
* `similar_text_pair_file`: 由相似文本对构成的评估集
* `corpus_file`: 召回库数据 corpus_file
-* `use_recompute`: 使用Recompute策略,用于节省显存,是一种以时间换空间的技术
-* `use_gradient_cache`: 使用Gradient Cache策略,用于节省显存,是一种以时间换空间的技术
-* `chunk_numbers`: 使用Gradient Cache策略的参数,表示的是同一个批次的样本分几次执行
+* `use_recompute`: 使用 Recompute 策略,用于节省显存,是一种以时间换空间的技术
+* `use_gradient_cache`: 使用 Gradient Cache 策略,用于节省显存,是一种以时间换空间的技术
+* `chunk_numbers`: 使用 Gradient Cache 策略的参数,表示的是同一个批次的样本分几次执行
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/train.sh
@@ -246,21 +246,21 @@ sh scripts/train.sh
效果评估分为 4 个步骤:
-a. 获取Doc端Embedding
+a. 获取 Doc 端 Embedding
-基于语义索引模型抽取出Doc样本库的文本向量。
+基于语义索引模型抽取出 Doc 样本库的文本向量。
-b. 采用hnswlib对Doc端Embedding建库
+b. 采用 hnswlib 对 Doc 端 Embedding 建库
使用 ANN 引擎构建索引库(这里基于 [hnswlib](https://github.com/nmslib/hnswlib) 进行 ANN 索引)
-c. 获取Query的Embedding并查询相似结果
+c. 获取 Query 的 Embedding 并查询相似结果
基于语义索引模型抽取出评估集 *Source Text* 的文本向量,在第 2 步中建立的索引库中进行 ANN 查询,召回 Top50 最相似的 *Target Text*, 产出评估集中 *Source Text* 的召回结果 `recall_result` 文件。
d. 评估
-基于评估集 `dev.csv` 和召回结果 `recall_result` 计算评估指标 Recall@k,其中k取值1,5,10,20,50。
+基于评估集 `dev.csv` 和召回结果 `recall_result` 计算评估指标 Recall@k,其中 k 取值1,5,10,20,50。
运行如下命令进行 ANN 建库、召回,产出召回结果数据 `recall_result`
@@ -295,13 +295,13 @@ python -u -m paddle.distributed.launch --gpus "3" --log_dir "recall_log/" \
* `similar_text_pair`: 由相似文本对构成的评估集
* `corpus_file`: 召回库数据 corpus_file
-也可以使用下面的bash脚本:
+也可以使用下面的 bash 脚本:
```
sh scripts/run_build_index.sh
```
-run_build_index.sh还包含cpu和gpu运行的脚本,默认是gpu的脚本
+run_build_index.sh 还包含 cpu 和 gpu 运行的脚本,默认是 gpu 的脚本
成功运行结束后,会在 `./recall_result_dir/` 目录下产出 `recall_result.txt` 文件
@@ -313,14 +313,14 @@ run_build_index.sh还包含cpu和gpu运行的脚本,默认是gpu的脚本
```
-接下来,运行如下命令进行效果评估,产出Recall@1, Recall@5, Recall@10, Recall@20 和 Recall@50 指标:
+接下来,运行如下命令进行效果评估,产出 Recall@1, Recall@5, Recall@10, Recall@20 和 Recall@50 指标:
```
python -u evaluate.py \
--similar_text_pair "recall/dev.csv" \
--recall_result_file "./recall_result_dir/recall_result.txt" \
--recall_num 50
```
-也可以使用下面的bash脚本:
+也可以使用下面的 bash 脚本:
```
sh scripts/evaluate.sh
@@ -405,12 +405,12 @@ python -u -m paddle.distributed.launch --gpus "0" \
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `text_pair_file`: 由文本 Pair 构成的待预测数据集
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/predict.sh
```
-predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
+predict.sh 文件包含了 cpu 和 gpu 运行的脚本,默认是 gpu 运行的脚本
产出如下结果
```
@@ -433,17 +433,17 @@ python export_model.py --params_path checkpoints/inbatch/model_40/model_state.pd
--model_name_or_path rocketqa-zh-base-query-encoder \
--output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
```
-### Paddle Inference预测
+### Paddle Inference 预测
预测既可以抽取向量也可以计算两个文本的相似度。
-修改id2corpus的样本:
+修改 id2corpus 的样本:
```
# 抽取向量
@@ -454,14 +454,14 @@ corpus_list=[['中西方语言与文化的差异','中西方文化差异以及
```
-然后使用PaddleInference
+然后使用 PaddleInference
```
python deploy/python/predict.py \
--model_dir=./output \
--model_name_or_path rocketqa-zh-base-query-encoder
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy.sh
@@ -478,9 +478,9 @@ sh deploy.sh
[0.959269642829895, 0.04725276678800583]
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成Serving的格式:
+Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成 Serving 的格式:
```
python export_to_serving.py \
@@ -507,9 +507,9 @@ python export_to_serving.py \
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署有两种方式,第一种方式是Pipeline的方式,第二种是C++的方式,下面分别介绍这两种方式的用法:
+Paddle Serving 的部署有两种方式,第一种方式是 Pipeline 的方式,第二种是 C++的方式,下面分别介绍这两种方式的用法:
-#### Pipeline方式
+#### Pipeline 方式
修改模型需要用到的`Tokenizer`
@@ -526,7 +526,7 @@ python web_service.py
启动客户端调用 Server。
-首先修改rpc_client.py中需要预测的样本:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [
@@ -556,7 +556,7 @@ PipelineClient::predict before time:1641450851.375738
#### C++的方式
-启动C++的Serving:
+启动 C++的 Serving:
```
python -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_id 2 --thread 5 --ir_optim True --use_trt --precision FP16
@@ -607,7 +607,7 @@ outputs {
## FAQ
-#### 如何基于无监督SimCSE训练出的模型参数作为参数初始化继续做有监督 In-Batch Negative 训练?
+#### 如何基于无监督 SimCSE 训练出的模型参数作为参数初始化继续做有监督 In-Batch Negative 训练?
+ 使用 `--init_from_ckpt` 参数加载即可,下面是使用示例:
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/ann_util.py b/slm/applications/neural_search/recall/in_batch_negative/ann_util.py
similarity index 99%
rename from legacy/applications/neural_search/recall/in_batch_negative/ann_util.py
rename to slm/applications/neural_search/recall/in_batch_negative/ann_util.py
index a76b916a7e30..5cd61f420d3c 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/ann_util.py
+++ b/slm/applications/neural_search/recall/in_batch_negative/ann_util.py
@@ -14,8 +14,9 @@
# coding=UTF-8
-import numpy as np
import hnswlib
+import numpy as np
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/base_model.py b/slm/applications/neural_search/recall/in_batch_negative/base_model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/base_model.py
rename to slm/applications/neural_search/recall/in_batch_negative/base_model.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/batch_negative/model.py b/slm/applications/neural_search/recall/in_batch_negative/batch_negative/model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/batch_negative/model.py
rename to slm/applications/neural_search/recall/in_batch_negative/batch_negative/model.py
diff --git a/legacy/applications/neural_search/recall/milvus/data.py b/slm/applications/neural_search/recall/in_batch_negative/data.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/data.py
rename to slm/applications/neural_search/recall/in_batch_negative/data.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/http_client.py b/slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/http_client.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/http_client.py
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/http_client.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/rpc_client.py b/slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/cpp/rpc_client.py
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/rpc_client.py
diff --git a/slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh b/slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
new file mode 100644
index 000000000000..d0d491537146
--- /dev/null
+++ b/slm/applications/neural_search/recall/in_batch_negative/deploy/cpp/start_server.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_id 2 --thread 5 --ir_optim True --use_trt --precision FP16
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/config_nlp.yml b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/python/config_nlp.yml
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/python/config_nlp.yml
diff --git a/slm/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
new file mode 100644
index 000000000000..f4b8c7b5207f
--- /dev/null
+++ b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/deploy.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/predict.py b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/python/predict.py
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/python/predict.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py
index d46979c75e15..c99c349352b3 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py
+++ b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/rpc_client.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
-import numpy as np
+import numpy as np
from paddle_serving_server.pipeline import PipelineClient
client = PipelineClient()
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/deploy/python/web_service.py b/slm/applications/neural_search/recall/in_batch_negative/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/deploy/python/web_service.py
rename to slm/applications/neural_search/recall/in_batch_negative/deploy/python/web_service.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/evaluate.py b/slm/applications/neural_search/recall/in_batch_negative/evaluate.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/evaluate.py
rename to slm/applications/neural_search/recall/in_batch_negative/evaluate.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/export_model.py b/slm/applications/neural_search/recall/in_batch_negative/export_model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/export_model.py
rename to slm/applications/neural_search/recall/in_batch_negative/export_model.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/export_to_serving.py b/slm/applications/neural_search/recall/in_batch_negative/export_to_serving.py
similarity index 99%
rename from legacy/applications/neural_search/recall/in_batch_negative/export_to_serving.py
rename to slm/applications/neural_search/recall/in_batch_negative/export_to_serving.py
index 1ba681a4dfb1..6cc932da1117 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/export_to_serving.py
+++ b/slm/applications/neural_search/recall/in_batch_negative/export_to_serving.py
@@ -13,6 +13,7 @@
# limitations under the License.
import argparse
+
import paddle_serving_client.io as serving_io
# yapf: disable
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/inference.py b/slm/applications/neural_search/recall/in_batch_negative/inference.py
similarity index 98%
rename from legacy/applications/neural_search/recall/in_batch_negative/inference.py
rename to slm/applications/neural_search/recall/in_batch_negative/inference.py
index a49d261a3be9..bd06c5071bea 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/inference.py
+++ b/slm/applications/neural_search/recall/in_batch_negative/inference.py
@@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from functools import partial
import os
+from functools import partial
import paddle
-from paddlenlp.data import Tuple, Pad
-from paddlenlp.datasets import MapDataset
-from paddlenlp.transformers import AutoModel, AutoTokenizer
-
from base_model import SemanticIndexBaseStatic
from data import convert_example, create_dataloader
+from paddlenlp.data import Pad, Tuple
+from paddlenlp.datasets import MapDataset
+from paddlenlp.transformers import AutoModel, AutoTokenizer
+
if __name__ == "__main__":
device = "gpu"
max_seq_length = 64
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/predict.py b/slm/applications/neural_search/recall/in_batch_negative/predict.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/predict.py
rename to slm/applications/neural_search/recall/in_batch_negative/predict.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/recall.py b/slm/applications/neural_search/recall/in_batch_negative/recall.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/recall.py
rename to slm/applications/neural_search/recall/in_batch_negative/recall.py
diff --git a/slm/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh b/slm/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
new file mode 100644
index 000000000000..8d9a3b2114b3
--- /dev/null
+++ b/slm/applications/neural_search/recall/in_batch_negative/scripts/evaluate.sh
@@ -0,0 +1,18 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -u evaluate.py \
+ --similar_text_pair "recall/dev.csv" \
+ --recall_result_file "./recall_result_dir/recall_result.txt" \
+ --recall_num 50
\ No newline at end of file
diff --git a/slm/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh b/slm/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
new file mode 100644
index 000000000000..f7805a493f52
--- /dev/null
+++ b/slm/applications/neural_search/recall/in_batch_negative/scripts/export_model.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_model.py --params_path checkpoints/inbatch/model_40/model_state.pdparams \
+ --model_name_or_path rocketqa-zh-base-query-encoder \
+ --output_path=./output
\ No newline at end of file
diff --git a/slm/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh b/slm/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
new file mode 100644
index 000000000000..3c13b06b2111
--- /dev/null
+++ b/slm/applications/neural_search/recall/in_batch_negative/scripts/export_to_serving.sh
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_to_serving.py \
+ --dirname "output" \
+ --model_filename "inference.get_pooled_embedding.pdmodel" \
+ --params_filename "inference.get_pooled_embedding.pdiparams" \
+ --server_path "serving_server" \
+ --client_path "serving_client" \
+ --fetch_alias_names "output_embedding"
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/scripts/predict.sh b/slm/applications/neural_search/recall/in_batch_negative/scripts/predict.sh
similarity index 51%
rename from legacy/applications/neural_search/recall/in_batch_negative/scripts/predict.sh
rename to slm/applications/neural_search/recall/in_batch_negative/scripts/predict.sh
index 3967bb2c9b5d..9f2114011ba2 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/scripts/predict.sh
+++ b/slm/applications/neural_search/recall/in_batch_negative/scripts/predict.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# gpu version
root_dir="checkpoints/inbatch"
python -u -m paddle.distributed.launch --gpus "0" \
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/scripts/run_build_index.sh b/slm/applications/neural_search/recall/in_batch_negative/scripts/run_build_index.sh
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/scripts/run_build_index.sh
rename to slm/applications/neural_search/recall/in_batch_negative/scripts/run_build_index.sh
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/train_batch_neg.py b/slm/applications/neural_search/recall/in_batch_negative/train_batch_neg.py
similarity index 100%
rename from legacy/applications/neural_search/recall/in_batch_negative/train_batch_neg.py
rename to slm/applications/neural_search/recall/in_batch_negative/train_batch_neg.py
diff --git a/legacy/applications/neural_search/recall/milvus/README.md b/slm/applications/neural_search/recall/milvus/README.md
similarity index 89%
rename from legacy/applications/neural_search/recall/milvus/README.md
rename to slm/applications/neural_search/recall/milvus/README.md
index de3f1666b960..d29fc91982b2 100644
--- a/legacy/applications/neural_search/recall/milvus/README.md
+++ b/slm/applications/neural_search/recall/milvus/README.md
@@ -1,7 +1,7 @@
**目录**
* [背景介绍](#背景介绍)
-* [Milvus召回](#Milvus召回)
+* [Milvus 召回](#Milvus 召回)
* [1. 技术方案和评估指标](#技术方案)
* [2. 环境依赖](#环境依赖)
* [3. 代码结构](#代码结构)
@@ -15,9 +15,9 @@
基于某检索平台开源的数据集构造生成了面向语义索引的召回库。
-
+
-# Milvus召回
+# Milvus 召回
@@ -95,11 +95,11 @@
## 5. 向量检索
-### 5.1 基于Milvus的向量检索系统搭建
+### 5.1 基于 Milvus 的向量检索系统搭建
-数据准备结束以后,我们开始搭建 Milvus 的语义检索引擎,用于语义向量的快速检索,我们使用[Milvus](https://milvus.io/)开源工具进行召回,Milvus 的搭建教程请参考官方教程 [Milvus官方安装教程](https://milvus.io/docs/v2.1.x/install_standalone-docker.md)本案例使用的是 Milvus 的2.1版本,建议使用官方的 Docker 安装方式,简单快捷。
+数据准备结束以后,我们开始搭建 Milvus 的语义检索引擎,用于语义向量的快速检索,我们使用[Milvus](https://milvus.io/)开源工具进行召回,Milvus 的搭建教程请参考官方教程 [Milvus 官方安装教程](https://milvus.io/docs/v2.1.x/install_standalone-docker.md)本案例使用的是 Milvus 的2.1版本,建议使用官方的 Docker 安装方式,简单快捷。
-Milvus 搭建完系统以后就可以插入和检索向量了,首先生成 embedding 向量,每个样本生成256维度的向量,使用的是32GB的V100的卡进行的提取:
+Milvus 搭建完系统以后就可以插入和检索向量了,首先生成 embedding 向量,每个样本生成256维度的向量,使用的是32GB 的 V100的卡进行的提取:
```
CUDA_VISIBLE_DEVICES=0 python feature_extract.py \
@@ -124,7 +124,7 @@ MILVUS_HOST='your milvus ip'
MILVUS_PORT = 8530
```
-然后运行下面的命令把向量插入到Milvus库中:
+然后运行下面的命令把向量插入到 Milvus 库中:
```
python milvus_ann_search.py --data_path milvus/milvus_data.csv \
@@ -146,7 +146,7 @@ python milvus_ann_search.py --data_path milvus/milvus_data.csv \
| ------------ | ------------ |
|1000万条|21min12s|
-另外,Milvus提供了可视化的管理界面,可以很方便的查看数据,安装地址为[Attu](https://github.com/zilliztech/attu).
+另外,Milvus 提供了可视化的管理界面,可以很方便的查看数据,安装地址为[Attu](https://github.com/zilliztech/attu).

@@ -170,7 +170,7 @@ hit: (distance: 0.5440893769264221, id: 4297885), text field: 宝钢集团负债
hit: (distance: 0.5455711483955383, id: 5661135), text field: 浅谈电网企业固定资产风险管理大数据,固定资产,风险管理
...
```
-返回的是向量的距离,向量的id,以及对应的文本。
+返回的是向量的距离,向量的 id,以及对应的文本。
也可以一键执行上述的过程:
@@ -217,4 +217,4 @@ hit: (distance: 0.46187296509742737, id: 9324797), text field: 财务杠杆、
#### 抽取文本语义向量后,利用 Milvus 进行 ANN 检索查询到了完全相同的文本,但是计算出的距离为什么不是 0?
-使用的是近似索引,详情请参考Milvus官方文档,[索引创建机制](https://milvus.io/cn/docs/v2.0.x/index.md)
+使用的是近似索引,详情请参考 Milvus 官方文档,[索引创建机制](https://milvus.io/cn/docs/v2.0.x/index.md)
diff --git a/legacy/applications/neural_search/recall/milvus/base_model.py b/slm/applications/neural_search/recall/milvus/base_model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/base_model.py
rename to slm/applications/neural_search/recall/milvus/base_model.py
diff --git a/legacy/applications/neural_search/recall/milvus/config.py b/slm/applications/neural_search/recall/milvus/config.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/config.py
rename to slm/applications/neural_search/recall/milvus/config.py
diff --git a/legacy/applications/neural_search/recall/in_batch_negative/data.py b/slm/applications/neural_search/recall/milvus/data.py
similarity index 99%
rename from legacy/applications/neural_search/recall/in_batch_negative/data.py
rename to slm/applications/neural_search/recall/milvus/data.py
index d35f0985be17..2acbc81b6af7 100644
--- a/legacy/applications/neural_search/recall/in_batch_negative/data.py
+++ b/slm/applications/neural_search/recall/milvus/data.py
@@ -13,7 +13,9 @@
# limitations under the License.
import os
+
import paddle
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/neural_search/recall/milvus/feature_extract.py b/slm/applications/neural_search/recall/milvus/feature_extract.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/feature_extract.py
rename to slm/applications/neural_search/recall/milvus/feature_extract.py
diff --git a/legacy/applications/neural_search/recall/milvus/inference.py b/slm/applications/neural_search/recall/milvus/inference.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/inference.py
rename to slm/applications/neural_search/recall/milvus/inference.py
diff --git a/legacy/applications/neural_search/recall/milvus/milvus_ann_search.py b/slm/applications/neural_search/recall/milvus/milvus_ann_search.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/milvus_ann_search.py
rename to slm/applications/neural_search/recall/milvus/milvus_ann_search.py
diff --git a/legacy/applications/neural_search/recall/milvus/milvus_util.py b/slm/applications/neural_search/recall/milvus/milvus_util.py
similarity index 100%
rename from legacy/applications/neural_search/recall/milvus/milvus_util.py
rename to slm/applications/neural_search/recall/milvus/milvus_util.py
diff --git a/slm/applications/neural_search/recall/milvus/scripts/feature_extract.sh b/slm/applications/neural_search/recall/milvus/scripts/feature_extract.sh
new file mode 100644
index 000000000000..4111c298e29b
--- /dev/null
+++ b/slm/applications/neural_search/recall/milvus/scripts/feature_extract.sh
@@ -0,0 +1,20 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CUDA_VISIBLE_DEVICES=2 python feature_extract.py \
+ --model_dir ./output \
+ --model_name_or_path rocketqa-zh-base-query-encoder \
+ --batch_size 512 \
+ --corpus_file "milvus/milvus_data.csv"
+
diff --git a/slm/applications/neural_search/recall/milvus/scripts/search.sh b/slm/applications/neural_search/recall/milvus/scripts/search.sh
new file mode 100644
index 000000000000..d34f98861f5b
--- /dev/null
+++ b/slm/applications/neural_search/recall/milvus/scripts/search.sh
@@ -0,0 +1,20 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python milvus_ann_search.py --data_path milvus/milvus_data.csv \
+ --embedding_path corpus_embedding.npy \
+ --batch_size 100000 \
+ --index 18 \
+ --insert \
+ --search
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/README.md b/slm/applications/neural_search/recall/simcse/README.md
similarity index 87%
rename from legacy/applications/neural_search/recall/simcse/README.md
rename to slm/applications/neural_search/recall/simcse/README.md
index 0173f4538245..0338d0fe5bf3 100644
--- a/legacy/applications/neural_search/recall/simcse/README.md
+++ b/slm/applications/neural_search/recall/simcse/README.md
@@ -18,7 +18,7 @@
语义索引(可通俗理解为向量索引)技术是搜索引擎、推荐系统、广告系统在召回阶段的核心技术之一。语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。语义索引模型的效果直接决定了语义相关的物料能否被成功召回进入系统参与上层排序,从基础层面影响整个系统的效果。
-在召回阶段,最常见的方式是通过双塔模型,学习Document(简写为Doc)的向量表示,对Doc端建立索引,用ANN召回。我们在这种方式的基础上,引入无监督预训练策略,以如下训练数据为例:
+在召回阶段,最常见的方式是通过双塔模型,学习 Document(简写为 Doc)的向量表示,对 Doc 端建立索引,用 ANN 召回。我们在这种方式的基础上,引入无监督预训练策略,以如下训练数据为例:
```
@@ -41,7 +41,7 @@ SimCSE 模型适合缺乏监督数据,但是又有大量无监督数据的匹
### 技术方案
-双塔模型,采用ERNIE1.0热启,在召回阶段引入 SimCSE 策略。
+双塔模型,采用 ERNIE1.0热启,在召回阶段引入 SimCSE 策略。
### 评估指标
@@ -123,7 +123,7 @@ simcse/
圆周运动向心加速度物理意义的理论分析匀速圆周运动,向心加速度,物理意义,角速度,物理量,线速度,周期
```
-召回集,验证集,测试集与inbatch-negative实验的数据保持一致
+召回集,验证集,测试集与 inbatch-negative 实验的数据保持一致
### 数据集下载
@@ -168,7 +168,7 @@ simcse/
### 单机单卡训练/单机多卡训练
-这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1,2,3 卡, 基于SimCSE训练模型,无监督的数据量比较大,4卡的训练的时长在16个小时左右。如果采用单机单卡训练,只需要把`--gpu`参数设置成单卡的卡号即可。
+这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1,2,3 卡, 基于 SimCSE 训练模型,无监督的数据量比较大,4卡的训练的时长在16个小时左右。如果采用单机单卡训练,只需要把`--gpu`参数设置成单卡的卡号即可。
训练的命令如下:
@@ -191,7 +191,7 @@ python -u -m paddle.distributed.launch --gpus '0,1,2,3' \
--test_set_file "./recall/dev.csv" \
--model_name_or_path "rocketqa-zh-base-query-encoder"
```
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/train.sh
@@ -204,16 +204,16 @@ sh scripts/train.sh
* `infer_with_fc_pooler`:可选,在预测阶段计算文本 embedding 表示的时候网络前向是否会过训练阶段最后一层的 fc; 建议打开模型效果最好。
* `scale`:可选,在计算 cross_entropy loss 之前对 cosine 相似度进行缩放的因子;默认为 20。
* `dropout`:可选,SimCSE 网络前向使用的 dropout 取值;默认 0.1。
-* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录checkpoints文件夹下。
+* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录 checkpoints 文件夹下。
* `max_seq_length`:可选,ERNIE-Gram 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.0。
* `epochs`: 训练轮次,默认为1。
-* `warmup_proption`:可选,学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.0。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `warmup_proption`:可选,学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.0。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000.
-* `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
* `model_name_or_path`: 预训练模型,用于模型和`Tokenizer`的参数初始化。
程序运行时将会自动进行训练,评估。同时训练过程中会自动保存模型在指定的`save_dir`中。
@@ -233,21 +233,21 @@ checkpoints/
效果评估分为 4 个步骤:
-a. 获取Doc端Embedding
+a. 获取 Doc 端 Embedding
-基于语义索引模型抽取出Doc样本库的文本向量,
+基于语义索引模型抽取出 Doc 样本库的文本向量,
-b. 采用hnswlib对Doc端Embedding建库
+b. 采用 hnswlib 对 Doc 端 Embedding 建库
使用 ANN 引擎构建索引库(这里基于 [hnswlib](https://github.com/nmslib/hnswlib) 进行 ANN 索引)
-c. 获取Query的Embedding并查询相似结果
+c. 获取 Query 的 Embedding 并查询相似结果
基于语义索引模型抽取出评估集 *Source Text* 的文本向量,在第 2 步中建立的索引库中进行 ANN 查询,召回 Top50 最相似的 *Target Text*, 产出评估集中 *Source Text* 的召回结果 `recall_result` 文件
d. 评估
-基于评估集 `dev.csv` 和召回结果 `recall_result` 计算评估指标 Recall@k,其中k取值1,5,10,20,50.
+基于评估集 `dev.csv` 和召回结果 `recall_result` 计算评估指标 Recall@k,其中 k 取值1,5,10,20,50.
运行如下命令进行 ANN 建库、召回,产出召回结果数据 `recall_result`
@@ -268,23 +268,23 @@ python -u -m paddle.distributed.launch --gpus "6" --log_dir "recall_log/" \
--similar_text_pair "recall/dev.csv" \
--corpus_file "recall/corpus.csv"
```
-也可以使用下面的bash脚本:
+也可以使用下面的 bash 脚本:
```
sh scripts/run_build_index.sh
```
-run_build_index.sh还包含cpu和gpu运行的脚本,默认是gpu的脚本
+run_build_index.sh 还包含 cpu 和 gpu 运行的脚本,默认是 gpu 的脚本
-接下来,运行如下命令进行效果评估,产出Recall@1, Recall@5, Recall@10, Recall@20 和 Recall@50 指标:
+接下来,运行如下命令进行效果评估,产出 Recall@1, Recall@5, Recall@10, Recall@20 和 Recall@50 指标:
```
python -u evaluate.py \
--similar_text_pair "recall/dev.csv" \
--recall_result_file "./recall_result_dir/recall_result.txt" \
--recall_num 50
```
-也可以使用下面的bash脚本:
+也可以使用下面的 bash 脚本:
```
bash scripts/evaluate.sh
@@ -348,7 +348,7 @@ huntington舞蹈病的动物模型 Huntington舞蹈病的动物模型
### 开始预测
-以上述 demo 数据为例,运行如下命令基于我们开源的 SimCSE无监督语义索引模型开始计算文本 Pair 的语义相似度:
+以上述 demo 数据为例,运行如下命令基于我们开源的 SimCSE 无监督语义索引模型开始计算文本 Pair 的语义相似度:
```
root_dir="checkpoints"
@@ -370,7 +370,7 @@ python -u -m paddle.distributed.launch --gpus "3" \
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `text_pair_file`: 由文本 Pair 构成的待预测数据集
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/predict.sh
@@ -397,17 +397,17 @@ python export_model.py --params_path checkpoints/model_12000/model_state.pdparam
--model_name_or_path rocketqa-zh-base-query-encoder \
--output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
```
-### Paddle Inference预测
+### Paddle Inference 预测
预测既可以抽取向量也可以计算两个文本的相似度。
-修改id2corpus的样本:
+修改 id2corpus 的样本:
```
# 抽取向量
@@ -417,12 +417,12 @@ corpus_list=[['中西方语言与文化的差异','中西方文化差异以及
['中西方语言与文化的差异','飞桨致力于让深度学习技术的创新与应用更简单']]
```
-然后使用PaddleInference
+然后使用 PaddleInference
```
python deploy/python/predict.py --model_dir=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy.sh
@@ -440,9 +440,9 @@ sh deploy.sh
```
## FAQ
-#### SimCSE模型怎么部署?
+#### SimCSE 模型怎么部署?
-+ SimCSE使用的模型跟 In-batch Negatives 训练出来的模型网络结构是一样的,使用 In-batch Negatives 的部署流程即可,参考[In-batch Negatives](../in_batch_negative/deploy/python)
++ SimCSE 使用的模型跟 In-batch Negatives 训练出来的模型网络结构是一样的,使用 In-batch Negatives 的部署流程即可,参考[In-batch Negatives](../in_batch_negative/deploy/python)
## Reference
[1] Gao, Tianyu, Xingcheng Yao, and Danqi Chen. “SimCSE: Simple Contrastive Learning of Sentence Embeddings.” ArXiv:2104.08821 [Cs], April 18, 2021. http://arxiv.org/abs/2104.08821.
diff --git a/legacy/examples/semantic_indexing/ann_util.py b/slm/applications/neural_search/recall/simcse/ann_util.py
similarity index 100%
rename from legacy/examples/semantic_indexing/ann_util.py
rename to slm/applications/neural_search/recall/simcse/ann_util.py
diff --git a/legacy/applications/neural_search/recall/simcse/data.py b/slm/applications/neural_search/recall/simcse/data.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/data.py
rename to slm/applications/neural_search/recall/simcse/data.py
diff --git a/slm/applications/neural_search/recall/simcse/deploy/python/deploy.sh b/slm/applications/neural_search/recall/simcse/deploy/python/deploy.sh
new file mode 100644
index 000000000000..f4b8c7b5207f
--- /dev/null
+++ b/slm/applications/neural_search/recall/simcse/deploy/python/deploy.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/deploy/python/predict.py b/slm/applications/neural_search/recall/simcse/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/deploy/python/predict.py
rename to slm/applications/neural_search/recall/simcse/deploy/python/predict.py
diff --git a/legacy/applications/neural_search/recall/simcse/evaluate.py b/slm/applications/neural_search/recall/simcse/evaluate.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/evaluate.py
rename to slm/applications/neural_search/recall/simcse/evaluate.py
diff --git a/legacy/applications/neural_search/recall/simcse/export_model.py b/slm/applications/neural_search/recall/simcse/export_model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/export_model.py
rename to slm/applications/neural_search/recall/simcse/export_model.py
diff --git a/legacy/applications/neural_search/recall/simcse/inference.py b/slm/applications/neural_search/recall/simcse/inference.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/inference.py
rename to slm/applications/neural_search/recall/simcse/inference.py
diff --git a/legacy/applications/neural_search/recall/simcse/model.py b/slm/applications/neural_search/recall/simcse/model.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/model.py
rename to slm/applications/neural_search/recall/simcse/model.py
diff --git a/legacy/applications/neural_search/recall/simcse/predict.py b/slm/applications/neural_search/recall/simcse/predict.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/predict.py
rename to slm/applications/neural_search/recall/simcse/predict.py
diff --git a/legacy/applications/neural_search/recall/simcse/recall.py b/slm/applications/neural_search/recall/simcse/recall.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/recall.py
rename to slm/applications/neural_search/recall/simcse/recall.py
diff --git a/slm/applications/neural_search/recall/simcse/scripts/evaluate.sh b/slm/applications/neural_search/recall/simcse/scripts/evaluate.sh
new file mode 100755
index 000000000000..bf0f5bffa24c
--- /dev/null
+++ b/slm/applications/neural_search/recall/simcse/scripts/evaluate.sh
@@ -0,0 +1,18 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ python -u evaluate.py \
+ --similar_text_pair "recall/dev.csv" \
+ --recall_result_file "./recall_result_dir/recall_result.txt" \
+ --recall_num 50
\ No newline at end of file
diff --git a/slm/applications/neural_search/recall/simcse/scripts/export_model.sh b/slm/applications/neural_search/recall/simcse/scripts/export_model.sh
new file mode 100644
index 000000000000..2e32e02ba091
--- /dev/null
+++ b/slm/applications/neural_search/recall/simcse/scripts/export_model.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_model.py --params_path checkpoints/model_12000/model_state.pdparams \
+ --model_name_or_path rocketqa-zh-base-query-encoder \
+ --output_path=./output
\ No newline at end of file
diff --git a/legacy/applications/neural_search/recall/simcse/scripts/predict.sh b/slm/applications/neural_search/recall/simcse/scripts/predict.sh
similarity index 50%
rename from legacy/applications/neural_search/recall/simcse/scripts/predict.sh
rename to slm/applications/neural_search/recall/simcse/scripts/predict.sh
index 758e3ecf1696..7bec586f6486 100644
--- a/legacy/applications/neural_search/recall/simcse/scripts/predict.sh
+++ b/slm/applications/neural_search/recall/simcse/scripts/predict.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# gpu
root_dir="checkpoints"
python -u -m paddle.distributed.launch --gpus "3" \
diff --git a/legacy/applications/neural_search/recall/simcse/scripts/run_build_index.sh b/slm/applications/neural_search/recall/simcse/scripts/run_build_index.sh
similarity index 64%
rename from legacy/applications/neural_search/recall/simcse/scripts/run_build_index.sh
rename to slm/applications/neural_search/recall/simcse/scripts/run_build_index.sh
index eee1ad359359..f53e9187de8b 100755
--- a/legacy/applications/neural_search/recall/simcse/scripts/run_build_index.sh
+++ b/slm/applications/neural_search/recall/simcse/scripts/run_build_index.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# gpu
python -u -m paddle.distributed.launch --gpus "0" --log_dir "recall_log/" \
recall.py \
diff --git a/legacy/applications/neural_search/recall/simcse/scripts/train.sh b/slm/applications/neural_search/recall/simcse/scripts/train.sh
similarity index 69%
rename from legacy/applications/neural_search/recall/simcse/scripts/train.sh
rename to slm/applications/neural_search/recall/simcse/scripts/train.sh
index 60817e0ff7b5..8c963081f1a2 100644
--- a/legacy/applications/neural_search/recall/simcse/scripts/train.sh
+++ b/slm/applications/neural_search/recall/simcse/scripts/train.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# simcse gpu
python -u -m paddle.distributed.launch --gpus '1,2,3,4' \
train.py \
diff --git a/legacy/applications/neural_search/recall/simcse/train.py b/slm/applications/neural_search/recall/simcse/train.py
similarity index 100%
rename from legacy/applications/neural_search/recall/simcse/train.py
rename to slm/applications/neural_search/recall/simcse/train.py
diff --git a/legacy/applications/neural_search/requirements.txt b/slm/applications/neural_search/requirements.txt
similarity index 100%
rename from legacy/applications/neural_search/requirements.txt
rename to slm/applications/neural_search/requirements.txt
diff --git a/legacy/applications/neural_search/run_system.py b/slm/applications/neural_search/run_system.py
similarity index 100%
rename from legacy/applications/neural_search/run_system.py
rename to slm/applications/neural_search/run_system.py
diff --git a/legacy/applications/question_answering/README.md b/slm/applications/question_answering/README.md
similarity index 68%
rename from legacy/applications/question_answering/README.md
rename to slm/applications/question_answering/README.md
index 702bad69f8a3..96540eccf118 100644
--- a/legacy/applications/question_answering/README.md
+++ b/slm/applications/question_answering/README.md
@@ -3,9 +3,9 @@
问答系统(Question Answering System, QA)是信息检索系统的一种高级形式,它能用准确、简洁的自然语言回答用户用自然语言提出的问题。问答系统的应用空间十分包括,包括搜索引擎,小度音响等智能硬件,聊天机器人,以及政府、金融、银行、电信、电商领域的智能客服等。
在问答系统中,检索式问答系统是最容易落地的一种,它具有速度快、可控性好、容易拓展等特点。
-检索式问答系统是一种基于问题答案对进行检索匹配的系统,根据是否需要FAQ(Frequently asked questions)可以进一步分为有监督检索式问答系统和无监督检索式问答系统,前者需要用户提供FAQ语料,后者不需要预备问答语料,可通过问题答案对生成的方式自动生成语料。
+检索式问答系统是一种基于问题答案对进行检索匹配的系统,根据是否需要 FAQ(Frequently asked questions)可以进一步分为有监督检索式问答系统和无监督检索式问答系统,前者需要用户提供 FAQ 语料,后者不需要预备问答语料,可通过问题答案对生成的方式自动生成语料。
-PaddleNLP提供了[无监督检索式问答系统](./unsupervised_qa),开发者可根据实际情况进行选择。
+PaddleNLP 提供了[无监督检索式问答系统](./unsupervised_qa),开发者可根据实际情况进行选择。
关于问答场景应用案例请查阅飞桨新产品[RocketQA](https://github.com/PaddlePaddle/RocketQA)。
diff --git a/legacy/applications/question_answering/unsupervised_qa/README.md b/slm/applications/question_answering/unsupervised_qa/README.md
similarity index 71%
rename from legacy/applications/question_answering/unsupervised_qa/README.md
rename to slm/applications/question_answering/unsupervised_qa/README.md
index dbed88d1f2b5..9dcf99661643 100644
--- a/legacy/applications/question_answering/unsupervised_qa/README.md
+++ b/slm/applications/question_answering/unsupervised_qa/README.md
@@ -14,7 +14,7 @@
- [快速体验无监督检索式问答系统](#快速体验无监督检索式问答系统)
- [可视化无监督检索式问答系统](#可视化无监督检索式问答系统)
- [离线问答对语料构建](#离线问答对语料构建)
- - [基于Pipelines构建问答系统](#基于Pipelines构建问答系统)
+ - [基于 Pipelines 构建问答系统](#基于 Pipelines 构建问答系统)
- [自定义模型](#自定义模型)
- [数据准备](#数据准备)
- [模型微调](#模型微调)
@@ -26,22 +26,22 @@
- [References](#References)
## 简介
-问答(QA)系统中最关键的挑战之一是标记数据的稀缺性,这是因为对目标领域获取问答对或常见问答对(FAQ)的成本很高,需要消耗大量的人力和时间。由于上述制约,这导致检索式问答系统落地困难,解决此问题的一种方法是依据问题上下文或大量非结构化文本自动生成的QA问答对。
+问答(QA)系统中最关键的挑战之一是标记数据的稀缺性,这是因为对目标领域获取问答对或常见问答对(FAQ)的成本很高,需要消耗大量的人力和时间。由于上述制约,这导致检索式问答系统落地困难,解决此问题的一种方法是依据问题上下文或大量非结构化文本自动生成的 QA 问答对。
-在此背景下,无监督检索式问答系统(即问答对自动生成智能检索式问答),基于PaddleNLP[问题生成](../../../examples/question_generation/README.md)、[UIE](../../../model_zoo/uie/README.md)、[检索式问答](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/applications/question_answering/supervised_qa/faq_finance/README.md),支持以非结构化文本形式为上下文自动生成QA问答对,生成的问答对语料可以通过无监督的方式构建检索式问答系统。
+在此背景下,无监督检索式问答系统(即问答对自动生成智能检索式问答),基于 PaddleNLP[问题生成](../../../examples/question_generation/README.md)、[UIE](../../../model_zoo/uie/README.md)、[检索式问答](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/applications/question_answering/supervised_qa/faq_finance/README.md),支持以非结构化文本形式为上下文自动生成 QA 问答对,生成的问答对语料可以通过无监督的方式构建检索式问答系统。
-若开发者已有FAQ语料,请参考[supervised_qa](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/applications/question_answering/supervised_qa)。
+若开发者已有 FAQ 语料,请参考[supervised_qa](https://github.com/PaddlePaddle/PaddleNLP/blob/release/2.8/applications/question_answering/supervised_qa)。
### 项目优势
具体来说,本项目具有以下优势:
+ 低成本
- + 可通过自动生成的方式快速大量合成QA语料,大大降低人力成本
+ + 可通过自动生成的方式快速大量合成 QA 语料,大大降低人力成本
+ 可控性好,合成语料和语义检索问答解耦合,可以人工筛查和删除合成的问答对,也可以添加人工标注的问答对
+ 低门槛
+ 手把手搭建无监督检索式问答系统
- + 无需相似Query-Query Pair标注数据也能构建问答系统
+ + 无需相似 Query-Query Pair 标注数据也能构建问答系统
+ 效果好
+ 可通过自动问答对生成提升问答对语料覆盖度,缓解中长尾问题覆盖较少的问题
@@ -49,13 +49,13 @@
+ 针对无标注数据场景的领先解决方案: 检索预训练模型 + 增强的无监督语义索引微调
+ 端到端
- + 提供包括问答语料生成、索引库构建、模型服务部署、WebUI可视化一整套端到端智能问答系统能力
- + 支持对Txt、Word、PDF、Image多源数据上传,同时支持离线、在线QA语料生成和ANN数据库更新
+ + 提供包括问答语料生成、索引库构建、模型服务部署、WebUI 可视化一整套端到端智能问答系统能力
+ + 支持对 Txt、Word、PDF、Image 多源数据上传,同时支持离线、在线 QA 语料生成和 ANN 数据库更新
## 方案介绍
+**问答对生成**:问答对生成使用的指标是软召回率 Recall@K,
+**语义索引**:语义索引使用的指标是 Recall@K,表示的是预测的前 topK(从最后的按得分排序的召回列表中返回前 K 个结果)结果和语料库中真实的前 K 个相关结果的重叠率,衡量的是检索系统的查全率。 -->
### 流程图
本项目的流程图如下,对于给定的非结构化文本,我们首先通过答案抽取、问题生成、以及往返过滤模块,得到大量语料相关的问答对。针对这些得到的问答对,用户可以通过可以人工筛查和删除的方式来调整生成的问答对,也可以进一步添加人工标注的问答对。随后开发者就可以通过语义索引模块,来构建向量索引库。在构造完索引库之后,我们就可以通过召回模块和排序模块对问答对进行查询,得到最终的查询结果。
@@ -64,29 +64,29 @@
### 技术方案
-由于涉及较多的模块,本项目将基于PaddleNLP Pipelines进行模块的组合和项目的构建。PaddleNLP Pipelines是一个端到端NLP流水线系统框架,它可以通过插拔式组件产线化设计来构建一个完整的无监督问答系统。具体来说,我们的技术方案包含以下方面:
+由于涉及较多的模块,本项目将基于 PaddleNLP Pipelines 进行模块的组合和项目的构建。PaddleNLP Pipelines 是一个端到端 NLP 流水线系统框架,它可以通过插拔式组件产线化设计来构建一个完整的无监督问答系统。具体来说,我们的技术方案包含以下方面:
-**答案抽取**:我们基于UIE训练了一个答案抽取模型,该答案抽取模型接收“答案”作为提示词,该模型可以用来对潜在的答案信息进行挖掘抽取,我们同时提供了训练好的模型权重`uie-base-answer-extractor`。
+**答案抽取**:我们基于 UIE 训练了一个答案抽取模型,该答案抽取模型接收“答案”作为提示词,该模型可以用来对潜在的答案信息进行挖掘抽取,我们同时提供了训练好的模型权重`uie-base-answer-extractor`。
-**问题生成**:我们基于中文预训练语言模型UNIMO-Text、模版策略和大规模多领域问题生成数据集训练了一个通用点问题生成预训练模型`unimo-text-1.0-question-generation`。
+**问题生成**:我们基于中文预训练语言模型 UNIMO-Text、模版策略和大规模多领域问题生成数据集训练了一个通用点问题生成预训练模型`unimo-text-1.0-question-generation`。
**往返过滤**:我们采用过生成(overgenerate)的策略生成大量的潜在答案和问题,并通过往返过滤的方式针对生成的过量问答对进行过滤得到最终的问答对。我们的往返过滤模块需要训练一个有条件抽取式问答模型 3。
-**语义索引**:针对给定问答对语料,我们基于RocketQA(即`rocketqa-zh-base-query-encoder`)对问答对进行语义向量化,并通过ElasticSearch的ANN服务构建索引库。
+**语义索引**:针对给定问答对语料,我们基于 RocketQA(即`rocketqa-zh-base-query-encoder`)对问答对进行语义向量化,并通过 ElasticSearch 的 ANN 服务构建索引库。
-**召回排序**:给定用户查询,我们基于RocketQA的query-encoder和cross-encoder分别进行召回和排序操作,得到目标的问答对,从而返回给用户查询结果。
+**召回排序**:给定用户查询,我们基于 RocketQA 的 query-encoder 和 cross-encoder 分别进行召回和排序操作,得到目标的问答对,从而返回给用户查询结果。
-**Pipelines**:由于本项目设计的模块较多,我们使用PaddleNLP Pipelines进行模块的组合和项目的构建。大体来说,我们的Pipelines包含两个具体的pipeline和三个服务。两个pipeline分别是qa_generation_pipeline和dense_faq_pipeline;三个服务分别是基于ElasticSearch的ANN在线索引库服务,基于RestAPI的模型后端服务以及基于Streamlit的前端WebUI服务。
+**Pipelines**:由于本项目设计的模块较多,我们使用 PaddleNLP Pipelines 进行模块的组合和项目的构建。大体来说,我们的 Pipelines 包含两个具体的 pipeline 和三个服务。两个 pipeline 分别是 qa_generation_pipeline 和 dense_faq_pipeline;三个服务分别是基于 ElasticSearch 的 ANN 在线索引库服务,基于 RestAPI 的模型后端服务以及基于 Streamlit 的前端 WebUI 服务。
## 快速体验
### 运行环境和安装说明
-基于Pipelines构建问答系统需要安装paddle-pipelines依赖,使用pip安装命令如下:
+基于 Pipelines 构建问答系统需要安装 paddle-pipelines 依赖,使用 pip 安装命令如下:
```bash
# pip一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
```
-或者进入pipelines目录下,针对源码进行安装:
+或者进入 pipelines 目录下,针对源码进行安装:
```bash
# 源码进行安装
cd PaddleNLP/pipelines/
@@ -99,7 +99,7 @@ python setup.py install
### 快速体验无监督检索式问答系统
开发者可以通过如下命令快速体验无监督智能检索问答系统的效果,系统将自动根据提供的纯文本文件构建问答对语料库,并基于生成的问答对语料库构造索引库。
-我们建议在GPU环境下运行本示例,运行速度较快,运行命令如下:
+我们建议在 GPU 环境下运行本示例,运行速度较快,运行命令如下:
```bash
# GPU环境下运行示例
# 设置1个空闲的GPU卡,此处假设0卡为空闲GPU
@@ -110,10 +110,10 @@ python run_pipelines_example.py --device gpu --source_file data/source_file.txt
- `device`: 使用的设备,默认为'gpu',可选择['cpu', 'gpu']。
- `source_file`: 源文件路径,指定该路径将自动为其生成问答对至`doc_dir`。
- `doc_dir`: 生成的问答对语料保存的位置,系统将根据该位置自动构建检索数据库,默认为'data/my_data'。
-- `index_name`: FAISS的ANN索引名称,默认为'faiss_index'。
-- `retriever_batch_size`: 构建ANN索引时的批量大小,默认为16。
+- `index_name`: FAISS 的 ANN 索引名称,默认为'faiss_index'。
+- `retriever_batch_size`: 构建 ANN 索引时的批量大小,默认为16。
-如果只有CPU机器,可以通过--device参数指定cpu即可, 运行耗时较长,运行命令如下:
+如果只有 CPU 机器,可以通过--device 参数指定 cpu 即可, 运行耗时较长,运行命令如下:
```bash
# CPU环境下运行示例
unset CUDA_VISIBLE_DEVICES
@@ -124,17 +124,17 @@ python run_pipelines_example.py --device cpu --source_file data/source_file.txt
## 可视化无监督检索式问答系统
-开发者可以基于Pipelines进一步构建Web可视化的无监督检索式问答系统,其效果如下,
+开发者可以基于 Pipelines 进一步构建 Web 可视化的无监督检索式问答系统,其效果如下,
-
### 离线问答对语料构建
-这一部分介绍如何离线构建问答对语料,同时我们我们也在Pipeline中集成了在线问答对语料。
+这一部分介绍如何离线构建问答对语料,同时我们我们也在 Pipeline 中集成了在线问答对语料。
#### 数据说明
我们以提供的纯文本文件[source_file.txt](https://paddlenlp.bj.bcebos.com/applications/unsupervised_qa/source_file.txt)为例,系统将每一条都视为一个上下文并基于此生成多个问答对,随后系统将根据这些问答对构建索引库,该文件可直接下载放入`data`,开发者也可以使用自己的文件。
@@ -165,61 +165,61 @@ python -u run_qa_pairs_generation.py \
```
关键参数释义如下:
- `source_file_path` 源文件路径,源文件中每一行代表一条待生成问答对的上下文文本。
-- `target_file_path` 目标文件路径,生成的目标文件为json格式。
-- `answer_generation_model_path` 要加载的答案抽取模型的路径,可以是PaddleNLP提供的预训练模型,或者是本地模型checkpoint路径。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `target_file_path` 目标文件路径,生成的目标文件为 json 格式。
+- `answer_generation_model_path` 要加载的答案抽取模型的路径,可以是 PaddleNLP 提供的预训练模型,或者是本地模型 checkpoint 路径。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
| 可选预训练模型 |
|------------------------------|
| uie-base-answer-extractor-v1 |
-- `question_generation_model_path` 要加载的问题生成模型的路径,可以是PaddleNLP提供的预训练模型,或者是本地模型checkpoint路径。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `question_generation_model_path` 要加载的问题生成模型的路径,可以是 PaddleNLP 提供的预训练模型,或者是本地模型 checkpoint 路径。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
| 可选预训练模型 |
|------------------------------------------------|
| unimo-text-1.0-question-generation |
| unimo-text-1.0-dureader_qg |
| unimo-text-1.0-question-generation-dureader_qg |
-- `filtration_model_path` 要加载的过滤模型的路径,可以是PaddleNLP提供的预训练模型,或者是本地模型checkpoint路径。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `filtration_model_path` 要加载的过滤模型的路径,可以是 PaddleNLP 提供的预训练模型,或者是本地模型 checkpoint 路径。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
| 可选预训练模型 |
|-----------------------|
| uie-base-qa-filter-v1 |
-- `batch_size` 使用taskflow时的批处理大小,请结合机器情况进行调整,默认为8。
+- `batch_size` 使用 taskflow 时的批处理大小,请结合机器情况进行调整,默认为8。
- `a_max_answer_candidates` 答案抽取阶段,每个输入的最大返回答案候选数,默认为5。
- `a_prompt` 答案抽取阶段,使用的提示词,以","分隔,默认为"答案"。
- `a_position_prob` 答案抽取阶段,置信度阈值,默认为0.01。
- `q_num_return_sequences` 问题生成阶段,返回问题候选数,在使用"beam_search"解码策略时它应该小于`q_num_beams`,默认为3。
- `q_max_question_length` 问题生成阶段,最大解码长度,默认为50。
- `q_decode_strategy` 问题生成阶段,解码策略,默认为"sampling"。
-- `q_top_k` 问题生成阶段,使用"sampling"解码策略时的top k值,默认为5。
-- `q_top_p` 问题生成阶段,使用"sampling"解码策略时的top p值,默认为0。
-- `q_num_beams` 问题生成阶段,使用"beam_search"解码策略时的beam大小,默认为6。
+- `q_top_k` 问题生成阶段,使用"sampling"解码策略时的 top k 值,默认为5。
+- `q_top_p` 问题生成阶段,使用"sampling"解码策略时的 top p 值,默认为0。
+- `q_num_beams` 问题生成阶段,使用"beam_search"解码策略时的 beam 大小,默认为6。
- `do_filtration` 是否进行过滤。
- `f_filtration_position_prob` 过滤阶段,过滤置信度阈值,默认为0.1。
- `do_debug` 是否进入调试状态,调试状态下将输出过滤掉的生成问答对。
#### 语料转换
-执行以下脚本对生成的问答对进行转换,得到语义索引所需要的语料train.csv、dev.csv、q_corpus.csv、qa_pair.csv:
+执行以下脚本对生成的问答对进行转换,得到语义索引所需要的语料 train.csv、dev.csv、q_corpus.csv、qa_pair.csv:
```shell
python -u run_corpus_preparation.py \
--source_file_path data/target_file.json \
--target_dir_path data/my_corpus
```
关键参数释义如下:
-- `source_file_path` 指示了要转换的训练数据集文件或测试数据集文件,文件格式要求见从本地文件创建数据集部分。指示了要转换的问答对json文件路径,生成的目标文件为json格式
+- `source_file_path` 指示了要转换的训练数据集文件或测试数据集文件,文件格式要求见从本地文件创建数据集部分。指示了要转换的问答对 json 文件路径,生成的目标文件为 json 格式
- `target_dir_path` 输出数据的目标文件夹,默认为"data/my_corpus"。
- `test_sample_num` 构建检索系统时保留的测试样本数目,默认为0。
- `train_sample_num` 构建检索系统时保留的有监督训练样本数目,默认为0。
-- `all_sample_num` 构建检索系统时保留的总样本数目,默认为None,表示保留除了前`test_sample_num`+`train_sample_num`个样本外的所有样本。
+- `all_sample_num` 构建检索系统时保留的总样本数目,默认为 None,表示保留除了前`test_sample_num`+`train_sample_num`个样本外的所有样本。
+关于如何对语义检索模型进行无监督训练,以及针对给定问答语料库进行模型部署,请参考 faq_system -->
-### 基于Pipelines构建问答系统
-本项目提供了基于Pipelines的低成本构建问答对自动生成智能检索问答系统的能力。开发者只需要提供非结构化的纯文本,就可以使用本项目预制的问答对生成模块生成大量的问答对,并基于此快速搭建一个针对自己业务的检索问答系统,并可以提供Web可视化产品服务。Web可视化产品服务支持问答检索、在线问答对生成,在线文件上传和解析,在线索引库更新等功能,用户也可根据需要自行调整。具体的构建流程请参考[Pipelines-无监督智能检索问答系统](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/unsupervised-question-answering)。
+### 基于 Pipelines 构建问答系统
+本项目提供了基于 Pipelines 的低成本构建问答对自动生成智能检索问答系统的能力。开发者只需要提供非结构化的纯文本,就可以使用本项目预制的问答对生成模块生成大量的问答对,并基于此快速搭建一个针对自己业务的检索问答系统,并可以提供 Web 可视化产品服务。Web 可视化产品服务支持问答检索、在线问答对生成,在线文件上传和解析,在线索引库更新等功能,用户也可根据需要自行调整。具体的构建流程请参考[Pipelines-无监督智能检索问答系统](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/pipelines/examples/unsupervised-question-answering)。
@@ -279,7 +279,7 @@ python -u run_data_preprocess.py \
- `do_domain_prompt` 表示在构造答案抽取数据时是否添加领域提示词。
- `domain` 表示添加的领域提示词,在`do_domain_prompt`时有效。
-**NOTE:** 预处理后的微调用数据将分别位于`target_dir`下的answer_extraction、question_generation、filtration三个子文件夹中。
+**NOTE:** 预处理后的微调用数据将分别位于`target_dir`下的 answer_extraction、question_generation、filtration 三个子文件夹中。
### 模型微调
#### 答案抽取
@@ -313,9 +313,9 @@ python -u -m paddle.distributed.launch --gpus "1,2" --log_dir log/answer_extract
- `model`: 选择模型,程序会基于选择的模型进行模型微调,可选有`uie-base-answer-extractor`,`uie-base`,`uie-medium`, `uie-mini`, `uie-micro`和`uie-nano`,默认为`uie-base`。
- `init_from_ckpt`: 用于初始化的模型参数的路径。
- `seed`: 随机种子,默认为1000.
-- `logging_steps`: 日志打印的间隔steps数,默认10。
-- `valid_steps`: evaluate的间隔steps数,默认100。
-- `device`: 选用什么设备进行训练,可选cpu或gpu。
+- `logging_steps`: 日志打印的间隔 steps 数,默认10。
+- `valid_steps`: evaluate 的间隔 steps 数,默认100。
+- `device`: 选用什么设备进行训练,可选 cpu 或 gpu。
通过运行以下命令在样例验证集上进行模型评估:
@@ -335,8 +335,8 @@ python finetune/answer_extraction_and_roundtrip_filtration/evaluate.py \
- `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
- `max_seq_len`: 文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
- `model`: 选择所使用的模型,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`和`uie-nano`,默认为`uie-base`。
-- `debug`: 是否开启debug模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
-- `limit`: SpanEvaluator测评指标的`limit`,当概率数组中的最后一个维度大于该值时将返回相应的文本片段;当limit设置为0.01时表示关注模型的召回率,也即答案的覆盖率。
+- `debug`: 是否开启 debug 模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
+- `limit`: SpanEvaluator 测评指标的`limit`,当概率数组中的最后一个维度大于该值时将返回相应的文本片段;当 limit 设置为0.01时表示关注模型的召回率,也即答案的覆盖率。
#### 问题生成
运行如下命令即可在样例训练集上微调问题生成模型,并在样例验证集上进行验证。
@@ -371,11 +371,11 @@ python -u -m paddle.distributed.launch --gpus "1,2" --log_dir log/question_gener
关键参数释义如下:
-- `gpus` 指示了训练所用的GPU,使用多卡训练可以指定多个GPU卡号,例如 --gpus "0,1"。
+- `gpus` 指示了训练所用的 GPU,使用多卡训练可以指定多个 GPU 卡号,例如 --gpus "0,1"。
- `dataset_name` 数据集名称,用来指定数据集格式,默认为`dureader_qg`。
-- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为None。
-- `predict_file` 本地测试数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为None。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一,默认为`unimo-text-1.0`。
+- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为 None。
+- `predict_file` 本地测试数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为 None。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一,默认为`unimo-text-1.0`。
| 可选预训练模型 |
|------------------------------------|
| unimo-text-1.0 |
@@ -389,16 +389,16 @@ python -u -m paddle.distributed.launch --gpus "1,2" --log_dir log/question_gener
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数占总步数的比例。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数占总步数的比例。
- `max_seq_len` 模型输入序列的最大长度。
- `max_target_len` 模型训练时标签的最大长度。
- `min_dec_len` 模型生成序列的最小长度。
- `max_dec_len` 模型生成序列的最大长度。
- `do_train` 是否进行训练。
- `do_predict` 是否进行预测,在验证集上会自动评估。
-- `device` 表示使用的设备,从gpu和cpu中选择。
+- `device` 表示使用的设备,从 gpu 和 cpu 中选择。
- `template` 表示使用的模版,从[0, 1, 2, 3, 4]中选择,0表示不选择模版,1表示使用默认模版。
程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中。
@@ -437,9 +437,9 @@ python -u -m paddle.distributed.launch --gpus "1,2" --log_dir log/filtration fin
- `model`: 选择模型,程序会基于选择的模型进行模型微调,可选有`uie-base-qa-filter`,`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`和`uie-nano`,默认为`uie-base`。
- `init_from_ckpt`: 用于初始化的模型参数的路径。
- `seed`: 随机种子,默认为1000.
-- `logging_steps`: 日志打印的间隔steps数,默认10。
-- `valid_steps`: evaluate的间隔steps数,默认100。
-- `device`: 选用什么设备进行训练,可选cpu或gpu。
+- `logging_steps`: 日志打印的间隔 steps 数,默认10。
+- `valid_steps`: evaluate 的间隔 steps 数,默认100。
+- `device`: 选用什么设备进行训练,可选 cpu 或 gpu。
通过运行以下命令在样例验证集上进行模型评估:
@@ -459,14 +459,14 @@ python finetune/answer_extraction_and_roundtrip_filtration/evaluate.py \
- `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
- `max_seq_len`: 文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
- `model`: 选择所使用的模型,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`和`uie-nano`,默认为`uie-base`。
-- `debug`: 是否开启debug模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
-- `limit`: SpanEvaluator测评指标的`limit`,当概率数组中的最后一个维度大于该值时将返回相应的文本片段。
+- `debug`: 是否开启 debug 模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
+- `limit`: SpanEvaluator 测评指标的`limit`,当概率数组中的最后一个维度大于该值时将返回相应的文本片段。
#### 语义索引和召回模型
-我们的语义索引和召回模型是基于RocketQA的QueryEncoder训练的双塔模型,该模型用于语义索引和召回阶段,分别进行语义向量抽取和相似度召回。除使用预置模型外,如果用户想训练并接入自己的模型,模型训练可以参考[FAQ Finance](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa/faq_finance)。
+我们的语义索引和召回模型是基于 RocketQA 的 QueryEncoder 训练的双塔模型,该模型用于语义索引和召回阶段,分别进行语义向量抽取和相似度召回。除使用预置模型外,如果用户想训练并接入自己的模型,模型训练可以参考[FAQ Finance](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa/faq_finance)。
#### 排序模型
-我们的排序模型是基于RocketQA的CrossEncoder训练的单塔模型,该模型用于搜索的排序阶段,对召回的结果进行重新排序的作用。关于排序的定制训练,可以参考[CrossEncoder](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/neural_search/ranking/cross_encoder)。
+我们的排序模型是基于 RocketQA 的 CrossEncoder 训练的单塔模型,该模型用于搜索的排序阶段,对召回的结果进行重新排序的作用。关于排序的定制训练,可以参考[CrossEncoder](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/neural_search/ranking/cross_encoder)。
## References
[1] Zheng, Chujie, and Minlie Huang. "Exploring prompt-based few-shot learning for grounded dialog generation." arXiv preprint arXiv:2109.06513 (2021).
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/evaluate.py b/slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/evaluate.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/evaluate.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/evaluate.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/finetune.py b/slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/finetune.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/finetune.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/finetune.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/span.py b/slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/span.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/span.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/span.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/utils.py b/slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/utils.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/utils.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/answer_extraction_and_roundtrip_filtration/utils.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/gen_utils.py b/slm/applications/question_answering/unsupervised_qa/finetune/question_generation/gen_utils.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/gen_utils.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/question_generation/gen_utils.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/predict.py b/slm/applications/question_answering/unsupervised_qa/finetune/question_generation/predict.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/predict.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/question_generation/predict.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/train.py b/slm/applications/question_answering/unsupervised_qa/finetune/question_generation/train.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/finetune/question_generation/train.py
rename to slm/applications/question_answering/unsupervised_qa/finetune/question_generation/train.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/run_corpus_preparation.py b/slm/applications/question_answering/unsupervised_qa/run_corpus_preparation.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/run_corpus_preparation.py
rename to slm/applications/question_answering/unsupervised_qa/run_corpus_preparation.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/run_data_preprocess.py b/slm/applications/question_answering/unsupervised_qa/run_data_preprocess.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/run_data_preprocess.py
rename to slm/applications/question_answering/unsupervised_qa/run_data_preprocess.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/run_pipelines_example.py b/slm/applications/question_answering/unsupervised_qa/run_pipelines_example.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/run_pipelines_example.py
rename to slm/applications/question_answering/unsupervised_qa/run_pipelines_example.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/run_qa_pairs_generation.py b/slm/applications/question_answering/unsupervised_qa/run_qa_pairs_generation.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/run_qa_pairs_generation.py
rename to slm/applications/question_answering/unsupervised_qa/run_qa_pairs_generation.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/tools/create_synthetic_answer.py b/slm/applications/question_answering/unsupervised_qa/tools/create_synthetic_answer.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/tools/create_synthetic_answer.py
rename to slm/applications/question_answering/unsupervised_qa/tools/create_synthetic_answer.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/tools/create_synthetic_question.py b/slm/applications/question_answering/unsupervised_qa/tools/create_synthetic_question.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/tools/create_synthetic_question.py
rename to slm/applications/question_answering/unsupervised_qa/tools/create_synthetic_question.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/tools/dev_qq_pair_creation.py b/slm/applications/question_answering/unsupervised_qa/tools/dev_qq_pair_creation.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/tools/dev_qq_pair_creation.py
rename to slm/applications/question_answering/unsupervised_qa/tools/dev_qq_pair_creation.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/tools/json_format_indent.py b/slm/applications/question_answering/unsupervised_qa/tools/json_format_indent.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/tools/json_format_indent.py
rename to slm/applications/question_answering/unsupervised_qa/tools/json_format_indent.py
diff --git a/legacy/applications/question_answering/unsupervised_qa/tools/question_coverage.py b/slm/applications/question_answering/unsupervised_qa/tools/question_coverage.py
similarity index 100%
rename from legacy/applications/question_answering/unsupervised_qa/tools/question_coverage.py
rename to slm/applications/question_answering/unsupervised_qa/tools/question_coverage.py
diff --git a/legacy/applications/text_classification/README.md b/slm/applications/text_classification/README.md
similarity index 72%
rename from legacy/applications/text_classification/README.md
rename to slm/applications/text_classification/README.md
index edba001669ca..8f3eeb711cec 100644
--- a/legacy/applications/text_classification/README.md
+++ b/slm/applications/text_classification/README.md
@@ -15,7 +15,7 @@
## 1. 文本分类应用简介
文本分类应用针对**多分类、多标签、层次分类等高频场景开源了产业级分类应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,旨在解决细分场景应用的痛点和难点,快速实现文本分类产品落地。
-文本分类简单来说就是对给定的一个句子或一段文本使用分类模型分类。虽然文本分类在金融、医疗、法律、工业等领域都有广泛的成功实践应用,但如何选择合适的方案和预训练模型、数据标注质量差、效果调优困难、AI入门成本高、如何高效训练部署等问题使部分开发者望而却步。针对文本分类领域的痛点和难点,PaddleNLP文本分类应用提出了多种前沿解决方案,助力开发者简单高效实现文本分类数据标注、训练、调优、上线,降低文本分类落地技术门槛。
+文本分类简单来说就是对给定的一个句子或一段文本使用分类模型分类。虽然文本分类在金融、医疗、法律、工业等领域都有广泛的成功实践应用,但如何选择合适的方案和预训练模型、数据标注质量差、效果调优困难、AI 入门成本高、如何高效训练部署等问题使部分开发者望而却步。针对文本分类领域的痛点和难点,PaddleNLP 文本分类应用提出了多种前沿解决方案,助力开发者简单高效实现文本分类数据标注、训练、调优、上线,降低文本分类落地技术门槛。

@@ -24,8 +24,8 @@
**文本分类应用技术特色:**
- **方案全面🎓:** 涵盖多分类、多标签、层次分类等高频分类场景,提供预训练模型微调、提示学习(小样本学习)、语义索引三种端到端全流程分类方案,满足开发者多样文本分类落地需求。
-- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
+- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的 ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
- **简单易用👶:** 开发者**无需机器学习背景知识**,仅需提供指定格式的标注分类数据,一行命令即可开启文本分类训练,轻松完成上线部署,不再让技术成为文本分类的门槛。
@@ -48,11 +48,11 @@
-- **多分类🚶:** 数据集的标签集含有两个或两个以上的类别,所有输入句子/文本有且只有一个标签。在文本多分类场景中,我们需要预测输入句子/文本最可能来自 `n` 个标签类别中的哪一个类别。以上图多分类中新闻文本为例,该新闻文本的标签为 `娱乐`。快速开启多分类任务参见 👉 [多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class#readme)
+- **多分类🚶:** 数据集的标签集含有两个或两个以上的类别,所有输入句子/文本有且只有一个标签。在文本多分类场景中,我们需要预测输入句子/文本最可能来自 `n` 个标签类别中的哪一个类别。以上图多分类中新闻文本为例,该新闻文本的标签为 `娱乐`。快速开启多分类任务参见 👉 [多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class#readme)
-- **多标签👫 :** 数据集的标签集含有两个或两个以上的类别,输入句子/文本具有一个或多个标签。在文本多标签任务中,我们需要预测输入句子/文本可能来自 `n` 个标签类别中的哪几个类别。以上图多标签中新闻文本为例,该新闻文本具有 `相机` 和 `芯片` 两个标签。快速开启多标签任务参见 👉 [多标签指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label#readme) 。
+- **多标签👫 :** 数据集的标签集含有两个或两个以上的类别,输入句子/文本具有一个或多个标签。在文本多标签任务中,我们需要预测输入句子/文本可能来自 `n` 个标签类别中的哪几个类别。以上图多标签中新闻文本为例,该新闻文本具有 `相机` 和 `芯片` 两个标签。快速开启多标签任务参见 👉 [多标签指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label#readme) 。
-- **层次分类👪 :** 数据集的标签集具有多级标签且标签之间具有层级结构关系,输入句子/文本具有一个或多个标签。在文本层次分类任务中,我们需要预测输入句子/文本可能来自于不同级标签类别中的某一个或几个类别。以上图层次分类中新闻文本为例(新闻为根节点),该新闻一级分类标签为 `体育`,二级分类标签为 `足球`。快速开启层次分类任务参见 👉 [层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical#readme) 。
+- **层次分类👪 :** 数据集的标签集具有多级标签且标签之间具有层级结构关系,输入句子/文本具有一个或多个标签。在文本层次分类任务中,我们需要预测输入句子/文本可能来自于不同级标签类别中的某一个或几个类别。以上图层次分类中新闻文本为例(新闻为根节点),该新闻一级分类标签为 `体育`,二级分类标签为 `足球`。快速开启层次分类任务参见 👉 [层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical#readme) 。
#### 2.1.2 多方案满足定制需求
@@ -63,7 +63,7 @@
【方案介绍】ERNIE 3.0 轻量级模型不能直接在文本分类任务上使用,预训练模型微调在预训练模型 `[CLS]` 输出向量后接入线性层作为文本分类器,用具体任务数据进行微调训练文本分类器,使预训练模型”更懂”这个任务。
-【方案效果】下表展示在多标签任务CAIL2019—婚姻家庭要素提取数据集中ERNIE 3.0 系列轻量级模型效果评测。
+【方案效果】下表展示在多标签任务 CAIL2019—婚姻家庭要素提取数据集中 ERNIE 3.0 系列轻量级模型效果评测。
@@ -72,9 +72,9 @@
【快速开始】
-- 快速开启多分类任务参见 👉 [预训练模型微调-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class#readme)
-- 快速开启多标签分类任务参见 👉 [预训练模型微调-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label#readme)
-- 快速开启层次分类任务参见 👉 [预训练模型微调-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical#readme)
+- 快速开启多分类任务参见 👉 [预训练模型微调-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class#readme)
+- 快速开启多标签分类任务参见 👉 [预训练模型微调-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label#readme)
+- 快速开启层次分类任务参见 👉 [预训练模型微调-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical#readme)
#### 方案二:提示学习
@@ -88,7 +88,7 @@
-【方案效果】我们比较预训练模型微调与提示学习在多分类、多标签、层次分类小样本场景的模型表现(多分类精度为准确率,多标签和层次分类精度为Macro F1值),可以看到在样本较少的情况下,提示学习比预训练模型微调有明显优势。
+【方案效果】我们比较预训练模型微调与提示学习在多分类、多标签、层次分类小样本场景的模型表现(多分类精度为准确率,多标签和层次分类精度为 Macro F1值),可以看到在样本较少的情况下,提示学习比预训练模型微调有明显优势。

@@ -99,9 +99,9 @@
【快速开始】
更多测评和使用细节详见各场景文档:
-- 快速开启多分类任务参见 👉 [提示学习(小样本)-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class/few-shot#readme)
-- 快速开启多标签分类任务参见 👉 [提示学习(小样本)-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label/few-shot#readme)
-- 快速开启层次分类任务参见 👉 [提示学习(小样本)-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical/few-shot#readme)
+- 快速开启多分类任务参见 👉 [提示学习(小样本)-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class/few-shot#readme)
+- 快速开启多标签分类任务参见 👉 [提示学习(小样本)-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label/few-shot#readme)
+- 快速开启层次分类任务参见 👉 [提示学习(小样本)-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical/few-shot#readme)
#### 方案三:语义索引
@@ -114,9 +114,9 @@
【快速开始】
-- 快速开启多分类任务参见 👉 [语义索引-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class/retrieval_based#readme)
-- 快速开启多标签分类任务参见 👉 [语义索引-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label/retrieval_based#readme)
-- 快速开启层次分类任务参见 👉 [语义索引-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical/retrieval_based#readme)
+- 快速开启多分类任务参见 👉 [语义索引-多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class/retrieval_based#readme)
+- 快速开启多标签分类任务参见 👉 [语义索引-多标签分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label/retrieval_based#readme)
+- 快速开启层次分类任务参见 👉 [语义索引-层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical/retrieval_based#readme)
@@ -126,7 +126,7 @@
近年来,大量的研究表明在超大规模的语料采用无监督或者弱监督的方式训练模型,模型能够获得语言相关的知识。预训练模型学习到的文本语义表示能够避免从零开始训练模型,同时有利于下游自然语言处理(NLP)任务。预训练模型与具体的文本分类任务的关系可以直观地理解为,**预训练模型已经懂得了相关句法、语义的语言知识,用具体任务数据训练使得预训练模型”更懂”这个任务**,在预训练过程中学到的知识基础使学习文本分类任务事半功倍。
-文本分类应用使用**ERNIE 3.0轻量级模型作为预训练模型**,ERNIE 3.0 轻量级模型是文心大模型ERNIE 3.0基础上通过在线蒸馏技术得到的轻量级模型。下面是ERNIE 3.0 效果-时延图,ERNIE 3.0 轻量级模型在精度和性能上的综合表现已全面领先于 UER-py、Huawei-Noah 以及 HFL 的中文模型,具体的测评细节可以见[ERNIE 3.0 效果和性能测评文档](../../model_zoo/ernie-3.0)。
+文本分类应用使用**ERNIE 3.0轻量级模型作为预训练模型**,ERNIE 3.0 轻量级模型是文心大模型 ERNIE 3.0基础上通过在线蒸馏技术得到的轻量级模型。下面是 ERNIE 3.0 效果-时延图,ERNIE 3.0 轻量级模型在精度和性能上的综合表现已全面领先于 UER-py、Huawei-Noah 以及 HFL 的中文模型,具体的测评细节可以见[ERNIE 3.0 效果和性能测评文档](../../model_zoo/ernie-3.0)。

@@ -138,7 +138,7 @@
### 2.3 高效模型调优方案
-有这么一句话在业界广泛流传,"数据决定了机器学习的上限,而模型和算法只是逼近这个上限",可见数据质量的重要性。文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)开源了模型分析模块,针对标注数据质量不高、训练数据覆盖不足、样本数量少等文本分类常见数据痛点,提供稀疏数据筛选、脏数据清洗、数据增强三种数据优化方案,解决训练数据缺陷问题,用低成本方式获得大幅度的效果提升。
+有这么一句话在业界广泛流传,"数据决定了机器学习的上限,而模型和算法只是逼近这个上限",可见数据质量的重要性。文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)开源了模型分析模块,针对标注数据质量不高、训练数据覆盖不足、样本数量少等文本分类常见数据痛点,提供稀疏数据筛选、脏数据清洗、数据增强三种数据优化方案,解决训练数据缺陷问题,用低成本方式获得大幅度的效果提升。
- **稀疏数据筛选**基于特征相似度的实例级证据分析方法挖掘待预测数据中缺乏证据支持的数据(也即稀疏数据),并进行有选择的训练集数据增强或针对性筛选未标注数据进行标注来解决稀疏数据问题,有效提升模型表现。
@@ -146,7 +146,7 @@
-我们采用在多分类、多标签、层次分类场景中评测稀疏数据-数据增强策略和稀疏数据-数据标注策略,下图表明稀疏数据筛选方案在各场景能够有效提高模型表现(多分类精度为准确率,多标签和层次分类精度为Macro F1值)。
+我们采用在多分类、多标签、层次分类场景中评测稀疏数据-数据增强策略和稀疏数据-数据标注策略,下图表明稀疏数据筛选方案在各场景能够有效提高模型表现(多分类精度为准确率,多标签和层次分类精度为 Macro F1值)。

@@ -159,14 +159,14 @@
-我们采用在多分类、多标签、层次分类场景中评测脏数据清洗方案,实验表明方案能够高效筛选出训练集中脏数据,提高模型表现(多分类精度为准确率,多标签和层次分类精度为Macro F1值)。
+我们采用在多分类、多标签、层次分类场景中评测脏数据清洗方案,实验表明方案能够高效筛选出训练集中脏数据,提高模型表现(多分类精度为准确率,多标签和层次分类精度为 Macro F1值)。
-- **数据增强**在数据量较少的情况下能够通过增加数据集多样性,提升模型效果。PaddleNLP内置[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),支持词替换、词删除、词插入、词置换、基于上下文生成词(MLM预测)、TF-IDF等多种数据增强策略。数据增强方案提供一行命令,快速完成数据集增强。以CAIL2019—婚姻家庭要素提取数据子集(500条)为例,我们在数据集应用多种数据增强策略,策略效果如下表。
+- **数据增强**在数据量较少的情况下能够通过增加数据集多样性,提升模型效果。PaddleNLP 内置[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),支持词替换、词删除、词插入、词置换、基于上下文生成词(MLM 预测)、TF-IDF 等多种数据增强策略。数据增强方案提供一行命令,快速完成数据集增强。以 CAIL2019—婚姻家庭要素提取数据子集(500条)为例,我们在数据集应用多种数据增强策略,策略效果如下表。

@@ -177,9 +177,9 @@
更多使用方法和测评细节详见各场景模型分析模块:
-- 体验模型分析模块 👉 [多分类-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class/analysis)
-- 体验模型分析模块 👉 [多标签-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label/analysis)
-- 体验模型分析模块 👉 [层次分类-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical/analysis)
+- 体验模型分析模块 👉 [多分类-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class/analysis)
+- 体验模型分析模块 👉 [多标签-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label/analysis)
+- 体验模型分析模块 👉 [层次分类-模型分析模块](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical/analysis)
@@ -202,19 +202,19 @@
- 我们根据文本分类任务选择对应的场景目录: [多分类场景目录](./multi_class)、
[多标签场景目录](./multi_label)、[层次分类场景目录](./hierarchical)。
-- 如果没有已标注的数据集,我们推荐doccano数据标注工具进行标注,详见[文本分类标注指南](./doccano.md)。如果已有标注好的本地数据集,我们需要根据不同任务要求将数据集整理为文档要求的格式,详见各分类场景文档。
+- 如果没有已标注的数据集,我们推荐 doccano 数据标注工具进行标注,详见[文本分类标注指南](./doccano.md)。如果已有标注好的本地数据集,我们需要根据不同任务要求将数据集整理为文档要求的格式,详见各分类场景文档。
**2.模型训练**
-- 数据准备完成后,开始进行预训练模型微调训练。可以根据实际数据调整可配置参数,选择使用GPU或CPU进行模型训练,脚本默认保存在开发集最佳表现模型参数。
+- 数据准备完成后,开始进行预训练模型微调训练。可以根据实际数据调整可配置参数,选择使用 GPU 或 CPU 进行模型训练,脚本默认保存在开发集最佳表现模型参数。
-- 训练结束后,使用模型分析(analysis)模块对分析模型表现,同时模型分析(analysis)模块依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供稀疏数据筛选、脏数据清洗、数据增强三种优化方案帮助提升模型效果。
+- 训练结束后,使用模型分析(analysis)模块对分析模型表现,同时模型分析(analysis)模块依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供稀疏数据筛选、脏数据清洗、数据增强三种优化方案帮助提升模型效果。
- 模型训练、调优完成后,可以通过预测脚本加载最佳模型参数,打印模型预测结果。
**3.模型部署**
-- 现实部署场景需要同时考虑模型的精度和性能表现,文本分类应用接入PaddleNLP 模型压缩 API 。采用了DynaBERT 中宽度自适应裁剪策略,对预训练模型多头注意力机制中的头(Head )进行重要性排序,保证更重要的头(Head )不容易被裁掉,然后用原模型作为蒸馏过程中的教师模型,宽度更小的模型作为学生模型,蒸馏得到的学生模型就是我们裁剪得到的模型。实验表明模型裁剪能够有效缩小模型体积、减少内存占用、提升推理速度。模型裁剪去掉了部分冗余参数的扰动,增加了模型的泛化能力,在部分任务中预测精度得到提高。
+- 现实部署场景需要同时考虑模型的精度和性能表现,文本分类应用接入 PaddleNLP 模型压缩 API 。采用了 DynaBERT 中宽度自适应裁剪策略,对预训练模型多头注意力机制中的头(Head )进行重要性排序,保证更重要的头(Head )不容易被裁掉,然后用原模型作为蒸馏过程中的教师模型,宽度更小的模型作为学生模型,蒸馏得到的学生模型就是我们裁剪得到的模型。实验表明模型裁剪能够有效缩小模型体积、减少内存占用、提升推理速度。模型裁剪去掉了部分冗余参数的扰动,增加了模型的泛化能力,在部分任务中预测精度得到提高。

@@ -222,18 +222,18 @@
- 模型部署需要将保存的最佳模型参数(动态图参数)导出成静态图参数,用于后续的推理部署。p.s.模型裁剪之后会默认导出静态图模型
-- 文本分类应用提供了离线部署,并且支持在GPU设备使用FP16,在CPU设备使用动态量化的低精度加速推理;同时提供基于Paddle Serving的在线服务化部署,详见各分类场景文档中模型部署介绍。
+- 文本分类应用提供了离线部署,并且支持在 GPU 设备使用 FP16,在 CPU 设备使用动态量化的低精度加速推理;同时提供基于 Paddle Serving 的在线服务化部署,详见各分类场景文档中模型部署介绍。
## 3. 快速开始
-- 快速开启多分类 👉 [多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_class#readme)
+- 快速开启多分类 👉 [多分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_class#readme)
-- 快速开启多标签分类 👉 [多标签指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/multi_label#readme)
+- 快速开启多标签分类 👉 [多标签指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/multi_label#readme)
-- 快速开启层次分类 👉 [层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/text_classification/hierarchical#readme)
+- 快速开启层次分类 👉 [层次分类指南](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/text_classification/hierarchical#readme)
@@ -241,15 +241,15 @@
**多分类数据集:**
-- [THUCNews新闻分类数据集](http://thuctc.thunlp.org/)
+- [THUCNews 新闻分类数据集](http://thuctc.thunlp.org/)
- [百科问答分类数据集](https://github.com/brightmart/nlp_chinese_corpus#3%E7%99%BE%E7%A7%91%E7%B1%BB%E9%97%AE%E7%AD%94json%E7%89%88baike2018qa)
-- [头条新闻标题数据集TNEWS](https://github.com/aceimnorstuvwxz/toutiao-text-classfication-dataset)
+- [头条新闻标题数据集 TNEWS](https://github.com/aceimnorstuvwxz/toutiao-text-classfication-dataset)
- [复旦新闻文本数据集](https://www.heywhale.com/mw/dataset/5d3a9c86cf76a600360edd04)
-- [IFLYTEK app应用描述分类数据集](https://storage.googleapis.com/cluebenchmark/tasks/iflytek_public.zip)
+- [IFLYTEK app 应用描述分类数据集](https://storage.googleapis.com/cluebenchmark/tasks/iflytek_public.zip)
- [CAIL 2022事件检测](http://cail.cipsc.org.cn/task1.html?raceID=1&cail_tag=2022)
@@ -263,9 +263,9 @@
- [外卖评论情感分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/waimai_10k/intro.ipynb)
-- [weibo情感二分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/weibo_senti_100k/intro.ipynb)
+- [weibo 情感二分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/weibo_senti_100k/intro.ipynb)
-- [weibo情感四分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/simplifyweibo_4_moods/intro.ipynb)
+- [weibo 情感四分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/simplifyweibo_4_moods/intro.ipynb)
- [商品评论情感分类数据集](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/online_shopping_10_cats/intro.ipynb)
@@ -283,7 +283,7 @@
**层次分类数据集:**
-- [头条新闻标题分类-TNEWS的升级版](https://github.com/aceimnorstuvwxz/toutiao-multilevel-text-classfication-dataset)
+- [头条新闻标题分类-TNEWS 的升级版](https://github.com/aceimnorstuvwxz/toutiao-multilevel-text-classfication-dataset)
- [网页层次分类数据集](https://csri.scu.edu.cn/info/1012/2827.htm)
diff --git a/legacy/applications/text_classification/doccano.md b/slm/applications/text_classification/doccano.md
similarity index 79%
rename from legacy/applications/text_classification/doccano.md
rename to slm/applications/text_classification/doccano.md
index af9ecd7e8b23..ad46df117374 100644
--- a/legacy/applications/text_classification/doccano.md
+++ b/slm/applications/text_classification/doccano.md
@@ -1,4 +1,4 @@
-# 文本分类任务doccano使用指南
+# 文本分类任务 doccano 使用指南
**目录**
@@ -18,7 +18,7 @@
- Python 3.8+
- doccano 1.6.2
-在终端(terminal)使用pip安装doccano:
+在终端(terminal)使用 pip 安装 doccano:
```shell
pip install doccano==1.6.2
@@ -37,13 +37,13 @@ doccano webserver --port 8000
# Start the task queue to handle file upload/download.
doccano task
```
-在浏览器打开[http://127.0.0.1:8000/](http://127.0.0.1:8000/),输入用户名和密码登录,开始使用doccano进行标注。doccano支持中文版本,可以点击右上角选择ZH(中文)。
+在浏览器打开[http://127.0.0.1:8000/](http://127.0.0.1:8000/),输入用户名和密码登录,开始使用 doccano 进行标注。doccano 支持中文版本,可以点击右上角选择 ZH(中文)。
-doccano还支持PostgreSQL、Docker、Docker Compose等安装方式,详情请参考[doccano官方文档](https://github.com/doccano/doccano) 完成doccano的安装与初始配置。
+doccano 还支持 PostgreSQL、Docker、Docker Compose 等安装方式,详情请参考[doccano 官方文档](https://github.com/doccano/doccano) 完成 doccano 的安装与初始配置。
@@ -52,7 +52,7 @@ doccano还支持PostgreSQL、Docker、Docker Compose等安装方式,详情请
文本分类支持多分类、多标签、层次分类三种类型的文本分类任务。
-点击创建(Create)开始创建一个新的项目,选择文本分类,然后填写项目名称、描述、Tags等项目信息。如果是多分类任务或者是单路径层次分类任务,勾选 `Allow single label` ,勾选后标签标注只允许选择一个标签进行标注。点击创建成功创建一个doccano项目。
+点击创建(Create)开始创建一个新的项目,选择文本分类,然后填写项目名称、描述、Tags 等项目信息。如果是多分类任务或者是单路径层次分类任务,勾选 `Allow single label` ,勾选后标签标注只允许选择一个标签进行标注。点击创建成功创建一个 doccano 项目。
@@ -67,8 +67,8 @@ doccano还支持PostgreSQL、Docker、Docker Compose等安装方式,详情请
-doccano支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式,文本分类本地数据集定制训练中**统一使用TextLine**这一文件格式,即上传的文件需要为txt等格式,且在数据标注时,该文件的每一行待标注文本显示为一页内容。
-上传的文件为txt等格式,每一行为一条待标注文本,示例:
+doccano 支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式,文本分类本地数据集定制训练中**统一使用 TextLine**这一文件格式,即上传的文件需要为 txt 等格式,且在数据标注时,该文件的每一行待标注文本显示为一页内容。
+上传的文件为 txt 等格式,每一行为一条待标注文本,示例:
```text
黑苦荞茶的功效与作用及食用方法
@@ -79,7 +79,7 @@ doccano支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式
...
```
-上传数据类型**选择TextLine**,选择待标注文本或拖拽文本导入doccano项目中,点击导入,导入待标注数据集。
+上传数据类型**选择 TextLine**,选择待标注文本或拖拽文本导入 doccano 项目中,点击导入,导入待标注数据集。

@@ -151,7 +151,7 @@ doccano支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式
```
标注数据保存在同一个文本文件中,每条样例占一行且存储为``jsonl``格式,其包含以下字段
-- ``id``: 样本在数据集中的唯一标识ID。
+- ``id``: 样本在数据集中的唯一标识 ID。
- ``data``: 原始文本数据。
- ``label``: 文本对应类别标签。
@@ -159,7 +159,7 @@ doccano支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式
## 7.数据转换
-该章节详细说明如何通过`doccano.py`脚本对doccano平台导出的标注数据进行转换,一键生成训练/验证/测试集。当标注完成后,在 doccano 平台上导出 `JSON` 形式的文件,并将其重命名为 `doccano.jsonl`。
+该章节详细说明如何通过`doccano.py`脚本对 doccano 平台导出的标注数据进行转换,一键生成训练/验证/测试集。当标注完成后,在 doccano 平台上导出 `JSON` 形式的文件,并将其重命名为 `doccano.jsonl`。
### 7.1 多分类任务
@@ -209,17 +209,17 @@ python doccano.py \
稀疏数据识别出的有效标注请增加配置参数`--valid`,脏数据清洗的标注数据(文本中有脏数据标签)请增加配置参数`--dirty`,更多稀疏数据识别和脏数据清洗详见[层次分类训练评估与模型优化指南](hierarchical/analysis/README.md)
可配置参数说明:
-- ``doccano_file``: 从doccano导出的数据标注文件。
+- ``doccano_file``: 从 doccano 导出的数据标注文件。
- ``save_dir``: 训练数据的保存目录,默认存储在``data``目录下。
- ``splits``: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.2]表示按照``8:2``的比例将数据划分为训练集、验证集。
- ``task_type``: 可选,选择任务类型,有多分类,多标签,层次分类三种类型的任务。
-- ``is_shuffle``: 是否对数据集进行随机打散,默认为True。
+- ``is_shuffle``: 是否对数据集进行随机打散,默认为 True。
- ``seed``: 随机种子,默认为1000.
- ``separator``: 不同层标签之间的分隔符,该参数只对层次文本分类任务有效。默认为"##"。
-- ``valid``: 是否为稀疏数据筛选的有效标注数据,默认为False.
-- ``dirty``: 是否为脏数据清洗策略标注数据,默认为False.
+- ``valid``: 是否为稀疏数据筛选的有效标注数据,默认为 False.
+- ``dirty``: 是否为脏数据清洗策略标注数据,默认为 False.
-转化后的doccano标注数据目录结构如下:
+转化后的 doccano 标注数据目录结构如下:
```text
data/
@@ -231,10 +231,10 @@ data/
```
备注:
-- 默认情况下 [doccano.py](./doccano.py) 脚本会按照比例将数据划分成train/dev 数据集,也可以划分为 train/dev/test 数据集。
-- 脚本会自动生成data.txt,如果数据划分为 train/dev/test 数据集,data.txt则为test数据集无标签数据;如果数据划分为 train/dev 数据集,data.txt为无标签数据。**如果有未标注数据,则用未标注数据文件替换data.txt**
+- 默认情况下 [doccano.py](./doccano.py) 脚本会按照比例将数据划分成 train/dev 数据集,也可以划分为 train/dev/test 数据集。
+- 脚本会自动生成 data.txt,如果数据划分为 train/dev/test 数据集,data.txt 则为 test 数据集无标签数据;如果数据划分为 train/dev 数据集,data.txt 为无标签数据。**如果有未标注数据,则用未标注数据文件替换 data.txt**
- 每次执行 [doccano.py](./doccano.py) 脚本,将会覆盖已有的同名数据文件
-- 对于从doccano导出的文件,默认文件中的每条数据都是经过人工正确标注的。
+- 对于从 doccano 导出的文件,默认文件中的每条数据都是经过人工正确标注的。
## References
- **[doccano](https://github.com/doccano/doccano)**
diff --git a/legacy/applications/text_classification/doccano.py b/slm/applications/text_classification/doccano.py
similarity index 100%
rename from legacy/applications/text_classification/doccano.py
rename to slm/applications/text_classification/doccano.py
diff --git a/legacy/applications/text_classification/hierarchical/README.md b/slm/applications/text_classification/hierarchical/README.md
similarity index 74%
rename from legacy/applications/text_classification/hierarchical/README.md
rename to slm/applications/text_classification/hierarchical/README.md
index 98ae356572ac..de7a80b91e21 100644
--- a/legacy/applications/text_classification/hierarchical/README.md
+++ b/slm/applications/text_classification/hierarchical/README.md
@@ -14,7 +14,7 @@
## 1. 层次分类简介
-本项目提供通用场景下**基于预训练模型微调的层次分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低AI开发落地门槛。
+本项目提供通用场景下**基于预训练模型微调的层次分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低 AI 开发落地门槛。
层次文本分类任务的中数据样本具有多个标签且标签之间存在特定的层级结构,目标是**预测输入句子/文本可能来自于不同级标签类别中的某一个或几个类别**。以下图新闻文本分类为例,该新闻的一级标签为体育,二级标签为足球,体育与足球之间存在层级关系。在现实场景中,大量的数据如新闻分类、专利分类、学术论文分类等标签集合存在层次化结构,需要利用算法为文本自动标注更细粒度和更准确的标签。
@@ -25,8 +25,8 @@
**方案亮点:**
-- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
+- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的 ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
- **简单易用👶:** 开发者**无需机器学习背景知识**,仅需提供指定格式的标注分类数据,一行命令即可开启文本分类训练,轻松完成上线部署,不再让技术成为文本分类的门槛。
**更多选择:**
@@ -67,20 +67,20 @@ rm baidu_extract_2020.tar.gz
- paddlenlp >= 2.4.8
- scikit-learn >= 1.0.2
-**安装PaddlePaddle:**
+**安装 PaddlePaddle:**
- 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+ 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-**安装PaddleNLP:**
+**安装 PaddleNLP:**
-安装PaddleNLP默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(删去 -i https://mirror.baidu.com/pypi/simple),更多关于PaddleNLP安装的详细教程请查见[PaddleNLP快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+安装 PaddleNLP 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(删去 -i https://mirror.baidu.com/pypi/simple),更多关于 PaddleNLP 安装的详细教程请查见[PaddleNLP 快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
```shell
python3 -m pip install --upgrade paddlenlp -i https://mirror.baidu.com/pypi/simple
```
-**安装sklearn:**
+**安装 sklearn:**
```shell
python3 -m pip install scikit-learn==1.0.2
```
@@ -122,7 +122,7 @@ data/
└── data.txt # 待预测数据文件(可选)
```
-**训练、开发、测试数据集文件:** 文本与标签类别名用tab符`'\t'`分隔开,标签中多个标签之间用英文逗号`','`分隔开,文本中避免出现tab符`'\t'`。
+**训练、开发、测试数据集文件:** 文本与标签类别名用 tab 符`'\t'`分隔开,标签中多个标签之间用英文逗号`','`分隔开,文本中避免出现 tab 符`'\t'`。
- train.txt/dev.txt/test.txt 文件格式:
```text
@@ -182,7 +182,7 @@ data/
#### 2.4.1 预训练模型微调
-使用CPU/GPU训练,默认为GPU训练。使用CPU训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定GPU卡号:
+使用 CPU/GPU 训练,默认为 GPU 训练。使用 CPU 训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定 GPU 卡号:
```shell
python train.py \
--dataset_dir "data" \
@@ -194,7 +194,7 @@ python train.py \
--epochs 100
```
-如果在GPU环境中使用,可以指定`gpus`参数进行单卡/多卡训练。使用多卡训练可以指定多个GPU卡号,例如 --gpus "0,1"。如果设备只有一个GPU卡号默认为0,可使用`nvidia-smi`命令查看GPU使用情况。
+如果在 GPU 环境中使用,可以指定`gpus`参数进行单卡/多卡训练。使用多卡训练可以指定多个 GPU 卡号,例如 --gpus "0,1"。如果设备只有一个 GPU 卡号默认为0,可使用`nvidia-smi`命令查看 GPU 使用情况。
```shell
unset CUDA_VISIBLE_DEVICES
@@ -211,21 +211,21 @@ python -m paddle.distributed.launch --gpus "0" train.py \
可支持配置的参数:
-* `device`: 选用什么设备进行训练,选择cpu、gpu、xpu、npu。如使用gpu训练,可使用参数--gpus指定GPU卡号;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt,dev.txt和label.txt文件;默认为None。
-* `save_dir`:保存训练模型的目录;默认保存在当前目录checkpoint文件夹下。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `device`: 选用什么设备进行训练,选择 cpu、gpu、xpu、npu。如使用 gpu 训练,可使用参数--gpus 指定 GPU 卡号;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt,dev.txt 和 label.txt 文件;默认为 None。
+* `save_dir`:保存训练模型的目录;默认保存在当前目录 checkpoint 文件夹下。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `model_name`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh",根据任务复杂度和硬件条件进行选择。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `learning_rate`:训练最大学习率;默认为3e-5。
* `epochs`: 训练轮次,使用早停法时可以选择100;默认为10。
-* `early_stop`:选择是否使用早停法(EarlyStopping),模型在开发集经过一定epoch后精度表现不再上升,训练终止;默认为False。
+* `early_stop`:选择是否使用早停法(EarlyStopping),模型在开发集经过一定 epoch 后精度表现不再上升,训练终止;默认为 False。
* `early_stop_nums`:在设定的早停训练轮次内,模型在开发集上表现不再上升,训练终止;默认为10。
-* `logging_steps`: 训练过程中日志打印的间隔steps数,默认5。
+* `logging_steps`: 训练过程中日志打印的间隔 steps 数,默认5。
* `weight_decay`:控制正则项力度的参数,用于防止过拟合,默认为0.0。
-* `warmup`:是否使用学习率warmup策略,使用时应设置适当的训练轮次(epochs);默认为False。
-* `warmup_steps`:学习率warmup策略的比例数,如果设为1000,则学习率会在1000steps数从0慢慢增长到learning_rate, 而后再缓慢衰减;默认为0。
-* `init_from_ckpt`: 模型初始checkpoint参数地址,默认None。
+* `warmup`:是否使用学习率 warmup 策略,使用时应设置适当的训练轮次(epochs);默认为 False。
+* `warmup_steps`:学习率 warmup 策略的比例数,如果设为1000,则学习率会在1000steps 数从0慢慢增长到 learning_rate, 而后再缓慢衰减;默认为0。
+* `init_from_ckpt`: 模型初始 checkpoint 参数地址,默认 None。
* `seed`:随机种子,默认为3。
* `train_file`:本地数据集中训练集文件名;默认为"train.txt"。
* `dev_file`:本地数据集中开发集文件名;默认为"dev.txt"。
@@ -244,16 +244,16 @@ checkpoint/
**NOTE:**
* 如需恢复模型训练,则可以设置 `--init_from_ckpt checkpoint/model_state.pdparams` 。
* 如需训练英文文本分类任务,只需更换预训练模型参数 `model_name` 。英文训练任务推荐使用"ernie-2.0-base-en"、"ernie-2.0-large-en"。
-* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M论文](https://arxiv.org/pdf/2012.15674.pdf)。
+* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M 论文](https://arxiv.org/pdf/2012.15674.pdf)。
#### 2.4.2 训练评估与模型优化
-文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis模块](./analysis) 提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis 模块](./analysis) 提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
-**模型评估:** 训练后的模型我们可以使用 [Analysis模块](./analysis) 对每个类别分别进行评估,并输出预测错误样本(bad case),默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`:
+**模型评估:** 训练后的模型我们可以使用 [Analysis 模块](./analysis) 对每个类别分别进行评估,并输出预测错误样本(bad case),默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`:
```shell
python analysis/evaluate.py --device "gpu" --max_seq_length 128 --batch_size 32 --bad_case_file "bad_case.txt" --dataset_dir "data" --params_path "./checkpoint"
@@ -277,14 +277,14 @@ python analysis/evaluate.py --device "gpu" --max_seq_length 128 --batch_size 32
...
```
-预测错误的样本保存在bad_case.txt文件中:
+预测错误的样本保存在 bad_case.txt 文件中:
```text
-Text Label Prediction
-据猛龙随队记者JoshLewenberg报道,消息人士透露,猛龙已将前锋萨加巴-科纳特裁掉。此前他与猛龙签下了一份Exhibit10合同。在被裁掉后,科纳特下赛季大概率将前往猛龙的发展联盟球队效力。 组织关系,组织关系##加盟,组织关系##裁员 组织关系,组织关系##解雇
-冠军射手被裁掉,欲加入湖人队,但湖人却无意,冠军射手何去何从 组织关系,组织关系##裁员 组织关系,组织关系##解雇
-6月7日报道,IBM将裁员超过1000人。IBM周四确认,将裁减一千多人。据知情人士称,此次裁员将影响到约1700名员工,约占IBM全球逾34万员工中的0.5%。IBM股价今年累计上涨16%,但该公司4月发布的财报显示,一季度营收下降5%,低于市场预期。 组织关系,组织关系##裁员 组织关系,组织关系##裁员,财经/交易
-有多名魅族员工表示,从6月份开始,魅族开始了新一轮裁员,重点裁员区域是营销和线下。裁员占比超过30%,剩余员工将不过千余人,魅族的知名工程师,爱讲真话的洪汉生已经从钉钉里退出了,外界传言说他去了OPPO。 组织关系,组织关系##退出,组织关系##裁员 组织关系,组织关系##裁员
+Text Label Prediction
+据猛龙随队记者JoshLewenberg报道,消息人士透露,猛龙已将前锋萨加巴-科纳特裁掉。此前他与猛龙签下了一份Exhibit10合同。在被裁掉后,科纳特下赛季大概率将前往猛龙的发展联盟球队效力。 组织关系,组织关系##加盟,组织关系##裁员 组织关系,组织关系##解雇
+冠军射手被裁掉,欲加入湖人队,但湖人却无意,冠军射手何去何从 组织关系,组织关系##裁员 组织关系,组织关系##解雇
+6月7日报道,IBM将裁员超过1000人。IBM周四确认,将裁减一千多人。据知情人士称,此次裁员将影响到约1700名员工,约占IBM全球逾34万员工中的0.5%。IBM股价今年累计上涨16%,但该公司4月发布的财报显示,一季度营收下降5%,低于市场预期。 组织关系,组织关系##裁员 组织关系,组织关系##裁员,财经/交易
+有多名魅族员工表示,从6月份开始,魅族开始了新一轮裁员,重点裁员区域是营销和线下。裁员占比超过30%,剩余员工将不过千余人,魅族的知名工程师,爱讲真话的洪汉生已经从钉钉里退出了,外界传言说他去了OPPO。 组织关系,组织关系##退出,组织关系##裁员 组织关系,组织关系##裁员
...
```
@@ -301,20 +301,20 @@ text: 据猛龙随队记者JoshLewenberg报道,消息人士透露,猛龙已
predict label: 组织关系,组织关系##解雇
label: 组织关系,组织关系##加盟,组织关系##裁员
examples with positive influence
-support1 text: 尼克斯官方今日宣布,他们已经裁掉了前锋扎克-欧文,后者昨日才与尼克斯签约。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.99357
-support2 text: 活塞官方今日宣布,他们已经签下了克雷格-斯沃德,并且裁掉了托德-威瑟斯。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.98344
-support3 text: 孟菲斯灰熊今年宣布,球队已经签下后卫达斯蒂-汉纳斯(DustyHannahs,版头图)并裁掉马特-穆尼。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.98219
+support1 text: 尼克斯官方今日宣布,他们已经裁掉了前锋扎克-欧文,后者昨日才与尼克斯签约。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.99357
+support2 text: 活塞官方今日宣布,他们已经签下了克雷格-斯沃德,并且裁掉了托德-威瑟斯。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.98344
+support3 text: 孟菲斯灰熊今年宣布,球队已经签下后卫达斯蒂-汉纳斯(DustyHannahs,版头图)并裁掉马特-穆尼。 label: 组织关系,组织关系##加盟,组织关系##解雇 score: 0.98219
...
```
-**数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果,策略细节详见[训练评估与模型优化指南](analysis/README.md)。
+**数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果,策略细节详见[训练评估与模型优化指南](analysis/README.md)。
- 稀疏数据筛选主要是解决数据不均衡、训练数据覆盖不足的问题,通过数据增强和数据标注两种方式解决这一问题。
- 脏数据清洗可以帮助开发者筛选训练集中错误标注的数据,对这些数据重新进行人工标注,得到标注正确的数据再重新进行训练。
- 数据增强策略提供多种数据增强方案,可以快速扩充数据,提高模型泛化性和鲁棒性。
#### 2.4.3 模型预测
-训练结束后,输入待预测数据(data.txt)和类别标签对照列表(label.txt),使用训练好的模型进行,默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`:
+训练结束后,输入待预测数据(data.txt)和类别标签对照列表(label.txt),使用训练好的模型进行,默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`:
```shell
python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_dir "data"
@@ -322,8 +322,8 @@ python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_
可支持配置的参数:
-* `device`: 选用什么设备进行预测,可选cpu、gpu、xpu、npu;默认为gpu。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含data.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行预测,可选 cpu、gpu、xpu、npu;默认为 gpu。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 data.txt 和 label.txt 文件;默认为 None。
* `params_path`:待预测模型的目录;默认为"./checkpoint/"。
* `max_seq_length`:模型使用的最大序列长度,建议与训练时最大序列长度一致, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
@@ -343,13 +343,13 @@ python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_
python export_model.py --params_path ./checkpoint/ --output_path ./export
```
-如果使用多语言模型 ERNIE M作为预训练模型,运行方式:
+如果使用多语言模型 ERNIE M 作为预训练模型,运行方式:
```shell
python export_model.py --params_path ./checkpoint/ --output_path ./export --multilingual
```
可支持配置的参数:
-* `multilingual`:是否为多语言任务(是否使用ERNIE M作为预训练模型);默认为False。
+* `multilingual`:是否为多语言任务(是否使用 ERNIE M 作为预训练模型);默认为 False。
* `params_path`:动态图训练保存的参数路径;默认为"./checkpoint/"。
* `output_path`:静态图图保存的参数路径;默认为"./export"。
@@ -361,10 +361,10 @@ export/
├── float32.pdiparams.info
└── float32.pdmodel
```
- 导出模型之后用于部署,项目提供了基于ONNXRuntime的 [离线部署方案](./deploy/predictor/README.md) 和基于Paddle Serving的 [在线服务化部署方案](./deploy/predictor/README.md)。
+ 导出模型之后用于部署,项目提供了基于 ONNXRuntime 的 [离线部署方案](./deploy/predictor/README.md) 和基于 Paddle Serving 的 [在线服务化部署方案](./deploy/predictor/README.md)。
#### 2.5.2 模型裁剪
-如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
+如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
使用裁剪功能需要安装 paddleslim:
@@ -372,7 +372,7 @@ export/
pip install paddleslim==2.4.1
```
-开始模型裁剪训练,默认为GPU训练,使用CPU训练只需将设备参数配置改为`--device "cpu"`:
+开始模型裁剪训练,默认为 GPU 训练,使用 CPU 训练只需将设备参数配置改为`--device "cpu"`:
```shell
python prune.py \
--device "gpu" \
@@ -390,17 +390,17 @@ python prune.py \
可支持配置的参数:
-* `output_dir`:必须,保存模型输出和中间checkpoint的输出目录;默认为 `None` 。
-* `device`: 选用什么设备进行裁剪,选择cpu、gpu。如使用gpu训练,可使用参数--gpus指定GPU卡号。
+* `output_dir`:必须,保存模型输出和中间 checkpoint 的输出目录;默认为 `None` 。
+* `device`: 选用什么设备进行裁剪,选择 cpu、gpu。如使用 gpu 训练,可使用参数--gpus 指定 GPU 卡号。
* `per_device_train_batch_size`:训练集裁剪训练过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `per_device_eval_batch_size`:开发集评测过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `learning_rate`:训练最大学习率;默认为5e-5。
* `num_train_epochs`: 训练轮次,使用早停法时可以选择100;默认为10。
-* `logging_steps`: 训练过程中日志打印的间隔steps数,默认100。
-* `save_steps`: 训练过程中保存模型checkpoint的间隔steps数,默认100。
+* `logging_steps`: 训练过程中日志打印的间隔 steps 数,默认100。
+* `save_steps`: 训练过程中保存模型 checkpoint 的间隔 steps 数,默认100。
* `seed`:随机种子,默认为3。
-* `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对self_attention中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed数量)应为整数;默认是None。
-* `dataset_dir`:本地数据集路径,需包含train.txt,dev.txt,label.txt;默认为None。
+* `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对 self_attention 中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed 数量)应为整数;默认是 None。
+* `dataset_dir`:本地数据集路径,需包含 train.txt,dev.txt,label.txt;默认为 None。
* `max_seq_length`:模型使用的最大序列长度,建议与训练过程保持一致, 若出现显存不足,请适当调低这一参数;默认为128。
* `params_dir`:待预测模型参数文件;默认为"./checkpoint/"。
@@ -421,15 +421,15 @@ prune/
1. 目前支持的裁剪策略需要训练,训练时间视下游任务数据量而定,且和微调的训练时间是一个量级。 裁剪类似蒸馏过程,方便起见,可以直接使用微调时的超参。为了进一步提升精度,可以对 `per_device_train_batch_size`、`learning_rate`、`num_train_epochs`、`max_seq_length` 等超参进行网格搜索(grid search)。
-2. 模型裁剪主要用于推理部署,因此裁剪后的模型都是静态图模型,只可用于推理部署,不能再通过 `from_pretrained` 导入继续训练。导出模型之后用于部署,项目提供了基于ONNXRuntime的 [离线部署方案](./deploy/predictor/README.md) 和基于Paddle Serving的 [在线服务化部署方案](./deploy/predictor/README.md)。
+2. 模型裁剪主要用于推理部署,因此裁剪后的模型都是静态图模型,只可用于推理部署,不能再通过 `from_pretrained` 导入继续训练。导出模型之后用于部署,项目提供了基于 ONNXRuntime 的 [离线部署方案](./deploy/predictor/README.md) 和基于 Paddle Serving 的 [在线服务化部署方案](./deploy/predictor/README.md)。
-3. ERNIE Base、Medium、Mini、Micro、Nano的模型宽度(multi head数量)为12,ERNIE Xbase、Large 模型宽度(multi head数量)为16,保留比例`width_mult`乘以宽度(multi haed数量)应为整数。
+3. ERNIE Base、Medium、Mini、Micro、Nano 的模型宽度(multi head 数量)为12,ERNIE Xbase、Large 模型宽度(multi head 数量)为16,保留比例`width_mult`乘以宽度(multi haed 数量)应为整数。
#### 2.5.3 部署方案
- 离线部署搭建请参考[离线部署](deploy/predictor/README.md)。
-- 在线服务化部署搭建请参考 [PaddleNLP SimpleServing部署指南](deploy/simple_serving/README.md) 或 [Triton部署指南](deploy/triton_serving/README.md)。
+- 在线服务化部署搭建请参考 [PaddleNLP SimpleServing 部署指南](deploy/simple_serving/README.md) 或 [Triton 部署指南](deploy/triton_serving/README.md)。
@@ -459,7 +459,7 @@ prune/
4. PaddleNLP 版本:2.4
-5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU部署运行时间 total_time,计算 latency = total_time / total_samples
+5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU 部署运行时间 total_time,计算 latency = total_time / total_samples
6. 精度评价指标:Micro F1分数、Macro F1分数
diff --git a/legacy/applications/text_classification/hierarchical/analysis/README.md b/slm/applications/text_classification/hierarchical/analysis/README.md
similarity index 78%
rename from legacy/applications/text_classification/hierarchical/analysis/README.md
rename to slm/applications/text_classification/hierarchical/analysis/README.md
index 68dce6680b3b..cc18f13daa96 100644
--- a/legacy/applications/text_classification/hierarchical/analysis/README.md
+++ b/slm/applications/text_classification/hierarchical/analysis/README.md
@@ -1,7 +1,7 @@
# 训练评估与模型优化指南
**目录**
- * [Analysis模块介绍](#Analysis模块介绍)
+ * [Analysis 模块介绍](#Analysis 模块介绍)
* [环境准备](#环境准备)
* [模型评估](#模型评估)
* [可解释性分析](#可解释性分析)
@@ -12,15 +12,15 @@
* [脏数据清洗方案](#脏数据清洗方案)
* [数据增强策略方案](#数据增强策略方案)
-## Analysis模块介绍
+## Analysis 模块介绍
-Analysis模块提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+Analysis 模块提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
- **模型评估:** 对整体分类情况和每个类别分别进行评估,并打印预测错误样本,帮助开发者分析模型表现找到训练和预测数据中存在的问题。
- **可解释性分析:** 基于[TrustAI](https://github.com/PaddlePaddle/TrustAI)提供单词和句子级别的模型可解释性分析,帮助理解模型预测结果。
-- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。
+- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。

@@ -44,12 +44,12 @@ analysis/
- trustai >= 0.1.7
- interpretdl >= 0.7.0
-**安装TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装TrustAI。
+**安装 TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装 TrustAI。
```shell
pip install trustai==0.1.7
```
-**安装InterpretDL**(可选)如果使用词级别可解释性分析GradShap方法,需要安装InterpretDL
+**安装 InterpretDL**(可选)如果使用词级别可解释性分析 GradShap 方法,需要安装 InterpretDL
```shell
pip install interpretdl==0.7.0
```
@@ -68,14 +68,14 @@ python evaluate.py \
--bad_case_file "bad_case.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `dev_file`:本地数据集中开发集文件名;默认为"dev.txt"。
* `label_file`:本地数据集中标签集文件名;默认为"label.txt"。
@@ -101,7 +101,7 @@ python evaluate.py \
...
```
-预测错误的样本保存在bad_case.txt文件中:
+预测错误的样本保存在 bad_case.txt 文件中:
```text
Text Label Prediction
@@ -113,10 +113,10 @@ Text Label Prediction
```
## 可解释性分析
-"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于TrustAI开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
+"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于 TrustAI 开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
### 单词级别可解释性分析
-本项目开源模型的词级别可解释性分析Notebook,提供LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用Jupyter Notebook进行数据分析。
+本项目开源模型的词级别可解释性分析 Notebook,提供 LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用 Jupyter Notebook 进行数据分析。
运行 `word_interpret.ipynb`代码,即可分析影响样本预测结果的关键词以及可视化所有词对预测结果的贡献情况,颜色越深代表这个词对预测结果影响越大:
@@ -160,14 +160,14 @@ python sent_interpret.py \
--interpret_result_file "sent_interpret.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `top_k`:筛选支持训练证据数量;默认为3。
@@ -193,7 +193,7 @@ support3 text: 孟菲斯灰熊今年宣布,球队已经签下后卫达斯蒂-
稀疏数据筛选适用于文本分类中**数据不平衡或训练数据覆盖不足**的场景,简单来说,就是由于模型在训练过程中没有学习到足够与待预测样本相似的数据,模型难以正确预测样本所属类别的情况。稀疏数据筛选旨在开发集中挖掘缺乏训练证据支持的数据,通常可以采用**数据增强**或**少量数据标注**的两种低成本方式,提升模型在开发集的预测效果。
-本项目中稀疏数据筛选基于TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
+本项目中稀疏数据筛选基于 TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
#### 稀疏数据识别—数据增强
@@ -220,15 +220,15 @@ python sparse.py \
--support_num 100
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `aug_strategy`:数据增强类型,可选"duplicate","substitute", "insert", "delete", "swap";默认为"substitute"。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -286,15 +286,15 @@ python sparse.py \
--unlabeled_file "data.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
-* `annotate`:选择稀疏数据识别--数据标注模式;默认为False。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
+* `annotate`:选择稀疏数据识别--数据标注模式;默认为 False。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -309,7 +309,7 @@ python sparse.py \
* `sparse_file`:保存在本地数据集路径中稀疏数据文件名;默认为"sparse.txt"。
* `support_file`:保存在本地数据集路径中支持训练数据文件名;默认为"support.txt"。
-我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
+我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
```shell
cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
@@ -331,7 +331,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
脏数据清洗方案是基于已训练好的文本分类模型,筛选出训练数据集中标注错误的数据,再由人工检查重新标注,获得标注正确的数据集进行重新训练。我们将介绍脏数据清洗流程:
-- **脏数据筛选:** 基于TrustAI中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
+- **脏数据筛选:** 基于 TrustAI 中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
- **数据清洗、训练:** 将筛选出的脏数据由人工重新检查,为数据打上正确的标签。将清洗后的训练数据重新放入文本分类模型进行训练。
@@ -349,14 +349,14 @@ python dirty.py \
--rest_file "train_dirty_rest.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt和label.txt文件;默认为None。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt 和 label.txt 文件;默认为 None。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `dirty_file`:保存脏数据文件名,默认为"train_dirty.txt"。
@@ -365,7 +365,7 @@ python dirty.py \
* `dirty_threshold`:筛选脏数据用于重新标注的阈值,只选择影响分数大于阈值作为支持数据,默认为0。
-我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具doccano帮助更快重新标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
+我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具 doccano 帮助更快重新标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
```shell
cat ../data/train_dirty_rest.txt ../data/train_dirty.txt > ../data/train_clean.txt
@@ -400,10 +400,10 @@ python aug.py \
* `train_path`:待增强训练数据集文件路径;默认为"../data/train.txt"。
* `aug_path`:增强生成的训练数据集文件路径;默认为"../data/train_aug.txt"。
* `aug_strategy`:数据增强策略,可选"mix", "substitute", "insert", "delete", "swap","mix"为多种数据策略混合使用;默认为"substitute"。
-* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在GPU环境下使用mlm类型;默认为"synonym"。
+* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在 GPU 环境下使用 mlm 类型;默认为"synonym"。
* `create_n`:生成的句子数量,默认为2。
* `aug_percent`:生成词替换百分比,默认为0.1。
-* `device`: 选用什么设备进行增强,可选择cpu、gpu、xpu、npu,仅在使用mlm类型有影响;默认为"gpu"。
+* `device`: 选用什么设备进行增强,可选择 cpu、gpu、xpu、npu,仅在使用 mlm 类型有影响;默认为"gpu"。
生成的增强数据保存在`"aug.txt"`文件中,与训练集数据`train.txt`合并得到新的训练集`train_aug.txt`重新进行训练:
@@ -411,7 +411,7 @@ python aug.py \
cat ../data/aug.txt ../data/train.txt > ../data/train_aug.txt
```
-PaddleNLP内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
+PaddleNLP 内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
**方案效果**
diff --git a/legacy/applications/text_classification/hierarchical/analysis/aug.py b/slm/applications/text_classification/hierarchical/analysis/aug.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/aug.py
rename to slm/applications/text_classification/hierarchical/analysis/aug.py
diff --git a/legacy/applications/text_classification/hierarchical/analysis/dirty.py b/slm/applications/text_classification/hierarchical/analysis/dirty.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/dirty.py
rename to slm/applications/text_classification/hierarchical/analysis/dirty.py
diff --git a/legacy/applications/text_classification/hierarchical/analysis/evaluate.py b/slm/applications/text_classification/hierarchical/analysis/evaluate.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/evaluate.py
rename to slm/applications/text_classification/hierarchical/analysis/evaluate.py
diff --git a/legacy/applications/text_classification/hierarchical/analysis/sent_interpret.py b/slm/applications/text_classification/hierarchical/analysis/sent_interpret.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/sent_interpret.py
rename to slm/applications/text_classification/hierarchical/analysis/sent_interpret.py
diff --git a/legacy/applications/text_classification/hierarchical/analysis/sparse.py b/slm/applications/text_classification/hierarchical/analysis/sparse.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/sparse.py
rename to slm/applications/text_classification/hierarchical/analysis/sparse.py
diff --git a/legacy/applications/text_classification/hierarchical/analysis/word_interpret.ipynb b/slm/applications/text_classification/hierarchical/analysis/word_interpret.ipynb
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/analysis/word_interpret.ipynb
rename to slm/applications/text_classification/hierarchical/analysis/word_interpret.ipynb
diff --git a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/README.md b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/README.md
similarity index 71%
rename from legacy/applications/text_classification/hierarchical/deploy/paddle_serving/README.md
rename to slm/applications/text_classification/hierarchical/deploy/paddle_serving/README.md
index dde838a31d34..c53880ac1eab 100644
--- a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/README.md
+++ b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/README.md
@@ -1,4 +1,4 @@
-# 基于Paddle Serving的服务化部署
+# 基于 Paddle Serving 的服务化部署
本文档将介绍如何使用[Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/develop/README_CN.md)工具搭建层次分类在线服务部署。
@@ -8,37 +8,37 @@
- [部署模型](#部署模型)
## 环境准备
-需要准备PaddleNLP的运行环境和Paddle Serving的运行环境。
+需要准备 PaddleNLP 的运行环境和 Paddle Serving 的运行环境。
- python >= 3.6
- paddlepaddle >= 2.3
- paddlenlp >= 2.4
-### 安装PaddlePaddle
+### 安装 PaddlePaddle
- 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+ 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-### 安装PaddleNLP
+### 安装 PaddleNLP
-安装PaddleNLP默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以删去` -i https://mirror.baidu.com/pypi/simple` ,更多关于PaddleNLP安装的详细教程请查见[PaddleNLP快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+安装 PaddleNLP 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以删去` -i https://mirror.baidu.com/pypi/simple` ,更多关于 PaddleNLP 安装的详细教程请查见[PaddleNLP 快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
```shell
python3 -m pip install --upgrade paddlenlp -i https://mirror.baidu.com/pypi/simple
```
-### 安装Paddle Serving
+### 安装 Paddle Serving
-安装client和serving app,用于向服务发送请求:
+安装 client 和 serving app,用于向服务发送请求:
```shell
pip install paddle_serving_app paddle_serving_client
```
-安装serving,用于启动服务,根据服务器设备选择安装CPU server或GPU server:
+安装 serving,用于启动服务,根据服务器设备选择安装 CPU server 或 GPU server:
-- 安装CPU server
+- 安装 CPU server
```shell
pip install paddle_serving_server
```
-- 安装GPU server, 注意选择跟本地环境一致的命令
+- 安装 GPU server, 注意选择跟本地环境一致的命令
```shell
# CUDA10.2 + Cudnn7 + TensorRT6
pip install paddle-serving-server-gpu==0.8.3.post102 -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -52,14 +52,14 @@ pip install paddle-serving-server-gpu==0.8.3.post112 -i https://pypi.tuna.tsingh
**NOTE:**
- 默认开启国内清华镜像源来加速下载,如果您使用 HTTP 代理可以关闭(-i https://pypi.tuna.tsinghua.edu.cn/simple)
-- 更多wheel包请参考[serving官网文档](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)
+- 更多 wheel 包请参考[serving 官网文档](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)
## 模型转换
-使用Paddle Serving做服务化部署时,需要将保存的inference模型转换为serving易于部署的模型。
+使用 Paddle Serving 做服务化部署时,需要将保存的 inference 模型转换为 serving 易于部署的模型。
-用已安装的paddle_serving_client将静态图参数模型转换成serving格式。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型地址`dirname`,模型文件和参数名`model_filename`,`params_filename`根据实际填写即可。
+用已安装的 paddle_serving_client 将静态图参数模型转换成 serving 格式。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型地址`dirname`,模型文件和参数名`model_filename`,`params_filename`根据实际填写即可。
```shell
python -m paddle_serving_client.convert --dirname ../../export --model_filename float32.pdmodel --params_filename float32.pdiparams
@@ -85,7 +85,7 @@ paddle_serving/
## 部署模型
-serving目录包含启动pipeline服务和发送预测请求的代码和模型,包括:
+serving 目录包含启动 pipeline 服务和发送预测请求的代码和模型,包括:
```
serving/
@@ -128,7 +128,7 @@ python service.py --max_seq_length 128 --model_name "ernie-3.0-medium-zh"
```
可支持配置的参数:
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `model_name`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh",根据实际使用的预训练模型选择。
输出打印如下:
@@ -146,8 +146,8 @@ I0727 06:50:34.993671 43126 naive_executor.cc:102] --- skip [linear_75.tmp_1],
[OP Object] init success
```
-#### 启动rpc client测试
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)
+#### 启动 rpc client 测试
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)
```shell
python rpc_client.py
```
@@ -163,8 +163,8 @@ text: 金属卡扣安装不到位,上海乐扣乐扣贸易有限公司将召
label: 产品行为,产品行为##召回
--------------------
```
-#### 启动http client测试
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)
+#### 启动 http client 测试
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)
```shell
python http_client.py
```
diff --git a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/config.yml b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/config.yml
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/paddle_serving/config.yml
rename to slm/applications/text_classification/hierarchical/deploy/paddle_serving/config.yml
diff --git a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/http_client.py b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/http_client.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/paddle_serving/http_client.py
rename to slm/applications/text_classification/hierarchical/deploy/paddle_serving/http_client.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/rpc_client.py b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/rpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/paddle_serving/rpc_client.py
rename to slm/applications/text_classification/hierarchical/deploy/paddle_serving/rpc_client.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/paddle_serving/service.py b/slm/applications/text_classification/hierarchical/deploy/paddle_serving/service.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/paddle_serving/service.py
rename to slm/applications/text_classification/hierarchical/deploy/paddle_serving/service.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/predictor/README.md b/slm/applications/text_classification/hierarchical/deploy/predictor/README.md
similarity index 56%
rename from legacy/applications/text_classification/hierarchical/deploy/predictor/README.md
rename to slm/applications/text_classification/hierarchical/deploy/predictor/README.md
index 232293fffb39..5fe1ac0a1c30 100644
--- a/legacy/applications/text_classification/hierarchical/deploy/predictor/README.md
+++ b/slm/applications/text_classification/hierarchical/deploy/predictor/README.md
@@ -1,25 +1,25 @@
-# 基于ONNXRuntime推理部署指南
+# 基于 ONNXRuntime 推理部署指南
**目录**
* [环境准备](#环境准备)
- * [基于GPU部署推理样例](#基于GPU部署推理样例)
- * [基于CPU部署推理样例](#基于CPU部署推理样例)
+ * [基于 GPU 部署推理样例](#基于 GPU 部署推理样例)
+ * [基于 CPU 部署推理样例](#基于 CPU 部署推理样例)
* [性能与精度测试](#性能与精度测试)
## 环境准备
-模型转换与ONNXRuntime预测部署依赖Paddle2ONNX和ONNXRuntime,Paddle2ONNX支持将Paddle静态图模型转化为ONNX模型格式,算子目前稳定支持导出ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[静态图导出](../../README.md),模型使用裁剪API进行裁剪之后会自动生成静态图模型。
+模型转换与 ONNXRuntime 预测部署依赖 Paddle2ONNX 和 ONNXRuntime,Paddle2ONNX 支持将 Paddle 静态图模型转化为 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[静态图导出](../../README.md),模型使用裁剪 API 进行裁剪之后会自动生成静态图模型。
-如果基于GPU部署,请先确保机器已正确安装NVIDIA相关驱动和基础软件,确保CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
+如果基于 GPU 部署,请先确保机器已正确安装 NVIDIA 相关驱动和基础软件,确保 CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
```shell
python -m pip install onnxruntime-gpu onnx onnxconverter-common==1.9.0 psutil paddle2onnx==1.0.5
```
-如果基于CPU部署,请使用如下命令安装所需依赖:
+如果基于 CPU 部署,请使用如下命令安装所需依赖:
```shell
python -m pip install onnxruntime psutil
```
-## 基于GPU部署推理样例
+## 基于 GPU 部署推理样例
请使用如下命令进行部署
```
python infer.py \
@@ -35,17 +35,17 @@ python infer.py \
* `model_path_prefix`:必须,待推理模型路径前缀。
* `model_name_or_path`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh",根据实际使用的预训练模型选择。
-* `max_seq_length`:ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
-* `use_fp16`:选择是否开启FP16进行加速;默认为False。
+* `max_seq_length`:ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `use_fp16`:选择是否开启 FP16进行加速;默认为 False。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `device`: 选用什么设备进行训练,可选cpu、gpu。
-* `device_id`: 选择GPU卡号;默认为0。
-* `perf`:选择进行模型性能和精度评估;默认为False。
-* `dataset_dir`:本地数据集地址,需包含data.txt, label.txt, test.txt/dev.txt(可选,如果启动模型性能和精度评估);默认为None。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu。
+* `device_id`: 选择 GPU 卡号;默认为0。
+* `perf`:选择进行模型性能和精度评估;默认为 False。
+* `dataset_dir`:本地数据集地址,需包含 data.txt, label.txt, test.txt/dev.txt(可选,如果启动模型性能和精度评估);默认为 None。
* `perf_dataset`:评估数据集,可选'dev'、'test',选择在开发集或测试集评估模型;默认为"dev"。
-型);默认为False。
+型);默认为 False。
-在GPU设备的CUDA计算能力 (CUDA Compute Capability) 大于7.0,在包括V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启FP16进行加速,在CPU或者CUDA计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。可以使用如下命令开启ONNXRuntime的FP16进行推理加速:
+在 GPU 设备的 CUDA 计算能力 (CUDA Compute Capability) 大于7.0,在包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启 FP16进行加速,在 CPU 或者 CUDA 计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。可以使用如下命令开启 ONNXRuntime 的 FP16进行推理加速:
```
python infer.py \
@@ -58,7 +58,7 @@ python infer.py \
--dataset_dir "../../data"
```
-可以使用如下命令开启ONNXRuntime推理评估模型的性能和精度:
+可以使用如下命令开启 ONNXRuntime 推理评估模型的性能和精度:
```
python infer.py \
@@ -72,7 +72,7 @@ python infer.py \
--dataset_dir "../../data"
```
-## 基于CPU部署推理样例
+## 基于 CPU 部署推理样例
请使用如下命令进行部署
```
@@ -89,16 +89,16 @@ python infer.py \
* `model_path_prefix`:必须,待推理模型路径前缀。
* `model_name_or_path`:选择预训练模型;默认为"ernie-3.0-medium-zh",中文数据集推荐使用"ernie-3.0-medium-zh"。
-* `max_seq_length`:ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
-* `use_quantize`:选择是否开启INT8动态量化进行加速;默认为False。
+* `max_seq_length`:ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `use_quantize`:选择是否开启 INT8动态量化进行加速;默认为 False。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为200。
-* `num_threads`:cpu线程数;默认为cpu的物理核心数量。
-* `device`: 选用什么设备进行训练,可选cpu、gpu。
-* `perf`:选择进行模型性能和精度评估;默认为False。
-* `dataset_dir`:本地数据集地址,需包含data.txt, label.txt, dev.txt/test.txt(可选,如果启动模型性能和精度评估);默认为None。
+* `num_threads`:cpu 线程数;默认为 cpu 的物理核心数量。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu。
+* `perf`:选择进行模型性能和精度评估;默认为 False。
+* `dataset_dir`:本地数据集地址,需包含 data.txt, label.txt, dev.txt/test.txt(可选,如果启动模型性能和精度评估);默认为 None。
* `perf_dataset`:评估数据集,选择在开发集或测试集评估模型;默认为"dev"。
-可以使用如下命令开启ONNXRuntime的INT8动态量化进行推理加速:
+可以使用如下命令开启 ONNXRuntime 的 INT8动态量化进行推理加速:
```
python infer.py \
@@ -111,9 +111,9 @@ python infer.py \
--dataset_dir "../../data"
```
-**Note**:INT8动态量化与FP16相比精度损失较大,GPU部署建议使用FP16加速。
+**Note**:INT8动态量化与 FP16相比精度损失较大,GPU 部署建议使用 FP16加速。
-可以使用如下命令开启ONNXRuntime推理评估模型的性能和精度:
+可以使用如下命令开启 ONNXRuntime 推理评估模型的性能和精度:
```
python infer.py \
@@ -154,7 +154,7 @@ python infer.py \
4. PaddleNLP 版本:2.3.1
-5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU部署运行时间 total_time,计算 latency = total_time / total_samples
+5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU 部署运行时间 total_time,计算 latency = total_time / total_samples
6. 精度评价指标:Micro F1分数、Macro F1分数
@@ -166,4 +166,4 @@ python infer.py \
| ERNIE 3.0 Medium+INT8+CPU | 95.03 | 92.87| 12.14 |
-经过FP16转化加速比达到3~4倍左右,精度变化较小,与FP16相比,INT8在线量化精度下降较大,加速比在1.5~2倍左右。
+经过 FP16转化加速比达到3~4倍左右,精度变化较小,与 FP16相比,INT8在线量化精度下降较大,加速比在1.5~2倍左右。
diff --git a/legacy/applications/text_classification/hierarchical/deploy/predictor/infer.py b/slm/applications/text_classification/hierarchical/deploy/predictor/infer.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/predictor/infer.py
rename to slm/applications/text_classification/hierarchical/deploy/predictor/infer.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/predictor/predictor.py b/slm/applications/text_classification/hierarchical/deploy/predictor/predictor.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/predictor/predictor.py
rename to slm/applications/text_classification/hierarchical/deploy/predictor/predictor.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/README.md b/slm/applications/text_classification/hierarchical/deploy/simple_serving/README.md
similarity index 70%
rename from legacy/applications/text_classification/hierarchical/deploy/simple_serving/README.md
rename to slm/applications/text_classification/hierarchical/deploy/simple_serving/README.md
index 13ec53a993ba..54878e5bc55a 100644
--- a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/README.md
+++ b/slm/applications/text_classification/hierarchical/deploy/simple_serving/README.md
@@ -1,22 +1,22 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server启动服务](#Server服务启动)
+- [Server 启动服务](#Server 服务启动)
- [其他参数设置](#其他参数设置)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本
+使用有 SimpleServing 功能的 PaddleNLP 版本
```shell
pip install paddlenlp --upgrade
```
-## Server服务启动
+## Server 服务启动
### 分类任务启动
#### 启动 分类 Server 服务
```bash
paddlenlp server server:app --host 0.0.0.0 --port 8189
```
-如果是ERNIE-M模型则启动
+如果是 ERNIE-M 模型则启动
```bash
paddlenlp server ernie_m_server:app --host 0.0.0.0 --port 8189
```
@@ -27,7 +27,7 @@ python client.py
## 其他参数设置
-可以在client端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
+可以在 client 端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
```python
data = {
'data': {
diff --git a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/client.py b/slm/applications/text_classification/hierarchical/deploy/simple_serving/client.py
similarity index 99%
rename from legacy/applications/text_classification/hierarchical/deploy/simple_serving/client.py
rename to slm/applications/text_classification/hierarchical/deploy/simple_serving/client.py
index a1eb7fc8357a..e16e8f97912f 100644
--- a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/client.py
+++ b/slm/applications/text_classification/hierarchical/deploy/simple_serving/client.py
@@ -13,9 +13,10 @@
# limitations under the License.
import argparse
-import requests
import json
+import requests
+
# yapf: disable
parser = argparse.ArgumentParser()
parser.add_argument("--max_seq_len", default=128, type=int, help="The maximum total input sequence length after tokenization.")
diff --git a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/ernie_m_server.py b/slm/applications/text_classification/hierarchical/deploy/simple_serving/ernie_m_server.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/simple_serving/ernie_m_server.py
rename to slm/applications/text_classification/hierarchical/deploy/simple_serving/ernie_m_server.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/simple_serving/server.py b/slm/applications/text_classification/hierarchical/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/simple_serving/server.py
rename to slm/applications/text_classification/hierarchical/deploy/simple_serving/server.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/README.md b/slm/applications/text_classification/hierarchical/deploy/triton_serving/README.md
similarity index 61%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/README.md
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/README.md
index aee42cc32a52..1e9fde858b4b 100644
--- a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/README.md
+++ b/slm/applications/text_classification/hierarchical/deploy/triton_serving/README.md
@@ -1,6 +1,6 @@
-# 基于Triton Inference Server的服务化部署指南
+# 基于 Triton Inference Server 的服务化部署指南
-本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于ERNIE 2.0英文模型文本层次分类的pipeline在线服务。
+本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于 ERNIE 2.0英文模型文本层次分类的 pipeline 在线服务。
## 目录
- [服务端环境准备](#服务端环境准备)
@@ -10,8 +10,8 @@
## 服务端环境准备
-### 安装Triton Server
-拉取Triton Server镜像:
+### 安装 Triton Server
+拉取 Triton Server 镜像:
```shell
docker pull nvcr.io/nvidia/tritonserver:21.10-py3
```
@@ -22,19 +22,19 @@ docker run -it --gpus all --net=host --name triton_server -v /path/triton/model
**NOTE:**
-1. Triton版本号`21.10`可以根据自己的需求调整,各个Triton版本对应的Driver、CUDA、TRT和ONNX Runtime等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果NVIDIA Driver低于文档中要求,在启动运行时会报错。
+1. Triton 版本号`21.10`可以根据自己的需求调整,各个 Triton 版本对应的 Driver、CUDA、TRT 和 ONNX Runtime 等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果 NVIDIA Driver 低于文档中要求,在启动运行时会报错。
-2. 可以使用`--gpus '"device=1"'`来指定GPU卡号,更多GPU指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
+2. 可以使用`--gpus '"device=1"'`来指定 GPU 卡号,更多 GPU 指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
-### 进入容器并准备PaddleNLP环境
-整个服务的前后处理依赖PaddleNLP,需要在容器内安装相关python包
+### 进入容器并准备 PaddleNLP 环境
+整个服务的前后处理依赖 PaddleNLP,需要在容器内安装相关 python 包
进入容器:
```shell
docker exec -it triton_server bash
```
-安装PaddlePaddle、PaddleNLP
+安装 PaddlePaddle、PaddleNLP
```shell
python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/pypi/simple
```
@@ -43,14 +43,14 @@ python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/py
1. 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(-i https://mirror.baidu.com/pypi/simple)
-2. 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+2. 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-3. 更多关于PaddleNLP安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+3. 更多关于 PaddleNLP 安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
## 模型获取和转换
-使用Triton做服务化部署时,选择ONNX Runtime后端运行需要先将模型转换成ONNX格式。
+使用 Triton 做服务化部署时,选择 ONNX Runtime 后端运行需要先将模型转换成 ONNX 格式。
首先将保存的动态图参数导出成静态图参数,具体代码见[静态图导出脚本](../../export_model.py)。静态图参数保存在`output_path`指定路径中。运行方式:
@@ -59,13 +59,13 @@ python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/py
python ../../export_model.py --params_path=../../checkpoint/model_state.pdparams --output_path=./wos_infer_model
```
-使用Paddle2ONNX将Paddle静态图模型转换为ONNX模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成model.onnx模型文件。
+使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成 model.onnx 模型文件。
```shell
paddle2onnx --model_dir infer_model/ --model_filename float32.pdmodel --params_filename float32.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --enable_dev_version True
```
-创建空白目录/seqcls/1和seqcls_model/1,并将将转换好的ONNX模型移动到模型仓库目录
+创建空白目录/seqcls/1和 seqcls_model/1,并将将转换好的 ONNX 模型移动到模型仓库目录
```shell
mkdir /models/seqcls/1
@@ -73,9 +73,9 @@ mkdir /models/seqcls_model/1
mv model.onnx /models/seqcls_model/1
```
-Paddle2ONNX的命令行参数说明请查阅:[Paddle2ONNX命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
+Paddle2ONNX 的命令行参数说明请查阅:[Paddle2ONNX 命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
-模型下载转换好之后,models目录结构如下:
+模型下载转换好之后,models 目录结构如下:
```
models
├── seqcls
@@ -95,11 +95,11 @@ models
└── config.pbtxt
```
-模型配置文件config.pbtxt配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
+模型配置文件 config.pbtxt 配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
## 部署模型
-triton目录包含启动pipeline服务的配置和发送预测请求的代码,包括:
+triton 目录包含启动 pipeline 服务的配置和发送预测请求的代码,包括:
```
models # Triton启动需要的模型仓库,包含模型和服务配置文件
@@ -108,7 +108,7 @@ seqcls_grpc_client.py # 层次分类任务发送pipeline预测请求的脚
### 启动服务端
-在容器内执行下面命令启动服务,默认启动models下所有模型:
+在容器内执行下面命令启动服务,默认启动 models 下所有模型:
```shell
tritonserver --model-repository=/models
```
@@ -145,11 +145,11 @@ I0619 13:43:33.409775 5127 http_server.cc:167] Started Metrics Service at 0.0.0.
**NOTE:**
-启动服务时,Triton Server的每个python后端进程默认申请`64M`内存,默认启动的docker无法启动多个python后端节点。两个解决方案:
+启动服务时,Triton Server 的每个 python 后端进程默认申请`64M`内存,默认启动的 docker 无法启动多个 python 后端节点。两个解决方案:
1. 启动容器时设置`shm-size`参数, 比如:`docker run -it --net=host --name triton_server --shm-size="1g" -v /path/triton/models:/models nvcr.io/nvidia/tritonserver:21.10-py3 bash`
-2. 启动服务时设置python后端的`shm-default-byte-size`参数, 设置python后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
+2. 启动服务时设置 python 后端的`shm-default-byte-size`参数, 设置 python 后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
## 客户端请求
@@ -169,7 +169,7 @@ docker run -it --net=host --name triton_client -v /path/to/triton:/triton_code
```
### 启动客户端测试
-注意执行客户端请求时关闭代理,并根据实际情况修改main函数中的ip地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 main 函数中的 ip 地址(启动服务所在的机器)
```
python seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls/config.pbtxt b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls/config.pbtxt
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls/config.pbtxt
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_model/config.pbtxt b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_model/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_model/config.pbtxt
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_model/config.pbtxt
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/1/model.py b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/1/model.py
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/1/model.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/1/model.py b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/1/model.py
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/1/model.py
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/config.pbtxt b/slm/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/config.pbtxt
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/models/tokenizer/config.pbtxt
diff --git a/legacy/applications/text_classification/hierarchical/deploy/triton_serving/seqcls_grpc_client.py b/slm/applications/text_classification/hierarchical/deploy/triton_serving/seqcls_grpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/deploy/triton_serving/seqcls_grpc_client.py
rename to slm/applications/text_classification/hierarchical/deploy/triton_serving/seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/hierarchical/export_model.py b/slm/applications/text_classification/hierarchical/export_model.py
similarity index 99%
rename from legacy/applications/text_classification/hierarchical/export_model.py
rename to slm/applications/text_classification/hierarchical/export_model.py
index c57dc23372f9..a9afa457409c 100644
--- a/legacy/applications/text_classification/hierarchical/export_model.py
+++ b/slm/applications/text_classification/hierarchical/export_model.py
@@ -16,6 +16,7 @@
import os
import paddle
+
from paddlenlp.transformers import AutoModelForSequenceClassification
# yapf: disable
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/README.md b/slm/applications/text_classification/hierarchical/few-shot/README.md
similarity index 86%
rename from legacy/applications/text_classification/hierarchical/few-shot/README.md
rename to slm/applications/text_classification/hierarchical/few-shot/README.md
index c3a7c85e983c..101ccbd6fab9 100644
--- a/legacy/applications/text_classification/hierarchical/few-shot/README.md
+++ b/slm/applications/text_classification/hierarchical/few-shot/README.md
@@ -124,7 +124,7 @@
### 3.3 数据标注
-我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即doccano导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano数据标注指南](../../doccano.md)。
+我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即 doccano 导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano 数据标注指南](../../doccano.md)。
**示例数据**
@@ -151,7 +151,7 @@ data/
**训练/验证/测试数据**
-对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由tab符`\t`分隔,多个标签以英文逗号`,`分隔,同一标签内不同层级以`##`字符连接。格式如下
+对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由 tab 符`\t`分隔,多个标签以英文逗号`,`分隔,同一标签内不同层级以`##`字符连接。格式如下
```text
<文本>'\t'<标签>','<标签>','<标签>
<文本>'\t'<标签>','<标签>
@@ -263,13 +263,13 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `data_dir`: 训练数据集路径,数据格式要求详见[数据标注](#数据标注)。
- `output_dir`: 模型参数、训练日志和静态图导出的保存目录。
- `prompt`: 提示模板。定义了如何将文本和提示拼接结合。
-- `soft_encoder`: 提示向量的编码器,`lstm`表示双向LSTM, `mlp`表示双层线性层, None表示直接使用提示向量。默认为`lstm`。
+- `soft_encoder`: 提示向量的编码器,`lstm`表示双向 LSTM, `mlp`表示双层线性层, None 表示直接使用提示向量。默认为`lstm`。
- `use_rdrop`: 使用 [R-Drop](https://arxiv.org/abs/2106.14448) 策略。
- `use_rgl`: 使用 [RGL](https://aclanthology.org/2022.findings-naacl.81/) 策略。
-- `encoder_hidden_size`: 提示向量的维度。若为None,则使用预训练模型字向量维度。默认为200。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
-- `learning_rate`: 预训练语言模型参数基础学习率大小,将与learning rate scheduler产生的值相乘作为当前学习率。
-- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用learning rate scheduler。一般设为`learning_rate`的十倍。
+- `encoder_hidden_size`: 提示向量的维度。若为 None,则使用预训练模型字向量维度。默认为200。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
+- `learning_rate`: 预训练语言模型参数基础学习率大小,将与 learning rate scheduler 产生的值相乘作为当前学习率。
+- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用 learning rate scheduler。一般设为`learning_rate`的十倍。
- `do_train`: 是否进行训练。
- `do_eval`: 是否进行评估。
- `do_predict`: 是否进行预测。
@@ -280,8 +280,8 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `device`: 使用的设备,默认为`gpu`。
- `eval_steps`: 评估模型的间隔步数。
- `logging_steps`: 打印日志的间隔步数。
-- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
-- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
+- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
+- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
- `load_best_model_at_end`: 是否在模型训练结束后加载评估指标最优的模型参数。
- `evaluation_strategy`: 模型评估的间隔策略。若为`epoch`,则每轮训练结束后评估模型。
- `save_strategy`: 模型保存的间隔策略。若为`epoch`,则每轮训练结束后保存当前模型参数。
@@ -303,7 +303,7 @@ python train.py --do_predict --data_dir ./data --output_dir ./predict_checkpoint
- `output_dir`: 日志的保存目录。
- `resume_from_checkpoint`: 训练时模型参数的保存目录,用于加载模型参数。
- `do_predict`: 是否进行测试集评估。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
### 3.6 模型部署
@@ -323,31 +323,31 @@ python train.py --do_export --data_dir ./data --output_dir ./export_checkpoint -
- `do_export`: 是否将模型导出为静态图,保存路径为`output_dir/export`。
- `export_type`: 模型导出的格式,默认为`paddle`,即导出静态图。
-#### ONNXRuntime部署
+#### ONNXRuntime 部署
**运行环境**
-模型转换与ONNXRuntime预测部署依赖Paddle2ONNX和ONNXRuntime,Paddle2ONNX支持将Paddle静态图模型转化为ONNX模型格式,算子目前稳定支持导出ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
+模型转换与 ONNXRuntime 预测部署依赖 Paddle2ONNX 和 ONNXRuntime,Paddle2ONNX 支持将 Paddle 静态图模型转化为 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
-- 如果基于GPU部署,请先确保机器已正确安装NVIDIA相关驱动和基础软件,确保CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
+- 如果基于 GPU 部署,请先确保机器已正确安装 NVIDIA 相关驱动和基础软件,确保 CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime-gpu onnx onnxconverter-common
```
-- 如果基于CPU部署,请使用如下命令安装所需依赖:
+- 如果基于 CPU 部署,请使用如下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime
```
-**CPU端推理样例**
+**CPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device cpu
```
-**GPU端推理样例**
+**GPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device gpu --device_id 0
@@ -356,16 +356,16 @@ python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data -
可配置参数说明:
- `model_path_prefix`: 导出的静态图模型路径及文件前缀。
-- `model_name`: 内置预训练模型名,用于加载tokenizer。默认为`ernie-3.0-base-zh`。
+- `model_name`: 内置预训练模型名,用于加载 tokenizer。默认为`ernie-3.0-base-zh`。
- `data_dir`: 待推理数据所在路径,数据应存放在该目录下的`data.txt`文件。
-- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
- `batch_size`: 每次预测的样本数量。
- `device`: 选择推理设备,包括`cpu`和`gpu`。默认为`gpu`。
-- `device_id`: 指定GPU设备ID。
-- `use_fp16`: 是否使用半精度加速推理。仅在GPU设备上有效。
-- `num_threads`: 设置CPU使用的线程数。默认为机器上的物理内核数。
+- `device_id`: 指定 GPU 设备 ID。
+- `use_fp16`: 是否使用半精度加速推理。仅在 GPU 设备上有效。
+- `num_threads`: 设置 CPU 使用的线程数。默认为机器上的物理内核数。
-**Note**: 在GPU设备的CUDA计算能力 (CUDA Compute Capability) 大于7.0,在包括V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启FP16进行加速,在CPU或者CUDA计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
+**Note**: 在 GPU 设备的 CUDA 计算能力 (CUDA Compute Capability) 大于7.0,在包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启 FP16进行加速,在 CPU 或者 CUDA 计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
## 4. References
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/infer.py b/slm/applications/text_classification/hierarchical/few-shot/infer.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/infer.py
rename to slm/applications/text_classification/hierarchical/few-shot/infer.py
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/metric.py b/slm/applications/text_classification/hierarchical/few-shot/metric.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/metric.py
rename to slm/applications/text_classification/hierarchical/few-shot/metric.py
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/requirements_cpu.txt b/slm/applications/text_classification/hierarchical/few-shot/requirements_cpu.txt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/requirements_cpu.txt
rename to slm/applications/text_classification/hierarchical/few-shot/requirements_cpu.txt
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/requirements_gpu.txt b/slm/applications/text_classification/hierarchical/few-shot/requirements_gpu.txt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/requirements_gpu.txt
rename to slm/applications/text_classification/hierarchical/few-shot/requirements_gpu.txt
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/train.py b/slm/applications/text_classification/hierarchical/few-shot/train.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/train.py
rename to slm/applications/text_classification/hierarchical/few-shot/train.py
diff --git a/legacy/applications/text_classification/hierarchical/few-shot/utils.py b/slm/applications/text_classification/hierarchical/few-shot/utils.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/few-shot/utils.py
rename to slm/applications/text_classification/hierarchical/few-shot/utils.py
diff --git a/legacy/applications/text_classification/hierarchical/metric.py b/slm/applications/text_classification/hierarchical/metric.py
similarity index 97%
rename from legacy/applications/text_classification/hierarchical/metric.py
rename to slm/applications/text_classification/hierarchical/metric.py
index 608e23f2cf73..e46d46ed093b 100644
--- a/legacy/applications/text_classification/hierarchical/metric.py
+++ b/slm/applications/text_classification/hierarchical/metric.py
@@ -13,9 +13,9 @@
# limitations under the License.
import numpy as np
-from sklearn.metrics import f1_score, classification_report
-
from paddle.metric import Metric
+from sklearn.metrics import classification_report, f1_score
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/hierarchical/predict.py b/slm/applications/text_classification/hierarchical/predict.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/predict.py
rename to slm/applications/text_classification/hierarchical/predict.py
diff --git a/legacy/applications/text_classification/hierarchical/prune.py b/slm/applications/text_classification/hierarchical/prune.py
similarity index 96%
rename from legacy/applications/text_classification/hierarchical/prune.py
rename to slm/applications/text_classification/hierarchical/prune.py
index e4b9dff397e3..86f8e0e63933 100644
--- a/legacy/applications/text_classification/hierarchical/prune.py
+++ b/slm/applications/text_classification/hierarchical/prune.py
@@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
import functools
+import os
+from dataclasses import dataclass, field
import paddle
import paddle.nn.functional as F
+from metric import MetricReport
from paddleslim.nas.ofa import OFA
-from paddlenlp.utils.log import logger
+from utils import preprocess_function, read_local_dataset
+
from paddlenlp.data import DataCollatorWithPadding
from paddlenlp.datasets import load_dataset
-from paddlenlp.trainer import PdArgumentParser, Trainer, CompressionArguments
-from paddlenlp.transformers import AutoTokenizer, AutoModelForSequenceClassification
-from dataclasses import dataclass, field
-
-from utils import preprocess_function, read_local_dataset
-from metric import MetricReport
+from paddlenlp.trainer import CompressionArguments, PdArgumentParser, Trainer
+from paddlenlp.transformers import AutoModelForSequenceClassification, AutoTokenizer
+from paddlenlp.utils.log import logger
# yapf: disable
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/README.md b/slm/applications/text_classification/hierarchical/retrieval_based/README.md
similarity index 80%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/README.md
rename to slm/applications/text_classification/hierarchical/retrieval_based/README.md
index b07c6e9e0136..407a470f654f 100644
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/README.md
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/README.md
@@ -15,18 +15,18 @@
# 1.基于语义索引的分类任务介绍
-以前的分类任务中,标签信息作为无实际意义,独立存在的one-hot编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
+以前的分类任务中,标签信息作为无实际意义,独立存在的 one-hot 编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
-本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入In-batch Negatives 策略,使用hnswlib建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
+本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入 In-batch Negatives 策略,使用 hnswlib 建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
**效果评估**
| 模型 | Accuracy | 策略简要说明|
| ------------ | ------------ |--------- |
-| ernie-3.0-medium-zh | 50.580 | ernie-3.0-medium-zh多分类,5个epoch,对于新增类别需要重新训练|
-| In-batch Negatives + RocketQA | 49.755 | Inbatch-negative有监督训练,标签当作召回集,对新增类别不需要重新训练|
-| In-batch Negatives + RocketQA + 投票| **51.756** | Inbatch-negative有监督训练,训练集当作召回集,对新增类别,需要至少一条的数据放入召回库中|
+| ernie-3.0-medium-zh | 50.580 | ernie-3.0-medium-zh 多分类,5个 epoch,对于新增类别需要重新训练|
+| In-batch Negatives + RocketQA | 49.755 | Inbatch-negative 有监督训练,标签当作召回集,对新增类别不需要重新训练|
+| In-batch Negatives + RocketQA + 投票| **51.756** | Inbatch-negative 有监督训练,训练集当作召回集,对新增类别,需要至少一条的数据放入召回库中|
@@ -69,7 +69,7 @@
## 3. 环境准备
-推荐使用GPU进行训练,在预测阶段使用CPU或者GPU均可。
+推荐使用 GPU 进行训练,在预测阶段使用 CPU 或者 GPU 均可。
**环境依赖**
* python >= 3.6.2
@@ -86,7 +86,7 @@ pip install -r requirements.txt
## 4. 数据准备
-训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。
+训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。
**指定格式本地数据集目录结构**
@@ -99,9 +99,9 @@ pip install -r requirements.txt
**训练、开发、测试数据集**
-train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用tab符`'\t'`分隔开,层次标签之间用`'##'`号分隔开。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
+train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用 tab 符`'\t'`分隔开,层次标签之间用`'##'`号分隔开。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
-**注意文本中不能包含tab符`'\t'`**。
+**注意文本中不能包含 tab 符`'\t'`**。
- train.txt/dev.txt/test.txt 文件格式:
```text
@@ -150,7 +150,7 @@ label.txt(层次分类标签文件)记录数据集中所有标签路径集合,
我们使用百科知识问答的数据来构建训练集,开发集。
-**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集30k条,开发集10k条,每行由文本的标题,内容和类别标签组成,以tab符分割,第一列是问题的标题和问题的描述拼接,剩下的列问题的类别。
+**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集30k 条,开发集10k 条,每行由文本的标题,内容和类别标签组成,以 tab 符分割,第一列是问题的标题和问题的描述拼接,剩下的列问题的类别。
**召回库(label.txt)** 召回库的构建有2种方式,第一种是把所有的类别标签当成召回库,第二种是把训练集当成召回集合,我们以第一种为例。
数据集选择的是百科问答数据集的一个子集,问答数据集详情请参考[nlp_chinese_corpus](https://github.com/brightmart/nlp_chinese_corpus)
@@ -166,9 +166,9 @@ unzip baike_qa_category.zip
这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1 卡;如果采用单机单卡训练,只需要把`--gpus`参数设置成单卡的卡号即可。
-如果使用CPU进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成cpu即可,详细请参考train.sh文件的训练设置
+如果使用 CPU 进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成 cpu 即可,详细请参考 train.sh 文件的训练设置
-然后运行下面的命令使用GPU训练,得到语义索引模型:
+然后运行下面的命令使用 GPU 训练,得到语义索引模型:
```
root_path=inbatch
@@ -197,9 +197,9 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `device`: 使用 cpu/gpu 进行训练
* `save_dir`: 模型存储路径
-* `batch_size`: 训练的batch size的大小
+* `batch_size`: 训练的 batch size 的大小
* `learning_rate`: 训练的学习率的大小
-* `epochs`: 训练的epoch数
+* `epochs`: 训练的 epoch 数
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `save_steps`: 模型存储 checkpoint 的间隔 steps 个数
* `max_seq_length`: 输入序列的最大长度
@@ -214,7 +214,7 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `similar_text_pair`: 由相似文本对构成的评估集
* `corpus_file`: 召回库数据 corpus_file
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/train.sh
@@ -249,12 +249,12 @@ python -u -m paddle.distributed.launch --gpus "0" \
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `text_pair_file`: 由文本 Pair 构成的待预测数据集
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/predict.sh
```
-predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
+predict.sh 文件包含了 cpu 和 gpu 运行的脚本,默认是 gpu 运行的脚本
产出如下结果
```
@@ -276,17 +276,17 @@ predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
```
python export_model.py --params_path checkpoints/inbatch/model_best/model_state.pdparams --output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
```
-### Paddle Inference预测
+### Paddle Inference 预测
预测既可以抽取向量也可以计算两个文本的相似度。
-修改deploy/python/predict.py中的id2corpus和corpus_list的样本:
+修改 deploy/python/predict.py 中的 id2corpus 和 corpus_list 的样本:
```
# 抽取向量
@@ -306,12 +306,12 @@ corpus_list = [{
```
-然后使用PaddleInference
+然后使用 PaddleInference
```
python deploy/python/predict.py --model_dir=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy.sh
@@ -329,7 +329,7 @@ sh deploy.sh
### 向量引擎
-模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU版本,建议使用官方的 Docker 安装方式,简单快捷。
+模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus 官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU 版本,建议使用官方的 Docker 安装方式,简单快捷。
Milvus 搭建完系统以后就可以插入和检索向量了,首先生成 embedding 向量,每个样本生成768维度的向量:
@@ -355,9 +355,9 @@ python utils/vector_insert.py \
sh scripts/run.sh
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成Serving的格式:
+Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成 Serving 的格式:
```
python export_to_serving.py \
@@ -383,9 +383,9 @@ python export_to_serving.py \
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署有两种方式,第一种方式是Pipeline的方式,第二种是C++的方式,下面分别介绍这两种方式的用法:
+Paddle Serving 的部署有两种方式,第一种方式是 Pipeline 的方式,第二种是 C++的方式,下面分别介绍这两种方式的用法:
-#### Pipeline方式
+#### Pipeline 方式
启动 Pipeline Server:
@@ -394,7 +394,7 @@ cd deploy/python/
python web_service.py
```
-启动客户端调用 Server, 使用 POST的方式:
+启动客户端调用 Server, 使用 POST 的方式:
向服务端发送 POST 请求示例:
@@ -402,8 +402,8 @@ python web_service.py
curl -X POST -k http://localhost:8090/ernie/prediction -d '{"key": ["0"], "value": ["{\"sentence\": \"CPU每秒执行的指令数CPU频率3.0G,执行一条指令需要1.5,频率3.0G,执行一条指令需要1.5个周期,每秒执行的指令数为?是20亿吗?\"}"]}'
```
-也可以使用 rpc的方式:
-首先修改rpc_client.py中需要预测的样本:
+也可以使用 rpc 的方式:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [{
@@ -434,7 +434,7 @@ time to cost :0.014188766479492188 seconds
## 8. 分类流程
-基于检索的分类系统使用了Client Server的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问。
+基于检索的分类系统使用了 Client Server 的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问。
```
python run_system.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/base_model.py b/slm/applications/text_classification/hierarchical/retrieval_based/base_model.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/base_model.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/base_model.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/data.py b/slm/applications/text_classification/hierarchical/retrieval_based/data.py
similarity index 99%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/data.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/data.py
index 9d440967a218..de1ed0de7097 100644
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/data.py
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/data.py
@@ -17,6 +17,7 @@
import hnswlib
import numpy as np
import paddle
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/config_nlp.yml b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/config_nlp.yml
rename to slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/config_nlp.yml
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
new file mode 100644
index 000000000000..f4b8c7b5207f
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/deploy.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/predict.py b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/predict.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/predict.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py
index c3d5e71e3d09..3222fcb45fe1 100644
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/rpc_client.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
-import numpy as np
+import numpy as np
from paddle_serving_server.pipeline import PipelineClient
client = PipelineClient()
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/web_service.py b/slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/deploy/python/web_service.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/deploy/python/web_service.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/evaluate.py b/slm/applications/text_classification/hierarchical/retrieval_based/evaluate.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/evaluate.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/evaluate.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/export_model.py b/slm/applications/text_classification/hierarchical/retrieval_based/export_model.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/export_model.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/export_model.py
diff --git a/legacy/applications/neural_search/ranking/ernie_matching/export_to_serving.py b/slm/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py
similarity index 99%
rename from legacy/applications/neural_search/ranking/ernie_matching/export_to_serving.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py
index 1ba681a4dfb1..6cc932da1117 100644
--- a/legacy/applications/neural_search/ranking/ernie_matching/export_to_serving.py
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py
@@ -13,6 +13,7 @@
# limitations under the License.
import argparse
+
import paddle_serving_client.io as serving_io
# yapf: disable
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/model.py b/slm/applications/text_classification/hierarchical/retrieval_based/model.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/model.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/model.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/predict.py b/slm/applications/text_classification/hierarchical/retrieval_based/predict.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/predict.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/predict.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/recall.py b/slm/applications/text_classification/hierarchical/retrieval_based/recall.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/recall.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/recall.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/requirements.txt b/slm/applications/text_classification/hierarchical/retrieval_based/requirements.txt
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/requirements.txt
rename to slm/applications/text_classification/hierarchical/retrieval_based/requirements.txt
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/run_system.py b/slm/applications/text_classification/hierarchical/retrieval_based/run_system.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/run_system.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/run_system.py
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
new file mode 100644
index 000000000000..9d5c6e82aee8
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/evaluate.sh
@@ -0,0 +1,18 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -u evaluate.py \
+ --similar_text_pair "data/dev.txt" \
+ --recall_result_file "./recall_result_dir/recall_result.txt" \
+ --recall_num 50
\ No newline at end of file
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
new file mode 100644
index 000000000000..c805d21a93f2
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_model.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_model.py --params_path checkpoints/inbatch/model_best/model_state.pdparams --output_path=./output
\ No newline at end of file
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
new file mode 100644
index 000000000000..3c13b06b2111
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/export_to_serving.sh
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python export_to_serving.py \
+ --dirname "output" \
+ --model_filename "inference.get_pooled_embedding.pdmodel" \
+ --params_filename "inference.get_pooled_embedding.pdiparams" \
+ --server_path "serving_server" \
+ --client_path "serving_client" \
+ --fetch_alias_names "output_embedding"
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh
similarity index 50%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh
rename to slm/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh
index 67c9eee02da0..3e07af5f7795 100644
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/predict.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# gpu version
root_dir="checkpoints/inbatch/model_best"
python -u -m paddle.distributed.launch --gpus "0" \
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
new file mode 100644
index 000000000000..e2ca24f3e358
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run.sh
@@ -0,0 +1,22 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CUDA_VISIBLE_DEVICES=0 python utils/feature_extract.py \
+ --data_name label \
+ --model_dir ./output \
+ --output_dir data \
+ --corpus_file "./data/label.txt"
+
+python utils/vector_insert.py \
+ --vector_path ./data/label_embedding.npy
\ No newline at end of file
diff --git a/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
new file mode 100755
index 000000000000..3168409f037b
--- /dev/null
+++ b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/run_build_index.sh
@@ -0,0 +1,30 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# GPU version
+root_dir="checkpoints/inbatch"
+python -u -m paddle.distributed.launch --gpus "0" --log_dir "recall_log/" \
+ recall.py \
+ --device gpu \
+ --recall_result_dir "recall_result_dir" \
+ --recall_result_file "recall_result.txt" \
+ --params_path "${root_dir}/model_best/model_state.pdparams" \
+ --hnsw_m 100 \
+ --hnsw_ef 100 \
+ --batch_size 64 \
+ --output_emb_size 0 \
+ --max_seq_length 384 \
+ --recall_num 50 \
+ --similar_text_pair "data/dev.txt" \
+ --corpus_file "data/train.txt"
\ No newline at end of file
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/scripts/train.sh b/slm/applications/text_classification/hierarchical/retrieval_based/scripts/train.sh
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/scripts/train.sh
rename to slm/applications/text_classification/hierarchical/retrieval_based/scripts/train.sh
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/train.py b/slm/applications/text_classification/hierarchical/retrieval_based/train.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/train.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/train.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/utils/__init__.py b/slm/applications/text_classification/hierarchical/retrieval_based/utils/__init__.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/utils/__init__.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/utils/__init__.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/utils/config.py b/slm/applications/text_classification/hierarchical/retrieval_based/utils/config.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/utils/config.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/utils/config.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/utils/feature_extract.py b/slm/applications/text_classification/hierarchical/retrieval_based/utils/feature_extract.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/utils/feature_extract.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/utils/feature_extract.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/utils/milvus_util.py b/slm/applications/text_classification/hierarchical/retrieval_based/utils/milvus_util.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/utils/milvus_util.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/utils/milvus_util.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/utils/vector_insert.py b/slm/applications/text_classification/hierarchical/retrieval_based/utils/vector_insert.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/utils/vector_insert.py
rename to slm/applications/text_classification/hierarchical/retrieval_based/utils/vector_insert.py
diff --git a/legacy/applications/text_classification/hierarchical/train.py b/slm/applications/text_classification/hierarchical/train.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/train.py
rename to slm/applications/text_classification/hierarchical/train.py
diff --git a/legacy/applications/text_classification/multi_label/utils.py b/slm/applications/text_classification/hierarchical/utils.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/utils.py
rename to slm/applications/text_classification/hierarchical/utils.py
index 9915906c9a2a..22663eefa8c4 100644
--- a/legacy/applications/text_classification/multi_label/utils.py
+++ b/slm/applications/text_classification/hierarchical/utils.py
@@ -13,9 +13,9 @@
# limitations under the License.
import numpy as np
-
import paddle
import paddle.nn.functional as F
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/multi_class/README.md b/slm/applications/text_classification/multi_class/README.md
similarity index 75%
rename from legacy/applications/text_classification/multi_class/README.md
rename to slm/applications/text_classification/multi_class/README.md
index 86cee4b55d72..6003d4e4ee29 100644
--- a/legacy/applications/text_classification/multi_class/README.md
+++ b/slm/applications/text_classification/multi_class/README.md
@@ -16,7 +16,7 @@
## 1. 二分类/多分类简介
-本项目提供通用场景下**基于预训练模型微调的二分类/多分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低AI开发落地门槛。
+本项目提供通用场景下**基于预训练模型微调的二分类/多分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低 AI 开发落地门槛。
二分类/多分类数据集的标签集含有两个或两个以上的类别,所有输入句子/文本有且只有一个标签。在文本多分类场景中,我们需要预测**输入句子/文本最可能来自 `n` 个标签类别中的哪一个类别**。在本项目中二分类任务被视为多分类任务中标签集包含两个类别的情况,以下统一称为多分类任务。以下图为例,该新闻文本的最可能的标签为 `娱乐`。多分类任务在商品分类、网页标签、新闻分类、医疗文本分类等各种现实场景中具有广泛的适用性。
@@ -27,8 +27,8 @@
**方案亮点:**
-- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
+- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的 ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
- **简单易用👶:** 开发者**无需机器学习背景知识**,仅需提供指定格式的标注分类数据,一行命令即可开启文本分类训练,轻松完成上线部署,不再让技术成为文本分类的门槛。
**更多选择:**
@@ -44,7 +44,7 @@
## 2. 快速开始
-接下来我们将以CBLUE公开数据集KUAKE-QIC任务为示例,演示多分类全流程方案使用。下载数据集:
+接下来我们将以 CBLUE 公开数据集 KUAKE-QIC 任务为示例,演示多分类全流程方案使用。下载数据集:
```shell
wget https://paddlenlp.bj.bcebos.com/datasets/KUAKE_QIC.tar.gz
@@ -71,19 +71,19 @@ rm -rf KUAKE_QIC.tar.gz
- paddlenlp >= 2.5.1
- scikit-learn >= 1.0.2
-**安装PaddlePaddle:**
+**安装 PaddlePaddle:**
- 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+ 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-**安装PaddleNLP:**
+**安装 PaddleNLP:**
```shell
pip install --upgrade paddlenlp
```
-**安装sklearn:**
+**安装 sklearn:**
```shell
pip install scikit-learn
```
@@ -109,7 +109,7 @@ multi_class/
### 2.3 数据准备
-训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务doccano数据标注使用指南](../doccano.md)进行文本分类数据标注。指定格式本地数据集目录结构:
+训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务 doccano 数据标注使用指南](../doccano.md)进行文本分类数据标注。指定格式本地数据集目录结构:
```text
data/
@@ -118,7 +118,7 @@ data/
└── label.txt # 分类标签文件
```
-**训练、开发、测试数据集** 文件中文本与标签类别名用tab符`'\t'`分隔开,文本中避免出现tab符`'\t'`。
+**训练、开发、测试数据集** 文件中文本与标签类别名用 tab 符`'\t'`分隔开,文本中避免出现 tab 符`'\t'`。
- train.txt/dev.txt/test.txt 文件格式:
```text
@@ -165,7 +165,7 @@ label.txt(分类标签文件)记录数据集中所有标签集合,每一行为
#### 2.4.1 预训练模型微调
-使用CPU/GPU训练,默认为GPU训练。使用CPU训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定GPU卡号:
+使用 CPU/GPU 训练,默认为 GPU 训练。使用 CPU 训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定 GPU 卡号:
```shell
python train.py \
--do_train \
@@ -189,7 +189,7 @@ python train.py \
--save_total_limit 1
```
-如果在GPU环境中使用,可以指定`gpus`参数进行多卡分布式训练。使用多卡训练可以指定多个GPU卡号,例如 --gpus 0,1。如果设备只有一个GPU卡号默认为0,可使用`nvidia-smi`命令查看GPU使用情况:
+如果在 GPU 环境中使用,可以指定`gpus`参数进行多卡分布式训练。使用多卡训练可以指定多个 GPU 卡号,例如 --gpus 0,1。如果设备只有一个 GPU 卡号默认为0,可使用`nvidia-smi`命令查看 GPU 使用情况:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -218,7 +218,7 @@ python -m paddle.distributed.launch --gpus 0,1 train.py \
主要的配置的参数为:
- `do_train`: 是否进行训练。
- `do_eval`: 是否进行评估。
-- `debug`: 与`do_eval`配合使用,是否开启debug模型,对每一个类别进行评估。
+- `debug`: 与`do_eval`配合使用,是否开启 debug 模型,对每一个类别进行评估。
- `do_export`: 训练结束后是否导出静态图。
- `do_compress`: 训练结束后是否进行模型裁剪。
- `model_name_or_path`: 内置模型名,或者模型参数配置目录路径。默认为`ernie-3.0-tiny-medium-v2-zh`。
@@ -227,17 +227,17 @@ python -m paddle.distributed.launch --gpus 0,1 train.py \
- `num_train_epochs`: 训练轮次,使用早停法时可以选择100。
- `early_stopping`: 是否使用早停法,也即一定轮次后评估指标不再增长则停止训练。
- `early_stopping_patience`: 在设定的早停训练轮次内,模型在开发集上表现不再上升,训练终止;默认为4。
-- `learning_rate`: 预训练语言模型参数基础学习率大小,将与learning rate scheduler产生的值相乘作为当前学习率。
-- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
-- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
-- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
-- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `learning_rate`: 预训练语言模型参数基础学习率大小,将与 learning rate scheduler 产生的值相乘作为当前学习率。
+- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
+- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
+- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
+- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
- `train_path`: 训练集路径,默认为"./data/train.txt"。
- `dev_path`: 开发集集路径,默认为"./data/dev.txt"。
- `test_path`: 测试集路径,默认为"./data/dev.txt"。
- `label_path`: 标签路径,默认为"./data/label.txt"。
- `bad_case_path`: 错误样本保存路径,默认为"./data/bad_case.txt"。
-- `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对self_attention中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed数量)应为整数;默认是None。
+- `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对 self_attention 中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed 数量)应为整数;默认是 None。
训练脚本支持所有`TrainingArguments`的参数,更多参数介绍可参考[TrainingArguments 参数介绍](https://paddlenlp.readthedocs.io/zh/latest/trainer.html#trainingarguments)。
程序运行时将会自动进行训练,评估。同时训练过程中会自动保存开发集上最佳模型在指定的 `output_dir` 中,保存模型文件结构如下所示:
@@ -255,10 +255,10 @@ checkpoint/
**NOTE:**
* 中文训练任务(文本支持含部分英文)推荐使用"ernie-1.0-large-zh-cw"、"ernie-3.0-tiny-base-v2-zh"、"ernie-3.0-tiny-medium-v2-zh"、"ernie-3.0-tiny-micro-v2-zh"、"ernie-3.0-tiny-mini-v2-zh"、"ernie-3.0-tiny-nano-v2-zh"、"ernie-3.0-tiny-pico-v2-zh"。
* 英文训练任务推荐使用"ernie-3.0-tiny-mini-v2-en"、 "ernie-2.0-base-en"、"ernie-2.0-large-en"。
-* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M论文](https://arxiv.org/pdf/2012.15674.pdf)。
+* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M 论文](https://arxiv.org/pdf/2012.15674.pdf)。
#### 2.4.2 训练评估
-训练后的模型我们可以开启`debug`模式,对每个类别分别进行评估,并打印错误预测样本保存在`bad_case.txt`。默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`:
+训练后的模型我们可以开启`debug`模式,对每个类别分别进行评估,并打印错误预测样本保存在`bad_case.txt`。默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`:
```shell
python train.py \
@@ -287,11 +287,11 @@ python train.py \
...
```
-文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis模块](./analysis) 提供了**可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis 模块](./analysis) 提供了**可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
#### 2.4.3 模型裁剪(可选)
-如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
+如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
使用裁剪功能需要安装 paddleslim:
@@ -299,7 +299,7 @@ python train.py \
pip install paddleslim == 2.4.1
```
-开始模型裁剪训练,默认为GPU训练,使用CPU训练只需将设备参数配置改为`--device "cpu"`:
+开始模型裁剪训练,默认为 GPU 训练,使用 CPU 训练只需将设备参数配置改为`--device "cpu"`:
```shell
python train.py \
--do_compress \
@@ -334,12 +334,12 @@ checkpoint/prune/
2. 模型裁剪主要用于推理部署,因此裁剪后的模型都是静态图模型,只可用于推理部署。
-3. ERNIE Base、Medium、Mini、Micro、Nano的模型宽度(multi head数量)为12,ERNIE Xbase、Large 模型宽度(multi head数量)为16,保留比例`width_mult`乘以宽度(multi haed数量)应为整数。
+3. ERNIE Base、Medium、Mini、Micro、Nano 的模型宽度(multi head 数量)为12,ERNIE Xbase、Large 模型宽度(multi head 数量)为16,保留比例`width_mult`乘以宽度(multi haed 数量)应为整数。
### 2.5 模型预测
-我们推荐使用taskflow进行模型预测,请保证paddlenlp版本大于2.5.1。
+我们推荐使用 taskflow 进行模型预测,请保证 paddlenlp 版本大于2.5.1。
```
from paddlenlp import Taskflow
@@ -355,25 +355,25 @@ cls(["黑苦荞茶的功效与作用及食用方法","幼儿挑食的生理原
```
#### 可配置参数说明
-* `task_path`:自定义任务路径,默认为None。
-* `is_static_model`:task_path中是否为静态图模型参数,默认为False。
+* `task_path`:自定义任务路径,默认为 None。
+* `is_static_model`:task_path 中是否为静态图模型参数,默认为 False。
* `max_length`:最长输入长度,包括所有标签的长度,默认为512。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
-* `id2label`:标签映射字典,如果`task_path`中包含id2label.json或加载动态图参数无需定义。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `id2label`:标签映射字典,如果`task_path`中包含 id2label.json 或加载动态图参数无需定义。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快。如果选择`fp16`,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
在线服务化部署搭建请参考:
-- 【简单易用】 👉 [Simple Serving部署指南](deploy/simple_serving)
-- 【低时延】 👉 [Triton部署指南](deploy/triton_serving)。
+- 【简单易用】 👉 [Simple Serving 部署指南](deploy/simple_serving)
+- 【低时延】 👉 [Triton 部署指南](deploy/triton_serving)。
### 2.6 模型效果
-PaddleNLP提供ERNIE 3.0 全系列轻量化模型,对于中文训练任务可以根据需求选择不同的预训练模型参数进行训练,我们评测了不同预训练模型在KUAKE-QIC任务的表现,测试配置如下:
+PaddleNLP 提供 ERNIE 3.0 全系列轻量化模型,对于中文训练任务可以根据需求选择不同的预训练模型参数进行训练,我们评测了不同预训练模型在 KUAKE-QIC 任务的表现,测试配置如下:
-1. 数据集:CBLUE数据集中医疗搜索检索词意图分类(KUAKE-QIC)任务开发集
+1. 数据集:CBLUE 数据集中医疗搜索检索词意图分类(KUAKE-QIC)任务开发集
2. 物理机环境
@@ -395,7 +395,7 @@ PaddleNLP提供ERNIE 3.0 全系列轻量化模型,对于中文训练任务可
4. PaddleNLP 版本:2.3.1
-5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU部署运行时间 total_time,计算 latency = total_time / total_samples
+5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU 部署运行时间 total_time,计算 latency = total_time / total_samples
6. 精度评价指标:Accuracy
diff --git a/legacy/applications/text_classification/multi_class/analysis/README.md b/slm/applications/text_classification/multi_class/analysis/README.md
similarity index 68%
rename from legacy/applications/text_classification/multi_class/analysis/README.md
rename to slm/applications/text_classification/multi_class/analysis/README.md
index 0b47dd14c45c..9f4d831e7ea2 100644
--- a/legacy/applications/text_classification/multi_class/analysis/README.md
+++ b/slm/applications/text_classification/multi_class/analysis/README.md
@@ -1,7 +1,7 @@
# 训练评估与模型优化指南
**目录**
- * [Analysis模块介绍](#Analysis模块介绍)
+ * [Analysis 模块介绍](#Analysis 模块介绍)
* [环境准备](#环境准备)
* [可解释性分析](#可解释性分析)
* [单词级别可解释性分析](#单词级别可解释性分析)
@@ -11,14 +11,14 @@
* [脏数据清洗方案](#脏数据清洗方案)
* [数据增强策略方案](#数据增强策略方案)
-## Analysis模块介绍
+## Analysis 模块介绍
-Analysis模块提供了**可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+Analysis 模块提供了**可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
- **可解释性分析:** 基于[TrustAI](https://github.com/PaddlePaddle/TrustAI)提供单词和句子级别的模型可解释性分析,帮助理解模型预测结果。
-- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。
+- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。

@@ -41,21 +41,21 @@ analysis/
- trustai >= 0.1.12
- interpretdl >= 0.7.0
-**安装TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装TrustAI。
+**安装 TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装 TrustAI。
```shell
pip install trustai==0.1.12
```
-**安装InterpretDL**(可选)如果使用词级别可解释性分析GradShap方法,需要安装InterpretDL
+**安装 InterpretDL**(可选)如果使用词级别可解释性分析 GradShap 方法,需要安装 InterpretDL
```shell
pip install interpretdl==0.7.0
```
## 可解释性分析
-"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于TrustAI开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
+"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于 TrustAI 开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
### 单词级别可解释性分析
-本项目开源模型的词级别可解释性分析Notebook,提供LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用Jupyter Notebook进行数据分析。
+本项目开源模型的词级别可解释性分析 Notebook,提供 LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用 Jupyter Notebook 进行数据分析。
运行`word_interpret.ipynb`代码,即可分析影响样本预测结果的关键词以及可视化所有词对预测结果的贡献情况,颜色越深代表这个词对预测结果影响越大:
@@ -80,14 +80,14 @@ python sent_interpret.py \
--interpret_result_file "sent_interpret.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `top_k`:筛选支持训练证据数量;默认为3。
@@ -101,7 +101,7 @@ python sent_interpret.py \
稀疏数据筛选适用于文本分类中**数据不平衡或训练数据覆盖不足**的场景,简单来说,就是由于模型在训练过程中没有学习到足够与待预测样本相似的数据,模型难以正确预测样本所属类别的情况。稀疏数据筛选旨在开发集中挖掘缺乏训练证据支持的数据,通常可以采用**数据增强**或**少量数据标注**的两种低成本方式,提升模型在开发集的预测效果。
-本项目中稀疏数据筛选基于TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
+本项目中稀疏数据筛选基于 TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
#### 稀疏数据识别—数据增强
@@ -128,15 +128,15 @@ python sparse.py \
--support_num 100
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `aug_strategy`:数据增强类型,可选"duplicate","substitute", "insert", "delete", "swap";默认为"substitute"。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -158,7 +158,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_aug.txt
**方案效果**
-我们在KUAKE-QIC数据集部分数据(训练集数据规模:500)进行实验,筛选稀疏数据数量和支持数据数量均设为100条,使用不同的数据增强方法进行评测:
+我们在 KUAKE-QIC 数据集部分数据(训练集数据规模:500)进行实验,筛选稀疏数据数量和支持数据数量均设为100条,使用不同的数据增强方法进行评测:
| |Accuracy(%) |
| ---------| ------------ |
|训练集|73.50|
@@ -193,15 +193,15 @@ python sparse.py \
--unlabeled_file "data.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
-* `annotate`:选择稀疏数据识别--数据标注模式;默认为False。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
+* `annotate`:选择稀疏数据识别--数据标注模式;默认为 False。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -216,7 +216,7 @@ python sparse.py \
* `sparse_file`:保存在本地数据集路径中稀疏数据文件名;默认为"sparse.txt"。
* `support_file`:保存在本地数据集路径中支持训练数据文件名;默认为"support.txt"。
-我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
+我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
```shell
cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
@@ -224,7 +224,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
**方案效果**
-我们在KUAKE-QIC数据集部分数据(训练集数据规模:500)进行实验,筛选稀疏数据数量设为100条,筛选待标注数据数量为50和100条。我们比较了使用稀疏数据方案的策略采样和随机采样的效果,下表结果表明使用稀疏数据方案的策略采样能够支持指导训练数据扩充,在标注更少的数据情况下获得更大提升的效果:
+我们在 KUAKE-QIC 数据集部分数据(训练集数据规模:500)进行实验,筛选稀疏数据数量设为100条,筛选待标注数据数量为50和100条。我们比较了使用稀疏数据方案的策略采样和随机采样的效果,下表结果表明使用稀疏数据方案的策略采样能够支持指导训练数据扩充,在标注更少的数据情况下获得更大提升的效果:
| |Accuracy(%) |
| ---------| ------------ |
@@ -238,7 +238,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
脏数据清洗方案是基于已训练好的文本分类模型,筛选出训练数据集中标注错误的数据,再由人工检查重新标注,获得标注正确的数据集进行重新训练。我们将介绍脏数据清洗流程:
-- **脏数据筛选:** 基于TrustAI中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
+- **脏数据筛选:** 基于 TrustAI 中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
- **数据清洗、训练:** 将筛选出的脏数据由人工重新检查,为数据打上正确的标签。将清洗后的训练数据重新放入文本分类模型进行训练。
@@ -256,14 +256,14 @@ python dirty.py \
--rest_file "train_dirty_rest.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt和label.txt文件;默认为None。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt 和 label.txt 文件;默认为 None。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `dirty_file`:保存脏数据文件名,默认为"train_dirty.txt"。
@@ -272,7 +272,7 @@ python dirty.py \
* `dirty_threshold`:筛选脏数据用于重新标注的阈值,只选择影响分数大于阈值作为支持数据,默认为0。
-我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具doccano帮助更快重新标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
+我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具 doccano 帮助更快重新标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
```shell
cat ../data/train_dirty_rest.txt ../data/train_dirty.txt > ../data/train_clean.txt
@@ -280,7 +280,7 @@ cat ../data/train_dirty_rest.txt ../data/train_dirty.txt > ../data/train_clean.t
**方案效果**
-我们在KUAKE-QIC数据集部分数据(训练集数据规模:500)进行实验,取100条数据进行脏数据处理,也即100条训练数据为标签错误数据,选择不同`dirty_num`应用脏数据清洗策略进行评测:
+我们在 KUAKE-QIC 数据集部分数据(训练集数据规模:500)进行实验,取100条数据进行脏数据处理,也即100条训练数据为标签错误数据,选择不同`dirty_num`应用脏数据清洗策略进行评测:
| |Accuracy(%) |
| ---------| ------------ |
@@ -307,10 +307,10 @@ python aug.py \
* `train_path`:待增强训练数据集文件路径;默认为"../data/train.txt"。
* `aug_path`:增强生成的训练数据集文件路径;默认为"../data/train_aug.txt"。
* `aug_strategy`:数据增强策略,可选"mix", "substitute", "insert", "delete", "swap","mix"为多种数据策略混合使用;默认为"substitute"。
-* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在GPU环境下使用mlm类型;默认为"synonym"。
+* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在 GPU 环境下使用 mlm 类型;默认为"synonym"。
* `create_n`:生成的句子数量,默认为2。
* `aug_percent`:生成词替换百分比,默认为0.1。
-* `device`: 选用什么设备进行增强,可选择cpu、gpu、xpu、npu,仅在使用mlm类型有影响;默认为"gpu"。
+* `device`: 选用什么设备进行增强,可选择 cpu、gpu、xpu、npu,仅在使用 mlm 类型有影响;默认为"gpu"。
生成的增强数据保存在`"aug.txt"`文件中,与训练集数据`train.txt`合并得到新的训练集`train_aug.txt`重新进行训练:
@@ -318,4 +318,4 @@ python aug.py \
cat ../data/aug.txt ../data/train.txt > ../data/train_aug.txt
```
-PaddleNLP内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
+PaddleNLP 内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
diff --git a/legacy/applications/text_classification/multi_class/analysis/aug.py b/slm/applications/text_classification/multi_class/analysis/aug.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/analysis/aug.py
rename to slm/applications/text_classification/multi_class/analysis/aug.py
diff --git a/legacy/applications/text_classification/multi_class/analysis/dirty.py b/slm/applications/text_classification/multi_class/analysis/dirty.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/analysis/dirty.py
rename to slm/applications/text_classification/multi_class/analysis/dirty.py
diff --git a/legacy/applications/text_classification/multi_class/analysis/sent_interpret.py b/slm/applications/text_classification/multi_class/analysis/sent_interpret.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/analysis/sent_interpret.py
rename to slm/applications/text_classification/multi_class/analysis/sent_interpret.py
diff --git a/legacy/applications/text_classification/multi_class/analysis/sparse.py b/slm/applications/text_classification/multi_class/analysis/sparse.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/analysis/sparse.py
rename to slm/applications/text_classification/multi_class/analysis/sparse.py
diff --git a/legacy/applications/text_classification/multi_class/analysis/word_interpret.ipynb b/slm/applications/text_classification/multi_class/analysis/word_interpret.ipynb
similarity index 100%
rename from legacy/applications/text_classification/multi_class/analysis/word_interpret.ipynb
rename to slm/applications/text_classification/multi_class/analysis/word_interpret.ipynb
diff --git a/legacy/applications/text_classification/multi_class/deploy/simple_serving/README.md b/slm/applications/text_classification/multi_class/deploy/simple_serving/README.md
similarity index 65%
rename from legacy/applications/text_classification/multi_class/deploy/simple_serving/README.md
rename to slm/applications/text_classification/multi_class/deploy/simple_serving/README.md
index 6ec4f03ad227..8728b8433bcc 100644
--- a/legacy/applications/text_classification/multi_class/deploy/simple_serving/README.md
+++ b/slm/applications/text_classification/multi_class/deploy/simple_serving/README.md
@@ -1,16 +1,16 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server启动服务](#Server服务启动)
+- [Server 启动服务](#Server 服务启动)
- [其他参数设置](#其他参数设置)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本
+使用有 SimpleServing 功能的 PaddleNLP 版本
```shell
pip install paddlenlp >= 2.5.1
```
-## Server服务启动
+## Server 服务启动
### 分类任务启动
#### 启动分类 Server 服务
```bash
diff --git a/legacy/applications/text_classification/multi_class/deploy/simple_serving/client.py b/slm/applications/text_classification/multi_class/deploy/simple_serving/client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/simple_serving/client.py
rename to slm/applications/text_classification/multi_class/deploy/simple_serving/client.py
diff --git a/legacy/applications/text_classification/multi_class/deploy/simple_serving/server.py b/slm/applications/text_classification/multi_class/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/simple_serving/server.py
rename to slm/applications/text_classification/multi_class/deploy/simple_serving/server.py
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/README.md b/slm/applications/text_classification/multi_class/deploy/triton_serving/README.md
similarity index 62%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/README.md
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/README.md
index 608999868824..96d44211111d 100644
--- a/legacy/applications/text_classification/multi_class/deploy/triton_serving/README.md
+++ b/slm/applications/text_classification/multi_class/deploy/triton_serving/README.md
@@ -1,6 +1,6 @@
-# 基于Triton Inference Server的服务化部署指南
+# 基于 Triton Inference Server 的服务化部署指南
-本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于ERNIE 3.0中文模型文本多分类的pipeline在线服务。
+本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于 ERNIE 3.0中文模型文本多分类的 pipeline 在线服务。
## 目录
- [服务端环境准备](#服务端环境准备)
@@ -10,8 +10,8 @@
## 服务端环境准备
-### 安装Triton Server
-拉取Triton Server镜像:
+### 安装 Triton Server
+拉取 Triton Server 镜像:
```shell
docker pull nvcr.io/nvidia/tritonserver:21.10-py3
```
@@ -22,19 +22,19 @@ docker run -it --gpus all --net=host --name triton_server -v /path/triton/model
**NOTE:**
-1. Triton版本号`21.10`可以根据自己的需求调整,各个Triton版本对应的Driver、CUDA、TRT和ONNX Runtime等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果NVIDIA Driver低于文档中要求,在启动运行时会报错。
+1. Triton 版本号`21.10`可以根据自己的需求调整,各个 Triton 版本对应的 Driver、CUDA、TRT 和 ONNX Runtime 等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果 NVIDIA Driver 低于文档中要求,在启动运行时会报错。
-2. 可以使用`--gpus '"device=1"'`来指定GPU卡号,更多GPU指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
+2. 可以使用`--gpus '"device=1"'`来指定 GPU 卡号,更多 GPU 指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
-### 进入容器并准备PaddleNLP环境
-整个服务的前后处理依赖PaddleNLP,需要在容器内安装相关python包
+### 进入容器并准备 PaddleNLP 环境
+整个服务的前后处理依赖 PaddleNLP,需要在容器内安装相关 python 包
进入容器:
```shell
docker exec -it triton_server bash
```
-安装PaddlePaddle、PaddleNLP
+安装 PaddlePaddle、PaddleNLP
```shell
python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/pypi/simple
```
@@ -43,27 +43,27 @@ python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/py
1. 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(-i https://mirror.baidu.com/pypi/simple)
-2. 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+2. 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-3. 更多关于PaddleNLP安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+3. 更多关于 PaddleNLP 安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
## 模型获取和转换
-使用Triton做服务化部署时,选择ONNX Runtime后端运行需要先将模型转换成ONNX格式。使用Paddle2ONNX将Paddle静态图模型转换为ONNX模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成model.onnx模型文件。
+使用 Triton 做服务化部署时,选择 ONNX Runtime 后端运行需要先将模型转换成 ONNX 格式。使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成 model.onnx 模型文件。
```shell
paddle2onnx --model_dir ../../checkpoint/export --model_filename model.pdmodel --params_filename model.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --enable_dev_version True
```
-创建空白目录/seqcls/1和seqcls_model/1,并将将转换好的ONNX模型移动到模型仓库目录
+创建空白目录/seqcls/1和 seqcls_model/1,并将将转换好的 ONNX 模型移动到模型仓库目录
```shell
mkdir /models/seqcls/1
mkdir /models/seqcls_model/1
mv model.onnx /models/seqcls_model/1
```
-Paddle2ONNX的命令行参数说明请查阅:[Paddle2ONNX命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
+Paddle2ONNX 的命令行参数说明请查阅:[Paddle2ONNX 命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
-模型下载转换好之后,models目录结构如下:
+模型下载转换好之后,models 目录结构如下:
```
models
├── seqcls
@@ -83,11 +83,11 @@ models
└── config.pbtxt
```
-模型配置文件config.pbtxt配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
+模型配置文件 config.pbtxt 配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
## 部署模型
-triton目录包含启动pipeline服务的配置和发送预测请求的代码,包括:
+triton 目录包含启动 pipeline 服务的配置和发送预测请求的代码,包括:
```
models # Triton启动需要的模型仓库,包含模型和服务配置文件
@@ -96,7 +96,7 @@ seqcls_grpc_client.py # 分类任务发送pipeline预测请求的脚本
### 启动服务端
-在容器内执行下面命令启动服务,默认启动models下所有模型:
+在容器内执行下面命令启动服务,默认启动 models 下所有模型:
```shell
tritonserver --model-repository=/models
```
@@ -107,11 +107,11 @@ tritonserver --model-repository=/models --model-control-mode=explicit --load-mod
**NOTE:**
-启动服务时,Triton Server的每个python后端进程默认申请`64M`内存,默认启动的docker无法启动多个python后端节点。两个解决方案:
+启动服务时,Triton Server 的每个 python 后端进程默认申请`64M`内存,默认启动的 docker 无法启动多个 python 后端节点。两个解决方案:
1. 启动容器时设置`shm-size`参数, 比如:`docker run -it --net=host --name triton_server --shm-size="1g" -v /path/triton/models:/models nvcr.io/nvidia/tritonserver:21.10-py3 bash`
-2. 启动服务时设置python后端的`shm-default-byte-size`参数, 设置python后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
+2. 启动服务时设置 python 后端的`shm-default-byte-size`参数, 设置 python 后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
输出打印如下:
@@ -158,7 +158,7 @@ docker run -it --net=host --name triton_client -v /path/to/triton:/triton_code
```
### 启动客户端测试
-注意执行客户端请求时关闭代理,并根据实际情况修改main函数中的ip地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 main 函数中的 ip 地址(启动服务所在的机器)
```shell
python seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls/config.pbtxt b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls/config.pbtxt
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_model/config.pbtxt b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_model/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_model/config.pbtxt
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_model/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/1/model.py b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/1/model.py
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/1/model.py
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/1/model.py b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/1/model.py
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/1/model.py
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/config.pbtxt b/slm/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/config.pbtxt
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/models/tokenizer/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_class/deploy/triton_serving/seqcls_grpc_client.py b/slm/applications/text_classification/multi_class/deploy/triton_serving/seqcls_grpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/deploy/triton_serving/seqcls_grpc_client.py
rename to slm/applications/text_classification/multi_class/deploy/triton_serving/seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/multi_class/few-shot/README.md b/slm/applications/text_classification/multi_class/few-shot/README.md
similarity index 83%
rename from legacy/applications/text_classification/multi_class/few-shot/README.md
rename to slm/applications/text_classification/multi_class/few-shot/README.md
index 476e81b36be9..08e1f1ca6734 100644
--- a/legacy/applications/text_classification/multi_class/few-shot/README.md
+++ b/slm/applications/text_classification/multi_class/few-shot/README.md
@@ -124,11 +124,11 @@ python train.py --data_dir ./data/ --output_dir ./checkpoints/ --prompt "这条
### 3.3 数据标注
-我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即doccano导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano数据标注指南](../../doccano.md)。
+我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即 doccano 导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano 数据标注指南](../../doccano.md)。
**示例数据**
-这里我们使用[FewCLUE](https://github.com/CLUEbenchmark/FewCLUE)中的新闻分类tnews数据集后缀为0的子集作为示例数据集,可点击[这里](https://paddlenlp.bj.bcebos.com/datasets/few-shot/tnews.tar.gz)下载解压并放入`./data/`文件夹,或者运行以下脚本
+这里我们使用[FewCLUE](https://github.com/CLUEbenchmark/FewCLUE)中的新闻分类 tnews 数据集后缀为0的子集作为示例数据集,可点击[这里](https://paddlenlp.bj.bcebos.com/datasets/few-shot/tnews.tar.gz)下载解压并放入`./data/`文件夹,或者运行以下脚本
```
wget https://paddlenlp.bj.bcebos.com/datasets/few-shot/tnews.tar.gz
@@ -151,7 +151,7 @@ data/
**训练/验证/测试数据**
-对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由tab符`\t`分隔。格式如下
+对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由 tab 符`\t`分隔。格式如下
```text
<文本>'\t'<标签>
<文本>'\t'<标签>
@@ -253,13 +253,13 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `data_dir`: 训练数据集路径,数据格式要求详见[数据标注](#数据标注)。
- `output_dir`: 模型参数、训练日志和静态图导出的保存目录。
- `prompt`: 提示模板。定义了如何将文本和提示拼接结合。
-- `soft_encoder`: 提示向量的编码器,`lstm`表示双向LSTM, `mlp`表示双层线性层, None表示直接使用提示向量。默认为`lstm`。
+- `soft_encoder`: 提示向量的编码器,`lstm`表示双向 LSTM, `mlp`表示双层线性层, None 表示直接使用提示向量。默认为`lstm`。
- `use_rdrop`: 使用 [R-Drop](https://arxiv.org/abs/2106.14448) 策略。
- `use_rgl`: 使用 [RGL](https://aclanthology.org/2022.findings-naacl.81/) 策略。
-- `encoder_hidden_size`: 提示向量的维度。若为None,则使用预训练模型字向量维度。默认为200。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
-- `learning_rate`: 预训练语言模型参数基础学习率大小,将与learning rate scheduler产生的值相乘作为当前学习率。
-- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用learning rate scheduler。一般设为`learning_rate`的十倍。
+- `encoder_hidden_size`: 提示向量的维度。若为 None,则使用预训练模型字向量维度。默认为200。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
+- `learning_rate`: 预训练语言模型参数基础学习率大小,将与 learning rate scheduler 产生的值相乘作为当前学习率。
+- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用 learning rate scheduler。一般设为`learning_rate`的十倍。
- `do_train`: 是否进行训练。
- `do_eval`: 是否进行评估。
- `do_predict`: 是否进行预测。
@@ -269,8 +269,8 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `eval_steps`: 评估模型的间隔步数。
- `device`: 使用的设备,默认为`gpu`。
- `logging_steps`: 打印日志的间隔步数。
-- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
-- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
+- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
+- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
更多参数介绍可参考[配置文件](https://paddlenlp.readthedocs.io/zh/latest/trainer.html)。
@@ -288,7 +288,7 @@ python train.py --do_predict --data_dir ./data --output_dir ./predict_checkpoint
- `output_dir`: 日志的保存目录。
- `resume_from_checkpoint`: 训练时模型参数的保存目录,用于加载模型参数。
- `do_predict`: 是否进行预测。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
### 3.6 模型部署
@@ -308,31 +308,31 @@ python train.py --do_export --data_dir ./data --output_dir ./export_checkpoint -
- `do_export`: 是否将模型导出为静态图,保存路径为`output_dir/export`。
- `export_type`: 模型导出的格式,默认为`paddle`,即导出静态图。
-#### ONNXRuntime部署
+#### ONNXRuntime 部署
**运行环境**
-模型转换与ONNXRuntime预测部署依赖Paddle2ONNX和ONNXRuntime,Paddle2ONNX支持将Paddle静态图模型转化为ONNX模型格式,算子目前稳定支持导出ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
+模型转换与 ONNXRuntime 预测部署依赖 Paddle2ONNX 和 ONNXRuntime,Paddle2ONNX 支持将 Paddle 静态图模型转化为 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
-- 如果基于GPU部署,请先确保机器已正确安装NVIDIA相关驱动和基础软件,确保CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
+- 如果基于 GPU 部署,请先确保机器已正确安装 NVIDIA 相关驱动和基础软件,确保 CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime-gpu onnx onnxconverter-common
```
-- 如果基于CPU部署,请使用如下命令安装所需依赖:
+- 如果基于 CPU 部署,请使用如下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime
```
-**CPU端推理样例**
+**CPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device cpu
```
-**GPU端推理样例**
+**GPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device gpu --device_id 0
@@ -341,16 +341,16 @@ python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data -
可配置参数说明:
- `model_path_prefix`: 导出的静态图模型路径及文件前缀。
-- `model_name`: 内置预训练模型名,用于加载tokenizer。默认为`ernie-3.0-base-zh`。
+- `model_name`: 内置预训练模型名,用于加载 tokenizer。默认为`ernie-3.0-base-zh`。
- `data_dir`: 待推理数据所在路径,数据应存放在该目录下的`data.txt`文件。
-- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
- `batch_size`: 每次预测的样本数量。
- `device`: 选择推理设备,包括`cpu`和`gpu`。默认为`gpu`。
-- `device_id`: 指定GPU设备ID。
-- `use_fp16`: 是否使用半精度加速推理。仅在GPU设备上有效。
-- `num_threads`: 设置CPU使用的线程数。默认为机器上的物理内核数。
+- `device_id`: 指定 GPU 设备 ID。
+- `use_fp16`: 是否使用半精度加速推理。仅在 GPU 设备上有效。
+- `num_threads`: 设置 CPU 使用的线程数。默认为机器上的物理内核数。
-**Note**: 在GPU设备的CUDA计算能力 (CUDA Compute Capability) 大于7.0,在包括V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启FP16进行加速,在CPU或者CUDA计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
+**Note**: 在 GPU 设备的 CUDA 计算能力 (CUDA Compute Capability) 大于7.0,在包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启 FP16进行加速,在 CPU 或者 CUDA 计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
## 4. References
diff --git a/legacy/applications/text_classification/multi_class/few-shot/infer.py b/slm/applications/text_classification/multi_class/few-shot/infer.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/few-shot/infer.py
rename to slm/applications/text_classification/multi_class/few-shot/infer.py
diff --git a/legacy/applications/text_classification/multi_class/few-shot/requirements_cpu.txt b/slm/applications/text_classification/multi_class/few-shot/requirements_cpu.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/few-shot/requirements_cpu.txt
rename to slm/applications/text_classification/multi_class/few-shot/requirements_cpu.txt
diff --git a/legacy/applications/text_classification/multi_class/few-shot/requirements_gpu.txt b/slm/applications/text_classification/multi_class/few-shot/requirements_gpu.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/few-shot/requirements_gpu.txt
rename to slm/applications/text_classification/multi_class/few-shot/requirements_gpu.txt
diff --git a/legacy/applications/text_classification/multi_class/few-shot/train.py b/slm/applications/text_classification/multi_class/few-shot/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/few-shot/train.py
rename to slm/applications/text_classification/multi_class/few-shot/train.py
diff --git a/legacy/applications/text_classification/multi_class/few-shot/utils.py b/slm/applications/text_classification/multi_class/few-shot/utils.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/few-shot/utils.py
rename to slm/applications/text_classification/multi_class/few-shot/utils.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/README.md b/slm/applications/text_classification/multi_class/retrieval_based/README.md
similarity index 81%
rename from legacy/applications/text_classification/multi_class/retrieval_based/README.md
rename to slm/applications/text_classification/multi_class/retrieval_based/README.md
index 4cbf3a33ee1e..2979aa8e7c81 100644
--- a/legacy/applications/text_classification/multi_class/retrieval_based/README.md
+++ b/slm/applications/text_classification/multi_class/retrieval_based/README.md
@@ -15,9 +15,9 @@
# 1.基于语义索引的分类任务介绍
-以前的分类任务中,标签信息作为无实际意义,独立存在的one-hot编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
+以前的分类任务中,标签信息作为无实际意义,独立存在的 one-hot 编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
-本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入In-batch Negatives 策略,使用hnswlib建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
+本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入 In-batch Negatives 策略,使用 hnswlib 建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
@@ -61,7 +61,7 @@
## 3. 环境准备
-推荐使用GPU进行训练,在预测阶段使用CPU或者GPU均可。
+推荐使用 GPU 进行训练,在预测阶段使用 CPU 或者 GPU 均可。
**环境依赖**
* python >= 3.6.2
@@ -78,7 +78,7 @@ pip install -r requirements.txt
## 4. 数据准备
-训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。
+训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。
**指定格式本地数据集目录结构**
@@ -91,7 +91,7 @@ pip install -r requirements.txt
**训练、开发、测试数据集**
-train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用tab符`'\t'`分隔开。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
+train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用 tab 符`'\t'`分隔开。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
- train.txt/dev.txt/test.txt 文件格式:
```text
@@ -132,7 +132,7 @@ label.txt(分类标签文件)记录数据集中所有标签集合,每一行为
我们使用百科知识问答的数据来构建训练集,开发集。
-**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集61510条,开发集6835条,每行由文本的标题,内容和类别标签组成,以tab符分割,第一列是问题的标题和描述拼接,剩下的列是问题的类别,另外,标签有5981个。
+**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集61510条,开发集6835条,每行由文本的标题,内容和类别标签组成,以 tab 符分割,第一列是问题的标题和描述拼接,剩下的列是问题的类别,另外,标签有5981个。
**召回库(label.txt)** 召回库的构建有2种方式,第一种是把所有的类别标签当成召回库,第二种是把训练集当成召回集合,我们以第一种为例。
数据集选择的是百科问答数据集的一个子集,问答数据集详情请参考[nlp_chinese_corpus](https://github.com/brightmart/nlp_chinese_corpus)
@@ -148,9 +148,9 @@ unzip webtext2019zh_qa.zip
这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1 卡;如果采用单机单卡训练,只需要把`--gpus`参数设置成单卡的卡号即可。
-如果使用CPU进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成cpu即可,详细请参考train.sh文件的训练设置
+如果使用 CPU 进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成 cpu 即可,详细请参考 train.sh 文件的训练设置
-然后运行下面的命令使用GPU训练,得到语义索引模型:
+然后运行下面的命令使用 GPU 训练,得到语义索引模型:
```
root_path=inbatch
@@ -179,9 +179,9 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `device`: 使用 cpu/gpu 进行训练
* `save_dir`: 模型存储路径
-* `batch_size`: 训练的batch size的大小
+* `batch_size`: 训练的 batch size 的大小
* `learning_rate`: 训练的学习率的大小
-* `epochs`: 训练的epoch数
+* `epochs`: 训练的 epoch 数
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `save_steps`: 模型存储 checkpoint 的间隔 steps 个数
* `max_seq_length`: 输入序列的最大长度
@@ -196,7 +196,7 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `similar_text_pair`: 由相似文本对构成的评估集
* `corpus_file`: 召回库数据 corpus_file
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/train.sh
@@ -233,12 +233,12 @@ python -u -m paddle.distributed.launch --gpus "0" \
* `model_name_or_path`: 预训练模型,用于模型和`Tokenizer`的参数初始化。
* `text_pair_file`: 由文本 Pair 构成的待预测数据集
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/predict.sh
```
-predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
+predict.sh 文件包含了 cpu 和 gpu 运行的脚本,默认是 gpu 运行的脚本
产出如下结果
```
@@ -263,17 +263,17 @@ python export_model.py \
--model_name_or_path rocketqa-zh-dureader-query-encoder \
--output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
```
-### Paddle Inference预测
+### Paddle Inference 预测
预测既可以抽取向量也可以计算两个文本的相似度。
-修改deploy/python/predict.py中的id2corpus和corpus_list的样本:
+修改 deploy/python/predict.py 中的 id2corpus 和 corpus_list 的样本:
```
# 抽取向量
@@ -296,12 +296,12 @@ corpus_list = [{
```
-然后使用PaddleInference
+然后使用 PaddleInference
```
python deploy/python/predict.py --model_dir=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy.sh
@@ -320,7 +320,7 @@ sh deploy.sh
### 向量引擎
-模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU版本,建议使用官方的 Docker 安装方式,简单快捷。
+模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus 官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU 版本,建议使用官方的 Docker 安装方式,简单快捷。
Milvus 搭建完系统以后就可以插入和检索向量了,首先生成 embedding 向量,每个样本生成768维度的向量:
@@ -346,9 +346,9 @@ python utils/vector_insert.py \
sh scripts/run.sh
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成Serving的格式:
+Paddle Serving 的详细文档请参考 [Pipeline_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Python_Pipeline/Pipeline_Design_CN.md)和[Serving_Design](https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Design_CN.md),首先把静态图模型转换成 Serving 的格式:
```
python export_to_serving.py \
@@ -374,9 +374,9 @@ python export_to_serving.py \
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署有两种方式,第一种方式是Pipeline的方式,第二种是C++的方式,下面分别介绍这两种方式的用法:
+Paddle Serving 的部署有两种方式,第一种方式是 Pipeline 的方式,第二种是 C++的方式,下面分别介绍这两种方式的用法:
-#### Pipeline方式
+#### Pipeline 方式
启动 Pipeline Server:
@@ -385,7 +385,7 @@ cd deploy/python/
python web_service.py
```
-启动客户端调用 Server, 使用 POST的方式:
+启动客户端调用 Server, 使用 POST 的方式:
向服务端发送 POST 请求示例:
@@ -393,8 +393,8 @@ python web_service.py
curl -X POST -k http://localhost:8090/ernie/prediction -d '{"key": ["0"], "value": ["{\"sentence\": \"青岛有什么好一点的国际青旅推荐?离海近一点 外国人多一点 氛围好点的\"}"]}'
```
-也可以使用 rpc的方式:
-首先修改rpc_client.py中需要预测的样本:
+也可以使用 rpc 的方式:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [{
@@ -425,7 +425,7 @@ time to cost :0.014188766479492188 seconds
## 8. 分类流程
-基于检索的分类系统使用了Client Server的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问。
+基于检索的分类系统使用了 Client Server 的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问。
```
python run_system.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/base_model.py b/slm/applications/text_classification/multi_class/retrieval_based/base_model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/base_model.py
rename to slm/applications/text_classification/multi_class/retrieval_based/base_model.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/data.py b/slm/applications/text_classification/multi_class/retrieval_based/data.py
similarity index 99%
rename from legacy/applications/text_classification/multi_class/retrieval_based/data.py
rename to slm/applications/text_classification/multi_class/retrieval_based/data.py
index 17081543edaa..7913310d5520 100644
--- a/legacy/applications/text_classification/multi_class/retrieval_based/data.py
+++ b/slm/applications/text_classification/multi_class/retrieval_based/data.py
@@ -17,6 +17,7 @@
import hnswlib
import numpy as np
import paddle
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/config_nlp.yml b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/config_nlp.yml
rename to slm/applications/text_classification/multi_class/retrieval_based/deploy/python/config_nlp.yml
diff --git a/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
new file mode 100644
index 000000000000..f4b8c7b5207f
--- /dev/null
+++ b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/deploy.sh
@@ -0,0 +1,15 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python predict.py --model_dir=../../output
\ No newline at end of file
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/predict.py b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/predict.py
rename to slm/applications/text_classification/multi_class/retrieval_based/deploy/python/predict.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/rpc_client.py b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/rpc_client.py
rename to slm/applications/text_classification/multi_class/retrieval_based/deploy/python/rpc_client.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/web_service.py b/slm/applications/text_classification/multi_class/retrieval_based/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/web_service.py
rename to slm/applications/text_classification/multi_class/retrieval_based/deploy/python/web_service.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/evaluate.py b/slm/applications/text_classification/multi_class/retrieval_based/evaluate.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/evaluate.py
rename to slm/applications/text_classification/multi_class/retrieval_based/evaluate.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/export_model.py b/slm/applications/text_classification/multi_class/retrieval_based/export_model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/export_model.py
rename to slm/applications/text_classification/multi_class/retrieval_based/export_model.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/export_to_serving.py b/slm/applications/text_classification/multi_class/retrieval_based/export_to_serving.py
similarity index 99%
rename from legacy/applications/text_classification/multi_class/retrieval_based/export_to_serving.py
rename to slm/applications/text_classification/multi_class/retrieval_based/export_to_serving.py
index 1ba681a4dfb1..6cc932da1117 100644
--- a/legacy/applications/text_classification/multi_class/retrieval_based/export_to_serving.py
+++ b/slm/applications/text_classification/multi_class/retrieval_based/export_to_serving.py
@@ -13,6 +13,7 @@
# limitations under the License.
import argparse
+
import paddle_serving_client.io as serving_io
# yapf: disable
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/model.py b/slm/applications/text_classification/multi_class/retrieval_based/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/model.py
rename to slm/applications/text_classification/multi_class/retrieval_based/model.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/predict.py b/slm/applications/text_classification/multi_class/retrieval_based/predict.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/predict.py
rename to slm/applications/text_classification/multi_class/retrieval_based/predict.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/recall.py b/slm/applications/text_classification/multi_class/retrieval_based/recall.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/recall.py
rename to slm/applications/text_classification/multi_class/retrieval_based/recall.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/requirements.txt b/slm/applications/text_classification/multi_class/retrieval_based/requirements.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/requirements.txt
rename to slm/applications/text_classification/multi_class/retrieval_based/requirements.txt
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/run_system.py b/slm/applications/text_classification/multi_class/retrieval_based/run_system.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/run_system.py
rename to slm/applications/text_classification/multi_class/retrieval_based/run_system.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/evaluate.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/evaluate.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/evaluate.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/evaluate.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/export_model.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/export_model.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/export_model.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/export_model.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/export_to_serving.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/export_to_serving.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/export_to_serving.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/export_to_serving.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/predict.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/predict.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/predict.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/predict.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/run.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/run.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/run.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/run.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/run_build_index.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/run_build_index.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/run_build_index.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/run_build_index.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/scripts/train.sh b/slm/applications/text_classification/multi_class/retrieval_based/scripts/train.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/scripts/train.sh
rename to slm/applications/text_classification/multi_class/retrieval_based/scripts/train.sh
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/train.py b/slm/applications/text_classification/multi_class/retrieval_based/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/train.py
rename to slm/applications/text_classification/multi_class/retrieval_based/train.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/utils/__init__.py b/slm/applications/text_classification/multi_class/retrieval_based/utils/__init__.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/utils/__init__.py
rename to slm/applications/text_classification/multi_class/retrieval_based/utils/__init__.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/utils/config.py b/slm/applications/text_classification/multi_class/retrieval_based/utils/config.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/utils/config.py
rename to slm/applications/text_classification/multi_class/retrieval_based/utils/config.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/utils/feature_extract.py b/slm/applications/text_classification/multi_class/retrieval_based/utils/feature_extract.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/utils/feature_extract.py
rename to slm/applications/text_classification/multi_class/retrieval_based/utils/feature_extract.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/utils/milvus_util.py b/slm/applications/text_classification/multi_class/retrieval_based/utils/milvus_util.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/utils/milvus_util.py
rename to slm/applications/text_classification/multi_class/retrieval_based/utils/milvus_util.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/utils/vector_insert.py b/slm/applications/text_classification/multi_class/retrieval_based/utils/vector_insert.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/utils/vector_insert.py
rename to slm/applications/text_classification/multi_class/retrieval_based/utils/vector_insert.py
diff --git a/legacy/applications/text_classification/multi_class/train.py b/slm/applications/text_classification/multi_class/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/train.py
rename to slm/applications/text_classification/multi_class/train.py
diff --git a/legacy/applications/text_classification/multi_class/utils.py b/slm/applications/text_classification/multi_class/utils.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/utils.py
rename to slm/applications/text_classification/multi_class/utils.py
diff --git a/legacy/applications/text_classification/multi_label/README.md b/slm/applications/text_classification/multi_label/README.md
similarity index 75%
rename from legacy/applications/text_classification/multi_label/README.md
rename to slm/applications/text_classification/multi_label/README.md
index 94896cc8cc14..33f6d0ff5c39 100644
--- a/legacy/applications/text_classification/multi_label/README.md
+++ b/slm/applications/text_classification/multi_label/README.md
@@ -14,7 +14,7 @@
## 1. 多标签分类简介
-本项目提供通用场景下**基于预训练模型微调的多标签分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低AI开发落地门槛。
+本项目提供通用场景下**基于预训练模型微调的多标签分类端到端应用方案**,打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,有效缩短开发周期,降低 AI 开发落地门槛。
多标签数据集的标签集含有两个或两个以上的类别,输入句子/文本具有一个或多个标签,多标签任务的目标是预测**样本属于哪些标签类别,这些类别具有不相互排斥的属性**。文本多标签分类在各种现实场景中具有广泛的适用性,例如商品分类、网页标签、新闻标注、蛋白质功能分类、电影分类、语义场景分类等。以下图为例,该新闻文本具有 `相机` 和 `芯片` 两个标签。
@@ -26,8 +26,8 @@
**方案亮点:**
-- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
-- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
+- **效果领先🏃:** 使用在中文领域内模型效果和模型计算效率有突出效果的 ERNIE 3.0 轻量级系列模型作为训练基座,ERNIE 3.0 轻量级系列提供多种尺寸的预训练模型满足不同需求,具有广泛成熟的实践应用性。
+- **高效调优✊:** 文本分类应用依托[TrustAI](https://github.com/PaddlePaddle/TrustAI)可信增强能力和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md),提供模型分析模块助力开发者实现模型分析,并提供稀疏数据筛选、脏数据清洗、数据增强等多种解决方案。
- **简单易用👶:** 开发者**无需机器学习背景知识**,仅需提供指定格式的标注分类数据,一行命令即可开启文本分类训练,轻松完成上线部署,不再让技术成为文本分类的门槛。
**更多选择:**
@@ -40,7 +40,7 @@
## 2. 快速开始
-我们以公开数据集CAIL2019—婚姻家庭要素提取任务为示例,演示多标签分类全流程方案使用。下载数据集:
+我们以公开数据集 CAIL2019—婚姻家庭要素提取任务为示例,演示多标签分类全流程方案使用。下载数据集:
```shell
wget https://paddlenlp.bj.bcebos.com/datasets/divorce.tar.gz
tar -zxvf divorce.tar.gz
@@ -66,20 +66,20 @@ rm divorce.tar.gz
- paddlenlp >= 2.4.8
- scikit-learn >= 1.0.2
-**安装PaddlePaddle:**
+**安装 PaddlePaddle:**
- 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+ 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-**安装PaddleNLP:**
+**安装 PaddleNLP:**
-安装PaddleNLP默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(删去 -i https://mirror.baidu.com/pypi/simple),更多关于PaddleNLP安装的详细教程请查见[PaddleNLP快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+安装 PaddleNLP 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(删去 -i https://mirror.baidu.com/pypi/simple),更多关于 PaddleNLP 安装的详细教程请查见[PaddleNLP 快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
```shell
python3 -m pip install --upgrade paddlenlp -i https://mirror.baidu.com/pypi/simple
```
-**安装sklearn:**
+**安装 sklearn:**
```shell
python3 -m pip install scikit-learn==1.0.2
```
@@ -118,7 +118,7 @@ data/
├── label.txt # 分类标签文件
└── data.txt # 待预测数据文件(可选)
```
-**训练、开发、测试数据集**文件中文本与标签类别名用tab符`'\t'`分隔开,标签中多个标签之间用`','`逗号分隔开,文本中避免出现tab符`'\t'`。
+**训练、开发、测试数据集**文件中文本与标签类别名用 tab 符`'\t'`分隔开,标签中多个标签之间用`','`逗号分隔开,文本中避免出现 tab 符`'\t'`。
- train.txt/dev.txt/test.txt 文件格式:
```text
@@ -180,7 +180,7 @@ data/
#### 2.4.1 预训练模型微调
-使用CPU/GPU训练,默认为GPU训练。使用CPU训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定GPU卡号:
+使用 CPU/GPU 训练,默认为 GPU 训练。使用 CPU 训练只需将设备参数配置改为`--device cpu`,可以使用`--device gpu:0`指定 GPU 卡号:
```shell
python train.py \
--dataset_dir "data" \
@@ -192,7 +192,7 @@ python train.py \
--epochs 100
```
-如果在GPU环境中使用,可以指定`gpus`参数进行单卡/多卡训练。使用多卡训练可以指定多个GPU卡号,例如 --gpus "0,1"。如果设备只有一个GPU卡号默认为0,可使用`nvidia-smi`命令查看GPU使用情况。
+如果在 GPU 环境中使用,可以指定`gpus`参数进行单卡/多卡训练。使用多卡训练可以指定多个 GPU 卡号,例如 --gpus "0,1"。如果设备只有一个 GPU 卡号默认为0,可使用`nvidia-smi`命令查看 GPU 使用情况。
```shell
unset CUDA_VISIBLE_DEVICES
@@ -207,21 +207,21 @@ python -m paddle.distributed.launch --gpus "0" train.py \
```
可支持配置的参数:
-* `device`: 选用什么设备进行训练,选择cpu、gpu、xpu、npu。如使用gpu训练,可使用参数--gpus指定GPU卡号;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt,dev.txt和label.txt文件;默认为None。
-* `save_dir`:保存训练模型的目录;默认保存在当前目录checkpoint文件夹下。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `device`: 选用什么设备进行训练,选择 cpu、gpu、xpu、npu。如使用 gpu 训练,可使用参数--gpus 指定 GPU 卡号;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt,dev.txt 和 label.txt 文件;默认为 None。
+* `save_dir`:保存训练模型的目录;默认保存在当前目录 checkpoint 文件夹下。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `model_name`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh"。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `learning_rate`:训练最大学习率;默认为3e-5。
* `epochs`: 训练轮次,使用早停法时可以选择100;默认为10。
-* `early_stop`:选择是否使用早停法(EarlyStopping),模型在开发集经过一定epoch后精度表现不再上升,训练终止;默认为False。
+* `early_stop`:选择是否使用早停法(EarlyStopping),模型在开发集经过一定 epoch 后精度表现不再上升,训练终止;默认为 False。
* `early_stop_nums`:在设定的早停训练轮次内,模型在开发集上表现不再上升,训练终止;默认为4。
-* `logging_steps`: 训练过程中日志打印的间隔steps数,默认5。
+* `logging_steps`: 训练过程中日志打印的间隔 steps 数,默认5。
* `weight_decay`:控制正则项力度的参数,用于防止过拟合,默认为0.0。
-* `warmup`:是否使用学习率warmup策略,使用时应设置适当的训练轮次(epochs);默认为False。
-* `warmup_steps`:学习率warmup策略的比例数,如果设为1000,则学习率会在1000steps数从0慢慢增长到learning_rate, 而后再缓慢衰减;默认为0。
-* `init_from_ckpt`: 模型初始checkpoint参数地址,默认None。
+* `warmup`:是否使用学习率 warmup 策略,使用时应设置适当的训练轮次(epochs);默认为 False。
+* `warmup_steps`:学习率 warmup 策略的比例数,如果设为1000,则学习率会在1000steps 数从0慢慢增长到 learning_rate, 而后再缓慢衰减;默认为0。
+* `init_from_ckpt`: 模型初始 checkpoint 参数地址,默认 None。
* `seed`:随机种子,默认为3。
* `train_file`:本地数据集中训练集文件名;默认为"train.txt"。
* `dev_file`:本地数据集中开发集文件名;默认为"dev.txt"。
@@ -241,17 +241,17 @@ checkpoint/
**NOTE:**
* 如需恢复模型训练,则可以设置 `init_from_ckpt` , 如 `init_from_ckpt=checkpoint/model_state.pdparams` 。
* 如需训练英文文本分类任务,只需更换预训练模型参数 `model_name` 。英文训练任务推荐使用"ernie-2.0-base-en"、"ernie-2.0-large-en"。
-* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M论文](https://arxiv.org/pdf/2012.15674.pdf)。
+* 英文和中文以外语言的文本分类任务,推荐使用基于96种语言(涵盖法语、日语、韩语、德语、西班牙语等几乎所有常见语言)进行预训练的多语言预训练模型"ernie-m-base"、"ernie-m-large",详情请参见[ERNIE-M 论文](https://arxiv.org/pdf/2012.15674.pdf)。
#### 2.4.2 训练评估与模型优化
-文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis模块](./analysis) 提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+文本分类预测过程中常会遇到诸如"模型为什么会预测出错误的结果","如何提升模型的表现"等问题。[Analysis 模块](./analysis) 提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
-**模型评估:** 训练后的模型我们可以使用 [Analysis模块](./analysis) 对每个类别分别进行评估,并输出预测错误样本(bad case),默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`:
+**模型评估:** 训练后的模型我们可以使用 [Analysis 模块](./analysis) 对每个类别分别进行评估,并输出预测错误样本(bad case),默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`:
```shell
python analysis/evaluate.py --device "gpu" --max_seq_length 128 --batch_size 32 --bad_case_file "bad_case.txt" --dataset_dir "data" --params_path "./checkpoint"
@@ -273,10 +273,10 @@ python analysis/evaluate.py --device "gpu" --max_seq_length 128 --batch_size 32
...
```
-预测错误的样本保存在bad_case.txt文件中:
+预测错误的样本保存在 bad_case.txt 文件中:
```text
-Text Label Prediction
+Text Label Prediction
2014年,王X以其与肖X协议离婚时未分割该套楼房的首付款为由,起诉至法院,要求分得楼房的首付款15万元。 不动产分割,有夫妻共同财产 不动产分割
但原、被告对已建立起的夫妻感情不够珍惜,因琐事即发生吵闹并最终分居,对夫妻感情造成了严重的影响,现原、被告已分居六年有余,且经人民法院判决不准离婚后仍未和好,夫妻感情确已破裂,依法应准予原、被告离婚。 二次起诉离婚,准予离婚,婚后分居,法定离婚 婚后分居,准予离婚
婚后生有一女,取名彭某乙,已11岁,现已由被告从铁炉白族乡中心小学转入走马镇李桥小学读书。 婚后有子女 婚后有子女,限制行为能力子女抚养
@@ -295,13 +295,13 @@ text: 2015年2月23日,被告将原告赶出家门,原告居住于娘家待
predict label: 婚后分居
label: 不履行家庭义务,婚后分居
examples with positive influence
-support1 text: 2014年中秋节原告回了娘家,原、被告分居至今。 label: 婚后分居 score: 0.99942
-support2 text: 原告于2013年8月13日离开被告家,分居至今。 label: 婚后分居 score: 0.99916
-support3 text: 2014年4月,被告外出务工,双方分居至今。 label: 婚后分居 score: 0.99902
+support1 text: 2014年中秋节原告回了娘家,原、被告分居至今。 label: 婚后分居 score: 0.99942
+support2 text: 原告于2013年8月13日离开被告家,分居至今。 label: 婚后分居 score: 0.99916
+support3 text: 2014年4月,被告外出务工,双方分居至今。 label: 婚后分居 score: 0.99902
...
```
-**数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果,策略细节详见[训练评估与模型优化指南](analysis/README.md)。
+**数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果,策略细节详见[训练评估与模型优化指南](analysis/README.md)。
- 稀疏数据筛选主要是解决数据不均衡、训练数据覆盖不足的问题,通过数据增强和数据标注两种方式解决这一问题。
- 脏数据清洗可以帮助开发者筛选训练集中错误标注的数据,对这些数据重新进行人工标注,得到标注正确的数据再重新进行训练。
@@ -309,7 +309,7 @@ support3 text: 2014年4月,被告外出务工,双方分居至今。 label:
#### 2.4.3 模型预测
-训练结束后,输入待预测数据(data.txt)和类别标签对照列表(label.txt),使用训练好的模型进行,默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`:
+训练结束后,输入待预测数据(data.txt)和类别标签对照列表(label.txt),使用训练好的模型进行,默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`:
```shell
python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_dir "data"
@@ -317,8 +317,8 @@ python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_
可支持配置的参数:
-* `device`: 选用什么设备进行预测,可选cpu、gpu、xpu、npu;默认为gpu。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含data.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行预测,可选 cpu、gpu、xpu、npu;默认为 gpu。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 data.txt 和 label.txt 文件;默认为 None。
* `params_path`:待预测模型的目录;默认为"./checkpoint/"。
* `max_seq_length`:模型使用的最大序列长度,建议与训练时最大序列长度一致, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
@@ -337,7 +337,7 @@ python predict.py --device "gpu" --max_seq_length 128 --batch_size 32 --dataset_
python export_model.py --params_path ./checkpoint/ --output_path ./export
```
-如果使用多语言模型 ERNIE M作为预训练模型,运行方式:
+如果使用多语言模型 ERNIE M 作为预训练模型,运行方式:
```shell
python export_model.py --params_path ./checkpoint/ --output_path ./export --multilingual
@@ -345,7 +345,7 @@ python export_model.py --params_path ./checkpoint/ --output_path ./export --mult
可支持配置的参数:
-* `multilingual`:是否为多语言任务(是否使用ERNIE M作为预训练模型);默认为False。
+* `multilingual`:是否为多语言任务(是否使用 ERNIE M 作为预训练模型);默认为 False。
* `params_path`:动态图训练保存的参数路径;默认为"./checkpoint/"。
* `output_path`:静态图图保存的参数路径;默认为"./export"。
@@ -357,11 +357,11 @@ export/
├── float32.pdiparams.info
└── float32.pdmodel
```
- 导出模型之后用于部署,项目提供了基于ONNXRuntime的 [离线部署方案](./deploy/predictor/README.md) 和基于Paddle Serving的 [在线服务化部署方案](./deploy/predictor/README.md)。
+ 导出模型之后用于部署,项目提供了基于 ONNXRuntime 的 [离线部署方案](./deploy/predictor/README.md) 和基于 Paddle Serving 的 [在线服务化部署方案](./deploy/predictor/README.md)。
#### 2.5.2 模型裁剪
-如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
+如果有模型部署上线的需求,需要进一步压缩模型体积,可以使用 PaddleNLP 的 [压缩 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/compression.md), 一行命令即可启动模型裁剪。
使用裁剪功能需要安装 paddleslim:
@@ -369,7 +369,7 @@ export/
pip install paddleslim==2.4.1
```
-开始模型裁剪训练,默认为GPU训练,使用CPU训练只需将设备参数配置改为`--device "cpu"`:
+开始模型裁剪训练,默认为 GPU 训练,使用 CPU 训练只需将设备参数配置改为`--device "cpu"`:
```shell
python prune.py \
--device "gpu" \
@@ -387,17 +387,17 @@ python prune.py \
可支持配置的参数:
-* `output_dir`:必须,保存模型输出和中间checkpoint的输出目录;默认为 `None` 。
-* `device`: 选用什么设备进行裁剪,选择cpu、gpu。如使用gpu训练,可使用参数--gpus指定GPU卡号。
+* `output_dir`:必须,保存模型输出和中间 checkpoint 的输出目录;默认为 `None` 。
+* `device`: 选用什么设备进行裁剪,选择 cpu、gpu。如使用 gpu 训练,可使用参数--gpus 指定 GPU 卡号。
* `per_device_train_batch_size`:训练集裁剪训练过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `per_device_eval_batch_size`:开发集评测过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `learning_rate`:训练最大学习率;默认为5e-5。
* `num_train_epochs`: 训练轮次,使用早停法时可以选择100;默认为10。
-* `logging_steps`: 训练过程中日志打印的间隔steps数,默认100。
-* `save_steps`: 训练过程中保存模型checkpoint的间隔steps数,默认100。
+* `logging_steps`: 训练过程中日志打印的间隔 steps 数,默认100。
+* `save_steps`: 训练过程中保存模型 checkpoint 的间隔 steps 数,默认100。
* `seed`:随机种子,默认为3。
-* `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对self_attention中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed数量)应为整数;默认是None。
-* `dataset_dir`:本地数据集路径,需包含train.txt,dev.txt,label.txt;默认为None。
+* `width_mult_list`:裁剪宽度(multi head)保留的比例列表,表示对 self_attention 中的 `q`、`k`、`v` 以及 `ffn` 权重宽度的保留比例,保留比例乘以宽度(multi haed 数量)应为整数;默认是 None。
+* `dataset_dir`:本地数据集路径,需包含 train.txt,dev.txt,label.txt;默认为 None。
* `max_seq_length`:模型使用的最大序列长度,建议与训练过程保持一致, 若出现显存不足,请适当调低这一参数;默认为128。
* `params_dir`:待预测模型参数文件;默认为"./checkpoint/"。
@@ -418,22 +418,22 @@ prune/
1. 目前支持的裁剪策略需要训练,训练时间视下游任务数据量而定,且和微调的训练时间是一个量级。 裁剪类似蒸馏过程,方便起见,可以直接使用微调时的超参。为了进一步提升精度,可以对 `per_device_train_batch_size`、`learning_rate`、`num_train_epochs`、`max_seq_length` 等超参进行网格搜索(grid search)。
-2. 模型裁剪主要用于推理部署,因此裁剪后的模型都是静态图模型,只可用于推理部署,不能再通过 `from_pretrained` 导入继续训练。导出模型之后用于部署,项目提供了基于ONNXRuntime的 [离线部署方案](./deploy/predictor/README.md) 和基于Paddle Serving的 [在线服务化部署方案](./deploy/predictor/README.md)。
+2. 模型裁剪主要用于推理部署,因此裁剪后的模型都是静态图模型,只可用于推理部署,不能再通过 `from_pretrained` 导入继续训练。导出模型之后用于部署,项目提供了基于 ONNXRuntime 的 [离线部署方案](./deploy/predictor/README.md) 和基于 Paddle Serving 的 [在线服务化部署方案](./deploy/predictor/README.md)。
-3. ERNIE Base、Medium、Mini、Micro、Nano的模型宽度(multi head数量)为12,ERNIE Xbase、Large 模型宽度(multi head数量)为16,保留比例`width_mult`乘以宽度(multi haed数量)应为整数。
+3. ERNIE Base、Medium、Mini、Micro、Nano 的模型宽度(multi head 数量)为12,ERNIE Xbase、Large 模型宽度(multi head 数量)为16,保留比例`width_mult`乘以宽度(multi haed 数量)应为整数。
#### 2.5.3 部署方案
- 离线部署搭建请参考[离线部署](deploy/predictor/README.md)。
-- 在线服务化部署搭建请参考 [PaddleNLP SimpleServing部署指南](deploy/simple_serving/README.md) 或 [Triton部署指南](deploy/triton_serving/README.md)。
+- 在线服务化部署搭建请参考 [PaddleNLP SimpleServing 部署指南](deploy/simple_serving/README.md) 或 [Triton 部署指南](deploy/triton_serving/README.md)。
### 2.6 模型效果
-我们在CAIL2019—婚姻家庭要素提取任务数据集评测模型表现,测试配置如下:
+我们在 CAIL2019—婚姻家庭要素提取任务数据集评测模型表现,测试配置如下:
1. 数据集:CAIL2019—婚姻家庭要素提取任务数据集
@@ -457,7 +457,7 @@ prune/
4. PaddleNLP 版本:2.3.1
-5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU部署运行时间 total_time,计算 latency = total_time / total_samples
+5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU 部署运行时间 total_time,计算 latency = total_time / total_samples
6. 精度评价指标:Micro F1分数、Macro F1分数
diff --git a/legacy/applications/text_classification/multi_label/analysis/README.md b/slm/applications/text_classification/multi_label/analysis/README.md
similarity index 72%
rename from legacy/applications/text_classification/multi_label/analysis/README.md
rename to slm/applications/text_classification/multi_label/analysis/README.md
index 9c454ba88de4..e7c9c0984954 100644
--- a/legacy/applications/text_classification/multi_label/analysis/README.md
+++ b/slm/applications/text_classification/multi_label/analysis/README.md
@@ -1,7 +1,7 @@
# 训练评估与模型优化指南
**目录**
- * [Analysis模块介绍](#Analysis模块介绍)
+ * [Analysis 模块介绍](#Analysis 模块介绍)
* [环境准备](#环境准备)
* [模型评估](#模型评估)
* [可解释性分析](#可解释性分析)
@@ -12,15 +12,15 @@
* [脏数据清洗方案](#脏数据清洗方案)
* [数据增强策略方案](#数据增强策略方案)
-## Analysis模块介绍
+## Analysis 模块介绍
-Analysis模块提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
+Analysis 模块提供了**模型评估、可解释性分析、数据优化**等功能,旨在帮助开发者更好地分析文本分类模型预测结果和对模型效果进行优化。
- **模型评估:** 对整体分类情况和每个类别分别进行评估,并打印预测错误样本,帮助开发者分析模型表现找到训练和预测数据中存在的问题。
- **可解释性分析:** 基于[TrustAI](https://github.com/PaddlePaddle/TrustAI)提供单词和句子级别的模型可解释性分析,帮助理解模型预测结果。
-- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。
+- **数据优化:** 结合[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)提供了**稀疏数据筛选、脏数据清洗、数据增强**三种优化策略,从多角度优化训练数据提升模型效果。

@@ -44,12 +44,12 @@ analysis/
- trustai >= 0.1.7
- interpretdl >= 0.7.0
-**安装TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装TrustAI。
+**安装 TrustAI**(可选)如果使用可解释性分析和数据优化中稀疏数据筛选和脏数据清洗需要安装 TrustAI。
```shell
pip install trustai==0.1.7
```
-**安装InterpretDL**(可选)如果使用词级别可解释性分析GradShap方法,需要安装InterpretDL
+**安装 InterpretDL**(可选)如果使用词级别可解释性分析 GradShap 方法,需要安装 InterpretDL
```shell
pip install interpretdl==0.7.0
```
@@ -68,14 +68,14 @@ python evaluate.py \
--bad_case_file "bad_case.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt、dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt、dev.txt 和 label.txt 文件;默认为 None。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `train_file`:本地数据集中开发集文件名;默认为"train.txt"。
* `dev_file`:本地数据集中开发集文件名;默认为"dev.txt"。
@@ -98,7 +98,7 @@ python evaluate.py \
...
```
-预测错误的样本保存在bad_case.txt文件中:
+预测错误的样本保存在 bad_case.txt 文件中:
```text
Text Label Prediction
@@ -108,10 +108,10 @@ Text Label Prediction
...
```
## 可解释性分析
-"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于TrustAI开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
+"模型为什么会预测出这个结果?"是文本分类任务开发者时常遇到的问题,如何分析错误样本(bad case)是文本分类任务落地中重要一环,本项目基于 TrustAI 开源了基于词级别和句子级别的模型可解释性分析方法,帮助开发者更好地理解文本分类模型与数据,有助于后续的模型优化与数据清洗标注。
### 单词级别可解释性分析
-本项目开源模型的词级别可解释性分析Notebook,提供LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用Jupyter Notebook进行数据分析。
+本项目开源模型的词级别可解释性分析 Notebook,提供 LIME、Integrated Gradient、GradShap 三种分析方法,支持分析微调后模型的预测结果,开发者可以通过更改**数据目录**和**模型目录**在自己的任务中使用 Jupyter Notebook 进行数据分析。
运行`word_interpret.ipynb`代码,即可分析影响样本预测结果的关键词以及可视化所有词对预测结果的贡献情况,颜色越深代表这个词对预测结果影响越大:
@@ -155,14 +155,14 @@ python sent_interpret.py \
--interpret_result_file "sent_interpret.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `top_k`:筛选支持训练证据数量;默认为3。
@@ -189,7 +189,7 @@ support3 text: 2014年4月,被告外出务工,双方分居至今。 label:
稀疏数据筛选适用于文本分类中**数据不平衡或训练数据覆盖不足**的场景,简单来说,就是由于模型在训练过程中没有学习到足够与待预测样本相似的数据,模型难以正确预测样本所属类别的情况。稀疏数据筛选旨在开发集中挖掘缺乏训练证据支持的数据,通常可以采用**数据增强**或**少量数据标注**的两种低成本方式,提升模型在开发集的预测效果。
-本项目中稀疏数据筛选基于TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
+本项目中稀疏数据筛选基于 TrustAI,利用基于特征相似度的实例级证据分析方法,抽取开发集中样本的支持训练证据,并计算支持证据平均分(通常为得分前三的支持训练证据均分)。分数较低的样本表明其训练证据不足,在训练集中较为稀疏,实验表明模型在这些样本上表现也相对较差。更多细节详见[TrustAI](https://github.com/PaddlePaddle/TrustAI)和[实例级证据分析](https://github.com/PaddlePaddle/TrustAI/blob/main/trustai/interpretation/example_level/README.md)。
#### 稀疏数据识别—数据增强
@@ -216,15 +216,15 @@ python sparse.py \
--support_num 100
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
* `aug_strategy`:数据增强类型,可选"duplicate","substitute", "insert", "delete", "swap";默认为"substitute"。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -246,7 +246,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_aug.txt
**方案效果**
-我们在CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,筛选稀疏数据数量和筛选支持数据数量均设为100条,使用不同的数据增强方法进行评测:
+我们在 CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,筛选稀疏数据数量和筛选支持数据数量均设为100条,使用不同的数据增强方法进行评测:
| |Micro F1(%) | Macro F1(%) |
| ---------| ------------ |------------ |
@@ -282,15 +282,15 @@ python sparse.py \
--unlabeled_file "data.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含dev.txt和label.txt文件;默认为None。
-* `annotate`:选择稀疏数据识别--数据标注模式;默认为False。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 dev.txt 和 label.txt 文件;默认为 None。
+* `annotate`:选择稀疏数据识别--数据标注模式;默认为 False。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `rationale_num_sparse`:筛选稀疏数据时计算样本置信度时支持训练证据数量;认为3。
@@ -305,7 +305,7 @@ python sparse.py \
* `sparse_file`:保存在本地数据集路径中稀疏数据文件名;默认为"sparse.txt"。
* `support_file`:保存在本地数据集路径中支持训练数据文件名;默认为"support.txt"。
-我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
+我们将筛选出的支持数据`support.txt`进行标注,可以使用标注工具帮助更快标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已标注数据`support.txt`与训练集数据`train.txt`合并得到新的训练集`train_sparse_annotate.txt`重新进行训练:
```shell
cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
@@ -313,7 +313,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
**方案效果**
-我们在CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,筛选稀疏数据数量设为100条,筛选待标注数据数量为50和100条。我们比较了使用稀疏数据方案的策略采样和随机采样的效果,下表结果表明使用稀疏数据方案的策略采样能够有效指导训练数据扩充,在标注更少的数据情况下获得更大提升的效果:
+我们在 CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,筛选稀疏数据数量设为100条,筛选待标注数据数量为50和100条。我们比较了使用稀疏数据方案的策略采样和随机采样的效果,下表结果表明使用稀疏数据方案的策略采样能够有效指导训练数据扩充,在标注更少的数据情况下获得更大提升的效果:
| |Micro F1(%) | Macro F1(%) |
| ---------| ------------ | ------------ |
@@ -327,7 +327,7 @@ cat ../data/train.txt ../data/support.txt > ../data/train_sparse_annotate.txt
脏数据清洗方案是基于已训练好的文本分类模型,筛选出训练数据集中标注错误的数据,再由人工检查重新标注,获得标注正确的数据集进行重新训练。我们将介绍脏数据清洗流程:
-- **脏数据筛选:** 基于TrustAI中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
+- **脏数据筛选:** 基于 TrustAI 中表示点方法,计算训练数据对文本分类模型的影响分数,分数高的训练数据表明对模型影响大,这些数据有较大概率为标注错误样本,记为脏数据集(Dirty Dataset)。
- **数据清洗、训练:** 将筛选出的脏数据由人工重新检查,为数据打上正确的标签。将清洗后的训练数据重新放入文本分类模型进行训练。
@@ -345,14 +345,14 @@ python dirty.py \
--rest_file "train_dirty_rest.txt"
```
-默认在GPU环境下使用,在CPU环境下修改参数配置为`--device "cpu"`
+默认在 GPU 环境下使用,在 CPU 环境下修改参数配置为`--device "cpu"`
可支持配置的参数:
-* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含train.txt和label.txt文件;默认为None。
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `dataset_dir`:必须,本地数据集路径,数据集路径中应包含 train.txt 和 label.txt 文件;默认为 None。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `params_path`:保存训练模型的目录;默认为"../checkpoint/"。
-* `device`: 选用什么设备进行训练,可选择cpu、gpu、xpu、npu;默认为"gpu"。
+* `device`: 选用什么设备进行训练,可选择 cpu、gpu、xpu、npu;默认为"gpu"。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
* `seed`:随机种子,默认为3。
* `dirty_file`:保存脏数据文件名,默认为"train_dirty.txt"。
@@ -361,7 +361,7 @@ python dirty.py \
* `dirty_threshold`:筛选脏数据用于重新标注的阈值,只选择影响分数大于阈值作为支持数据,默认为0。
-我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具doccano帮助更快重新标注,详情请参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
+我们将筛选出脏数据进行人工检查重新标注,可以将`train_dirty.txt`直接导入标注工具 doccano 帮助更快重新标注,详情请参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。然后将已重新标注的脏数据`train_dirty.txt`与剩余训练集数据`train_dirty_rest.txt`合并得到新的训练集`train_clean.txt`重新进行训练:
```shell
cat ../data/train_dirty_rest.txt ../data/train_dirty.txt > ../data/train_clean.txt
@@ -369,7 +369,7 @@ cat ../data/train_dirty_rest.txt ../data/train_dirty.txt > ../data/train_clean.t
**方案效果**
-我们在CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,取50条数据进行脏数据处理,也即50条训练数据为标签错误数据。选择不同`dirty_num`应用脏数据清洗策略进行评测:
+我们在 CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,取50条数据进行脏数据处理,也即50条训练数据为标签错误数据。选择不同`dirty_num`应用脏数据清洗策略进行评测:
| |Micro F1(%) | Macro F1(%) |
| ---------| ------------ |------------ |
@@ -396,10 +396,10 @@ python aug.py \
* `train_path`:待增强训练数据集文件路径;默认为"../data/train.txt"。
* `aug_path`:增强生成的训练数据集文件路径;默认为"../data/train_aug.txt"。
* `aug_strategy`:数据增强策略,可选"mix", "substitute", "insert", "delete", "swap"为多种数据策略混合使用;默认为"substitute"。
-* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在GPU环境下使用mlm类型;默认为"synonym"。
+* `aug_type`:词替换/词插入增强类型,可选"synonym", "homonym", "mlm",建议在 GPU 环境下使用 mlm 类型;默认为"synonym"。
* `create_n`:生成的句子数量,默认为2。
* `aug_percent`:生成词替换百分比,默认为0.1。
-* `device`: 选用什么设备进行增强,可选择cpu、gpu、xpu、npu,仅在使用mlm类型有影响;默认为"gpu"。
+* `device`: 选用什么设备进行增强,可选择 cpu、gpu、xpu、npu,仅在使用 mlm 类型有影响;默认为"gpu"。
生成的增强数据保存在`"aug.txt"`文件中,与训练集数据`train.txt`合并得到新的训练集`train_aug.txt`重新进行训练:
@@ -407,9 +407,9 @@ python aug.py \
cat ../data/aug.txt ../data/train.txt > ../data/train_aug.txt
```
-PaddleNLP内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
+PaddleNLP 内置多种数据增强策略,更多数据增强策略使用方法请参考[数据增强 API](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/dataaug.md)。
-我们在CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,采用不同数据增强策略进行两倍数据增强(每条样本生成两条增强样本):
+我们在 CAIL2019—婚姻家庭要素提取数据集抽取部分训练数据(训练集数据规模:500)进行实验,采用不同数据增强策略进行两倍数据增强(每条样本生成两条增强样本):
| |Micro F1(%) | Macro F1(%) |
| ---------| ------------ |------------ |
diff --git a/legacy/applications/text_classification/multi_label/analysis/aug.py b/slm/applications/text_classification/multi_label/analysis/aug.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/aug.py
rename to slm/applications/text_classification/multi_label/analysis/aug.py
diff --git a/legacy/applications/text_classification/multi_label/analysis/dirty.py b/slm/applications/text_classification/multi_label/analysis/dirty.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/dirty.py
rename to slm/applications/text_classification/multi_label/analysis/dirty.py
diff --git a/legacy/applications/text_classification/multi_label/analysis/evaluate.py b/slm/applications/text_classification/multi_label/analysis/evaluate.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/evaluate.py
rename to slm/applications/text_classification/multi_label/analysis/evaluate.py
diff --git a/legacy/applications/text_classification/multi_label/analysis/sent_interpret.py b/slm/applications/text_classification/multi_label/analysis/sent_interpret.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/sent_interpret.py
rename to slm/applications/text_classification/multi_label/analysis/sent_interpret.py
diff --git a/legacy/applications/text_classification/multi_label/analysis/sparse.py b/slm/applications/text_classification/multi_label/analysis/sparse.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/sparse.py
rename to slm/applications/text_classification/multi_label/analysis/sparse.py
diff --git a/legacy/applications/text_classification/multi_label/analysis/word_interpret.ipynb b/slm/applications/text_classification/multi_label/analysis/word_interpret.ipynb
similarity index 100%
rename from legacy/applications/text_classification/multi_label/analysis/word_interpret.ipynb
rename to slm/applications/text_classification/multi_label/analysis/word_interpret.ipynb
diff --git a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/README.md b/slm/applications/text_classification/multi_label/deploy/paddle_serving/README.md
similarity index 73%
rename from legacy/applications/text_classification/multi_label/deploy/paddle_serving/README.md
rename to slm/applications/text_classification/multi_label/deploy/paddle_serving/README.md
index ee19f95492da..0f89629175cf 100644
--- a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/README.md
+++ b/slm/applications/text_classification/multi_label/deploy/paddle_serving/README.md
@@ -1,4 +1,4 @@
-# 基于Paddle Serving的服务化部署
+# 基于 Paddle Serving 的服务化部署
本文档将介绍如何使用[Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/develop/README_CN.md)工具搭建多标签在线服务部署。
@@ -8,36 +8,36 @@
- [部署模型](#部署模型)
## 环境准备
-需要准备PaddleNLP的运行环境和Paddle Serving的运行环境。
+需要准备 PaddleNLP 的运行环境和 Paddle Serving 的运行环境。
- python >= 3.6
- paddlepaddle >= 2.3
- paddlenlp >= 2.4
-### 安装PaddlePaddle
+### 安装 PaddlePaddle
- 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+ 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.3, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-### 安装PaddleNLP
+### 安装 PaddleNLP
-安装PaddleNLP默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以删去` -i https://mirror.baidu.com/pypi/simple` ,更多关于PaddleNLP安装的详细教程请查见[PaddleNLP快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+安装 PaddleNLP 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以删去` -i https://mirror.baidu.com/pypi/simple` ,更多关于 PaddleNLP 安装的详细教程请查见[PaddleNLP 快速安装](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
```shell
python3 -m pip install --upgrade paddlenlp -i https://mirror.baidu.com/pypi/simple
```
-### 安装Paddle Serving
-安装client和serving app,用于向服务发送请求:
+### 安装 Paddle Serving
+安装 client 和 serving app,用于向服务发送请求:
```
pip install paddle_serving_app paddle_serving_client
```
-安装serving,用于启动服务,根据服务器设备选择安装CPU server或GPU server:
+安装 serving,用于启动服务,根据服务器设备选择安装 CPU server 或 GPU server:
-- 安装CPU server
+- 安装 CPU server
```shell
pip install paddle_serving_server
```
-- 安装GPU server, 注意选择跟本地环境一致的命令
+- 安装 GPU server, 注意选择跟本地环境一致的命令
```shell
# CUDA10.2 + Cudnn7 + TensorRT6
pip install paddle-serving-server-gpu==0.8.3.post102 -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -49,14 +49,14 @@ pip install paddle-serving-server-gpu==0.8.3.post112 -i https://pypi.tuna.tsingh
**NOTE:**
- 默认开启国内清华镜像源来加速下载,如果您使用 HTTP 代理可以关闭(-i https://pypi.tuna.tsinghua.edu.cn/simple)
-- 更多wheel包请参考[serving官网文档](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)
+- 更多 wheel 包请参考[serving 官网文档](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)
## 模型转换
-使用Paddle Serving做服务化部署时,需要将保存的inference模型转换为serving易于部署的模型。
+使用 Paddle Serving 做服务化部署时,需要将保存的 inference 模型转换为 serving 易于部署的模型。
-用已安装的paddle_serving_client将静态图参数模型转换成serving格式。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型地址`dirname`,模型文件和参数名`model_filename`,`params_filename`根据实际填写即可。
+用已安装的 paddle_serving_client 将静态图参数模型转换成 serving 格式。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型地址`dirname`,模型文件和参数名`model_filename`,`params_filename`根据实际填写即可。
```shell
python -m paddle_serving_client.convert --dirname ../../export --model_filename float32.pdmodel --params_filename float32.pdiparams
@@ -82,7 +82,7 @@ paddle_serving/
## 部署模型
-serving目录包含启动pipeline服务和发送预测请求的代码和模型,包括:
+serving 目录包含启动 pipeline 服务和发送预测请求的代码和模型,包括:
```
serving/
@@ -123,7 +123,7 @@ python service.py --max_seq_length 128 --model_name "ernie-3.0-medium-zh"
```
可支持配置的参数:
-* `max_seq_length`:分词器tokenizer使用的最大序列长度,ERNIE模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
+* `max_seq_length`:分词器 tokenizer 使用的最大序列长度,ERNIE 模型最大不能超过2048。请根据文本长度选择,通常推荐128、256或512,若出现显存不足,请适当调低这一参数;默认为128。
* `model_name`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh",根据实际使用的预训练模型选择。
输出打印如下:
@@ -143,8 +143,8 @@ W0625 16:45:40.312942 40218 gpu_context.cc:278] Please NOTE: device: 3, GPU Comp
W0625 16:45:40.316538 40218 gpu_context.cc:306] device: 3, cuDNN Version: 8.1.
```
-#### 启动rpc client测试
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)
+#### 启动 rpc client 测试
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)
```shell
python rpc_client.py
```
@@ -162,8 +162,8 @@ label: 婚前个人财产
data: 一、判决原告于某某与被告杨某某离婚;
label: 准予离婚,法定离婚
```
-#### 启动http client测试
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)
+#### 启动 http client 测试
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)
```shell
python http_client.py
```
diff --git a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/config.yml b/slm/applications/text_classification/multi_label/deploy/paddle_serving/config.yml
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/paddle_serving/config.yml
rename to slm/applications/text_classification/multi_label/deploy/paddle_serving/config.yml
diff --git a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/http_client.py b/slm/applications/text_classification/multi_label/deploy/paddle_serving/http_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/paddle_serving/http_client.py
rename to slm/applications/text_classification/multi_label/deploy/paddle_serving/http_client.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/rpc_client.py b/slm/applications/text_classification/multi_label/deploy/paddle_serving/rpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/paddle_serving/rpc_client.py
rename to slm/applications/text_classification/multi_label/deploy/paddle_serving/rpc_client.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/paddle_serving/service.py b/slm/applications/text_classification/multi_label/deploy/paddle_serving/service.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/paddle_serving/service.py
rename to slm/applications/text_classification/multi_label/deploy/paddle_serving/service.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/predictor/README.md b/slm/applications/text_classification/multi_label/deploy/predictor/README.md
similarity index 55%
rename from legacy/applications/text_classification/multi_label/deploy/predictor/README.md
rename to slm/applications/text_classification/multi_label/deploy/predictor/README.md
index 56786837f16a..97a01008c570 100644
--- a/legacy/applications/text_classification/multi_label/deploy/predictor/README.md
+++ b/slm/applications/text_classification/multi_label/deploy/predictor/README.md
@@ -2,25 +2,25 @@
**目录**
* [环境准备](#环境准备)
- * [基于GPU部署推理样例](#基于GPU部署推理样例)
- * [基于CPU部署推理样例](#基于CPU部署推理样例)
+ * [基于 GPU 部署推理样例](#基于 GPU 部署推理样例)
+ * [基于 CPU 部署推理样例](#基于 CPU 部署推理样例)
* [性能与精度测试](#性能与精度测试)
## 环境准备
-模型转换与ONNXRuntime预测部署依赖Paddle2ONNX和ONNXRuntime,Paddle2ONNX支持将Paddle静态图模型转化为ONNX模型格式,算子目前稳定支持导出ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型使用裁剪API进行裁剪之后会自动生成静态图模型。
+模型转换与 ONNXRuntime 预测部署依赖 Paddle2ONNX 和 ONNXRuntime,Paddle2ONNX 支持将 Paddle 静态图模型转化为 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。如何使用[静态图导出脚本](../../export_model.py)将训练后的模型转为静态图模型详见[模型静态图导出](../../README.md),模型使用裁剪 API 进行裁剪之后会自动生成静态图模型。
-如果基于GPU部署,请先确保机器已正确安装NVIDIA相关驱动和基础软件,确保CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
+如果基于 GPU 部署,请先确保机器已正确安装 NVIDIA 相关驱动和基础软件,确保 CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
```shell
python -m pip install onnxruntime-gpu onnx onnxconverter-common==1.9.0 paddle2onnx==1.0.5
```
-如果基于CPU部署,请使用如下命令安装所需依赖:
+如果基于 CPU 部署,请使用如下命令安装所需依赖:
```shell
python -m pip install onnxruntime
```
-## 基于GPU部署推理样例
+## 基于 GPU 部署推理样例
请使用如下命令进行部署
```
@@ -38,17 +38,17 @@ python infer.py \
* `model_path_prefix`:必须,待推理模型路径前缀。
* `model_name_or_path`:选择预训练模型,可选"ernie-1.0-large-zh-cw","ernie-3.0-xbase-zh", "ernie-3.0-base-zh", "ernie-3.0-medium-zh", "ernie-3.0-micro-zh", "ernie-3.0-mini-zh", "ernie-3.0-nano-zh", "ernie-2.0-base-en", "ernie-2.0-large-en","ernie-m-base","ernie-m-large";默认为"ernie-3.0-medium-zh",根据实际使用的预训练模型选择。
-* `max_seq_length`:ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
-* `use_fp16`:选择是否开启FP16进行加速;默认为False。
+* `max_seq_length`:ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `use_fp16`:选择是否开启 FP16进行加速;默认为 False。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `device`: 选用什么设备进行训练,可选cpu、gpu。
-* `device_id`: 选择GPU卡号;默认为0。
-* `perf`:选择进行模型性能和精度评估;默认为False。
-* `dataset_dir`:本地数据集地址,需包含data.txt, label.txt, test.txt/dev.txt(可选,如果启动模型性能和精度评估);默认为None。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu。
+* `device_id`: 选择 GPU 卡号;默认为0。
+* `perf`:选择进行模型性能和精度评估;默认为 False。
+* `dataset_dir`:本地数据集地址,需包含 data.txt, label.txt, test.txt/dev.txt(可选,如果启动模型性能和精度评估);默认为 None。
* `perf_dataset`:评估数据集,可选'dev'、'test',选择在开发集或测试集评估模型;默认为"dev"。
-* `multilingual`:是否为多语言任务(是否使用ERNIE M作为预训练模型);默认为False。
+* `multilingual`:是否为多语言任务(是否使用 ERNIE M 作为预训练模型);默认为 False。
-在GPU设备的CUDA计算能力 (CUDA Compute Capability) 大于7.0,在包括V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启FP16进行加速,在CPU或者CUDA计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。可以使用如下命令开启ONNXRuntime的FP16进行推理加速:
+在 GPU 设备的 CUDA 计算能力 (CUDA Compute Capability) 大于7.0,在包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启 FP16进行加速,在 CPU 或者 CUDA 计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。可以使用如下命令开启 ONNXRuntime 的 FP16进行推理加速:
```
python infer.py \
@@ -61,7 +61,7 @@ python infer.py \
--dataset_dir "../../data"
```
-可以使用如下命令开启ONNXRuntime推理评估模型的性能和精度:
+可以使用如下命令开启 ONNXRuntime 推理评估模型的性能和精度:
```
python infer.py \
@@ -75,7 +75,7 @@ python infer.py \
--dataset_dir "../../data"
```
-## 基于CPU部署推理样例
+## 基于 CPU 部署推理样例
请使用如下命令进行部署
```
@@ -92,16 +92,16 @@ python infer.py \
* `model_path_prefix`:必须,待推理模型路径前缀。
* `model_name_or_path`:选择预训练模型;默认为"ernie-3.0-medium-zh",中文数据集推荐使用"ernie-3.0-medium-zh"。
-* `max_seq_length`:ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
-* `use_quantize`:选择是否开启INT8动态量化进行加速;默认为False。
+* `max_seq_length`:ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `use_quantize`:选择是否开启 INT8动态量化进行加速;默认为 False。
* `batch_size`:批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为200。
-* `num_threads`:cpu线程数;默认为cpu的物理核心数量。
-* `device`: 选用什么设备进行训练,可选cpu、gpu。
-* `perf`:选择进行模型性能和精度评估;默认为False。
-* `dataset_dir`:本地数据集地址,需包含data.txt, label.txt, dev.txt/test.txt(可选,如果启动模型性能和精度评估);默认为None。
+* `num_threads`:cpu 线程数;默认为 cpu 的物理核心数量。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu。
+* `perf`:选择进行模型性能和精度评估;默认为 False。
+* `dataset_dir`:本地数据集地址,需包含 data.txt, label.txt, dev.txt/test.txt(可选,如果启动模型性能和精度评估);默认为 None。
* `perf_dataset`:评估数据集,选择在开发集或测试集评估模型;默认为"dev"。
-可以使用如下命令开启ONNXRuntime的INT8动态量化进行推理加速:
+可以使用如下命令开启 ONNXRuntime 的 INT8动态量化进行推理加速:
```
python infer.py \
@@ -114,9 +114,9 @@ python infer.py \
--dataset_dir "../../data"
```
-**Note**:INT8动态量化与FP16相比精度损失较大,GPU部署建议使用FP16加速。
+**Note**:INT8动态量化与 FP16相比精度损失较大,GPU 部署建议使用 FP16加速。
-可以使用如下命令开启ONNXRuntime推理评估模型的性能和精度:
+可以使用如下命令开启 ONNXRuntime 推理评估模型的性能和精度:
```
python infer.py \
@@ -158,7 +158,7 @@ python infer.py \
4. PaddleNLP 版本:2.3.1
-5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU部署运行时间 total_time,计算 latency = total_time / total_samples
+5. 性能数据指标:latency。latency 测试方法:固定 batch size 为 32,GPU 部署运行时间 total_time,计算 latency = total_time / total_samples
6. 精度评价指标:Micro F1分数、Macro F1分数
@@ -170,4 +170,4 @@ python infer.py \
| ERNIE 3.0 Medium+INT8+CPU | 90.05 | 77.69| 34.24 |
-经过FP16转化加速比达到3~4倍左右,精度变化较小,与FP16相比,INT8在线量化精度下降较大,加速比在1.5倍左右
+经过 FP16转化加速比达到3~4倍左右,精度变化较小,与 FP16相比,INT8在线量化精度下降较大,加速比在1.5倍左右
diff --git a/legacy/applications/text_classification/multi_label/deploy/predictor/infer.py b/slm/applications/text_classification/multi_label/deploy/predictor/infer.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/predictor/infer.py
rename to slm/applications/text_classification/multi_label/deploy/predictor/infer.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/predictor/predictor.py b/slm/applications/text_classification/multi_label/deploy/predictor/predictor.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/predictor/predictor.py
rename to slm/applications/text_classification/multi_label/deploy/predictor/predictor.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/simple_serving/README.md b/slm/applications/text_classification/multi_label/deploy/simple_serving/README.md
similarity index 70%
rename from legacy/applications/text_classification/multi_label/deploy/simple_serving/README.md
rename to slm/applications/text_classification/multi_label/deploy/simple_serving/README.md
index 583887019358..4b48242aaa9a 100644
--- a/legacy/applications/text_classification/multi_label/deploy/simple_serving/README.md
+++ b/slm/applications/text_classification/multi_label/deploy/simple_serving/README.md
@@ -1,22 +1,22 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server启动服务](#Server服务启动)
+- [Server 启动服务](#Server 服务启动)
- [其他参数设置](#其他参数设置)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本
+使用有 SimpleServing 功能的 PaddleNLP 版本
```shell
pip install paddlenlp --upgrade
```
-## Server服务启动
+## Server 服务启动
### 分类任务启动
#### 启动 分类 Server 服务
```bash
paddlenlp server server:app --host 0.0.0.0 --port 8189
```
-如果是ERNIE-M模型则启动
+如果是 ERNIE-M 模型则启动
```bash
paddlenlp server ernie_m_server:app --host 0.0.0.0 --port 8189
```
@@ -26,7 +26,7 @@ python client.py
```
## 其他参数设置
-可以在client端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
+可以在 client 端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
```python
data = {
'data': {
diff --git a/legacy/applications/text_classification/multi_label/deploy/simple_serving/client.py b/slm/applications/text_classification/multi_label/deploy/simple_serving/client.py
similarity index 99%
rename from legacy/applications/text_classification/multi_label/deploy/simple_serving/client.py
rename to slm/applications/text_classification/multi_label/deploy/simple_serving/client.py
index de347a19654a..f52702fc2d9f 100644
--- a/legacy/applications/text_classification/multi_label/deploy/simple_serving/client.py
+++ b/slm/applications/text_classification/multi_label/deploy/simple_serving/client.py
@@ -13,9 +13,10 @@
# limitations under the License.
import argparse
-import requests
import json
+import requests
+
# yapf: disable
parser = argparse.ArgumentParser()
parser.add_argument("--max_seq_len", default=128, type=int, help="The maximum total input sequence length after tokenization.")
diff --git a/legacy/applications/text_classification/multi_label/deploy/simple_serving/ernie_m_server.py b/slm/applications/text_classification/multi_label/deploy/simple_serving/ernie_m_server.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/simple_serving/ernie_m_server.py
rename to slm/applications/text_classification/multi_label/deploy/simple_serving/ernie_m_server.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/simple_serving/server.py b/slm/applications/text_classification/multi_label/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/simple_serving/server.py
rename to slm/applications/text_classification/multi_label/deploy/simple_serving/server.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/README.md b/slm/applications/text_classification/multi_label/deploy/triton_serving/README.md
similarity index 59%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/README.md
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/README.md
index 8fc05895baf2..05df2226fbcc 100644
--- a/legacy/applications/text_classification/multi_label/deploy/triton_serving/README.md
+++ b/slm/applications/text_classification/multi_label/deploy/triton_serving/README.md
@@ -1,6 +1,6 @@
-# 基于Triton Inference Server的服务化部署指南
+# 基于 Triton Inference Server 的服务化部署指南
-本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于ERNIE 3.0中文模型文本多标签分类的pipeline在线服务。
+本文档将介绍如何使用[Triton Inference Server](https://github.com/triton-inference-server/server)工具部署基于 ERNIE 3.0中文模型文本多标签分类的 pipeline 在线服务。
## 目录
- [服务端环境准备](#服务端环境准备)
@@ -10,8 +10,8 @@
## 服务端环境准备
-### 安装Triton Server
-拉取Triton Server镜像:
+### 安装 Triton Server
+拉取 Triton Server 镜像:
```shell
docker pull nvcr.io/nvidia/tritonserver:21.10-py3
```
@@ -22,19 +22,19 @@ docker run -it --gpus all --net=host --name triton_server -v /path/triton/model
**NOTE:**
-1. Triton版本号`21.10`可以根据自己的需求调整,各个Triton版本对应的Driver、CUDA、TRT和ONNX Runtime等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果NVIDIA Driver低于文档中要求,在启动运行时会报错。
+1. Triton 版本号`21.10`可以根据自己的需求调整,各个 Triton 版本对应的 Driver、CUDA、TRT 和 ONNX Runtime 等后端版本可以参考[官网文档](https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html)。注意其中的`NVIDIA Driver`行,如果 NVIDIA Driver 低于文档中要求,在启动运行时会报错。
-2. 可以使用`--gpus '"device=1"'`来指定GPU卡号,更多GPU指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
+2. 可以使用`--gpus '"device=1"'`来指定 GPU 卡号,更多 GPU 指定方式请参见[Nvidia User Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#gpu-enumeration)
-### 进入容器并准备PaddleNLP环境
-整个服务的前后处理依赖PaddleNLP,需要在容器内安装相关python包
+### 进入容器并准备 PaddleNLP 环境
+整个服务的前后处理依赖 PaddleNLP,需要在容器内安装相关 python 包
进入容器:
```shell
docker exec -it triton_server bash
```
-安装PaddlePaddle、PaddleNLP
+安装 PaddlePaddle、PaddleNLP
```shell
python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/pypi/simple
```
@@ -43,38 +43,38 @@ python3 -m pip install paddlepaddle-gpu paddlenlp -i https://mirror.baidu.com/py
1. 默认开启百度镜像源来加速下载,如果您使用 HTTP 代理可以关闭(-i https://mirror.baidu.com/pypi/simple)
-2. 环境中paddlepaddle-gpu或paddlepaddle版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的PaddlePaddle下载命令。
+2. 环境中 paddlepaddle-gpu 或 paddlepaddle 版本应大于或等于2.2, 请参见[飞桨快速安装](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)根据自己需求选择合适的 PaddlePaddle 下载命令。
-3. 更多关于PaddleNLP安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
+3. 更多关于 PaddleNLP 安装的详细教程请查看[Installation](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/get_started/installation.rst)。
## 模型获取和转换
-使用Triton做服务化部署时,选择ONNX Runtime后端运行需要先将模型转换成ONNX格式。
+使用 Triton 做服务化部署时,选择 ONNX Runtime 后端运行需要先将模型转换成 ONNX 格式。
-首先将保存的动态图参数导出成静态图参数,具体代码见[静态图导出脚本](../../export_model.py),静态图参数保存在`output_path`指定路径中,裁剪API裁剪会自动保存静态图模型。运行方式:
+首先将保存的动态图参数导出成静态图参数,具体代码见[静态图导出脚本](../../export_model.py),静态图参数保存在`output_path`指定路径中,裁剪 API 裁剪会自动保存静态图模型。运行方式:
```shell
python ../../export_model.py --params_path=../../checkpoint/model_state.pdparams --output_path=./infer_model
```
-使用Paddle2ONNX将Paddle静态图模型转换为ONNX模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成model.onnx模型文件。
+使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式的命令如下,以下命令成功运行后,将会在当前目录下生成 model.onnx 模型文件。
-用Paddle2ONNX转换分类模型
+用 Paddle2ONNX 转换分类模型
```shell
paddle2onnx --model_dir infer_model/ --model_filename float32.pdmodel --params_filename float32.pdiparams --save_file model.onnx --opset_version 13 --enable_onnx_checker True --enable_dev_version True
```
-创建空白目录/seqcls/1和seqcls_model/1,并将将转换好的ONNX模型移动到模型仓库目录
+创建空白目录/seqcls/1和 seqcls_model/1,并将将转换好的 ONNX 模型移动到模型仓库目录
```shell
mkdir /models/seqcls/1
mkdir /models/seqcls_model/1
mv model.onnx /models/seqcls_model/1
```
-Paddle2ONNX的命令行参数说明请查阅:[Paddle2ONNX命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
+Paddle2ONNX 的命令行参数说明请查阅:[Paddle2ONNX 命令行参数说明](https://github.com/PaddlePaddle/Paddle2ONNX#%E5%8F%82%E6%95%B0%E9%80%89%E9%A1%B9)
-模型下载转换好之后,models目录结构如下:
+模型下载转换好之后,models 目录结构如下:
```
models
├── seqcls
@@ -94,11 +94,11 @@ models
└── config.pbtxt
```
-模型配置文件config.pbtxt配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
+模型配置文件 config.pbtxt 配置细节请参见[Triton Server Model Configuration](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md)
## 部署模型
-triton目录包含启动pipeline服务的配置和发送预测请求的代码,包括:
+triton 目录包含启动 pipeline 服务的配置和发送预测请求的代码,包括:
```
models # Triton启动需要的模型仓库,包含模型和服务配置文件
@@ -108,7 +108,7 @@ seqcls_grpc_client.py # 分类任务发送pipeline预测请求的脚本
### 启动服务端
-在容器内执行下面命令启动服务,默认启动models下所有模型:
+在容器内执行下面命令启动服务,默认启动 models 下所有模型:
```shell
tritonserver --model-repository=/models
```
@@ -119,11 +119,11 @@ tritonserver --model-repository=/models --model-control-mode=explicit --load-mod
**NOTE:**
-启动服务时,Triton Server的每个python后端进程默认申请`64M`内存,默认启动的docker无法启动多个python后端节点。两个解决方案:
+启动服务时,Triton Server 的每个 python 后端进程默认申请`64M`内存,默认启动的 docker 无法启动多个 python 后端节点。两个解决方案:
1. 启动容器时设置`shm-size`参数, 比如:`docker run -it --net=host --name triton_server --shm-size="1g" -v /path/triton/models:/models nvcr.io/nvidia/tritonserver:21.10-py3 bash`
-2. 启动服务时设置python后端的`shm-default-byte-size`参数, 设置python后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
+2. 启动服务时设置 python 后端的`shm-default-byte-size`参数, 设置 python 后端的默认内存为10M: `tritonserver --model-repository=/models --backend-config=python,shm-default-byte-size=10485760`
输出打印如下:
@@ -171,7 +171,7 @@ docker run -it --net=host --name triton_client -v /path/to/triton:/triton_code
```
### 启动客户端测试
-注意执行客户端请求时关闭代理,并根据实际情况修改main函数中的ip地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 main 函数中的 ip 地址(启动服务所在的机器)
```
python seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls/config.pbtxt b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls/config.pbtxt
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_model/config.pbtxt b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_model/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_model/config.pbtxt
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_model/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/1/model.py b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/1/model.py
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/1/model.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/seqcls_postprocess/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/1/model.py b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/1/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/1/model.py
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/1/model.py
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/config.pbtxt b/slm/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/config.pbtxt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/config.pbtxt
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/models/tokenizer/config.pbtxt
diff --git a/legacy/applications/text_classification/multi_label/deploy/triton_serving/seqcls_grpc_client.py b/slm/applications/text_classification/multi_label/deploy/triton_serving/seqcls_grpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/deploy/triton_serving/seqcls_grpc_client.py
rename to slm/applications/text_classification/multi_label/deploy/triton_serving/seqcls_grpc_client.py
diff --git a/legacy/applications/text_classification/multi_label/export_model.py b/slm/applications/text_classification/multi_label/export_model.py
similarity index 99%
rename from legacy/applications/text_classification/multi_label/export_model.py
rename to slm/applications/text_classification/multi_label/export_model.py
index c57dc23372f9..a9afa457409c 100644
--- a/legacy/applications/text_classification/multi_label/export_model.py
+++ b/slm/applications/text_classification/multi_label/export_model.py
@@ -16,6 +16,7 @@
import os
import paddle
+
from paddlenlp.transformers import AutoModelForSequenceClassification
# yapf: disable
diff --git a/legacy/applications/text_classification/multi_label/few-shot/README.md b/slm/applications/text_classification/multi_label/few-shot/README.md
similarity index 83%
rename from legacy/applications/text_classification/multi_label/few-shot/README.md
rename to slm/applications/text_classification/multi_label/few-shot/README.md
index ba70fb55c3aa..4c7f398e04a3 100644
--- a/legacy/applications/text_classification/multi_label/few-shot/README.md
+++ b/slm/applications/text_classification/multi_label/few-shot/README.md
@@ -20,7 +20,7 @@
本项目提供了小样本场景下文本多标签分类的解决方案,在 ERNIE3.0 的基础上利用提示学习取得比微调更好的分类效果,充分利用标注信息。
-近年来,大量包含了案件事实及其适用法律条文信息的裁判文书逐渐在互联网上公开,海量的数据使自然语言处理技术的应用成为可能。现实中的案情错综复杂,案情描述通常涉及多个重要事实,以CAIL2019数据集中婚姻家庭领域的案情要素抽取为例:
+近年来,大量包含了案件事实及其适用法律条文信息的裁判文书逐渐在互联网上公开,海量的数据使自然语言处理技术的应用成为可能。现实中的案情错综复杂,案情描述通常涉及多个重要事实,以 CAIL2019数据集中婚姻家庭领域的案情要素抽取为例:
```text
"2013年11月28日原、被告离婚时自愿达成协议,婚生子张某乙由被告李某某抚养,本院以(2013)宝渭法民初字第01848号民事调解书对该协议内容予以了确认,该协议具有法律效力,对原、被告双方均有约束力。"
@@ -128,11 +128,11 @@
### 3.3 数据标注
-我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即doccano导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano数据标注指南](../../doccano.md)。
+我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano)进行自定义数据标注,本项目也打通了从标注到训练的通道,即 doccano 导出数据后可通过[doccano.py](../../doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano 数据标注指南](../../doccano.md)。
**示例数据**
-这里我们使用CAIL2019—婚姻家庭要素提取任务数据集的子集作为示例数据集。该数据集中原始训练集包括 14377 条标注样本,我们按每条标签随机采样 4 条样本,得到 80 条样本数据作为训练集,剩余训练集数据作为测试集。可点击[这里](https://paddlenlp.bj.bcebos.com/datasets/few-shot/elements.tar.gz)下载解压并放入`./data/`文件夹,或者运行以下脚本
+这里我们使用 CAIL2019—婚姻家庭要素提取任务数据集的子集作为示例数据集。该数据集中原始训练集包括 14377 条标注样本,我们按每条标签随机采样 4 条样本,得到 80 条样本数据作为训练集,剩余训练集数据作为测试集。可点击[这里](https://paddlenlp.bj.bcebos.com/datasets/few-shot/elements.tar.gz)下载解压并放入`./data/`文件夹,或者运行以下脚本
```
wget https://paddlenlp.bj.bcebos.com/datasets/few-shot/elements.tar.gz
@@ -155,7 +155,7 @@ data/
**训练/验证/测试数据**
-对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由tab符`\t`分隔,多个标签以英文逗号`,`分隔。格式如下
+对于训练/验证/测试数据集文件,每行数据表示一条样本,包括文本和标签两部分,由 tab 符`\t`分隔,多个标签以英文逗号`,`分隔。格式如下
```text
<文本>'\t'<标签>','<标签>','<标签>
<文本>'\t'<标签>','<标签>
@@ -266,13 +266,13 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `data_dir`: 训练数据集路径,数据格式要求详见[数据标注](#数据标注)。
- `output_dir`: 模型参数、训练日志和静态图导出的保存目录。
- `prompt`: 提示模板。定义了如何将文本和提示拼接结合。
-- `soft_encoder`: 提示向量的编码器,`lstm`表示双向LSTM, `mlp`表示双层线性层, None表示直接使用提示向量。默认为`lstm`。
+- `soft_encoder`: 提示向量的编码器,`lstm`表示双向 LSTM, `mlp`表示双层线性层, None 表示直接使用提示向量。默认为`lstm`。
- `use_rdrop`: 使用 [R-Drop](https://arxiv.org/abs/2106.14448) 策略。
- `use_rgl`: 使用 [RGL](https://aclanthology.org/2022.findings-naacl.81/) 策略。
-- `encoder_hidden_size`: 提示向量的维度。若为None,则使用预训练模型字向量维度。默认为200。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
-- `learning_rate`: 预训练语言模型参数基础学习率大小,将与learning rate scheduler产生的值相乘作为当前学习率。
-- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用learning rate scheduler。一般设为`learning_rate`的十倍。
+- `encoder_hidden_size`: 提示向量的维度。若为 None,则使用预训练模型字向量维度。默认为200。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
+- `learning_rate`: 预训练语言模型参数基础学习率大小,将与 learning rate scheduler 产生的值相乘作为当前学习率。
+- `ppt_learning_rate`: 提示相关参数的基础学习率大小,当预训练参数不固定时,与其共用 learning rate scheduler。一般设为`learning_rate`的十倍。
- `do_train`: 是否进行训练。
- `do_eval`: 是否进行评估。
- `do_predict`: 是否进行预测。
@@ -283,8 +283,8 @@ python -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \
- `device`: 使用的设备,默认为`gpu`。
- `eval_steps`: 评估模型的间隔步数。
- `logging_steps`: 打印日志的间隔步数。
-- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
-- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际GPU显存适当调小/调大此配置。
+- `per_device_train_batch_size`: 每次训练每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
+- `per_device_eval_batch_size`: 每次评估每张卡上的样本数量。可根据实际 GPU 显存适当调小/调大此配置。
- `load_best_model_at_end`: 是否在模型训练结束后加载评估指标最优的模型参数。
- `evaluation_strategy`: 模型评估的间隔策略。若为`epoch`,则每轮训练结束后评估模型。
- `save_strategy`: 模型保存的间隔策略。若为`epoch`,则每轮训练结束后保存当前模型参数。
@@ -305,7 +305,7 @@ python train.py --do_predict --data_dir ./data --output_dir ./predict_checkpoint
- `output_dir`: 日志的保存目录。
- `resume_from_checkpoint`: 训练时模型参数的保存目录,用于加载模型参数。
- `do_predict`: 是否进行测试集评估。
-- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_seq_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
### 3.6 模型部署
@@ -325,31 +325,31 @@ python train.py --do_export --data_dir ./data --output_dir ./export_checkpoint -
- `do_export`: 是否将模型导出为静态图,保存路径为`output_dir/export`。
- `export_type`: 模型导出的格式,默认为`paddle`,即导出静态图。
-#### ONNXRuntime部署
+#### ONNXRuntime 部署
**运行环境**
-模型转换与ONNXRuntime预测部署依赖Paddle2ONNX和ONNXRuntime,Paddle2ONNX支持将Paddle静态图模型转化为ONNX模型格式,算子目前稳定支持导出ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
+模型转换与 ONNXRuntime 预测部署依赖 Paddle2ONNX 和 ONNXRuntime,Paddle2ONNX 支持将 Paddle 静态图模型转化为 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 7~15,更多细节可参考:[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX)。
-- 如果基于GPU部署,请先确保机器已正确安装NVIDIA相关驱动和基础软件,确保CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
+- 如果基于 GPU 部署,请先确保机器已正确安装 NVIDIA 相关驱动和基础软件,确保 CUDA >= 11.2,CuDNN >= 8.2,并使用以下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime-gpu onnx onnxconverter-common
```
-- 如果基于CPU部署,请使用如下命令安装所需依赖:
+- 如果基于 CPU 部署,请使用如下命令安装所需依赖:
```shell
pip install psutil
python -m pip install onnxruntime
```
-**CPU端推理样例**
+**CPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device cpu
```
-**GPU端推理样例**
+**GPU 端推理样例**
```
python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data --batch_size 32 --device gpu --device_id 0
@@ -358,16 +358,16 @@ python infer.py --model_path_prefix checkpoints/export/model --data_dir ./data -
可配置参数说明:
- `model_path_prefix`: 导出的静态图模型路径及文件前缀。
-- `model_name`: 内置预训练模型名,用于加载tokenizer。默认为`ernie-3.0-base-zh`。
+- `model_name`: 内置预训练模型名,用于加载 tokenizer。默认为`ernie-3.0-base-zh`。
- `data_dir`: 待推理数据所在路径,数据应存放在该目录下的`data.txt`文件。
-- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以Pad补全。提示文本不会被截断。
+- `max_length`: 最大句子长度,超过该长度的文本将被截断,不足的以 Pad 补全。提示文本不会被截断。
- `batch_size`: 每次预测的样本数量。
- `device`: 选择推理设备,包括`cpu`和`gpu`。默认为`gpu`。
-- `device_id`: 指定GPU设备ID。
-- `use_fp16`: 是否使用半精度加速推理。仅在GPU设备上有效。
-- `num_threads`: 设置CPU使用的线程数。默认为机器上的物理内核数。
+- `device_id`: 指定 GPU 设备 ID。
+- `use_fp16`: 是否使用半精度加速推理。仅在 GPU 设备上有效。
+- `num_threads`: 设置 CPU 使用的线程数。默认为机器上的物理内核数。
-**Note**: 在GPU设备的CUDA计算能力 (CUDA Compute Capability) 大于7.0,在包括V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启FP16进行加速,在CPU或者CUDA计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
+**Note**: 在 GPU 设备的 CUDA 计算能力 (CUDA Compute Capability) 大于7.0,在包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等设备上可以开启 FP16进行加速,在 CPU 或者 CUDA 计算能力 (CUDA Compute Capability) 小于7.0时开启不会带来加速效果。
## 4. References
diff --git a/legacy/applications/text_classification/multi_label/few-shot/infer.py b/slm/applications/text_classification/multi_label/few-shot/infer.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/infer.py
rename to slm/applications/text_classification/multi_label/few-shot/infer.py
diff --git a/legacy/applications/text_classification/multi_label/few-shot/metric.py b/slm/applications/text_classification/multi_label/few-shot/metric.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/metric.py
rename to slm/applications/text_classification/multi_label/few-shot/metric.py
diff --git a/legacy/applications/text_classification/multi_label/few-shot/requirements_cpu.txt b/slm/applications/text_classification/multi_label/few-shot/requirements_cpu.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/requirements_cpu.txt
rename to slm/applications/text_classification/multi_label/few-shot/requirements_cpu.txt
diff --git a/legacy/applications/text_classification/multi_label/few-shot/requirements_gpu.txt b/slm/applications/text_classification/multi_label/few-shot/requirements_gpu.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/requirements_gpu.txt
rename to slm/applications/text_classification/multi_label/few-shot/requirements_gpu.txt
diff --git a/legacy/applications/text_classification/multi_label/few-shot/train.py b/slm/applications/text_classification/multi_label/few-shot/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/train.py
rename to slm/applications/text_classification/multi_label/few-shot/train.py
diff --git a/legacy/applications/text_classification/multi_label/few-shot/utils.py b/slm/applications/text_classification/multi_label/few-shot/utils.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/few-shot/utils.py
rename to slm/applications/text_classification/multi_label/few-shot/utils.py
diff --git a/legacy/applications/text_classification/multi_label/metric.py b/slm/applications/text_classification/multi_label/metric.py
similarity index 97%
rename from legacy/applications/text_classification/multi_label/metric.py
rename to slm/applications/text_classification/multi_label/metric.py
index 44ca1c37f12c..f41317ba7603 100644
--- a/legacy/applications/text_classification/multi_label/metric.py
+++ b/slm/applications/text_classification/multi_label/metric.py
@@ -13,9 +13,9 @@
# limitations under the License.
import numpy as np
-from sklearn.metrics import f1_score, classification_report
-
from paddle.metric import Metric
+from sklearn.metrics import classification_report, f1_score
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/multi_label/predict.py b/slm/applications/text_classification/multi_label/predict.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/predict.py
rename to slm/applications/text_classification/multi_label/predict.py
diff --git a/legacy/applications/text_classification/multi_label/prune.py b/slm/applications/text_classification/multi_label/prune.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/prune.py
rename to slm/applications/text_classification/multi_label/prune.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/README.md b/slm/applications/text_classification/multi_label/retrieval_based/README.md
similarity index 78%
rename from legacy/applications/text_classification/multi_label/retrieval_based/README.md
rename to slm/applications/text_classification/multi_label/retrieval_based/README.md
index ff37beee7342..adb816b1c7ce 100644
--- a/legacy/applications/text_classification/multi_label/retrieval_based/README.md
+++ b/slm/applications/text_classification/multi_label/retrieval_based/README.md
@@ -16,11 +16,11 @@
# 1.基于语义索引的多标签分类任务介绍
-以前的分类任务中,标签信息作为无实际意义,独立存在的one-hot编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
+以前的分类任务中,标签信息作为无实际意义,独立存在的 one-hot 编码形式存在,这种做法会潜在的丢失标签的语义信息,本方案把文本分类任务中的标签信息转换成含有语义信息的语义向量,将文本分类任务转换成向量检索和匹配的任务。这样做的好处是对于一些类别标签不是很固定的场景,或者需要经常有一些新增类别的需求的情况非常合适。另外,对于一些新的相关的分类任务,这种方法也不需要模型重新学习或者设计一种新的模型结构来适应新的任务。总的来说,这种基于检索的文本分类方法能够有很好的拓展性,能够利用标签里面包含的语义信息,不需要重新进行学习。这种方法可以应用到相似标签推荐,文本标签标注,金融风险事件分类,政务信访分类等领域。
-本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的多标签分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入In-batch Negatives 策略,使用hnswlib建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
+本方案是基于语义索引模型的分类,语义索引模型的目标是:给定输入文本,模型可以从海量候选召回库中**快速、准确**地召回一批语义相关文本。基于语义索引的多标签分类方法有两种,第一种方法是直接把标签变成召回库,即把输入文本和标签的文本进行匹配,第二种是利用召回的文本带有类别标签,把召回文本的类别标签作为给定输入文本的类别。本方案使用双塔模型,训练阶段引入 In-batch Negatives 策略,使用 hnswlib 建立索引库,并把标签作为召回库,进行召回测试。最后利用召回的结果使用 Accuracy 指标来评估语义索引模型的分类的效果。
-**注意** 基于语义索引的文本分类的标签在预测过程中会抽取成向量,所以标签需要文本的形式,不能是ID形式的标签。
+**注意** 基于语义索引的文本分类的标签在预测过程中会抽取成向量,所以标签需要文本的形式,不能是 ID 形式的标签。
@@ -64,7 +64,7 @@
## 3. 环境准备
-推荐使用GPU进行训练,在预测阶段使用CPU或者GPU均可。
+推荐使用 GPU 进行训练,在预测阶段使用 CPU 或者 GPU 均可。
**环境依赖**
* python >= 3.7
@@ -81,7 +81,7 @@ pip install -r requirements.txt
## 4. 数据准备
-训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务doccano数据标注使用指南](../../doccano.md)进行文本分类数据标注。
+训练需要准备指定格式的本地数据集,如果没有已标注的数据集,可以参考[文本分类任务 doccano 数据标注使用指南](../../doccano.md)进行文本分类数据标注。
**指定格式本地数据集目录结构**
@@ -95,7 +95,7 @@ pip install -r requirements.txt
**训练、开发、测试数据集**
-train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用tab符`'\t'`分隔开,由于文本有多个标签,需要把文本拆分成多个单标签的形式,即多行文本标签对。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
+train.txt(训练数据集文件), dev.txt(开发数据集文件),test.txt(可选,测试数据集文件),文件中文本与标签类别名用 tab 符`'\t'`分隔开,由于文本有多个标签,需要把文本拆分成多个单标签的形式,即多行文本标签对。训练集指用于训练模型的数据;开发集指用于评测模型表现的数据,可以根据模型在开发集上的精度调整训练参数和模型;测试集用于测试模型表现,没有测试集时可以使用开发集代替。
- train.txt/test.txt 文件格式:
```text
@@ -152,7 +152,7 @@ label.txt(分类标签文件)记录数据集中所有标签集合,每一行为
我们使用百科知识问答的数据来构建训练集,开发集。
-**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集30k条,开发集10k条,每行由文本的标题,内容和类别标签组成,以tab符分割,第一列是问题的标题和问题的描述拼接,剩下的列问题的类别。
+**训练集(train.txt)** 和 **开发集(dev.txt)** 格式一致,训练集30k 条,开发集10k 条,每行由文本的标题,内容和类别标签组成,以 tab 符分割,第一列是问题的标题和问题的描述拼接,剩下的列问题的类别。
**召回库(label.txt)** 类别的数量是323类,召回标签库的构建有2种方式,第一种是把所有的类别标签当成召回库,第二种是把训练集当成召回集合,我们以第一种为例。
数据集选择的是百科问答数据集的一个子集,问答数据集详情请参考[nlp_chinese_corpus](https://github.com/brightmart/nlp_chinese_corpus)
@@ -168,9 +168,9 @@ unzip baike_qa_category.zip
这里采用单机多卡方式进行训练,通过如下命令,指定 GPU 0,1 卡;如果采用单机单卡训练,只需要把`--gpus`参数设置成单卡的卡号即可。
-如果使用CPU进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成cpu即可,详细请参考train.sh文件的训练设置
+如果使用 CPU 进行训练,则需要吧`--gpus`参数去除,然后吧`device`设置成 cpu 即可,详细请参考 train.sh 文件的训练设置
-然后运行下面的命令使用GPU训练,得到语义索引模型:
+然后运行下面的命令使用 GPU 训练,得到语义索引模型:
```
root_path=inbatch
@@ -199,9 +199,9 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `device`: 使用 cpu/gpu 进行训练
* `save_dir`: 模型存储路径
-* `batch_size`: 训练的batch size的大小
+* `batch_size`: 训练的 batch size 的大小
* `learning_rate`: 训练的学习率的大小
-* `epochs`: 训练的epoch数
+* `epochs`: 训练的 epoch 数
* `output_emb_size`: Transformer 顶层输出的文本向量维度
* `save_steps`: 模型存储 checkpoint 的间隔 steps 个数
* `max_seq_length`: 输入序列的最大长度
@@ -216,7 +216,7 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
* `similar_text_pair`: 由相似文本对构成的评估集
* `corpus_file`: 召回库数据 corpus_file
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/train.sh
@@ -233,7 +233,7 @@ python -u evaluate.py \
--recall_result_file "./recall_result_dir/recall_result.txt" \
--label_path data/label.txt
```
-也可以使用bash脚本:
+也可以使用 bash 脚本:
```
sh scripts/evaluate.sh
@@ -276,12 +276,12 @@ python -u -m paddle.distributed.launch --gpus "0" \
* `model_name_or_path`: 预训练模型,用于模型和`Tokenizer`的参数初始化。
* `text_pair_file`: 由文本 Pair 构成的待预测数据集
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/predict.sh
```
-predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
+predict.sh 文件包含了 cpu 和 gpu 运行的脚本,默认是 gpu 运行的脚本
产出如下结果
```
@@ -296,7 +296,7 @@ predict.sh文件包含了cpu和gpu运行的脚本,默认是gpu运行的脚本
## 8. 模型部署
-模型部署分为:动转静导出,向量引擎,Paddle Inference推理, Paddle Serving服务化这几个部分。为了提升预测速度,通常需要把训练好的模型转换成静态图,然后就可以使用Paddle Inference静态图进行推理,向量引擎则是存放标签的向量的形式,方便快速检索,另外,Paddle Inference可以进一步对模型服务化,即使用Paddle Serving进行服务化,这样可以通过HTTP或者RPC的方式进行调用。Paddle Serving的服务化形式有Pipeline和C++两种形式,Pipeline灵活一点,方便进行修改,C++部署更麻烦一点,但C++的部署形式效率更高。
+模型部署分为:动转静导出,向量引擎,Paddle Inference 推理, Paddle Serving 服务化这几个部分。为了提升预测速度,通常需要把训练好的模型转换成静态图,然后就可以使用 Paddle Inference 静态图进行推理,向量引擎则是存放标签的向量的形式,方便快速检索,另外,Paddle Inference 可以进一步对模型服务化,即使用 Paddle Serving 进行服务化,这样可以通过 HTTP 或者 RPC 的方式进行调用。Paddle Serving 的服务化形式有 Pipeline 和 C++两种形式,Pipeline 灵活一点,方便进行修改,C++部署更麻烦一点,但 C++的部署形式效率更高。
### 动转静导出
@@ -308,16 +308,16 @@ python export_model.py \
--model_name_or_path rocketqa-zh-dureader-query-encoder \
--output_path=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh scripts/export_model.sh
```
-### Paddle Inference预测
+### Paddle Inference 预测
预测既可以抽取向量也可以计算两个文本的相似度。
-修改deploy/python/predict.py中的id2corpus和corpus_list的样本:
+修改 deploy/python/predict.py 中的 id2corpus 和 corpus_list 的样本:
```
# 抽取向量
@@ -333,12 +333,12 @@ corpus_list = [{
```
-然后使用PaddleInference
+然后使用 PaddleInference
```
python deploy/python/predict.py --model_dir=./output
```
-也可以运行下面的bash脚本:
+也可以运行下面的 bash 脚本:
```
sh deploy.sh
@@ -356,7 +356,7 @@ sh deploy.sh
### 向量引擎
-模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU版本,建议使用官方的 Docker 安装方式,简单快捷。
+模型准备结束以后,开始搭建 Milvus 的向量检索引擎,用于文本语义向量的快速检索,本项目使用[Milvus](https://milvus.io/)开源工具进行向量检索,Milvus 的搭建教程请参考官方教程 [Milvus 官方安装教程](https://milvus.io/cn/docs/v1.1.1/milvus_docker-cpu.md)本案例使用的是 Milvus 的1.1.1 CPU 版本,建议使用官方的 Docker 安装方式,简单快捷。
Milvus 搭建完系统以后就可以插入和检索向量了,首先生成 embedding 向量,每个样本生成768维度的向量:
@@ -388,9 +388,9 @@ python utils/vector_insert.py \
sh scripts/run.sh
```
-### Paddle Serving部署
+### Paddle Serving 部署
-Paddle Serving 的安装可以参考[Paddle Serving 安装文档](https://github.com/PaddlePaddle/Serving#installation)。需要在服务端和客户端安装相关的依赖,用pip安装Paddle Serving的依赖如下:
+Paddle Serving 的安装可以参考[Paddle Serving 安装文档](https://github.com/PaddlePaddle/Serving#installation)。需要在服务端和客户端安装相关的依赖,用 pip 安装 Paddle Serving 的依赖如下:
```
pip install paddle-serving-client==0.8.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -407,7 +407,7 @@ pip install paddle-serving-server-gpu==0.8.3.post101 -i https://pypi.tuna.tsingh
# CUDA11.2 + TensorRT8
pip install paddle-serving-server-gpu==0.8.3.post112 -i https://pypi.tuna.tsinghua.edu.cn/simple
```
-更详细的安装信息请参考[链接](https://github.com/PaddlePaddle/Serving/blob/v0.9.0/doc/Install_Linux_Env_CN.md),安装完依赖后就可以执行下面的步骤。首先把生成的静态图模型导出为 Paddle Serving的格式,命令如下:
+更详细的安装信息请参考[链接](https://github.com/PaddlePaddle/Serving/blob/v0.9.0/doc/Install_Linux_Env_CN.md),安装完依赖后就可以执行下面的步骤。首先把生成的静态图模型导出为 Paddle Serving 的格式,命令如下:
```
python export_to_serving.py \
@@ -433,9 +433,9 @@ python export_to_serving.py \
sh scripts/export_to_serving.sh
```
-Paddle Serving的部署采用Pipeline的方式,如果用户有对性能有更高的要求,可以采用C++的部署形式,请参考[Neural Search](../../../neural_search/recall/in_batch_negative/#c%E7%9A%84%E6%96%B9%E5%BC%8F):
+Paddle Serving 的部署采用 Pipeline 的方式,如果用户有对性能有更高的要求,可以采用 C++的部署形式,请参考[Neural Search](../../../neural_search/recall/in_batch_negative/#c%E7%9A%84%E6%96%B9%E5%BC%8F):
-#### Pipeline方式
+#### Pipeline 方式
启动 Pipeline Server:
@@ -444,7 +444,7 @@ cd deploy/python/
python web_service.py
```
-启动客户端调用 Server, 使用 POST的方式:
+启动客户端调用 Server, 使用 POST 的方式:
向服务端发送 POST 请求示例:
@@ -452,8 +452,8 @@ python web_service.py
curl -X POST -k http://localhost:8090/ernie/prediction -d '{"key": ["0"], "value": ["{\"sentence\": \"中国农业大学怎么样?可以吗?\"}"]}'
```
-也可以使用 rpc的方式:
-首先修改rpc_client.py中需要预测的样本:
+也可以使用 rpc 的方式:
+首先修改 rpc_client.py 中需要预测的样本:
```
list_data = [{
@@ -484,7 +484,7 @@ time to cost :0.014188766479492188 seconds
## 9. 分类流程
-为了演示基于检索的文本分类流程,我们使用下面的python脚本来完成整个流程,该分类系统使用了Client Server的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问,得到分类的结果。
+为了演示基于检索的文本分类流程,我们使用下面的 python 脚本来完成整个流程,该分类系统使用了 Client Server 的模式,即抽取向量的模型部署在服务端,然后启动客户端(Client)端去访问,得到分类的结果。
```
python run_system.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/base_model.py b/slm/applications/text_classification/multi_label/retrieval_based/base_model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/base_model.py
rename to slm/applications/text_classification/multi_label/retrieval_based/base_model.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/data.py b/slm/applications/text_classification/multi_label/retrieval_based/data.py
similarity index 99%
rename from legacy/applications/text_classification/multi_label/retrieval_based/data.py
rename to slm/applications/text_classification/multi_label/retrieval_based/data.py
index 61b6fc701a8d..3625397bd088 100644
--- a/legacy/applications/text_classification/multi_label/retrieval_based/data.py
+++ b/slm/applications/text_classification/multi_label/retrieval_based/data.py
@@ -17,6 +17,7 @@
import hnswlib
import numpy as np
import paddle
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/config_nlp.yml b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/config_nlp.yml
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/config_nlp.yml
rename to slm/applications/text_classification/multi_label/retrieval_based/deploy/python/config_nlp.yml
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/deploy.sh b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/deploy.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/deploy.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/deploy/python/deploy.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/predict.py b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/predict.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/predict.py
rename to slm/applications/text_classification/multi_label/retrieval_based/deploy/python/predict.py
diff --git a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/rpc_client.py b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/rpc_client.py
similarity index 100%
rename from legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/rpc_client.py
rename to slm/applications/text_classification/multi_label/retrieval_based/deploy/python/rpc_client.py
index afb13b803f65..b20265cfb4e3 100644
--- a/legacy/applications/text_classification/multi_class/retrieval_based/deploy/python/rpc_client.py
+++ b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/rpc_client.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
-import numpy as np
+import numpy as np
from paddle_serving_server.pipeline import PipelineClient
client = PipelineClient()
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/web_service.py b/slm/applications/text_classification/multi_label/retrieval_based/deploy/python/web_service.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/deploy/python/web_service.py
rename to slm/applications/text_classification/multi_label/retrieval_based/deploy/python/web_service.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/evaluate.py b/slm/applications/text_classification/multi_label/retrieval_based/evaluate.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/evaluate.py
rename to slm/applications/text_classification/multi_label/retrieval_based/evaluate.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/export_model.py b/slm/applications/text_classification/multi_label/retrieval_based/export_model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/export_model.py
rename to slm/applications/text_classification/multi_label/retrieval_based/export_model.py
diff --git a/legacy/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py b/slm/applications/text_classification/multi_label/retrieval_based/export_to_serving.py
similarity index 99%
rename from legacy/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py
rename to slm/applications/text_classification/multi_label/retrieval_based/export_to_serving.py
index 1ba681a4dfb1..6cc932da1117 100644
--- a/legacy/applications/text_classification/hierarchical/retrieval_based/export_to_serving.py
+++ b/slm/applications/text_classification/multi_label/retrieval_based/export_to_serving.py
@@ -13,6 +13,7 @@
# limitations under the License.
import argparse
+
import paddle_serving_client.io as serving_io
# yapf: disable
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/metric.py b/slm/applications/text_classification/multi_label/retrieval_based/metric.py
similarity index 97%
rename from legacy/applications/text_classification/multi_label/retrieval_based/metric.py
rename to slm/applications/text_classification/multi_label/retrieval_based/metric.py
index d68451a538bb..cfdd30b67985 100644
--- a/legacy/applications/text_classification/multi_label/retrieval_based/metric.py
+++ b/slm/applications/text_classification/multi_label/retrieval_based/metric.py
@@ -13,8 +13,9 @@
# limitations under the License.
import numpy as np
-from sklearn.metrics import f1_score, classification_report
from paddle.metric import Metric
+from sklearn.metrics import classification_report, f1_score
+
from paddlenlp.utils.log import logger
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/model.py b/slm/applications/text_classification/multi_label/retrieval_based/model.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/model.py
rename to slm/applications/text_classification/multi_label/retrieval_based/model.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/predict.py b/slm/applications/text_classification/multi_label/retrieval_based/predict.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/predict.py
rename to slm/applications/text_classification/multi_label/retrieval_based/predict.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/recall.py b/slm/applications/text_classification/multi_label/retrieval_based/recall.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/recall.py
rename to slm/applications/text_classification/multi_label/retrieval_based/recall.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/requirements.txt b/slm/applications/text_classification/multi_label/retrieval_based/requirements.txt
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/requirements.txt
rename to slm/applications/text_classification/multi_label/retrieval_based/requirements.txt
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/run_system.py b/slm/applications/text_classification/multi_label/retrieval_based/run_system.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/run_system.py
rename to slm/applications/text_classification/multi_label/retrieval_based/run_system.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/evaluate.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/evaluate.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/evaluate.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/evaluate.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/export_model.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/export_model.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/export_model.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/export_model.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/export_to_serving.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/export_to_serving.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/export_to_serving.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/export_to_serving.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/predict.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/predict.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/predict.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/predict.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/run.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/run.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/run.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/run.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/run_build_index.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/run_build_index.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/run_build_index.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/run_build_index.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/scripts/train.sh b/slm/applications/text_classification/multi_label/retrieval_based/scripts/train.sh
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/scripts/train.sh
rename to slm/applications/text_classification/multi_label/retrieval_based/scripts/train.sh
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/train.py b/slm/applications/text_classification/multi_label/retrieval_based/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/train.py
rename to slm/applications/text_classification/multi_label/retrieval_based/train.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/utils/__init__.py b/slm/applications/text_classification/multi_label/retrieval_based/utils/__init__.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/utils/__init__.py
rename to slm/applications/text_classification/multi_label/retrieval_based/utils/__init__.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/utils/config.py b/slm/applications/text_classification/multi_label/retrieval_based/utils/config.py
similarity index 96%
rename from legacy/applications/text_classification/multi_label/retrieval_based/utils/config.py
rename to slm/applications/text_classification/multi_label/retrieval_based/utils/config.py
index 2da411d0c5e8..c558c23467f3 100644
--- a/legacy/applications/text_classification/multi_label/retrieval_based/utils/config.py
+++ b/slm/applications/text_classification/multi_label/retrieval_based/utils/config.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from milvus import MetricType, IndexType
+from milvus import IndexType, MetricType
MILVUS_HOST = "localhost"
MILVUS_PORT = 8530
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/utils/feature_extract.py b/slm/applications/text_classification/multi_label/retrieval_based/utils/feature_extract.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/utils/feature_extract.py
rename to slm/applications/text_classification/multi_label/retrieval_based/utils/feature_extract.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/utils/milvus_util.py b/slm/applications/text_classification/multi_label/retrieval_based/utils/milvus_util.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/utils/milvus_util.py
rename to slm/applications/text_classification/multi_label/retrieval_based/utils/milvus_util.py
diff --git a/legacy/applications/text_classification/multi_label/retrieval_based/utils/vector_insert.py b/slm/applications/text_classification/multi_label/retrieval_based/utils/vector_insert.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/retrieval_based/utils/vector_insert.py
rename to slm/applications/text_classification/multi_label/retrieval_based/utils/vector_insert.py
diff --git a/legacy/applications/text_classification/multi_label/train.py b/slm/applications/text_classification/multi_label/train.py
similarity index 100%
rename from legacy/applications/text_classification/multi_label/train.py
rename to slm/applications/text_classification/multi_label/train.py
diff --git a/legacy/applications/text_classification/hierarchical/utils.py b/slm/applications/text_classification/multi_label/utils.py
similarity index 100%
rename from legacy/applications/text_classification/hierarchical/utils.py
rename to slm/applications/text_classification/multi_label/utils.py
index 9915906c9a2a..22663eefa8c4 100644
--- a/legacy/applications/text_classification/hierarchical/utils.py
+++ b/slm/applications/text_classification/multi_label/utils.py
@@ -13,9 +13,9 @@
# limitations under the License.
import numpy as np
-
import paddle
import paddle.nn.functional as F
+
from paddlenlp.utils.log import logger
diff --git a/legacy/examples/README.md b/slm/examples/README.md
similarity index 97%
rename from legacy/examples/README.md
rename to slm/examples/README.md
index d036956f85b0..de97052ae333 100644
--- a/legacy/examples/README.md
+++ b/slm/examples/README.md
@@ -1,6 +1,6 @@
# PaddleNLP Examples
-PaddleNLP旨在提供覆盖从研究到产业应用的丰富示例,助力开发者加速文本任务开发效率。
+PaddleNLP 旨在提供覆盖从研究到产业应用的丰富示例,助力开发者加速文本任务开发效率。
PaddleNLP provides rich application examples covering mainstream NLP task to help developers accelerate problem solving.
diff --git a/legacy/examples/RLHF/README.md b/slm/examples/RLHF/README.md
similarity index 95%
rename from legacy/examples/RLHF/README.md
rename to slm/examples/RLHF/README.md
index 478f8365833b..8a4216ab59b1 100644
--- a/legacy/examples/RLHF/README.md
+++ b/slm/examples/RLHF/README.md
@@ -1,6 +1,6 @@
# RLHF PPO
-提供了基于强化学习 PPO 算法对 LLM 进行人类偏好对齐的代码及完整使用示例,支持**3D 分布式并行训练以及 rollout 阶段使用预测优化进行生成加速**。其中 PPO 代码实现细节参考了 [PKU-Alignment/safe-rlhf](https://github.com/PKU-Alignment/safe-rlhf)(PKU Beaver) 中的 PPO 实现,支持reward normalization、pretraining loss等常用的 PPO 稳定训练策略;示例使用 PKU-Alignment/safe-rlhf 提供的部分数据集和模型。后续将持续完善扩展,支持更好效果、更低成本、更高性能、更大规模的 RLHF 能力。
+提供了基于强化学习 PPO 算法对 LLM 进行人类偏好对齐的代码及完整使用示例,支持**3D 分布式并行训练以及 rollout 阶段使用预测优化进行生成加速**。其中 PPO 代码实现细节参考了 [PKU-Alignment/safe-rlhf](https://github.com/PKU-Alignment/safe-rlhf)(PKU Beaver) 中的 PPO 实现,支持 reward normalization、pretraining loss 等常用的 PPO 稳定训练策略;示例使用 PKU-Alignment/safe-rlhf 提供的部分数据集和模型。后续将持续完善扩展,支持更好效果、更低成本、更高性能、更大规模的 RLHF 能力。
## 快速开始
@@ -50,7 +50,7 @@ PPO 训练包括 Supervised Fine-Tuning、Reward Model Fine-Tuning、RLHF 三个
同[LLM 精调](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/llm#2-%E7%B2%BE%E8%B0%83),可以直接参考对应内容进行数据准备。
#### Reward Model Fine-Tuning 数据
-Reward Model Fine-Tuning 阶段需要使用人类偏好数据。示例使用 PKU-Alignment/safe-rlhf 提供的 [PKU-Alignment/PKU-SafeRLHF-30K](https://huggingface.co/datasets/PKU-Alignment/PKU-SafeRLHF-30K) 数据集,下面是其中一条样本,这里使用其中的`prompt、response_0、response_1、better_response_id`字段来组织偏好数据(safe字段,该数据集将helpful 和 harmless 分开标注,示例这里使用其 helpful 标注)。
+Reward Model Fine-Tuning 阶段需要使用人类偏好数据。示例使用 PKU-Alignment/safe-rlhf 提供的 [PKU-Alignment/PKU-SafeRLHF-30K](https://huggingface.co/datasets/PKU-Alignment/PKU-SafeRLHF-30K) 数据集,下面是其中一条样本,这里使用其中的`prompt、response_0、response_1、better_response_id`字段来组织偏好数据(safe 字段,该数据集将 helpful 和 harmless 分开标注,示例这里使用其 helpful 标注)。
```json
{
@@ -212,8 +212,8 @@ GLOG_minloglevel=2 python -u -m paddle.distributed.launch ppo_main.py ./ppo_conf
- `update_iters`:一次生成的数据被使用的次数。
- `kl_coeff`:对 reward 进行 KL-Penalty 的系数。
- `clip_range_score`:对 reward 进行裁剪的阈值。
-- `clip_range_value`:critic model(value function)对当前sequence的新值与Experience Buffer中旧值的差距超过该范围将进行裁剪。
-- `clip_range_ratio`:将当前sequence的新概率与Experience Buffer中旧概率比值裁剪到`(1-clip_range_ratio, 1+clip_range_ratio)`范围(PPO-Clip)。
+- `clip_range_value`:critic model(value function)对当前 sequence 的新值与 Experience Buffer 中旧值的差距超过该范围将进行裁剪。
+- `clip_range_ratio`:将当前 sequence 的新概率与 Experience Buffer 中旧概率比值裁剪到`(1-clip_range_ratio, 1+clip_range_ratio)`范围(PPO-Clip)。
- `ptx_coeff`: 预训练损失项 ptx-loss 的系数。
另外所有 [`TrainingArguments` 支持参数配置](https://paddlenlp.readthedocs.io/zh/latest/trainer.html#trainingarguments)将为 actor-model 和 critic-model 的训练复用(如`sharding_stage`),除单独提供了 `critic_learning_rate/critic_weight_decay/critic_lr_scheduler_type/critic_warmup_ratio/critic_recompute` 这些参数支持为 critic-model 训练单独指定相应配置。actor-model 和 critic-model 的 checkpoints 将分别保存在 `outpt_dir` 所指定目录的 policy 和 value 文件夹下。
@@ -223,7 +223,7 @@ GLOG_minloglevel=2 python -u -m paddle.distributed.launch ppo_main.py ./ppo_conf
- `eval_mode`:支持为空或者设置为 "single"、"tensor_parallel";通常可以在使用流水线并行训练时设置为"tensor_parallel",以此在 rollout 生成阶段使用非流水线并行模型并进行生成加速。
- `offload_level`:支持设置为"freeze_model"、"optimizer"、"train_model"或者同时使用(空格分隔),分别指示 reward+reference 两个冻结模型、actor+critic 两个训练模型的优化器状态和模型参数的 offload/reload,用于在不同阶段 model/optimizer 使用结束后及时 offload 并在下次使用时 reload 相应参数权重以节省显存。
-另外注意,在使用流水线并行时(pipeline_parallel_degree大于1)建议将 `dataloader_drop_last` 设置为 true, 以此避免不同batch size带来的问题。
+另外注意,在使用流水线并行时(pipeline_parallel_degree 大于1)建议将 `dataloader_drop_last` 设置为 true, 以此避免不同 batch size 带来的问题。
diff --git a/legacy/examples/RLHF/comm_utils.py b/slm/examples/RLHF/comm_utils.py
similarity index 100%
rename from legacy/examples/RLHF/comm_utils.py
rename to slm/examples/RLHF/comm_utils.py
diff --git a/legacy/examples/RLHF/data/__init__.py b/slm/examples/RLHF/data/__init__.py
similarity index 100%
rename from legacy/examples/RLHF/data/__init__.py
rename to slm/examples/RLHF/data/__init__.py
diff --git a/legacy/examples/RLHF/data/alpaca.py b/slm/examples/RLHF/data/alpaca.py
similarity index 100%
rename from legacy/examples/RLHF/data/alpaca.py
rename to slm/examples/RLHF/data/alpaca.py
diff --git a/legacy/examples/RLHF/data/base.py b/slm/examples/RLHF/data/base.py
similarity index 99%
rename from legacy/examples/RLHF/data/base.py
rename to slm/examples/RLHF/data/base.py
index ab3fd5b19d2c..6d0f4717c4d3 100644
--- a/legacy/examples/RLHF/data/base.py
+++ b/slm/examples/RLHF/data/base.py
@@ -259,7 +259,7 @@ def __init_subclass__(cls) -> None:
cls.__ALIAS_NAME_MAPPING.update(dict.fromkeys(aliases, name))
@staticmethod
- def load(name: str, /, *args: Any, **kwargs: Any) -> RawDataset:
+ def load(name: str, /, *args: Any, **kwargs: Any) -> RawDataset: # noqa: E999
"""Load a raw dataset by name."""
normalized_name = RawDataset.__ALIAS_NAME_MAPPING.get(name, name)
try:
diff --git a/legacy/examples/RLHF/data/preference.py b/slm/examples/RLHF/data/preference.py
similarity index 100%
rename from legacy/examples/RLHF/data/preference.py
rename to slm/examples/RLHF/data/preference.py
diff --git a/legacy/examples/RLHF/data/prompt_only.py b/slm/examples/RLHF/data/prompt_only.py
similarity index 100%
rename from legacy/examples/RLHF/data/prompt_only.py
rename to slm/examples/RLHF/data/prompt_only.py
diff --git a/legacy/examples/RLHF/data/safe_rlhf.py b/slm/examples/RLHF/data/safe_rlhf.py
similarity index 100%
rename from legacy/examples/RLHF/data/safe_rlhf.py
rename to slm/examples/RLHF/data/safe_rlhf.py
diff --git a/legacy/examples/RLHF/data/supervised.py b/slm/examples/RLHF/data/supervised.py
similarity index 100%
rename from legacy/examples/RLHF/data/supervised.py
rename to slm/examples/RLHF/data/supervised.py
diff --git a/legacy/examples/RLHF/infer_utils.py b/slm/examples/RLHF/infer_utils.py
similarity index 100%
rename from legacy/examples/RLHF/infer_utils.py
rename to slm/examples/RLHF/infer_utils.py
diff --git a/legacy/examples/RLHF/models/__init__.py b/slm/examples/RLHF/models/__init__.py
similarity index 100%
rename from legacy/examples/RLHF/models/__init__.py
rename to slm/examples/RLHF/models/__init__.py
diff --git a/legacy/examples/RLHF/models/infer_model_utils.py b/slm/examples/RLHF/models/infer_model_utils.py
similarity index 100%
rename from legacy/examples/RLHF/models/infer_model_utils.py
rename to slm/examples/RLHF/models/infer_model_utils.py
diff --git a/legacy/examples/RLHF/models/model_pp.py b/slm/examples/RLHF/models/model_pp.py
similarity index 100%
rename from legacy/examples/RLHF/models/model_pp.py
rename to slm/examples/RLHF/models/model_pp.py
diff --git a/legacy/examples/RLHF/models/pp_model_utils.py b/slm/examples/RLHF/models/pp_model_utils.py
similarity index 100%
rename from legacy/examples/RLHF/models/pp_model_utils.py
rename to slm/examples/RLHF/models/pp_model_utils.py
diff --git a/legacy/examples/RLHF/models/ppo_model.py b/slm/examples/RLHF/models/ppo_model.py
similarity index 100%
rename from legacy/examples/RLHF/models/ppo_model.py
rename to slm/examples/RLHF/models/ppo_model.py
diff --git a/legacy/examples/RLHF/models/ppo_model_utils.py b/slm/examples/RLHF/models/ppo_model_utils.py
similarity index 100%
rename from legacy/examples/RLHF/models/ppo_model_utils.py
rename to slm/examples/RLHF/models/ppo_model_utils.py
diff --git a/legacy/examples/RLHF/models/score_model.py b/slm/examples/RLHF/models/score_model.py
similarity index 100%
rename from legacy/examples/RLHF/models/score_model.py
rename to slm/examples/RLHF/models/score_model.py
diff --git a/legacy/examples/RLHF/models/score_model_utils.py b/slm/examples/RLHF/models/score_model_utils.py
similarity index 100%
rename from legacy/examples/RLHF/models/score_model_utils.py
rename to slm/examples/RLHF/models/score_model_utils.py
diff --git a/legacy/examples/RLHF/ppo_config.json b/slm/examples/RLHF/ppo_config.json
similarity index 100%
rename from legacy/examples/RLHF/ppo_config.json
rename to slm/examples/RLHF/ppo_config.json
diff --git a/legacy/examples/RLHF/ppo_main.py b/slm/examples/RLHF/ppo_main.py
similarity index 100%
rename from legacy/examples/RLHF/ppo_main.py
rename to slm/examples/RLHF/ppo_main.py
diff --git a/legacy/examples/RLHF/ppo_trainer.py b/slm/examples/RLHF/ppo_trainer.py
similarity index 100%
rename from legacy/examples/RLHF/ppo_trainer.py
rename to slm/examples/RLHF/ppo_trainer.py
diff --git a/legacy/examples/RLHF/reward_config.json b/slm/examples/RLHF/reward_config.json
similarity index 100%
rename from legacy/examples/RLHF/reward_config.json
rename to slm/examples/RLHF/reward_config.json
diff --git a/legacy/examples/RLHF/reward_main.py b/slm/examples/RLHF/reward_main.py
similarity index 100%
rename from legacy/examples/RLHF/reward_main.py
rename to slm/examples/RLHF/reward_main.py
diff --git a/legacy/examples/RLHF/reward_trainer.py b/slm/examples/RLHF/reward_trainer.py
similarity index 100%
rename from legacy/examples/RLHF/reward_trainer.py
rename to slm/examples/RLHF/reward_trainer.py
diff --git a/legacy/examples/RLHF/run.sh b/slm/examples/RLHF/run.sh
similarity index 100%
rename from legacy/examples/RLHF/run.sh
rename to slm/examples/RLHF/run.sh
diff --git a/legacy/examples/RLHF/tests/run_model.py b/slm/examples/RLHF/tests/run_model.py
similarity index 100%
rename from legacy/examples/RLHF/tests/run_model.py
rename to slm/examples/RLHF/tests/run_model.py
diff --git a/legacy/examples/RLHF/tests/test_export.py b/slm/examples/RLHF/tests/test_export.py
similarity index 100%
rename from legacy/examples/RLHF/tests/test_export.py
rename to slm/examples/RLHF/tests/test_export.py
diff --git a/legacy/examples/RLHF/trainer_utils.py b/slm/examples/RLHF/trainer_utils.py
similarity index 100%
rename from legacy/examples/RLHF/trainer_utils.py
rename to slm/examples/RLHF/trainer_utils.py
diff --git a/slm/examples/benchmark/ceval/README.md b/slm/examples/benchmark/ceval/README.md
new file mode 100644
index 000000000000..0790540c4243
--- /dev/null
+++ b/slm/examples/benchmark/ceval/README.md
@@ -0,0 +1,84 @@
+# C-Eval 评测脚本
+
+此 C-Eval 评测脚本修改自[ymcui/Chinese-LLaMA-Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca)项目。
+
+## 数据准备
+
+从 C-Eval 官方指定路径下载评测数据集,并解压至 data 文件夹:
+
+```
+wget https://huggingface.co/datasets/ceval/ceval-exam/resolve/main/ceval-exam.zip
+unzip ceval-exam.zip -d data
+```
+将 data 文件夹放置于本项目的 scripts/ceval 目录下。
+
+## 运行预测脚本
+
+运行以下脚本:
+
+```
+cd scripts/ceval
+python eval.py \
+ --model_name_or_path /path/to/your/model \
+ --cot False \
+ --few_shot False \
+ --with_prompt True \
+ --constrained_decoding True \
+ --temperature 0.2 \
+ --n_times 1 \
+ --ntrain 5 \
+ --do_save_csv False \
+ --do_test False \
+ --output_dir ${output_path} \
+```
+
+参数说明
+
+- model_path:待评测模型所在目录(合并 LoRA 后的 HF 格式模型)
+- cot:是否使用 chain-of-thought
+- few_shot:是否使用 few-shot
+- ntrain:few_shot=True 时,指定 few-shot 实例的数量(5-shot:ntrain=5);few_shot=False 时该项不起作用
+- with_prompt:模型输入是否包含针对 Alpaca 模型的指令模板
+- constrained_decoding:由于 C-Eval 评测的标准答案格式为选项'A'/'B'/'C'/'D',所以我们提供了两种从模型生成内容中抽取答案的方案:
+ - 当 constrained_decoding=True,计算模型生成的第一个 token 分别为'A', 'B', 'C', 'D'的概率,选择其中概率最大的一个作为答案
+ - 当 constrained_decoding=False,用正则表达式从模型生成内容中提取答案
+- temperature:模型解码时的温度
+- n_times:指定评测的重复次数,将在 output_dir 下生成指定次数的文件夹
+- do_save_csv:是否将模型生成结果、提取的答案等内容保存在 csv 文件中
+- output_dir:指定评测结果的输出路径
+- do_test:在 valid 或 test 集上测试:当 do_test=False,在 valid 集上测试;当 do_test=True,在 test 集上测试
+
+## 评测输出
+模型预测完成后,生成目录`outputs/take*`,其中*代表数字,范围为0至`n_times-1`,分别储存了`n_times`次解码的结果。
+
+`outputs/take*`下包含`submission.json`和`summary.json`两个 json 文件。若`do_save_csv=True`,还将包含52个保存的模型生成结果、提取的答案等内容的 csv 文件。
+
+`submission.json`为依据官方提交规范生成的存储模型评测答案的文件,形式如:
+
+```
+{
+ "computer_network": {
+ "0": "A",
+ "1": "B",
+ ...
+ },
+ "marxism": {
+ "0": "B",
+ "1": "A",
+ ...
+ },
+ ...
+}
+```
+
+summary.json 包含模型在52个主题下、4个大类下和总体平均的评测结果。例如,json 文件最后的 All 字段中会显示总体平均效果:
+
+```
+ "All": {
+ "score": 0.36701337295690933,
+ "num": 1346,
+ "correct": 494.0
+}
+```
+
+其中 score 为准确率,num 为测试的总样本条数,correct 为正确的数量。
diff --git a/legacy/examples/benchmark/ceval/eval.py b/slm/examples/benchmark/ceval/eval.py
similarity index 100%
rename from legacy/examples/benchmark/ceval/eval.py
rename to slm/examples/benchmark/ceval/eval.py
diff --git a/legacy/examples/benchmark/ceval/evaluator.py b/slm/examples/benchmark/ceval/evaluator.py
similarity index 100%
rename from legacy/examples/benchmark/ceval/evaluator.py
rename to slm/examples/benchmark/ceval/evaluator.py
diff --git a/legacy/examples/benchmark/ceval/model_evaluator.py b/slm/examples/benchmark/ceval/model_evaluator.py
similarity index 100%
rename from legacy/examples/benchmark/ceval/model_evaluator.py
rename to slm/examples/benchmark/ceval/model_evaluator.py
diff --git a/legacy/examples/benchmark/ceval/subject_mapping.json b/slm/examples/benchmark/ceval/subject_mapping.json
similarity index 100%
rename from legacy/examples/benchmark/ceval/subject_mapping.json
rename to slm/examples/benchmark/ceval/subject_mapping.json
diff --git a/legacy/examples/benchmark/clue/README.md b/slm/examples/benchmark/clue/README.md
similarity index 97%
rename from legacy/examples/benchmark/clue/README.md
rename to slm/examples/benchmark/clue/README.md
index cf6662d543a9..e6067538f6a6 100644
--- a/legacy/examples/benchmark/clue/README.md
+++ b/slm/examples/benchmark/clue/README.md
@@ -1,25 +1,25 @@
# CLUE Benchmark
**目录**
- * [CLUE 评测结果](#CLUE评测结果)
+ * [CLUE 评测结果](#CLUE 评测结果)
* [一键复现模型效果](#一键复现模型效果)
- * [启动 CLUE 分类任务](#启动CLUE分类任务)
- * [使用 Trainer 启动 CLUE 分类任务](#使用Trainer启动CLUE分类任务)
- * [启动 CLUE 阅读理解任务](#启动CLUE阅读理解任务)
- * [批量启动 Grid Search](#批量启动GridSearch)
+ * [启动 CLUE 分类任务](#启动 CLUE 分类任务)
+ * [使用 Trainer 启动 CLUE 分类任务](#使用 Trainer 启动 CLUE 分类任务)
+ * [启动 CLUE 阅读理解任务](#启动 CLUE 阅读理解任务)
+ * [批量启动 Grid Search](#批量启动 GridSearch)
* [环境依赖](#环境依赖)
* [一键启动方法](#一键启动方法)
- * [Grid Search 脚本说明](#GridSearch脚本说明)
- * [参加 CLUE 竞赛](#参加CLUE竞赛)
+ * [Grid Search 脚本说明](#GridSearch 脚本说明)
+ * [参加 CLUE 竞赛](#参加 CLUE 竞赛)
* [分类任务](#分类任务)
* [阅读理解任务](#阅读理解任务)
-[CLUE](https://www.cluebenchmarks.com/) 自成立以来发布了多项 NLP 评测基准,包括分类榜单,阅读理解榜单和自然语言推断榜单等,在学术界、工业界产生了深远影响。是目前应用最广泛的中文语言测评指标之一。详细可参考 [CLUE论文](https://arxiv.org/abs/2004.05986)。
+[CLUE](https://www.cluebenchmarks.com/) 自成立以来发布了多项 NLP 评测基准,包括分类榜单,阅读理解榜单和自然语言推断榜单等,在学术界、工业界产生了深远影响。是目前应用最广泛的中文语言测评指标之一。详细可参考 [CLUE 论文](https://arxiv.org/abs/2004.05986)。
本项目基于 PaddlePaddle 在 CLUE 数据集上对领先的开源预训练模型模型进行了充分评测,为开发者在预训练模型选择上提供参考,同时开发者基于本项目可以轻松一键复现模型效果,也可以参加 CLUE 竞赛取得好成绩。
-
+
## CLUE 评测结果
@@ -1212,7 +1212,7 @@ AFQMC(语义相似度)、TNEWS(文本分类)、IFLYTEK(长文本分类
**NOTE:具体评测方式如下**
1. 以上所有任务均基于 Grid Search 方式进行超参寻优。分类任务训练每间隔 100 steps 评估验证集效果,阅读理解任务每隔一个 epoch 评估验证集效果,取验证集最优效果作为表格中的汇报指标。
-2. 分类任务 Grid Search 超参范围: batch_size: 16, 32, 64; learning rates: 1e-5, 2e-5, 3e-5, 5e-5;因为 CLUEWSC2020 数据集较小,所以模型在该数据集上的效果对 batch_size 较敏感,所以对 CLUEWSC2020 评测时额外增加了 batch_size = 8 的超参搜索; 因为CLUEWSC2020 和 IFLYTEK 数据集对 dropout 概率值较为敏感,所以对 CLUEWSC2020 和 IFLYTEK 数据集评测时额外增加了 dropout_prob = 0.0 的超参搜索。
+2. 分类任务 Grid Search 超参范围: batch_size: 16, 32, 64; learning rates: 1e-5, 2e-5, 3e-5, 5e-5;因为 CLUEWSC2020 数据集较小,所以模型在该数据集上的效果对 batch_size 较敏感,所以对 CLUEWSC2020 评测时额外增加了 batch_size = 8 的超参搜索; 因为 CLUEWSC2020 和 IFLYTEK 数据集对 dropout 概率值较为敏感,所以对 CLUEWSC2020 和 IFLYTEK 数据集评测时额外增加了 dropout_prob = 0.0 的超参搜索。
3. 阅读理解任务 Grid Search 超参范围:batch_size: 24, 32; learning rates: 1e-5, 2e-5, 3e-5。阅读理解任务均使用多卡训练,其中 Grid Search 中的 batch_size 是指多张卡上的 batch_size 总和。
@@ -1267,7 +1267,7 @@ AFQMC(语义相似度)、TNEWS(文本分类)、IFLYTEK(长文本分类
这一节将会对分类、阅读理解任务分别展示如何一键复现本文的评测结果。
-
+
### 启动 CLUE 分类任务
以 CLUE 的 TNEWS 任务为例,启动 CLUE 任务进行 Fine-tuning 的方式如下:
@@ -1309,7 +1309,7 @@ python -u ./run_clue_classifier.py \
其中参数释义如下:
-- `model_name_or_path` 指示了 Fine-tuning 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,可以选择[Transformer预训练模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中相对应的中文预训练权重。注意 CLUE 任务应选择中文预训练权重。
+- `model_name_or_path` 指示了 Fine-tuning 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,可以选择[Transformer 预训练模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中相对应的中文预训练权重。注意 CLUE 任务应选择中文预训练权重。
- `task_name` 表示 Fine-tuning 的分类任务,当前支持 AFQMC、TNEWS、IFLYTEK、OCNLI、CMNLI、CSL、CLUEWSC2020。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
@@ -1319,7 +1319,7 @@ python -u ./run_clue_classifier.py \
- `save_steps` 表示模型保存及评估间隔。
- `save_best_model` 是否保存在评估集上效果最好的模型,默认为 True
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu' 表示使用GPU, 'xpu' 表示使用百度昆仑卡, 'cpu' 表示使用 CPU。
+- `device` 表示训练使用的设备, 'gpu' 表示使用 GPU, 'xpu' 表示使用百度昆仑卡, 'cpu' 表示使用 CPU。
Fine-tuning 过程将按照 `logging_steps` 和 `save_steps` 的设置打印出如下日志:
@@ -1334,7 +1334,7 @@ global step 400/20010, epoch: 0, batch: 399, rank_id: 0, loss: 2.631579, lr: 0.0
eval loss: 2.476962, acc: 0.1697, eval done total : 25.794789791107178 s
```
-
+
#### 使用 Trainer 启动 CLUE 分类任务
PaddleNLP 提供了 Trainer API,本示例新增了`run_clue_classifier_trainer.py`脚本供用户使用。
@@ -1377,12 +1377,12 @@ python -u ./run_clue_classifier_trainer.py \
- `dataset`, 同上文`task_name`,此处为小写字母。表示 Fine-tuning 的分类任务,当前支持 afamc、tnews、iflytek、ocnli、cmnli、csl、cluewsc2020。
- `per_device_train_batch_size` 同上文`batch_size`。训练时,每次迭代**每张卡**上的样本数目。
- `per_device_eval_batch_size` 同上文`batch_size`。评估时,每次迭代**每张卡**上的样本数目。
-- `warmup_ratio` 同上文`warmup_proportion`,warmup步数占总步数的比例。
+- `warmup_ratio` 同上文`warmup_proportion`,warmup 步数占总步数的比例。
- `metric_for_best_model` 评估时,最优评估指标。
- `load_best_model_at_end` 训练结束时,时候加载评估结果最好的 ckpt。
-- `save_total_limit` 保存的ckpt数量的最大限制
+- `save_total_limit` 保存的 ckpt 数量的最大限制
-
+
### 启动 CLUE 阅读理解任务
以 CLUE 的 C 3 任务为例,多卡启动 CLUE 任务进行 Fine-tuning 的方式如下:
@@ -1408,7 +1408,7 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_c3.py \
```
需要注意的是,如果显存无法容纳所传入的 `batch_size`,可以通过传入 `gradient_accumulation_steps` 参数来模拟该 `batch_size`。
-
+
### 批量启动 Grid Search
@@ -1416,7 +1416,7 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_c3.py \
#### 环境依赖
-Grid Search 需要在 GPU 环境下进行,需要注意的是 C 3 任务需要显存大于 16 GB,最好是在显存 32 GB的环境下启动。
+Grid Search 需要在 GPU 环境下进行,需要注意的是 C 3 任务需要显存大于 16 GB,最好是在显存 32 GB 的环境下启动。
Grid Search 中的 GPU 调度需要依赖 pynvml 库,pynvml 库提供了 GPU 管理的 Python 接口。可启动以下命令进行安装 pynvml:
@@ -1466,20 +1466,20 @@ C3 77.88 (3e-05,32,0.1)
另外,如遇意外情况(如机器重启)导致训练中断,可以直接再次启动 `grid_search.py` 脚本,之前已完成(输出完整日志)的任务则会直接跳过。
-
+
#### Grid Search 脚本说明
本节介绍 grid_search_tools 目录下各个脚本的功能:
- `grid_search.py` Grid Search 任务入口脚本,该脚本负责调度 GPU 资源,可自动将 7 个分类任务、3 个阅读理解下所有超参数对应的任务完成,训练完成后会自动调用抽取结果的脚本 `extract_result.sh` 打印出所有任务的最佳结果和对应的超参。
-- `warmup_dataset_and_model.py` 首次运行时,该脚本完成模型下载(如需)、数据集下载,阅读理解任务数据预处理、预处理文件缓存等工作,再次运行则会检查这些文件是否存在,存在则跳过。该脚本由 `grid_search.py` 在 Grid Search 训练前自动调用,预处理 cache 文件生成后,后面所有训练任务即可加载缓存文件避免重复进行数据预处理。如果该阶段任务失败,大多需要检查网络,解决之后需重启 `grid_search.py`,直到训练正常开始。该脚本也可手动调用,需要 1 个参数,模型名称或目录。该脚本在使用 Intel(R) Xeon(R) Gold 6271C CPU 且 `--num_proc`默认为 4 的情况下需约 30 分钟左右完成,可以更改 `run_mrc.sh` 中的 `--num_proc` 参数以改变生成 cache 的进程数。需要注意的是,若改变 num_proc,之前的缓存则不能再使用,该脚本会重新处理数据并生成新的 cache,cache 相关内容可查看[datasets.Dataset.map文档](https://huggingface.co/docs/datasets/v2.0.0/package_reference/main_classes?highlight=map#datasets.Dataset.map)。
+- `warmup_dataset_and_model.py` 首次运行时,该脚本完成模型下载(如需)、数据集下载,阅读理解任务数据预处理、预处理文件缓存等工作,再次运行则会检查这些文件是否存在,存在则跳过。该脚本由 `grid_search.py` 在 Grid Search 训练前自动调用,预处理 cache 文件生成后,后面所有训练任务即可加载缓存文件避免重复进行数据预处理。如果该阶段任务失败,大多需要检查网络,解决之后需重启 `grid_search.py`,直到训练正常开始。该脚本也可手动调用,需要 1 个参数,模型名称或目录。该脚本在使用 Intel(R) Xeon(R) Gold 6271C CPU 且 `--num_proc`默认为 4 的情况下需约 30 分钟左右完成,可以更改 `run_mrc.sh` 中的 `--num_proc` 参数以改变生成 cache 的进程数。需要注意的是,若改变 num_proc,之前的缓存则不能再使用,该脚本会重新处理数据并生成新的 cache,cache 相关内容可查看[datasets.Dataset.map 文档](https://huggingface.co/docs/datasets/v2.0.0/package_reference/main_classes?highlight=map#datasets.Dataset.map)。
- `extract_result.sh` 从日志抽取每个任务的最佳结果和对应的最佳超参并打印,`grid_search.py` 在完成训练任务后会自动调用,也可手动调用,需要 1 个参数:模型名称或目录。手动调用前需要确认训练均全部完成,并且保证该目录下有分类和阅读理解所有任务的日志。
- `run_mrc.sh` 阅读理解任务的启动脚本。
- `run_cls.sh` 分类任务的启动脚本。
-
+
## 参加 CLUE 竞赛
diff --git a/legacy/examples/benchmark/clue/classification/run_clue_classifier.py b/slm/examples/benchmark/clue/classification/run_clue_classifier.py
similarity index 100%
rename from legacy/examples/benchmark/clue/classification/run_clue_classifier.py
rename to slm/examples/benchmark/clue/classification/run_clue_classifier.py
diff --git a/legacy/examples/benchmark/clue/classification/run_clue_classifier_trainer.py b/slm/examples/benchmark/clue/classification/run_clue_classifier_trainer.py
similarity index 100%
rename from legacy/examples/benchmark/clue/classification/run_clue_classifier_trainer.py
rename to slm/examples/benchmark/clue/classification/run_clue_classifier_trainer.py
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/draw_pic.py b/slm/examples/benchmark/clue/grid_search_tools/draw_pic.py
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/draw_pic.py
rename to slm/examples/benchmark/clue/grid_search_tools/draw_pic.py
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/extract_result.sh b/slm/examples/benchmark/clue/grid_search_tools/extract_result.sh
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/extract_result.sh
rename to slm/examples/benchmark/clue/grid_search_tools/extract_result.sh
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/grid_search.py b/slm/examples/benchmark/clue/grid_search_tools/grid_search.py
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/grid_search.py
rename to slm/examples/benchmark/clue/grid_search_tools/grid_search.py
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/run_cls.sh b/slm/examples/benchmark/clue/grid_search_tools/run_cls.sh
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/run_cls.sh
rename to slm/examples/benchmark/clue/grid_search_tools/run_cls.sh
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/run_mrc.sh b/slm/examples/benchmark/clue/grid_search_tools/run_mrc.sh
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/run_mrc.sh
rename to slm/examples/benchmark/clue/grid_search_tools/run_mrc.sh
diff --git a/legacy/examples/benchmark/clue/grid_search_tools/warmup_dataset_and_model.py b/slm/examples/benchmark/clue/grid_search_tools/warmup_dataset_and_model.py
similarity index 100%
rename from legacy/examples/benchmark/clue/grid_search_tools/warmup_dataset_and_model.py
rename to slm/examples/benchmark/clue/grid_search_tools/warmup_dataset_and_model.py
diff --git a/legacy/examples/benchmark/clue/mrc/run_c3.py b/slm/examples/benchmark/clue/mrc/run_c3.py
similarity index 100%
rename from legacy/examples/benchmark/clue/mrc/run_c3.py
rename to slm/examples/benchmark/clue/mrc/run_c3.py
diff --git a/legacy/examples/benchmark/clue/mrc/run_chid.py b/slm/examples/benchmark/clue/mrc/run_chid.py
similarity index 100%
rename from legacy/examples/benchmark/clue/mrc/run_chid.py
rename to slm/examples/benchmark/clue/mrc/run_chid.py
diff --git a/legacy/examples/benchmark/clue/mrc/run_cmrc2018.py b/slm/examples/benchmark/clue/mrc/run_cmrc2018.py
similarity index 100%
rename from legacy/examples/benchmark/clue/mrc/run_cmrc2018.py
rename to slm/examples/benchmark/clue/mrc/run_cmrc2018.py
diff --git a/legacy/examples/benchmark/glue/README.md b/slm/examples/benchmark/glue/README.md
similarity index 62%
rename from legacy/examples/benchmark/glue/README.md
rename to slm/examples/benchmark/glue/README.md
index 14f9abc43460..bb31d4b48fab 100644
--- a/legacy/examples/benchmark/glue/README.md
+++ b/slm/examples/benchmark/glue/README.md
@@ -1,15 +1,15 @@
# GLUE Benchmark
-[GLUE](https://gluebenchmark.com/)是当今使用最为普遍的自然语言理解评测基准数据集,评测数据涵盖新闻、电影、百科等许多领域,其中有简单的句子,也有困难的句子。其目的是通过公开的得分榜,促进自然语言理解系统的发展。详细可参考 [GLUE论文](https://openreview.net/pdf?id=rJ4km2R5t7)
+[GLUE](https://gluebenchmark.com/)是当今使用最为普遍的自然语言理解评测基准数据集,评测数据涵盖新闻、电影、百科等许多领域,其中有简单的句子,也有困难的句子。其目的是通过公开的得分榜,促进自然语言理解系统的发展。详细可参考 [GLUE 论文](https://openreview.net/pdf?id=rJ4km2R5t7)
-本项目是 GLUE评测任务 在 Paddle 2.0上的开源实现。
+本项目是 GLUE 评测任务 在 Paddle 2.0上的开源实现。
-本项目支持BERT, ELECTRA,ERNIE,ALBERT,RoBERTa模型,可在model_type中进行指定。
+本项目支持 BERT, ELECTRA,ERNIE,ALBERT,RoBERTa 模型,可在 model_type 中进行指定。
## 快速开始
-### 启动GLUE任务
-以 GLUE/SST-2 任务为例,启动GLUE任务进行Fine-tuning的方式如下:
+### 启动 GLUE 任务
+以 GLUE/SST-2 任务为例,启动 GLUE 任务进行 Fine-tuning 的方式如下:
#### 单卡训练
```shell
@@ -51,20 +51,20 @@ python -m paddle.distributed.launch --gpus "0,1" run_glue.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了Fine-tuning使用的具体预训练模型,可以是PaddleNLP提供的预训练模型 或者 本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: /home/xx_model/,目录中需包含paddle预训练模型model_state.pdparams。
-如果使用PaddleNLP提供的预训练模型,可以选择`model_type`在[Transformer预训练模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中相对应的英文预训练权重。注意这里选择的模型权重要和上面配置的模型类型匹配,例如model_type 配置的是bert,则model_name_or_path只能选择bert相关的模型。另,glue任务应选择英文预训练权重。
-- `tokenizer_name_or_path` 指示了Fine-tuning使用的具体tokenizer,一般保持和model_name_or_path一致,也可以单独指定
-- `task_name` 表示 Fine-tuning 的任务,当前支持CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE。
+- `model_name_or_path` 指示了 Fine-tuning 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型 或者 本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: /home/xx_model/,目录中需包含 paddle 预训练模型 model_state.pdparams。
+如果使用 PaddleNLP 提供的预训练模型,可以选择`model_type`在[Transformer 预训练模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中相对应的英文预训练权重。注意这里选择的模型权重要和上面配置的模型类型匹配,例如 model_type 配置的是 bert,则 model_name_or_path 只能选择 bert 相关的模型。另,glue 任务应选择英文预训练权重。
+- `tokenizer_name_or_path` 指示了 Fine-tuning 使用的具体 tokenizer,一般保持和 model_name_or_path 一致,也可以单独指定
+- `task_name` 表示 Fine-tuning 的任务,当前支持 CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
-Fine-tuning过程将按照 `logging_steps` 和 `save_steps` 的设置打印如下日志:
+Fine-tuning 过程将按照 `logging_steps` 和 `save_steps` 的设置打印如下日志:
```
global step 6310/6315, epoch: 2, batch: 2099, rank_id: 0, loss: 0.035772, lr: 0.0000000880, speed: 3.1527 step/s
@@ -76,16 +76,16 @@ global step 6315/6315, epoch: 2, batch: 2104, rank_id: 0, loss: 0.046043, lr: 0.
eval loss: 0.549763, acc: 0.9151376146788991, eval done total : 1.8206987380981445 s
```
-使用各种预训练模型进行 Fine-tuning ,在GLUE验证集上有如下结果:
+使用各种预训练模型进行 Fine-tuning ,在 GLUE 验证集上有如下结果:
| Model GLUE Score | CoLA | SST-2 | MRPC | STS-B | QQP | MNLI | QNLI | RTE |
|--------------------|-------|--------|--------|--------|--------|--------|--------|--------|
| electra-small | 58.22 | 91.85 | 88.24 | 87.24 | 88.83 | 82.45 | 88.61 | 66.78 |
| ernie-2.0-large-en | 65.4 | 96.0 | 88.7 | 92.3 | 92.5 | 89.1 | 94.3 | 85.2 |
-关于GLUE Score的说明:
-1. 因Fine-tuning过程中有dropout等随机因素影响,同样预训练模型每次运行的GLUE Score会有较小差异,上表中的GLUE Score是运行多次取eval最好值的得分。
-2. 不同GLUE任务判定得分所使用的评价指标有些差异,简单如下表,详细说明可参考[GLUE论文](https://openreview.net/pdf?id=rJ4km2R5t7)。
+关于 GLUE Score 的说明:
+1. 因 Fine-tuning 过程中有 dropout 等随机因素影响,同样预训练模型每次运行的 GLUE Score 会有较小差异,上表中的 GLUE Score 是运行多次取 eval 最好值的得分。
+2. 不同 GLUE 任务判定得分所使用的评价指标有些差异,简单如下表,详细说明可参考[GLUE 论文](https://openreview.net/pdf?id=rJ4km2R5t7)。
| GLUE Task | Metric |
|------------|------------------------------|
diff --git a/legacy/examples/benchmark/glue/run_glue.py b/slm/examples/benchmark/glue/run_glue.py
similarity index 100%
rename from legacy/examples/benchmark/glue/run_glue.py
rename to slm/examples/benchmark/glue/run_glue.py
diff --git a/legacy/examples/benchmark/glue/run_glue_trainer.py b/slm/examples/benchmark/glue/run_glue_trainer.py
similarity index 100%
rename from legacy/examples/benchmark/glue/run_glue_trainer.py
rename to slm/examples/benchmark/glue/run_glue_trainer.py
diff --git a/legacy/examples/benchmark/llm/llama_single_gpu/benchmark.py b/slm/examples/benchmark/llm/llama_single_gpu/benchmark.py
similarity index 100%
rename from legacy/examples/benchmark/llm/llama_single_gpu/benchmark.py
rename to slm/examples/benchmark/llm/llama_single_gpu/benchmark.py
diff --git a/legacy/examples/benchmark/llm/llama_single_gpu/benchmark_utils.py b/slm/examples/benchmark/llm/llama_single_gpu/benchmark_utils.py
similarity index 100%
rename from legacy/examples/benchmark/llm/llama_single_gpu/benchmark_utils.py
rename to slm/examples/benchmark/llm/llama_single_gpu/benchmark_utils.py
diff --git a/legacy/examples/benchmark/peft/README.md b/slm/examples/benchmark/peft/README.md
similarity index 95%
rename from legacy/examples/benchmark/peft/README.md
rename to slm/examples/benchmark/peft/README.md
index 841e7f880af8..609e0d343b07 100644
--- a/legacy/examples/benchmark/peft/README.md
+++ b/slm/examples/benchmark/peft/README.md
@@ -3,12 +3,12 @@
### 配置
- 硬件: A100-80G with NVLink, 具体卡数见表
-- Torch环境: 见torch/requirements.txt
-- FP16配置: torch 使用 cuda amp fp16, paddle 使用 fp16 O2 opt level, intokens 设置为 1024, 并开启了flash attention
+- Torch 环境: 见 torch/requirements.txt
+- FP16配置: torch 使用 cuda amp fp16, paddle 使用 fp16 O2 opt level, intokens 设置为 1024, 并开启了 flash attention
### Bloom
-- 数据: 10k条[Chinese-Vicuna/guanaco_belle_merge_v1.0](https://huggingface.co/datasets/Chinese-Vicuna/guanaco_belle_merge_v1.0)
+- 数据: 10k 条[Chinese-Vicuna/guanaco_belle_merge_v1.0](https://huggingface.co/datasets/Chinese-Vicuna/guanaco_belle_merge_v1.0)
| Model | Method | Num GPUs | Batch Size | Paddle Setup | Paddle Effective Tokens/s | Torch Setup | Torch Effective Tokens/s | **Speedup** |
|---------------|----------|----------|------------|--------------|---------------------------|-------------|--------------------------|---------|
@@ -32,7 +32,7 @@
### Llama
-- 数据: 使用10k条[tatsu-lab/alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca)
+- 数据: 使用10k 条[tatsu-lab/alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca)
| Model | Method | Num GPUs | Batch Size | Paddle Setup | Paddle Effective Tokens/s | Torch Setup | Torch Effective Tokens/s | Speedup |
|-----------|----------|----------|-------------|--------------|---------------------------|-------------|--------------------------|---------|
diff --git a/legacy/examples/benchmark/peft/paddle/benchmark.py b/slm/examples/benchmark/peft/paddle/benchmark.py
similarity index 100%
rename from legacy/examples/benchmark/peft/paddle/benchmark.py
rename to slm/examples/benchmark/peft/paddle/benchmark.py
diff --git a/legacy/examples/benchmark/peft/paddle/inference_benchmark.py b/slm/examples/benchmark/peft/paddle/inference_benchmark.py
similarity index 100%
rename from legacy/examples/benchmark/peft/paddle/inference_benchmark.py
rename to slm/examples/benchmark/peft/paddle/inference_benchmark.py
diff --git a/legacy/examples/benchmark/peft/paddle/utils.py b/slm/examples/benchmark/peft/paddle/utils.py
similarity index 100%
rename from legacy/examples/benchmark/peft/paddle/utils.py
rename to slm/examples/benchmark/peft/paddle/utils.py
diff --git a/legacy/examples/benchmark/peft/torch/benchmark.py b/slm/examples/benchmark/peft/torch/benchmark.py
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/benchmark.py
rename to slm/examples/benchmark/peft/torch/benchmark.py
diff --git a/legacy/examples/benchmark/peft/torch/ds_config_stage2.json b/slm/examples/benchmark/peft/torch/ds_config_stage2.json
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/ds_config_stage2.json
rename to slm/examples/benchmark/peft/torch/ds_config_stage2.json
diff --git a/legacy/examples/benchmark/peft/torch/ds_config_stage3.json b/slm/examples/benchmark/peft/torch/ds_config_stage3.json
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/ds_config_stage3.json
rename to slm/examples/benchmark/peft/torch/ds_config_stage3.json
diff --git a/legacy/examples/benchmark/peft/torch/inference_benchmark.py b/slm/examples/benchmark/peft/torch/inference_benchmark.py
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/inference_benchmark.py
rename to slm/examples/benchmark/peft/torch/inference_benchmark.py
diff --git a/legacy/examples/benchmark/peft/torch/requirements.txt b/slm/examples/benchmark/peft/torch/requirements.txt
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/requirements.txt
rename to slm/examples/benchmark/peft/torch/requirements.txt
diff --git a/legacy/examples/benchmark/peft/torch/utils.py b/slm/examples/benchmark/peft/torch/utils.py
similarity index 100%
rename from legacy/examples/benchmark/peft/torch/utils.py
rename to slm/examples/benchmark/peft/torch/utils.py
diff --git a/legacy/examples/benchmark/wiki_lambada/README.md b/slm/examples/benchmark/wiki_lambada/README.md
similarity index 86%
rename from legacy/examples/benchmark/wiki_lambada/README.md
rename to slm/examples/benchmark/wiki_lambada/README.md
index 83eb739f6019..3efe6b9542a7 100644
--- a/legacy/examples/benchmark/wiki_lambada/README.md
+++ b/slm/examples/benchmark/wiki_lambada/README.md
@@ -12,7 +12,7 @@ wget https://paddlenlp.bj.bcebos.com/data/benchmark/wikitext-2.tar.gz
## 运行预测脚本
-验证Lambada数据集,运行以下脚本:
+验证 Lambada 数据集,运行以下脚本:
```
python eval.py \
--model_name_or_path /path/to/your/model \
@@ -22,7 +22,7 @@ python eval.py \
--cloze_eval
```
-验证WikiText数据集,运行以下脚本:
+验证 WikiText 数据集,运行以下脚本:
```
python eval.py \
--model_name_or_path /path/to/your/model \
diff --git a/legacy/examples/benchmark/wiki_lambada/eval.py b/slm/examples/benchmark/wiki_lambada/eval.py
similarity index 100%
rename from legacy/examples/benchmark/wiki_lambada/eval.py
rename to slm/examples/benchmark/wiki_lambada/eval.py
diff --git a/legacy/examples/code_generation/codegen/README.md b/slm/examples/code_generation/codegen/README.md
similarity index 74%
rename from legacy/examples/code_generation/codegen/README.md
rename to slm/examples/code_generation/codegen/README.md
index 9fcd886ae374..5e2e491bb83d 100644
--- a/legacy/examples/code_generation/codegen/README.md
+++ b/slm/examples/code_generation/codegen/README.md
@@ -1,11 +1,11 @@
-# 代码生成:写代码的AI助理
+# 代码生成:写代码的 AI 助理
**目录**
- [代码生成](#代码生成)
- [简介](#简介)
- [特色](#特色)
- [效果展示](#效果展示)
- - [Github Copilot插件配置](#GithubCopilot插件配置)
+ - [Github Copilot 插件配置](#GithubCopilot 插件配置)
- [环境依赖](#环境依赖)
- [代码结构说明](#代码结构说明)
- [启动服务](#启动服务)
@@ -17,7 +17,7 @@
- [数据准备](#数据准备)
- [从本地文件创建数据集](#从本地文件创建数据集)
- [模型训练](#模型训练)
- - [TaskFlow调用](#TaskFlow调用)
+ - [TaskFlow 调用](#TaskFlow 调用)
- [更多使用案例](#更多使用案例)
- [模型列表](#模型列表)
- [References](#references)
@@ -29,16 +29,16 @@
### 特色
-本项目是基于预训练语言模型CodeGen的代码生成,具有以下优势:
-- **效果领先**。CodeGen(16B)在HumanEval benchmark上评估指标已经超过[OpenAI's Codex](https://arxiv.org/pdf/2107.03374.pdf)。
-- **免费的Github Copilot**。支持通过Github Copilot调用该模型,让你免费体验代码AI助理。
+本项目是基于预训练语言模型 CodeGen 的代码生成,具有以下优势:
+- **效果领先**。CodeGen(16B)在 HumanEval benchmark 上评估指标已经超过[OpenAI's Codex](https://arxiv.org/pdf/2107.03374.pdf)。
+- **免费的 Github Copilot**。支持通过 Github Copilot 调用该模型,让你免费体验代码 AI 助理。
- **支持自定义数据集训练**。可增加自己的代码数据加以微调,让其更智能。
-- **开箱即用**。本项目提供TaskFlow接口,无需训练,仅需几行代码便可预测。
+- **开箱即用**。本项目提供 TaskFlow 接口,无需训练,仅需几行代码便可预测。
## 效果展示
-- Github Copilot代码提示效果展示
+- Github Copilot 代码提示效果展示
@@ -74,13 +74,13 @@ print(codegen(prompt))
-## Jupyter Lab插件配置
+## Jupyter Lab 插件配置
请参考[codegenJupyterLabExt](https://github.com/chenqianhe/codegenJupyterLabExt), 感谢生态开发者[@chenqianhe](https://github.com/chenqianhe)的贡献!👏👏
-## GithubCopilot插件配置
+## GithubCopilot 插件配置
-**以VS Code的插件为例**
+**以 VS Code 的插件为例**
### 环境依赖
- PaddleNLP >= 2.4.0
@@ -108,18 +108,18 @@ python codegen_server.py
```
##### 配置参数说明
-在codegen_server.py中配置如下参数:
+在 codegen_server.py 中配置如下参数:
- `model_name_or_path`:模型名,默认为 "Salesforce/codegen-350M-mono"
- `device`:运行设备,默认为"gpu"
-- `temperature`:解码参数temperature,默认为0.5
-- `top_k`:解码参数top_k,默认为10
-- `top_p`:解码参数top_p,默认为1.0
+- `temperature`:解码参数 temperature,默认为0.5
+- `top_k`:解码参数 top_k,默认为10
+- `top_p`:解码参数 top_p,默认为1.0
- `repetition_penalty`:解码重复惩罚项,默认为1.0
- `min_length`:生成的最小长度,默认为0
- `max_length`:生成的最大长度,默认为16
- `decode_strategy`:解码策略,默认为"greedy_search"
-- `use_fast`:是否使用FastGeneration,可加速推理,默认为True
-- `use_fp16_decoding`:是否使用fp16推理,可节省显存和加速推理,默认为True
+- `use_fast`:是否使用 FastGeneration,可加速推理,默认为 True
+- `use_fp16_decoding`:是否使用 fp16推理,可节省显存和加速推理,默认为 True
### 测试服务
```python
@@ -148,7 +148,7 @@ print(result)
}
'''
```
-**注意**:如果要从本地访问服务器,`127.0.0.1`需要换成服务器的对外IP。
+**注意**:如果要从本地访问服务器,`127.0.0.1`需要换成服务器的对外 IP。
### 配置插件
@@ -164,10 +164,10 @@ print(result)
#### 注意事项
-- 如果使用FastGeneration,需要设置[codegen_server.py](#配置参数说明)中`use_fast=True`,第一次推理会涉及到编译,会耗费一些时间。
+- 如果使用 FastGeneration,需要设置[codegen_server.py](#配置参数说明)中`use_fast=True`,第一次推理会涉及到编译,会耗费一些时间。
- 如果要使用自己训练好的模型,可以设置[codegen_server.py](#配置参数说明)中`model_name_or_path`为本地模型路径。
-- 如果要从本地访问服务器,上述的`127.0.0.1`需要换成服务器的对外IP。
-- 如果出现下方的提示和报错,则说明FastGeneration没有启动成功,需要定位下失败的原因。或者也可设置`use_fast=False`,不启动FastGeneration加速,但推理速度会较慢。
+- 如果要从本地访问服务器,上述的`127.0.0.1`需要换成服务器的对外 IP。
+- 如果出现下方的提示和报错,则说明 FastGeneration 没有启动成功,需要定位下失败的原因。或者也可设置`use_fast=False`,不启动 FastGeneration 加速,但推理速度会较慢。
```shell
FastGeneration is not available, and the original version would be used instead.
```
@@ -176,7 +176,7 @@ print(result)
[Hint: Expected kernels_iter != all_op_kernels.end(), but received kernels_iter == all_op_kernels.end().] (at /home/Paddle/paddle/fluid/imperative/prepared_operator.cc:341)
[operator < unsqueeze2 > error]
```
-- 本代码也支持插件[fauxpilot](https://marketplace.visualstudio.com/items?itemName=Venthe.fauxpilot),感谢[@linonetwo](https://github.com/linonetwo)测试。`settings.json`中配置"fauxpilot.server": "http://服务器ip:8978/v1/engines"
+- 本代码也支持插件[fauxpilot](https://marketplace.visualstudio.com/items?itemName=Venthe.fauxpilot),感谢[@linonetwo](https://github.com/linonetwo)测试。`settings.json`中配置"fauxpilot.server": "http://服务器 ip:8978/v1/engines"
## 训练定制
@@ -188,7 +188,7 @@ print(result)
本地数据集文件格式如下:
- train.json/test.json 文件格式:
-每行为一个jsonline
+每行为一个 jsonline
```text
{
"code": "from paddlenlp.transformers import CodeGenForCausalLM\n\n\nmodel = CodeGenForCausalLM.from_pretrained('Salesforce/codegen-2B-mono')\n"
@@ -199,7 +199,7 @@ print(result)
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证。
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证。
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -222,11 +222,11 @@ python -m paddle.distributed.launch --gpus 0,1 run_clm.py \
--do_eval \
--device gpu
```
-使用多卡训练可以指定多个GPU卡号,例如 --gpus "0,1"
+使用多卡训练可以指定多个 GPU 卡号,例如 --gpus "0,1"
关键参数释义如下:
-- `gpus` 指示了训练所用的GPU卡号。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型(详见[模型列表](#模型列表)),或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `gpus` 指示了训练所用的 GPU 卡号。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型(详见[模型列表](#模型列表)),或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- `block_size` 表示训练时候数据被拆分的块数。
- `output_dir` 表示模型的保存路径。
- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同。
@@ -236,11 +236,11 @@ python -m paddle.distributed.launch --gpus 0,1 run_clm.py \
- `save_steps` 表示模型保存及评估间隔。
- `per_device_train_batch_size` 表示训练时**每张卡**上的样本数目。
- `per_device_eval_batch_size` 表示测试时**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `warmup_ratio` 表示学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `warmup_ratio` 表示学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `do_train` 表示是否训练。
- `do_eval` 表示是否评测。
-- `device` 表示使用的设备,从gpu和cpu中选择。
+- `device` 表示使用的设备,从 gpu 和 cpu 中选择。
可通过`bash run_clm.sh`启动训练,更多参数详情和参数的默认值请参考`run_clm.py`。
@@ -261,8 +261,8 @@ python -m paddle.distributed.launch --gpus 0,1 run_clm.py \
**NOTE:** 如需恢复模型训练,`model_name_or_path`配置本地模型的目录地址即可。
-## TaskFlow调用
-参考[TaskFlow文档](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/model_zoo/taskflow.md)
+## TaskFlow 调用
+参考[TaskFlow 文档](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/model_zoo/taskflow.md)
## 更多使用案例
@@ -306,18 +306,18 @@ hello_world()
模型列表
| 模型名称 | 说明 |
| :--------------------------------- | -------------------------------- |
-| Salesforce/codegen-350M-mono | 基于Python数据集BIGPYTHON训练 |
-| Salesforce/codegen-2B-mono | 基于Python数据集BIGPYTHON训练 |
-| Salesforce/codegen-6B-mono | 基于Python数据集BIGPYTHON训练 |
-| Salesforce/codegen-16B-mono | 基于Python数据集BIGPYTHON训练 |
-| Salesforce/codegen-350M-nl | 基于自然语言数据集THEPILE训练 |
-| Salesforce/codegen-2B-nl | 基于自然语言数据集THEPILE训练 |
-| Salesforce/codegen-6B-nl | 基于自然语言数据集THEPILE训练 |
-| Salesforce/codegen-16B-nl | 基于自然语言数据集THEPILE训练 |
-| Salesforce/codegen-350M-multi | 基于多编程语言数据集BIGQUERY训练 |
-| Salesforce/codegen-2B-multi | 基于多编程语言数据集BIGQUERY训练 |
-| Salesforce/codegen-6B-multi | 基于多编程语言数据集BIGQUERY训练 |
-| Salesforce/codegen-16B-multi | 基于多编程语言数据集BIGQUERY训练 |
+| Salesforce/codegen-350M-mono | 基于 Python 数据集 BIGPYTHON 训练 |
+| Salesforce/codegen-2B-mono | 基于 Python 数据集 BIGPYTHON 训练 |
+| Salesforce/codegen-6B-mono | 基于 Python 数据集 BIGPYTHON 训练 |
+| Salesforce/codegen-16B-mono | 基于 Python 数据集 BIGPYTHON 训练 |
+| Salesforce/codegen-350M-nl | 基于自然语言数据集 THEPILE 训练 |
+| Salesforce/codegen-2B-nl | 基于自然语言数据集 THEPILE 训练 |
+| Salesforce/codegen-6B-nl | 基于自然语言数据集 THEPILE 训练 |
+| Salesforce/codegen-16B-nl | 基于自然语言数据集 THEPILE 训练 |
+| Salesforce/codegen-350M-multi | 基于多编程语言数据集 BIGQUERY 训练 |
+| Salesforce/codegen-2B-multi | 基于多编程语言数据集 BIGQUERY 训练 |
+| Salesforce/codegen-6B-multi | 基于多编程语言数据集 BIGQUERY 训练 |
+| Salesforce/codegen-16B-multi | 基于多编程语言数据集 BIGQUERY 训练 |
## References
- Nijkamp, Erik, et al. "A conversational paradigm for program synthesis." arXiv preprint arXiv:2203.13474 (2022).
diff --git a/legacy/examples/code_generation/codegen/codegen_server.py b/slm/examples/code_generation/codegen/codegen_server.py
similarity index 100%
rename from legacy/examples/code_generation/codegen/codegen_server.py
rename to slm/examples/code_generation/codegen/codegen_server.py
diff --git a/legacy/examples/code_generation/codegen/requirements.txt b/slm/examples/code_generation/codegen/requirements.txt
similarity index 100%
rename from legacy/examples/code_generation/codegen/requirements.txt
rename to slm/examples/code_generation/codegen/requirements.txt
diff --git a/legacy/examples/code_generation/codegen/run_clm.py b/slm/examples/code_generation/codegen/run_clm.py
similarity index 100%
rename from legacy/examples/code_generation/codegen/run_clm.py
rename to slm/examples/code_generation/codegen/run_clm.py
diff --git a/legacy/examples/code_generation/codegen/run_clm.sh b/slm/examples/code_generation/codegen/run_clm.sh
similarity index 100%
rename from legacy/examples/code_generation/codegen/run_clm.sh
rename to slm/examples/code_generation/codegen/run_clm.sh
diff --git a/legacy/examples/dialogue/README_DGU.md b/slm/examples/dialogue/README_DGU.md
similarity index 76%
rename from legacy/examples/dialogue/README_DGU.md
rename to slm/examples/dialogue/README_DGU.md
index 98541b51fb59..7716e4f2a49a 100644
--- a/legacy/examples/dialogue/README_DGU.md
+++ b/slm/examples/dialogue/README_DGU.md
@@ -1,12 +1,12 @@
# 对话通用理解模型 (DGU, Dialogue General Understanding)
-> **注意** 部分内容在PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
+> **注意** 部分内容在 PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
## 模型简介
-对话系统 (Dialogue System) 常常需要根据应用场景的变化去解决多种多样的任务。任务的多样性(意图识别、槽填充、行为识别、状态追踪等等),以及领域训练数据的稀少,给Dialogue System的研究和应用带来了巨大的困难和挑战,要使得Dialogue System得到更好的发展,需要开发一个通用的对话理解模型。为此,我们给出了基于BERT的对话通用理解模型 (DGU: Dialogue General Understanding),通过实验表明,使用base-model (BERT)并结合常见的学习范式,就可以在几乎全部对话理解任务上取得比肩甚至超越各个领域业内最好的模型的效果,展现了学习一个通用对话理解模型的巨大潜力。
+对话系统 (Dialogue System) 常常需要根据应用场景的变化去解决多种多样的任务。任务的多样性(意图识别、槽填充、行为识别、状态追踪等等),以及领域训练数据的稀少,给 Dialogue System 的研究和应用带来了巨大的困难和挑战,要使得 Dialogue System 得到更好的发展,需要开发一个通用的对话理解模型。为此,我们给出了基于 BERT 的对话通用理解模型 (DGU: Dialogue General Understanding),通过实验表明,使用 base-model (BERT)并结合常见的学习范式,就可以在几乎全部对话理解任务上取得比肩甚至超越各个领域业内最好的模型的效果,展现了学习一个通用对话理解模型的巨大潜力。
-DGU模型内共包含6个任务,全部基于公开数据集在Paddle2.0上完成训练及评估,详细说明如下:
+DGU 模型内共包含6个任务,全部基于公开数据集在 Paddle2.0上完成训练及评估,详细说明如下:
```
udc: 使用UDC (Ubuntu Corpus V1) 数据集完成对话匹配 (Dialogue Response Selection) 任务;
@@ -19,7 +19,7 @@ swda: 使用SwDAC (Switchboard Dialogue Act Corpus) 数据集完成对话行为
## 模型效果
-DGU模型中的6个任务,分别采用不同的评估指标在test集上进行评估,结果如下:
+DGU 模型中的6个任务,分别采用不同的评估指标在 test 集上进行评估,结果如下:
任务 | 评估指标 | DGU |
@@ -33,20 +33,20 @@ DGU模型中的6个任务,分别采用不同的评估指标在test集上进行
swda | Acc | 80.61% |
-**NOTE:** 以上结果均是采用默认配置在GPU单卡上训练和评估得到的,用户如需复现效果,可采用默认配置在单卡上进行训练评估。
+**NOTE:** 以上结果均是采用默认配置在 GPU 单卡上训练和评估得到的,用户如需复现效果,可采用默认配置在单卡上进行训练评估。
## 快速开始
### 数据准备
-下载数据集压缩包并解压后,DGU_datasets目录下共存在6个目录,分别对应每个任务的训练集train.txt、评估集dev.txt和测试集test.txt。
+下载数据集压缩包并解压后,DGU_datasets 目录下共存在6个目录,分别对应每个任务的训练集 train.txt、评估集 dev.txt 和测试集 test.txt。
```shell
wget https://bj.bcebos.com/paddlenlp/datasets/DGU_datasets.tar.gz
tar -zxf DGU_datasets.tar.gz
```
-DGU_datasets目录结构:
+DGU_datasets 目录结构:
```text
DGU_datasets/
@@ -120,7 +120,7 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log main.py --task_na
以上参数表示:
-* `task_name`:任务名称,可以为udc、dstc2、atis_slot、atis_intent、mrda或swda。
+* `task_name`:任务名称,可以为 udc、dstc2、atis_slot、atis_intent、mrda 或 swda。
* `data_dir`:训练数据路径。
* `output_dir`:训练保存模型的文件路径。
* `do_train:是否进行训练,默认为`True`。
@@ -142,4 +142,4 @@ checkpoints/
└── best.pdparams
```
-**NOTE:** 如需恢复模型训练,则init_from_ckpt只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/1000`即可,程序会自动加载模型参数`checkpoints/1000.pdparams`,也会自动加载优化器状态`checkpoints/1000.pdopt`。
+**NOTE:** 如需恢复模型训练,则 init_from_ckpt 只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/1000`即可,程序会自动加载模型参数`checkpoints/1000.pdparams`,也会自动加载优化器状态`checkpoints/1000.pdopt`。
diff --git a/legacy/examples/dialogue/README_LIC2021.md b/slm/examples/dialogue/README_LIC2021.md
similarity index 64%
rename from legacy/examples/dialogue/README_LIC2021.md
rename to slm/examples/dialogue/README_LIC2021.md
index 3a882a2b2637..11531e91d02b 100644
--- a/legacy/examples/dialogue/README_LIC2021.md
+++ b/slm/examples/dialogue/README_LIC2021.md
@@ -1,6 +1,6 @@
-# LIC 2021对话比赛baseline
+# LIC 2021对话比赛 baseline
-> **注意** 部分内容在PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
+> **注意** 部分内容在 PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
## 模型简介
@@ -8,9 +8,9 @@
LIC 2021对话比赛收集了一系列公开的开放域对话数据并提供了统一的评测方式,旨在为研究人员和开发者提供学术和技术交流的平台,进一步提升开放域对话的研究水平,推动自然语言理解和人工智能领域技术的应用和发展。
-为了方便参赛者快速了解LIC 2021对话比赛的流程,并快速地参与到比赛中,本项目基于UnifiedTransformer模型提供了一个基础baseline,利用小规模样例数据在预训练模型上完成了微调及预测。参赛者可以针对赛题进行其他改进,例如修改数据预处理方法、修改网络结构、修改训练方式、修改预测的解码方式或对结果的后处理策略等方式提升模型效果。
+为了方便参赛者快速了解 LIC 2021对话比赛的流程,并快速地参与到比赛中,本项目基于 UnifiedTransformer 模型提供了一个基础 baseline,利用小规模样例数据在预训练模型上完成了微调及预测。参赛者可以针对赛题进行其他改进,例如修改数据预处理方法、修改网络结构、修改训练方式、修改预测的解码方式或对结果的后处理策略等方式提升模型效果。
-UnifiedTransformer模型的细节可以[参阅论文](https://arxiv.org/abs/2006.16779)。
+UnifiedTransformer 模型的细节可以[参阅论文](https://arxiv.org/abs/2006.16779)。
## 快速开始
@@ -22,14 +22,14 @@ UnifiedTransformer模型的细节可以[参阅论文](https://arxiv.org/abs/2006
### 数据准备
-由于样例数据涉及LIC 2021对话比赛,暂不开放。
-关于数据集及数据集的预处理过程,详见[2021语言与智能技术竞赛:多技能对话](https://aistudio.baidu.com/aistudio/competition/detail/67)及官方提供的基线系统Baselines。
+由于样例数据涉及 LIC 2021对话比赛,暂不开放。
+关于数据集及数据集的预处理过程,详见[2021语言与智能技术竞赛:多技能对话](https://aistudio.baidu.com/aistudio/competition/detail/67)及官方提供的基线系统 Baselines。
-模型的输入由3部分组成:词向量token_ids,句向量token_type_ids和位置向量position_ids。本项目的数据集是样例文本经过数据预处理脚本得到的id化的数据集。数据的每一行由3列组成,以";"作为分割符,格式:token_ids;token_type_ids;position_ids。具体细节请参考`data.py`。
+模型的输入由3部分组成:词向量 token_ids,句向量 token_type_ids 和位置向量 position_ids。本项目的数据集是样例文本经过数据预处理脚本得到的 id 化的数据集。数据的每一行由3列组成,以";"作为分割符,格式:token_ids;token_type_ids;position_ids。具体细节请参考`data.py`。
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -53,10 +53,10 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log finetune.py \
```
其中参数释义如下:
-- `gpus` 指示了训练所用的GPU卡号。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `gpus` 指示了训练所用的 GPU 卡号。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -69,11 +69,11 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log finetune.py \
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `lr` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `lr` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的 lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_grad_norm` 表示梯度裁剪允许的最大梯度值。
-- `sort_pool_size` 表示在构建batch数据时,用来排序的pool size。
+- `sort_pool_size` 表示在构建 batch 数据时,用来排序的 pool size。
- `device` 表示训练使用的设备。
参数详情和参数的默认值请参考`args.py`。
@@ -116,9 +116,9 @@ python infer.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -132,7 +132,7 @@ python infer.py \
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_samples` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_samples`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示训练使用的设备。
参数详情和参数的默认值请参考`args.py`。
diff --git a/legacy/examples/dialogue/README_PLATO-2.md b/slm/examples/dialogue/README_PLATO-2.md
similarity index 77%
rename from legacy/examples/dialogue/README_PLATO-2.md
rename to slm/examples/dialogue/README_PLATO-2.md
index 479586c861a6..961938c290f2 100644
--- a/legacy/examples/dialogue/README_PLATO-2.md
+++ b/slm/examples/dialogue/README_PLATO-2.md
@@ -1,12 +1,12 @@
# PLATO-2
-> **注意** 部分内容在PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
+> **注意** 部分内容在 PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
## 模型简介
构建高质量的开放领域(Open-Domain)的对话机器人,使得它能用自然语言与人自由地交流,这一直是自然语言处理领域终极目标之一。
-为了能够简易地构建一个高质量的开放域聊天机器人,本项目在Paddle2.0上实现了PLATO-2的预测模型,并基于终端实现了简单的人机交互。用户可以通过下载预训练模型快速构建一个开放域聊天机器人。
+为了能够简易地构建一个高质量的开放域聊天机器人,本项目在 Paddle2.0上实现了 PLATO-2的预测模型,并基于终端实现了简单的人机交互。用户可以通过下载预训练模型快速构建一个开放域聊天机器人。
PLATO-2的网络结构见下图:
@@ -39,7 +39,7 @@ wget https://bj.bcebos.com/paddlenlp/models/transformers/plato2/24L.pdparams
**NOTE:** PLATO-2网络参数量较大,24层网络至少需要显存16G,32层网络至少需要显存22G,用户可选择合适的网络层数及预训练模型。
-sentencepiece分词预训练模型和词表文件下载:
+sentencepiece 分词预训练模型和词表文件下载:
```shell
wget https://bj.bcebos.com/paddlenlp/models/transformers/plato2/data.tar.gz
@@ -58,11 +58,11 @@ python interaction.py --vocab_path ./data/vocab.txt --spm_model_file ./data/spm.
以上参数表示:
* vocab_path:词表文件路径。
-* spm_model_file:sentencepiece分词预训练模型路径。
+* spm_model_file:sentencepiece 分词预训练模型路径。
* num_layers:PLATO-2组网层数。
* init_from_ckpt:PLATO-2预训练模型路径。
-32层PLATO-2网络交互示例:
+32层 PLATO-2网络交互示例:

diff --git a/legacy/examples/dialogue/README_PLATO-XL.md b/slm/examples/dialogue/README_PLATO-XL.md
similarity index 81%
rename from legacy/examples/dialogue/README_PLATO-XL.md
rename to slm/examples/dialogue/README_PLATO-XL.md
index ac28944d6b1d..bbc782684df5 100644
--- a/legacy/examples/dialogue/README_PLATO-XL.md
+++ b/slm/examples/dialogue/README_PLATO-XL.md
@@ -1,12 +1,12 @@
# PLATO-XL: Exploring the Large-scale Pre-training of Dialogue Generation
-> **注意** 部分内容在PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
+> **注意** 部分内容在 PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
## 模型简介
构建高质量的开放领域(Open-Domain)的对话机器人,使得它能用自然语言与人自由地交流,这一直是自然语言处理领域终极目标之一。
-PLATO-XL 是业界首个开源的百亿超大规模开放域对话预训练模型,其使用了参数高效(encoder-decoder共享参数)的 UnifiedTransformer(prefix LM)模型架构,将模型参数量提升到了11B量级,经过了十亿级样本对话数据的预训练,并引入role embedding区分多方对话中的对话角色提升预训练效果,最终模型闲聊测试效果超过了众多代表性的对话模型。可以直接使用 PLATO-XL 构建高质量的开放领域对话机器人。
+PLATO-XL 是业界首个开源的百亿超大规模开放域对话预训练模型,其使用了参数高效(encoder-decoder 共享参数)的 UnifiedTransformer(prefix LM)模型架构,将模型参数量提升到了11B 量级,经过了十亿级样本对话数据的预训练,并引入 role embedding 区分多方对话中的对话角色提升预训练效果,最终模型闲聊测试效果超过了众多代表性的对话模型。可以直接使用 PLATO-XL 构建高质量的开放领域对话机器人。
PaddleNLP 内置了 PLATO-XL 英文预训练模型以供使用。由于 PLATO-XL 模型规模较大,这使得其在预测时生成对话回复的时间较长,并且 11B 的参数量也可能超出部分型号 GPU 显存容量,这是大模型推理与落地存在的普遍和关键问题。PaddleNLP FastGeneration 为 PLATO-XL 提供了 GPU 上的高性能生成加速能力,并且支持模型并行(张量并行)推理允许通过多张小显存容量的 GPU 使用百亿大模型,相比单卡代码中也只增加了`enable_ft_para()`一行,此外模型并行能进一步提升预测速度。
@@ -23,13 +23,13 @@ python infer.py --topk 4 --max_out_len 64 --use_faster --use_fp16
该脚本各个参数含义如下:
-- `topk` 用于Top-K采样策略,采样时将只从概率最高K个token中采样,默认为1,即greedy search。
-- `topp` 用于Top-P采样策略,采样时将只从概率最高且累加概率不超过该值的token中采样,默认为1.0。
+- `topk` 用于 Top-K 采样策略,采样时将只从概率最高 K 个 token 中采样,默认为1,即 greedy search。
+- `topp` 用于 Top-P 采样策略,采样时将只从概率最高且累加概率不超过该值的 token 中采样,默认为1.0。
- `max_out_len` 指定生成的最大长度,默认为64。
- `min_out_len` 指定生成的最小长度,默认为1。
- `temperature` 用于调整预测概率分布,默认为1.0,即保持模型原有的预测概率。
- `use_faster` 使用 FastGeneration
-- `use_fp16` 使用FP16,只在使用FastGeneration时生效
+- `use_fp16` 使用 FP16,只在使用 FastGeneration 时生效
脚本中使用了一条如下的多轮对话的样本数据, 由`List[str]`表示,其中每个`str`表示一句话,将根据历史对话内容生成回复。
@@ -42,17 +42,17 @@ python infer.py --topk 4 --max_out_len 64 --use_faster --use_fp16
]
```
-**注意** 由于 PLATO-XL 模型较大,单卡预测至少需要22G显存(使用FP16时),且模型下载需要一定时间(FP32的权重文件约41G)。
+**注意** 由于 PLATO-XL 模型较大,单卡预测至少需要22G 显存(使用 FP16时),且模型下载需要一定时间(FP32的权重文件约41G)。
### 多卡并行推理
-多卡并行推理当前依赖 MPI([MPICH](https://www.mpich.org)、[OpenMPI](https://www.open-mpi.org)均可)和[NCCL](https://developer.nvidia.com/nccl),如需使用还请先安装依赖。安装完成后仍然使用 `infer.py` 来进行预测,相比单卡时不同的只是通过mpi来启动运行,如下:
+多卡并行推理当前依赖 MPI([MPICH](https://www.mpich.org)、[OpenMPI](https://www.open-mpi.org)均可)和[NCCL](https://developer.nvidia.com/nccl),如需使用还请先安装依赖。安装完成后仍然使用 `infer.py` 来进行预测,相比单卡时不同的只是通过 mpi 来启动运行,如下:
```shell
mpirun -n 4 python infer.py --topk 4 --max_out_len 64 --use_faster --use_fp16
```
-其中`-n 4`指明使用的进程和GPU数,在`n`设置为1时仍将进行单卡推理。由于多卡并行推理使用和单卡使用不同的依赖库,第一次运行时将重新进行JIT编译。
+其中`-n 4`指明使用的进程和 GPU 数,在`n`设置为1时仍将进行单卡推理。由于多卡并行推理使用和单卡使用不同的依赖库,第一次运行时将重新进行 JIT 编译。
### 性能测试
diff --git a/legacy/examples/dialogue/README_UnifiedTransformer.md b/slm/examples/dialogue/README_UnifiedTransformer.md
similarity index 67%
rename from legacy/examples/dialogue/README_UnifiedTransformer.md
rename to slm/examples/dialogue/README_UnifiedTransformer.md
index ea139132423b..0c5caaf78977 100644
--- a/legacy/examples/dialogue/README_UnifiedTransformer.md
+++ b/slm/examples/dialogue/README_UnifiedTransformer.md
@@ -1,6 +1,6 @@
# UnifiedTransformer
-> **注意** 部分内容在PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
+> **注意** 部分内容在 PaddleNLP 3.0以后不再进行维护,更多历史内容请参考[PaddleNLP 2.8](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/dialogue)。
## 模型简介
@@ -8,7 +8,7 @@
[UnifiedTransformer](https://arxiv.org/abs/2006.16779)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,采用灵活的注意力机制,十分适合对话生成任务。
-本项目是UnifiedTransformer在 Paddle 2.0上的开源实现,介绍了如何使用UnifiedTransformer在DuConv任务型对话数据集上进行微调,并给出了一个搭建简单中文聊天机器人的例子。
+本项目是 UnifiedTransformer 在 Paddle 2.0上的开源实现,介绍了如何使用 UnifiedTransformer 在 DuConv 任务型对话数据集上进行微调,并给出了一个搭建简单中文聊天机器人的例子。
## 快速开始
@@ -33,9 +33,9 @@
### 数据准备
-**DuConv**是百度发布的基于知识图谱的主动聊天任务数据集,让机器根据构建的知识图谱进行主动聊天,使机器具备模拟人类用语言进行信息传递的能力。数据集的创新性是:强调了bot的主动性,并且在闲聊对话中引入了明确的对话目标,即将对话引导到特定实体上。数据中的知识信息来源于电影和娱乐人物领域有聊天价值的知识信息,如票房、导演、评价等,以三元组SPO的形式组织,对话目标中的话题为电影或娱乐人物实体。数据集中共有3万session,约12万轮对话,划分为训练集、开发集、测试集1和测试集2,其中测试集1中包含对话的response,而测试集2中只有对话历史。
+**DuConv**是百度发布的基于知识图谱的主动聊天任务数据集,让机器根据构建的知识图谱进行主动聊天,使机器具备模拟人类用语言进行信息传递的能力。数据集的创新性是:强调了 bot 的主动性,并且在闲聊对话中引入了明确的对话目标,即将对话引导到特定实体上。数据中的知识信息来源于电影和娱乐人物领域有聊天价值的知识信息,如票房、导演、评价等,以三元组 SPO 的形式组织,对话目标中的话题为电影或娱乐人物实体。数据集中共有3万 session,约12万轮对话,划分为训练集、开发集、测试集1和测试集2,其中测试集1中包含对话的 response,而测试集2中只有对话历史。
-为了方便用户快速测试,PaddleNLP Dataset API内置了DuConv数据集,一键即可完成数据集加载,示例代码如下:
+为了方便用户快速测试,PaddleNLP Dataset API 内置了 DuConv 数据集,一键即可完成数据集加载,示例代码如下:
```python
from paddlenlp.datasets import load_dataset
@@ -44,17 +44,17 @@ train_ds, dev_ds, test1_ds, test2_ds = load_dataset('duconv', splits=('train', '
### 预训练模型
-以下是PaddleNLP支持的对话类预训练模型:
+以下是 PaddleNLP 支持的对话类预训练模型:
|模型名称| 模型参数 | 模型特点 |
|:-----:|:------:|:-------:|
|unified_transformer-12L-cn| 12-layers, 12-heads, 768-hidden| 在千万级别的中文会话数据上进行预训练。|
-|unified_transformer-12L-cn-luge| 12-layers, 12-heads, 768-hidden|由unified_transformer-12L-cn预训练模型在千言对话数据集上进行微调。并且模型输入中加入了标识不同对话技能的special token,使得模型能同时支持闲聊对话、推荐对话和知识对话。|
+|unified_transformer-12L-cn-luge| 12-layers, 12-heads, 768-hidden|由 unified_transformer-12L-cn 预训练模型在千言对话数据集上进行微调。并且模型输入中加入了标识不同对话技能的 special token,使得模型能同时支持闲聊对话、推荐对话和知识对话。|
|plato-mini| 6-layers, 12-heads, 768-hidden|在十亿级别的中文对话数据上进行预训练。参数量更小,但效果更好。只支持闲聊型对话。|
### 模型训练
-运行如下命令即可在训练集上进行finetune,并在验证集上进行验证
+运行如下命令即可在训练集上进行 finetune,并在验证集上进行验证
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -79,11 +79,11 @@ python -m paddle.distributed.launch --gpus '0' --log_dir ./log finetune.py \
```
其中参数释义如下:
-- `gpus` 指示了训练所用的GPU
+- `gpus` 指示了训练所用的 GPU
- `log_dir` 指示了日志保存目录
-- `model_name_or_path` 指示了finetune使用的预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -94,16 +94,16 @@ python -m paddle.distributed.launch --gpus '0' --log_dir ./log finetune.py \
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `lr` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `lr` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的 lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_grad_norm` 表示梯度裁剪允许的最大梯度值。
- `max_seq_len` 表示输入序列的最大长度。
-- `max_response_len` 表示输入response的最大长度。
-- `max_knowledge_len` 表示输入knowledge序列的最大长度。
+- `max_response_len` 表示输入 response 的最大长度。
+- `max_knowledge_len` 表示输入 knowledge 序列的最大长度。
- `device` 表示使用的设备。
-程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中,其中loss最小的模型会被保存在`save_dir/model_best`中。如:
+程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中,其中 loss 最小的模型会被保存在`save_dir/model_best`中。如:
```text
./checkpoints/
@@ -142,9 +142,9 @@ python infer.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了预测使用的模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了预测使用的模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -153,20 +153,20 @@ python infer.py \
- `logging_steps` 表示日志打印间隔。
- `seed` 表示随机数生成器的种子。
- `max_seq_len` 表示输入序列的最大长度。
-- `max_knowledge_len` 表示输入knowledge序列的最大长度。
+- `max_knowledge_len` 表示输入 knowledge 序列的最大长度。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
- `min_dec_len` 表示预测生成的句子的最小长度。
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_return_sequences` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_return_sequences`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示使用的设备。
同时,我们提供了基于 FastGeneration 的高性能预测的选项,可以选择性开启是否需要采用高性能预测,PaddleNLP 提供了 JIT 的方式,可以自动完成对所需的自定义 op 的动态库编译:
- `faster` 表示是否开启高性能预测。设置 `--faster` 即表示开启。
- `use_fp16_decoding` 表示在开启高性能预测的时候,是否使用 fp16 来完成预测过程。设置 `--use_fp16_decoding` 即表示使用 fp16 进行预测,否则使用 fp32。
-程序运行结束后会将预测生成的response保存在`output_path`中。同时终端中会输出评估结果。
+程序运行结束后会将预测生成的 response 保存在`output_path`中。同时终端中会输出评估结果。
采用预训练模型及微调模型在测试集上有如下结果:
@@ -175,7 +175,7 @@ python infer.py \
| unified_transformer-12L-cn-luge | 0.2606 / 0.1576 | 0.1168 / 0.2977 |
| ./checkpoints/model_best | 0.2808 / 0.1744 | 0.1124 / 0.2899 |
-**NOTE:** `./checkpoints/model_best`是按本项目中的超参在单卡上finetune得到的结果。
+**NOTE:** `./checkpoints/model_best`是按本项目中的超参在单卡上 finetune 得到的结果。
### 人机交互
@@ -195,9 +195,9 @@ python interaction.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了预测使用的模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了预测使用的模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -207,7 +207,7 @@ python interaction.py \
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_return_sequences` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_return_sequences`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示使用的设备。
**NOTE:** 输入"[EXIT]"退出交互程序,输入"[NEXT]"开启下一轮新的对话。需要注意使用退格会导致错误。
diff --git a/legacy/examples/dialogue/dgu/README.md b/slm/examples/dialogue/dgu/README.md
similarity index 78%
rename from legacy/examples/dialogue/dgu/README.md
rename to slm/examples/dialogue/dgu/README.md
index 90a9f57ec209..3b56f9447e11 100644
--- a/legacy/examples/dialogue/dgu/README.md
+++ b/slm/examples/dialogue/dgu/README.md
@@ -2,9 +2,9 @@
## 模型简介
-对话系统 (Dialogue System) 常常需要根据应用场景的变化去解决多种多样的任务。任务的多样性(意图识别、槽填充、行为识别、状态追踪等等),以及领域训练数据的稀少,给Dialogue System的研究和应用带来了巨大的困难和挑战,要使得Dialogue System得到更好的发展,需要开发一个通用的对话理解模型。为此,我们给出了基于BERT的对话通用理解模型 (DGU: Dialogue General Understanding),通过实验表明,使用base-model (BERT)并结合常见的学习范式,就可以在几乎全部对话理解任务上取得比肩甚至超越各个领域业内最好的模型的效果,展现了学习一个通用对话理解模型的巨大潜力。
+对话系统 (Dialogue System) 常常需要根据应用场景的变化去解决多种多样的任务。任务的多样性(意图识别、槽填充、行为识别、状态追踪等等),以及领域训练数据的稀少,给 Dialogue System 的研究和应用带来了巨大的困难和挑战,要使得 Dialogue System 得到更好的发展,需要开发一个通用的对话理解模型。为此,我们给出了基于 BERT 的对话通用理解模型 (DGU: Dialogue General Understanding),通过实验表明,使用 base-model (BERT)并结合常见的学习范式,就可以在几乎全部对话理解任务上取得比肩甚至超越各个领域业内最好的模型的效果,展现了学习一个通用对话理解模型的巨大潜力。
-DGU模型内共包含6个任务,全部基于公开数据集在Paddle2.0上完成训练及评估,详细说明如下:
+DGU 模型内共包含6个任务,全部基于公开数据集在 Paddle2.0上完成训练及评估,详细说明如下:
```
udc: 使用UDC (Ubuntu Corpus V1) 数据集完成对话匹配 (Dialogue Response Selection) 任务;
@@ -17,7 +17,7 @@ swda: 使用SwDAC (Switchboard Dialogue Act Corpus) 数据集完成对话行为
## 模型效果
-DGU模型中的6个任务,分别采用不同的评估指标在test集上进行评估,结果如下:
+DGU 模型中的6个任务,分别采用不同的评估指标在 test 集上进行评估,结果如下:
任务 | 评估指标 | DGU |
@@ -31,20 +31,20 @@ DGU模型中的6个任务,分别采用不同的评估指标在test集上进行
swda | Acc | 80.61% |
-**NOTE:** 以上结果均是采用默认配置在GPU单卡上训练和评估得到的,用户如需复现效果,可采用默认配置在单卡上进行训练评估。
+**NOTE:** 以上结果均是采用默认配置在 GPU 单卡上训练和评估得到的,用户如需复现效果,可采用默认配置在单卡上进行训练评估。
## 快速开始
### 数据准备
-下载数据集压缩包并解压后,DGU_datasets目录下共存在6个目录,分别对应每个任务的训练集train.txt、评估集dev.txt和测试集test.txt。
+下载数据集压缩包并解压后,DGU_datasets 目录下共存在6个目录,分别对应每个任务的训练集 train.txt、评估集 dev.txt 和测试集 test.txt。
```shell
wget https://bj.bcebos.com/paddlenlp/datasets/DGU_datasets.tar.gz
tar -zxf DGU_datasets.tar.gz
```
-DGU_datasets目录结构:
+DGU_datasets 目录结构:
```text
DGU_datasets/
@@ -118,7 +118,7 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log main.py --task_na
以上参数表示:
-* `task_name`:任务名称,可以为udc、dstc2、atis_slot、atis_intent、mrda或swda。
+* `task_name`:任务名称,可以为 udc、dstc2、atis_slot、atis_intent、mrda 或 swda。
* `data_dir`:训练数据路径。
* `output_dir`:训练保存模型的文件路径。
* `do_train:是否进行训练,默认为`True`。
@@ -140,4 +140,4 @@ checkpoints/
└── best.pdparams
```
-**NOTE:** 如需恢复模型训练,则init_from_ckpt只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/1000`即可,程序会自动加载模型参数`checkpoints/1000.pdparams`,也会自动加载优化器状态`checkpoints/1000.pdopt`。
+**NOTE:** 如需恢复模型训练,则 init_from_ckpt 只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/1000`即可,程序会自动加载模型参数`checkpoints/1000.pdparams`,也会自动加载优化器状态`checkpoints/1000.pdopt`。
diff --git a/legacy/examples/dialogue/dgu/args.py b/slm/examples/dialogue/dgu/args.py
similarity index 100%
rename from legacy/examples/dialogue/dgu/args.py
rename to slm/examples/dialogue/dgu/args.py
diff --git a/legacy/examples/dialogue/dgu/data.py b/slm/examples/dialogue/dgu/data.py
similarity index 100%
rename from legacy/examples/dialogue/dgu/data.py
rename to slm/examples/dialogue/dgu/data.py
index 469134f7cfc7..795d849ac27a 100644
--- a/legacy/examples/dialogue/dgu/data.py
+++ b/slm/examples/dialogue/dgu/data.py
@@ -13,9 +13,9 @@
# limitations under the License.
import os
-import numpy as np
from typing import List
+import numpy as np
from paddle.io import Dataset
# The input data bigin with '[CLS]', using '[SEP]' split conversation content(
diff --git a/legacy/examples/dialogue/dgu/main.py b/slm/examples/dialogue/dgu/main.py
similarity index 97%
rename from legacy/examples/dialogue/dgu/main.py
rename to slm/examples/dialogue/dgu/main.py
index f5ca4faf4572..8c8d3467becb 100644
--- a/legacy/examples/dialogue/dgu/main.py
+++ b/slm/examples/dialogue/dgu/main.py
@@ -15,25 +15,28 @@
import os
import random
import time
-import numpy as np
from functools import partial
+import data
+import metric
+import numpy as np
import paddle
+import paddle.distributed as dist
import paddle.nn as nn
import paddle.nn.functional as F
-import paddle.distributed as dist
-from paddle.io import DataLoader, DistributedBatchSampler, BatchSampler
-from paddle.optimizer import AdamW
+from args import parse_args, set_default_args
+from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
from paddle.metric import Accuracy
+from paddle.optimizer import AdamW
+from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import MapDataset
-from paddlenlp.data import Stack, Tuple, Pad
-from paddlenlp.transformers import BertTokenizer, BertForSequenceClassification, BertForTokenClassification
-from paddlenlp.transformers import LinearDecayWithWarmup
-
-from args import parse_args, set_default_args
-import data
-import metric
+from paddlenlp.transformers import (
+ BertForSequenceClassification,
+ BertForTokenClassification,
+ BertTokenizer,
+ LinearDecayWithWarmup,
+)
TASK_CLASSES = {
"udc": (data.UDCv1, metric.RecallAtK),
diff --git a/legacy/examples/dialogue/dgu/metric.py b/slm/examples/dialogue/dgu/metric.py
similarity index 99%
rename from legacy/examples/dialogue/dgu/metric.py
rename to slm/examples/dialogue/dgu/metric.py
index b5ef869f768c..50eec50ed671 100644
--- a/legacy/examples/dialogue/dgu/metric.py
+++ b/slm/examples/dialogue/dgu/metric.py
@@ -13,7 +13,6 @@
# limitations under the License.
import numpy as np
-
import paddle
import paddle.nn as nn
from paddle.metric import Metric
diff --git a/legacy/examples/dialogue/lic2021_baseline/README.md b/slm/examples/dialogue/lic2021_baseline/README.md
similarity index 66%
rename from legacy/examples/dialogue/lic2021_baseline/README.md
rename to slm/examples/dialogue/lic2021_baseline/README.md
index b0354b0f18d0..31430a23ecec 100644
--- a/legacy/examples/dialogue/lic2021_baseline/README.md
+++ b/slm/examples/dialogue/lic2021_baseline/README.md
@@ -1,4 +1,4 @@
-# LIC 2021对话比赛baseline
+# LIC 2021对话比赛 baseline
## 模型简介
@@ -6,9 +6,9 @@
LIC 2021对话比赛收集了一系列公开的开放域对话数据并提供了统一的评测方式,旨在为研究人员和开发者提供学术和技术交流的平台,进一步提升开放域对话的研究水平,推动自然语言理解和人工智能领域技术的应用和发展。
-为了方便参赛者快速了解LIC 2021对话比赛的流程,并快速地参与到比赛中,本项目基于UnifiedTransformer模型提供了一个基础baseline,利用小规模样例数据在预训练模型上完成了微调及预测。参赛者可以针对赛题进行其他改进,例如修改数据预处理方法、修改网络结构、修改训练方式、修改预测的解码方式或对结果的后处理策略等方式提升模型效果。
+为了方便参赛者快速了解 LIC 2021对话比赛的流程,并快速地参与到比赛中,本项目基于 UnifiedTransformer 模型提供了一个基础 baseline,利用小规模样例数据在预训练模型上完成了微调及预测。参赛者可以针对赛题进行其他改进,例如修改数据预处理方法、修改网络结构、修改训练方式、修改预测的解码方式或对结果的后处理策略等方式提升模型效果。
-UnifiedTransformer模型的细节可以[参阅论文](https://arxiv.org/abs/2006.16779)。
+UnifiedTransformer 模型的细节可以[参阅论文](https://arxiv.org/abs/2006.16779)。
## 快速开始
@@ -20,14 +20,14 @@ UnifiedTransformer模型的细节可以[参阅论文](https://arxiv.org/abs/2006
### 数据准备
-由于样例数据涉及LIC 2021对话比赛,暂不开放。
-关于数据集及数据集的预处理过程,详见[2021语言与智能技术竞赛:多技能对话](https://aistudio.baidu.com/aistudio/competition/detail/67)及官方提供的基线系统Baselines。
+由于样例数据涉及 LIC 2021对话比赛,暂不开放。
+关于数据集及数据集的预处理过程,详见[2021语言与智能技术竞赛:多技能对话](https://aistudio.baidu.com/aistudio/competition/detail/67)及官方提供的基线系统 Baselines。
-模型的输入由3部分组成:词向量token_ids,句向量token_type_ids和位置向量position_ids。本项目的数据集是样例文本经过数据预处理脚本得到的id化的数据集。数据的每一行由3列组成,以";"作为分割符,格式:token_ids;token_type_ids;position_ids。具体细节请参考`data.py`。
+模型的输入由3部分组成:词向量 token_ids,句向量 token_type_ids 和位置向量 position_ids。本项目的数据集是样例文本经过数据预处理脚本得到的 id 化的数据集。数据的每一行由3列组成,以";"作为分割符,格式:token_ids;token_type_ids;position_ids。具体细节请参考`data.py`。
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -51,10 +51,10 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log finetune.py \
```
其中参数释义如下:
-- `gpus` 指示了训练所用的GPU卡号。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `gpus` 指示了训练所用的 GPU 卡号。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -67,11 +67,11 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log finetune.py \
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `lr` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `lr` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的 lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_grad_norm` 表示梯度裁剪允许的最大梯度值。
-- `sort_pool_size` 表示在构建batch数据时,用来排序的pool size。
+- `sort_pool_size` 表示在构建 batch 数据时,用来排序的 pool size。
- `device` 表示训练使用的设备。
参数详情和参数的默认值请参考`args.py`。
@@ -114,9 +114,9 @@ python infer.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -130,7 +130,7 @@ python infer.py \
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_samples` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_samples`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示训练使用的设备。
参数详情和参数的默认值请参考`args.py`。
diff --git a/legacy/examples/dialogue/lic2021_baseline/args.py b/slm/examples/dialogue/lic2021_baseline/args.py
similarity index 100%
rename from legacy/examples/dialogue/lic2021_baseline/args.py
rename to slm/examples/dialogue/lic2021_baseline/args.py
diff --git a/legacy/examples/dialogue/lic2021_baseline/data.py b/slm/examples/dialogue/lic2021_baseline/data.py
similarity index 100%
rename from legacy/examples/dialogue/lic2021_baseline/data.py
rename to slm/examples/dialogue/lic2021_baseline/data.py
diff --git a/legacy/examples/dialogue/lic2021_baseline/finetune.py b/slm/examples/dialogue/lic2021_baseline/finetune.py
similarity index 100%
rename from legacy/examples/dialogue/lic2021_baseline/finetune.py
rename to slm/examples/dialogue/lic2021_baseline/finetune.py
diff --git a/legacy/examples/dialogue/lic2021_baseline/infer.py b/slm/examples/dialogue/lic2021_baseline/infer.py
similarity index 100%
rename from legacy/examples/dialogue/lic2021_baseline/infer.py
rename to slm/examples/dialogue/lic2021_baseline/infer.py
diff --git a/legacy/examples/dialogue/plato-2/README.md b/slm/examples/dialogue/plato-2/README.md
similarity index 84%
rename from legacy/examples/dialogue/plato-2/README.md
rename to slm/examples/dialogue/plato-2/README.md
index 20d6e6644d70..706f080c4a2b 100644
--- a/legacy/examples/dialogue/plato-2/README.md
+++ b/slm/examples/dialogue/plato-2/README.md
@@ -4,7 +4,7 @@
构建高质量的开放领域(Open-Domain)的对话机器人,使得它能用自然语言与人自由地交流,这一直是自然语言处理领域终极目标之一。
-为了能够简易地构建一个高质量的开放域聊天机器人,本项目在Paddle2.0上实现了PLATO-2的预测模型,并基于终端实现了简单的人机交互。用户可以通过下载预训练模型快速构建一个开放域聊天机器人。
+为了能够简易地构建一个高质量的开放域聊天机器人,本项目在 Paddle2.0上实现了 PLATO-2的预测模型,并基于终端实现了简单的人机交互。用户可以通过下载预训练模型快速构建一个开放域聊天机器人。
PLATO-2的网络结构见下图:
@@ -37,7 +37,7 @@ wget https://bj.bcebos.com/paddlenlp/models/transformers/plato2/24L.pdparams
**NOTE:** PLATO-2网络参数量较大,24层网络至少需要显存16G,32层网络至少需要显存22G,用户可选择合适的网络层数及预训练模型。
-sentencepiece分词预训练模型和词表文件下载:
+sentencepiece 分词预训练模型和词表文件下载:
```shell
wget https://bj.bcebos.com/paddlenlp/models/transformers/plato2/data.tar.gz
@@ -56,11 +56,11 @@ python interaction.py --vocab_path ./data/vocab.txt --spm_model_file ./data/spm.
以上参数表示:
* vocab_path:词表文件路径。
-* spm_model_file:sentencepiece分词预训练模型路径。
+* spm_model_file:sentencepiece 分词预训练模型路径。
* num_layers:PLATO-2组网层数。
* init_from_ckpt:PLATO-2预训练模型路径。
-32层PLATO-2网络交互示例:
+32层 PLATO-2网络交互示例:

diff --git a/legacy/examples/dialogue/plato-2/imgs/case.jpg b/slm/examples/dialogue/plato-2/imgs/case.jpg
similarity index 100%
rename from legacy/examples/dialogue/plato-2/imgs/case.jpg
rename to slm/examples/dialogue/plato-2/imgs/case.jpg
diff --git a/legacy/examples/dialogue/plato-2/imgs/network.png b/slm/examples/dialogue/plato-2/imgs/network.png
similarity index 100%
rename from legacy/examples/dialogue/plato-2/imgs/network.png
rename to slm/examples/dialogue/plato-2/imgs/network.png
diff --git a/legacy/examples/dialogue/plato-2/interaction.py b/slm/examples/dialogue/plato-2/interaction.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/interaction.py
rename to slm/examples/dialogue/plato-2/interaction.py
diff --git a/legacy/examples/dialogue/plato-2/model.py b/slm/examples/dialogue/plato-2/model.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/model.py
rename to slm/examples/dialogue/plato-2/model.py
diff --git a/legacy/examples/dialogue/plato-2/readers/dialog_reader.py b/slm/examples/dialogue/plato-2/readers/dialog_reader.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/readers/dialog_reader.py
rename to slm/examples/dialogue/plato-2/readers/dialog_reader.py
diff --git a/legacy/examples/dialogue/plato-2/readers/nsp_reader.py b/slm/examples/dialogue/plato-2/readers/nsp_reader.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/readers/nsp_reader.py
rename to slm/examples/dialogue/plato-2/readers/nsp_reader.py
diff --git a/legacy/examples/dialogue/plato-2/readers/plato_reader.py b/slm/examples/dialogue/plato-2/readers/plato_reader.py
similarity index 99%
rename from legacy/examples/dialogue/plato-2/readers/plato_reader.py
rename to slm/examples/dialogue/plato-2/readers/plato_reader.py
index 3d3cd790ee76..4459e808fc5f 100644
--- a/legacy/examples/dialogue/plato-2/readers/plato_reader.py
+++ b/slm/examples/dialogue/plato-2/readers/plato_reader.py
@@ -14,7 +14,6 @@
"""Plato Reader."""
import numpy as np
-
from readers.dialog_reader import DialogReader
from utils import pad_batch_data
from utils.masking import mask
diff --git a/legacy/examples/dialogue/plato-2/utils/__init__.py b/slm/examples/dialogue/plato-2/utils/__init__.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/utils/__init__.py
rename to slm/examples/dialogue/plato-2/utils/__init__.py
diff --git a/legacy/examples/dialogue/plato-2/utils/args.py b/slm/examples/dialogue/plato-2/utils/args.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/utils/args.py
rename to slm/examples/dialogue/plato-2/utils/args.py
diff --git a/legacy/examples/dialogue/plato-2/utils/masking.py b/slm/examples/dialogue/plato-2/utils/masking.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/utils/masking.py
rename to slm/examples/dialogue/plato-2/utils/masking.py
diff --git a/legacy/examples/dialogue/plato-2/utils/tokenization.py b/slm/examples/dialogue/plato-2/utils/tokenization.py
similarity index 100%
rename from legacy/examples/dialogue/plato-2/utils/tokenization.py
rename to slm/examples/dialogue/plato-2/utils/tokenization.py
index 7d4741ba984e..605dfe7e6100 100644
--- a/legacy/examples/dialogue/plato-2/utils/tokenization.py
+++ b/slm/examples/dialogue/plato-2/utils/tokenization.py
@@ -14,9 +14,9 @@
"""Tokenization classes."""
import collections
-import sentencepiece as spm
import unicodedata
+import sentencepiece as spm
from utils.args import str2bool
diff --git a/legacy/examples/dialogue/plato-xl b/slm/examples/dialogue/plato-xl
similarity index 100%
rename from legacy/examples/dialogue/plato-xl
rename to slm/examples/dialogue/plato-xl
diff --git a/legacy/examples/dialogue/unified_transformer/README.md b/slm/examples/dialogue/unified_transformer/README.md
similarity index 68%
rename from legacy/examples/dialogue/unified_transformer/README.md
rename to slm/examples/dialogue/unified_transformer/README.md
index 45cf6f32b239..e8b61507ec39 100644
--- a/legacy/examples/dialogue/unified_transformer/README.md
+++ b/slm/examples/dialogue/unified_transformer/README.md
@@ -6,7 +6,7 @@
[UnifiedTransformer](https://arxiv.org/abs/2006.16779)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,采用灵活的注意力机制,十分适合对话生成任务。
-本项目是UnifiedTransformer在 Paddle 2.0上的开源实现,介绍了如何使用UnifiedTransformer在DuConv任务型对话数据集上进行微调,并给出了一个搭建简单中文聊天机器人的例子。
+本项目是 UnifiedTransformer 在 Paddle 2.0上的开源实现,介绍了如何使用 UnifiedTransformer 在 DuConv 任务型对话数据集上进行微调,并给出了一个搭建简单中文聊天机器人的例子。
## 快速开始
@@ -31,9 +31,9 @@
### 数据准备
-**DuConv**是百度发布的基于知识图谱的主动聊天任务数据集,让机器根据构建的知识图谱进行主动聊天,使机器具备模拟人类用语言进行信息传递的能力。数据集的创新性是:强调了bot的主动性,并且在闲聊对话中引入了明确的对话目标,即将对话引导到特定实体上。数据中的知识信息来源于电影和娱乐人物领域有聊天价值的知识信息,如票房、导演、评价等,以三元组SPO的形式组织,对话目标中的话题为电影或娱乐人物实体。数据集中共有3万session,约12万轮对话,划分为训练集、开发集、测试集1和测试集2,其中测试集1中包含对话的response,而测试集2中只有对话历史。
+**DuConv**是百度发布的基于知识图谱的主动聊天任务数据集,让机器根据构建的知识图谱进行主动聊天,使机器具备模拟人类用语言进行信息传递的能力。数据集的创新性是:强调了 bot 的主动性,并且在闲聊对话中引入了明确的对话目标,即将对话引导到特定实体上。数据中的知识信息来源于电影和娱乐人物领域有聊天价值的知识信息,如票房、导演、评价等,以三元组 SPO 的形式组织,对话目标中的话题为电影或娱乐人物实体。数据集中共有3万 session,约12万轮对话,划分为训练集、开发集、测试集1和测试集2,其中测试集1中包含对话的 response,而测试集2中只有对话历史。
-为了方便用户快速测试,PaddleNLP Dataset API内置了DuConv数据集,一键即可完成数据集加载,示例代码如下:
+为了方便用户快速测试,PaddleNLP Dataset API 内置了 DuConv 数据集,一键即可完成数据集加载,示例代码如下:
```python
from paddlenlp.datasets import load_dataset
@@ -42,17 +42,17 @@ train_ds, dev_ds, test1_ds, test2_ds = load_dataset('duconv', splits=('train', '
### 预训练模型
-以下是PaddleNLP支持的对话类预训练模型:
+以下是 PaddleNLP 支持的对话类预训练模型:
|模型名称| 模型参数 | 模型特点 |
|:-----:|:------:|:-------:|
|unified_transformer-12L-cn| 12-layers, 12-heads, 768-hidden| 在千万级别的中文会话数据上进行预训练。|
-|unified_transformer-12L-cn-luge| 12-layers, 12-heads, 768-hidden|由unified_transformer-12L-cn预训练模型在千言对话数据集上进行微调。并且模型输入中加入了标识不同对话技能的special token,使得模型能同时支持闲聊对话、推荐对话和知识对话。|
+|unified_transformer-12L-cn-luge| 12-layers, 12-heads, 768-hidden|由 unified_transformer-12L-cn 预训练模型在千言对话数据集上进行微调。并且模型输入中加入了标识不同对话技能的 special token,使得模型能同时支持闲聊对话、推荐对话和知识对话。|
|plato-mini| 6-layers, 12-heads, 768-hidden|在十亿级别的中文对话数据上进行预训练。参数量更小,但效果更好。只支持闲聊型对话。|
### 模型训练
-运行如下命令即可在训练集上进行finetune,并在验证集上进行验证
+运行如下命令即可在训练集上进行 finetune,并在验证集上进行验证
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -77,11 +77,11 @@ python -m paddle.distributed.launch --gpus '0' --log_dir ./log finetune.py \
```
其中参数释义如下:
-- `gpus` 指示了训练所用的GPU
+- `gpus` 指示了训练所用的 GPU
- `log_dir` 指示了日志保存目录
-- `model_name_or_path` 指示了finetune使用的预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -92,16 +92,16 @@ python -m paddle.distributed.launch --gpus '0' --log_dir ./log finetune.py \
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `lr` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `lr` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_steps` 表示学习率逐渐升高到基础学习率(即上面配置的 lr)所需要的迭代数,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_grad_norm` 表示梯度裁剪允许的最大梯度值。
- `max_seq_len` 表示输入序列的最大长度。
-- `max_response_len` 表示输入response的最大长度。
-- `max_knowledge_len` 表示输入knowledge序列的最大长度。
+- `max_response_len` 表示输入 response 的最大长度。
+- `max_knowledge_len` 表示输入 knowledge 序列的最大长度。
- `device` 表示使用的设备。
-程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中,其中loss最小的模型会被保存在`save_dir/model_best`中。如:
+程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中,其中 loss 最小的模型会被保存在`save_dir/model_best`中。如:
```text
./checkpoints/
@@ -140,9 +140,9 @@ python infer.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了预测使用的模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了预测使用的模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -151,20 +151,20 @@ python infer.py \
- `logging_steps` 表示日志打印间隔。
- `seed` 表示随机数生成器的种子。
- `max_seq_len` 表示输入序列的最大长度。
-- `max_knowledge_len` 表示输入knowledge序列的最大长度。
+- `max_knowledge_len` 表示输入 knowledge 序列的最大长度。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
- `min_dec_len` 表示预测生成的句子的最小长度。
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_return_sequences` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_return_sequences`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示使用的设备。
同时,我们提供了基于 FastGeneration 的高性能预测的选项,可以选择性开启是否需要采用高性能预测,PaddleNLP 提供了 JIT 的方式,可以自动完成对所需的自定义 op 的动态库编译:
- `faster` 表示是否开启高性能预测。设置 `--faster` 即表示开启。
- `use_fp16_decoding` 表示在开启高性能预测的时候,是否使用 fp16 来完成预测过程。设置 `--use_fp16_decoding` 即表示使用 fp16 进行预测,否则使用 fp32。
-程序运行结束后会将预测生成的response保存在`output_path`中。同时终端中会输出评估结果。
+程序运行结束后会将预测生成的 response 保存在`output_path`中。同时终端中会输出评估结果。
采用预训练模型及微调模型在测试集上有如下结果:
@@ -173,7 +173,7 @@ python infer.py \
| unified_transformer-12L-cn-luge | 0.2606 / 0.1576 | 0.1168 / 0.2977 |
| ./checkpoints/model_best | 0.2808 / 0.1744 | 0.1124 / 0.2899 |
-**NOTE:** `./checkpoints/model_best`是按本项目中的超参在单卡上finetune得到的结果。
+**NOTE:** `./checkpoints/model_best`是按本项目中的超参在单卡上 finetune 得到的结果。
### 人机交互
@@ -193,9 +193,9 @@ python interaction.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了预测使用的模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了预测使用的模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unified_transformer-12L-cn |
| unified_transformer-12L-cn-luge |
@@ -205,7 +205,7 @@ python interaction.py \
- `max_dec_len` 表示预测生成的句子的最大长度。
- `num_return_sequences` 表示每条样本生成的句子的数量。对于每条样本,模型会生成`num_return_sequences`个句子,根据每个句子的概率得分进行排序,得分最高的句子作为最终的生成结果。
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
- `device` 表示使用的设备。
**NOTE:** 输入"[EXIT]"退出交互程序,输入"[NEXT]"开启下一轮新的对话。需要注意使用退格会导致错误。
diff --git a/legacy/examples/dialogue/unified_transformer/finetune.py b/slm/examples/dialogue/unified_transformer/finetune.py
similarity index 100%
rename from legacy/examples/dialogue/unified_transformer/finetune.py
rename to slm/examples/dialogue/unified_transformer/finetune.py
diff --git a/legacy/examples/dialogue/unified_transformer/infer.py b/slm/examples/dialogue/unified_transformer/infer.py
similarity index 100%
rename from legacy/examples/dialogue/unified_transformer/infer.py
rename to slm/examples/dialogue/unified_transformer/infer.py
diff --git a/legacy/examples/dialogue/unified_transformer/interaction.py b/slm/examples/dialogue/unified_transformer/interaction.py
similarity index 100%
rename from legacy/examples/dialogue/unified_transformer/interaction.py
rename to slm/examples/dialogue/unified_transformer/interaction.py
diff --git a/legacy/examples/dialogue/unified_transformer/utils.py b/slm/examples/dialogue/unified_transformer/utils.py
similarity index 99%
rename from legacy/examples/dialogue/unified_transformer/utils.py
rename to slm/examples/dialogue/unified_transformer/utils.py
index 90585d69e0ee..1049aa593f8c 100644
--- a/legacy/examples/dialogue/unified_transformer/utils.py
+++ b/slm/examples/dialogue/unified_transformer/utils.py
@@ -16,10 +16,10 @@
from functools import partial
import numpy as np
-
import paddle
import paddle.distributed as dist
-from paddle.io import DataLoader, DistributedBatchSampler, BatchSampler
+from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
+
from paddlenlp.data import Pad
diff --git a/legacy/examples/few_shot/README.md b/slm/examples/few_shot/README.md
similarity index 100%
rename from legacy/examples/few_shot/README.md
rename to slm/examples/few_shot/README.md
diff --git a/legacy/examples/few_shot/RGL/README.md b/slm/examples/few_shot/RGL/README.md
similarity index 100%
rename from legacy/examples/few_shot/RGL/README.md
rename to slm/examples/few_shot/RGL/README.md
diff --git a/legacy/examples/few_shot/RGL/data.py b/slm/examples/few_shot/RGL/data.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/data.py
rename to slm/examples/few_shot/RGL/data.py
diff --git a/legacy/examples/few_shot/RGL/rgl.py b/slm/examples/few_shot/RGL/rgl.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/rgl.py
rename to slm/examples/few_shot/RGL/rgl.py
diff --git a/legacy/examples/few_shot/RGL/scripts/run_pet.sh b/slm/examples/few_shot/RGL/scripts/run_pet.sh
similarity index 83%
rename from legacy/examples/few_shot/RGL/scripts/run_pet.sh
rename to slm/examples/few_shot/RGL/scripts/run_pet.sh
index ca50d8c6bd00..7411bbe62d09 100644
--- a/legacy/examples/few_shot/RGL/scripts/run_pet.sh
+++ b/slm/examples/few_shot/RGL/scripts/run_pet.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
dataset=$1
device=$2
diff --git a/legacy/examples/few_shot/RGL/scripts/run_rgl.sh b/slm/examples/few_shot/RGL/scripts/run_rgl.sh
similarity index 83%
rename from legacy/examples/few_shot/RGL/scripts/run_rgl.sh
rename to slm/examples/few_shot/RGL/scripts/run_rgl.sh
index 9b1a5d2dc216..5fa57a9e791e 100644
--- a/legacy/examples/few_shot/RGL/scripts/run_rgl.sh
+++ b/slm/examples/few_shot/RGL/scripts/run_rgl.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
dataset=$1
device=$2
diff --git a/legacy/examples/few_shot/RGL/template.py b/slm/examples/few_shot/RGL/template.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/template.py
rename to slm/examples/few_shot/RGL/template.py
diff --git a/legacy/examples/few_shot/RGL/tokenizer.py b/slm/examples/few_shot/RGL/tokenizer.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/tokenizer.py
rename to slm/examples/few_shot/RGL/tokenizer.py
diff --git a/legacy/examples/few_shot/RGL/utils.py b/slm/examples/few_shot/RGL/utils.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/utils.py
rename to slm/examples/few_shot/RGL/utils.py
diff --git a/legacy/examples/few_shot/RGL/verbalizer.py b/slm/examples/few_shot/RGL/verbalizer.py
similarity index 100%
rename from legacy/examples/few_shot/RGL/verbalizer.py
rename to slm/examples/few_shot/RGL/verbalizer.py
diff --git a/legacy/examples/few_shot/efl/README.md b/slm/examples/few_shot/efl/README.md
similarity index 100%
rename from legacy/examples/few_shot/efl/README.md
rename to slm/examples/few_shot/efl/README.md
diff --git a/legacy/examples/few_shot/efl/data.py b/slm/examples/few_shot/efl/data.py
similarity index 100%
rename from legacy/examples/few_shot/efl/data.py
rename to slm/examples/few_shot/efl/data.py
diff --git a/legacy/examples/few_shot/efl/prompt/bustm.json b/slm/examples/few_shot/efl/prompt/bustm.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/bustm.json
rename to slm/examples/few_shot/efl/prompt/bustm.json
diff --git a/legacy/examples/few_shot/efl/prompt/chid.json b/slm/examples/few_shot/efl/prompt/chid.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/chid.json
rename to slm/examples/few_shot/efl/prompt/chid.json
diff --git a/legacy/examples/few_shot/efl/prompt/cluewsc.json b/slm/examples/few_shot/efl/prompt/cluewsc.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/cluewsc.json
rename to slm/examples/few_shot/efl/prompt/cluewsc.json
diff --git a/legacy/examples/few_shot/efl/prompt/csl.json b/slm/examples/few_shot/efl/prompt/csl.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/csl.json
rename to slm/examples/few_shot/efl/prompt/csl.json
diff --git a/legacy/examples/few_shot/efl/prompt/csldcp.json b/slm/examples/few_shot/efl/prompt/csldcp.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/csldcp.json
rename to slm/examples/few_shot/efl/prompt/csldcp.json
diff --git a/legacy/examples/few_shot/efl/prompt/eprstmt.json b/slm/examples/few_shot/efl/prompt/eprstmt.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/eprstmt.json
rename to slm/examples/few_shot/efl/prompt/eprstmt.json
diff --git a/legacy/examples/few_shot/efl/prompt/iflytek.json b/slm/examples/few_shot/efl/prompt/iflytek.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/iflytek.json
rename to slm/examples/few_shot/efl/prompt/iflytek.json
diff --git a/legacy/examples/few_shot/efl/prompt/ocnli.json b/slm/examples/few_shot/efl/prompt/ocnli.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/ocnli.json
rename to slm/examples/few_shot/efl/prompt/ocnli.json
diff --git a/legacy/examples/few_shot/efl/prompt/tnews.json b/slm/examples/few_shot/efl/prompt/tnews.json
similarity index 100%
rename from legacy/examples/few_shot/efl/prompt/tnews.json
rename to slm/examples/few_shot/efl/prompt/tnews.json
diff --git a/legacy/examples/few_shot/efl/run_train.py b/slm/examples/few_shot/efl/run_train.py
similarity index 100%
rename from legacy/examples/few_shot/efl/run_train.py
rename to slm/examples/few_shot/efl/run_train.py
diff --git a/legacy/examples/few_shot/efl/utils.py b/slm/examples/few_shot/efl/utils.py
similarity index 100%
rename from legacy/examples/few_shot/efl/utils.py
rename to slm/examples/few_shot/efl/utils.py
diff --git a/legacy/examples/few_shot/p-tuning/README.md b/slm/examples/few_shot/p-tuning/README.md
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/README.md
rename to slm/examples/few_shot/p-tuning/README.md
diff --git a/legacy/examples/few_shot/p-tuning/data.py b/slm/examples/few_shot/p-tuning/data.py
similarity index 99%
rename from legacy/examples/few_shot/p-tuning/data.py
rename to slm/examples/few_shot/p-tuning/data.py
index 15dd653a29a9..54768bf2950b 100644
--- a/legacy/examples/few_shot/p-tuning/data.py
+++ b/slm/examples/few_shot/p-tuning/data.py
@@ -139,7 +139,7 @@ def convert_ids_to_words(example, token_ids):
the length of which should coincide with that of `mask` in prompt.
"""
if "label_ids" in example:
- label_ids_tensor = paddle.to_tensor([example.pop("label_ids")], dtype='int64')
+ label_ids_tensor = paddle.to_tensor([example.pop("label_ids")], dtype="int64")
labels = paddle.index_select(token_ids, label_ids_tensor, axis=0).squeeze(0)
example["labels"] = labels
return example
diff --git a/legacy/examples/few_shot/p-tuning/prompt/bustm.json b/slm/examples/few_shot/p-tuning/prompt/bustm.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/bustm.json
rename to slm/examples/few_shot/p-tuning/prompt/bustm.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/chid.json b/slm/examples/few_shot/p-tuning/prompt/chid.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/chid.json
rename to slm/examples/few_shot/p-tuning/prompt/chid.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/cluewsc.json b/slm/examples/few_shot/p-tuning/prompt/cluewsc.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/cluewsc.json
rename to slm/examples/few_shot/p-tuning/prompt/cluewsc.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/csl.json b/slm/examples/few_shot/p-tuning/prompt/csl.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/csl.json
rename to slm/examples/few_shot/p-tuning/prompt/csl.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/csldcp.json b/slm/examples/few_shot/p-tuning/prompt/csldcp.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/csldcp.json
rename to slm/examples/few_shot/p-tuning/prompt/csldcp.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/eprstmt.json b/slm/examples/few_shot/p-tuning/prompt/eprstmt.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/eprstmt.json
rename to slm/examples/few_shot/p-tuning/prompt/eprstmt.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/iflytek.json b/slm/examples/few_shot/p-tuning/prompt/iflytek.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/iflytek.json
rename to slm/examples/few_shot/p-tuning/prompt/iflytek.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/ocnli.json b/slm/examples/few_shot/p-tuning/prompt/ocnli.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/ocnli.json
rename to slm/examples/few_shot/p-tuning/prompt/ocnli.json
diff --git a/legacy/examples/few_shot/p-tuning/prompt/tnews.json b/slm/examples/few_shot/p-tuning/prompt/tnews.json
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/prompt/tnews.json
rename to slm/examples/few_shot/p-tuning/prompt/tnews.json
diff --git a/legacy/examples/few_shot/p-tuning/run_train.py b/slm/examples/few_shot/p-tuning/run_train.py
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/run_train.py
rename to slm/examples/few_shot/p-tuning/run_train.py
diff --git a/legacy/examples/few_shot/p-tuning/utils.py b/slm/examples/few_shot/p-tuning/utils.py
similarity index 100%
rename from legacy/examples/few_shot/p-tuning/utils.py
rename to slm/examples/few_shot/p-tuning/utils.py
diff --git a/legacy/examples/few_shot/pet/README.md b/slm/examples/few_shot/pet/README.md
similarity index 100%
rename from legacy/examples/few_shot/pet/README.md
rename to slm/examples/few_shot/pet/README.md
diff --git a/legacy/examples/few_shot/pet/data.py b/slm/examples/few_shot/pet/data.py
similarity index 100%
rename from legacy/examples/few_shot/pet/data.py
rename to slm/examples/few_shot/pet/data.py
diff --git a/legacy/examples/few_shot/pet/prompt/bustm.json b/slm/examples/few_shot/pet/prompt/bustm.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/bustm.json
rename to slm/examples/few_shot/pet/prompt/bustm.json
diff --git a/legacy/examples/few_shot/pet/prompt/chid.json b/slm/examples/few_shot/pet/prompt/chid.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/chid.json
rename to slm/examples/few_shot/pet/prompt/chid.json
diff --git a/legacy/examples/few_shot/pet/prompt/cluewsc.json b/slm/examples/few_shot/pet/prompt/cluewsc.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/cluewsc.json
rename to slm/examples/few_shot/pet/prompt/cluewsc.json
diff --git a/legacy/examples/few_shot/pet/prompt/csl.json b/slm/examples/few_shot/pet/prompt/csl.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/csl.json
rename to slm/examples/few_shot/pet/prompt/csl.json
diff --git a/legacy/examples/few_shot/pet/prompt/csldcp.json b/slm/examples/few_shot/pet/prompt/csldcp.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/csldcp.json
rename to slm/examples/few_shot/pet/prompt/csldcp.json
diff --git a/legacy/examples/few_shot/pet/prompt/eprstmt.json b/slm/examples/few_shot/pet/prompt/eprstmt.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/eprstmt.json
rename to slm/examples/few_shot/pet/prompt/eprstmt.json
diff --git a/legacy/examples/few_shot/pet/prompt/iflytek.json b/slm/examples/few_shot/pet/prompt/iflytek.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/iflytek.json
rename to slm/examples/few_shot/pet/prompt/iflytek.json
diff --git a/legacy/examples/few_shot/pet/prompt/ocnli.json b/slm/examples/few_shot/pet/prompt/ocnli.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/ocnli.json
rename to slm/examples/few_shot/pet/prompt/ocnli.json
diff --git a/legacy/examples/few_shot/pet/prompt/tnews.json b/slm/examples/few_shot/pet/prompt/tnews.json
similarity index 100%
rename from legacy/examples/few_shot/pet/prompt/tnews.json
rename to slm/examples/few_shot/pet/prompt/tnews.json
diff --git a/legacy/examples/few_shot/pet/run_train.py b/slm/examples/few_shot/pet/run_train.py
similarity index 100%
rename from legacy/examples/few_shot/pet/run_train.py
rename to slm/examples/few_shot/pet/run_train.py
diff --git a/legacy/examples/few_shot/pet/utils.py b/slm/examples/few_shot/pet/utils.py
similarity index 100%
rename from legacy/examples/few_shot/pet/utils.py
rename to slm/examples/few_shot/pet/utils.py
diff --git a/legacy/examples/information_extraction/DuEE/README.md b/slm/examples/information_extraction/DuEE/README.md
similarity index 66%
rename from legacy/examples/information_extraction/DuEE/README.md
rename to slm/examples/information_extraction/DuEE/README.md
index 1bdf5fab793a..36d3a8f19118 100644
--- a/legacy/examples/information_extraction/DuEE/README.md
+++ b/slm/examples/information_extraction/DuEE/README.md
@@ -7,10 +7,10 @@
-该示例展示了如何使用PaddleNLP快速复现[LIC2021事件抽取比赛](http://lic2021.ccf.org.cn/)基线并进阶优化基线。
+该示例展示了如何使用 PaddleNLP 快速复现[LIC2021事件抽取比赛](http://lic2021.ccf.org.cn/)基线并进阶优化基线。
同时,我们提供了该示例在线运行展示教程:
-[PaddleNLP实战——LIC2021事件抽取任务基线](https://aistudio.baidu.com/aistudio/projectdetail/1639964)
+[PaddleNLP 实战——LIC2021事件抽取任务基线](https://aistudio.baidu.com/aistudio/projectdetail/1639964)
## 目录结构
@@ -37,11 +37,11 @@ DuEE/
篇章级事件抽取数据集(DuEE-Fin)是金融领域篇章级别事件抽取数据集,
共包含13个已定义好的事件类型约束和1.15万中文篇章(存在部分非目标篇章作为负样例),其中6900训练集,1150验证集和3450测试集,数据集下载[地址](https://aistudio.baidu.com/aistudio/competition/detail/65) 。
-在该数据集上基线采用基于[ERNIE](https://github.com/PaddlePaddle/ERNIE)的序列标注(sequence labeling)方案,分为基于序列标注的触发词抽取模型、基于序列标注的论元抽取模型和枚举属性分类模型,属于PipeLine模型;基于序列标注的触发词抽取模型采用BIO方式,识别触发词的位置以及对应的事件类型,基于序列标注的论元抽取模型采用BIO方式识别出事件中的论元以及对应的论元角色;枚举属性分类模型采用ernie进行分类。
+在该数据集上基线采用基于[ERNIE](https://github.com/PaddlePaddle/ERNIE)的序列标注(sequence labeling)方案,分为基于序列标注的触发词抽取模型、基于序列标注的论元抽取模型和枚举属性分类模型,属于 PipeLine 模型;基于序列标注的触发词抽取模型采用 BIO 方式,识别触发词的位置以及对应的事件类型,基于序列标注的论元抽取模型采用 BIO 方式识别出事件中的论元以及对应的论元角色;枚举属性分类模型采用 ernie 进行分类。
### 评测方法
-本任务采用预测论元F1值作为评价指标,对于每个篇章,采用不放回的方式给每个目标事件寻找最相似的预测事件(事件级别匹配),搜寻方式是优先寻找与目标事件的事件类型相同且角色和论元正确数量最多的预测事件
+本任务采用预测论元 F1值作为评价指标,对于每个篇章,采用不放回的方式给每个目标事件寻找最相似的预测事件(事件级别匹配),搜寻方式是优先寻找与目标事件的事件类型相同且角色和论元正确数量最多的预测事件
f1_score = (2 * P * R) / (P + R),其中
@@ -49,11 +49,11 @@ f1_score = (2 * P * R) / (P + R),其中
- P=预测论元正确数量 / 所有预测论元的数量
- R=预测论元正确数量 / 所有人工标注论元的数量
-### 快速复现基线Step1:数据预处理并加载
+### 快速复现基线 Step1:数据预处理并加载
-从比赛官网下载数据集,逐层解压存放于data/DuEE-fin目录下,运行以下脚本将原始数据预处理成序列标注格式数据。
-处理之后的数据放在data/DuEE-Fin下,触发词识别数据文件存放在data/DuEE-Fin/role下,论元角色识别数据文件存放在data/DuEE-Fin/trigger下。
-枚举分类数据存放在data/DuEE-Fin/enum下。
+从比赛官网下载数据集,逐层解压存放于 data/DuEE-fin 目录下,运行以下脚本将原始数据预处理成序列标注格式数据。
+处理之后的数据放在 data/DuEE-Fin 下,触发词识别数据文件存放在 data/DuEE-Fin/role 下,论元角色识别数据文件存放在 data/DuEE-Fin/trigger 下。
+枚举分类数据存放在 data/DuEE-Fin/enum 下。
```
sh run_duee_fin.sh data_prepare
@@ -68,17 +68,17 @@ dev_ds = DuEventExtraction(args.dev_data, args.vocab_path, args.tag_path)
test_ds = DuEventExtraction(args.test_data, args.vocab_path, args.tag_path)
```
-### 快速复现基线Step2:构建模型
+### 快速复现基线 Step2:构建模型
-基于序列标注的触发词抽取模型是整体模型的一部分,该部分主要是给定事件类型,识别句子中出现的事件触发词对应的位置以及对应的事件类别,该模型是基于ERNIE开发序列标注模型,模型原理图如下:
+基于序列标注的触发词抽取模型是整体模型的一部分,该部分主要是给定事件类型,识别句子中出现的事件触发词对应的位置以及对应的事件类别,该模型是基于 ERNIE 开发序列标注模型,模型原理图如下:
-同样地,基于序列标注的论元抽取模型也是基于ERNIE开发序列标注模型,该部分主要是识别出事件中的论元以及对应论元角色,模型原理图如下:
+同样地,基于序列标注的论元抽取模型也是基于 ERNIE 开发序列标注模型,该部分主要是识别出事件中的论元以及对应论元角色,模型原理图如下:

@@ -86,7 +86,7 @@ test_ds = DuEventExtraction(args.test_data, args.vocab_path, args.tag_path)
上述样例中通过模型识别出:1)论元"新东方",并分配标签"B-收购方"、"I-收购方"、"I-收购方";2)论元"东方优播", 并分配标签"B-被收购方"、"I-被收购方"、"I-被收购方"、"I-被收购方"。最终识别出文本中包含的论元角色和论元对是<收购方,新东方>、<被收购方,东方优播>
-**PaddleNLP提供了ERNIE预训练模型常用序列标注模型,可以通过指定模型名字完成一键加载**:
+**PaddleNLP 提供了 ERNIE 预训练模型常用序列标注模型,可以通过指定模型名字完成一键加载**:
```python
from paddlenlp.transformers import AutoModelForTokenClassification
@@ -94,7 +94,7 @@ from paddlenlp.transformers import AutoModelForTokenClassification
model = AutoModelForTokenClassification.from_pretrained("ernie-3.0-medium-zh", num_classes=len(label_map))
```
-同时,对于枚举分类数据采用的是基于ERNIE的文本分类模型,枚举角色类型为环节。模型原理图如下:
+同时,对于枚举分类数据采用的是基于 ERNIE 的文本分类模型,枚举角色类型为环节。模型原理图如下:

@@ -103,7 +103,7 @@ model = AutoModelForTokenClassification.from_pretrained("ernie-3.0-medium-zh", n
> 给定文本,对文本进行分类,得到不同类别上的概率 筹备上市(0.8)、暂停上市(0.02)、正式上市(0.15)、终止上市(0.03)
-**同样地,PaddleNLP提供了ERNIE预训练模型常用文本分类模型,可以通过指定模型名字完成一键加载**:
+**同样地,PaddleNLP 提供了 ERNIE 预训练模型常用文本分类模型,可以通过指定模型名字完成一键加载**:
```python
from paddlenlp.transformers import AutoModelForSequenceClassification
@@ -111,10 +111,10 @@ from paddlenlp.transformers import AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained("ernie-3.0-medium-zh", num_classes=len(label_map))
```
-### 快速复现基线Step3:数据处理
+### 快速复现基线 Step3:数据处理
-我们需要将原始数据处理成模型可读入的数据。PaddleNLP为了方便用户处理数据,内置了对于各个预训练模型对应的Tokenizer,可以完成
-文本token化,转token ID,文本长度截断等操作。与加载模型类似地,也可以一键加载。
+我们需要将原始数据处理成模型可读入的数据。PaddleNLP 为了方便用户处理数据,内置了对于各个预训练模型对应的 Tokenizer,可以完成
+文本 token 化,转 token ID,文本长度截断等操作。与加载模型类似地,也可以一键加载。
```python
from paddlenlp.transformers import AutoTokenizer
@@ -122,7 +122,7 @@ from paddlenlp.transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ernie-3.0-medium-zh")
```
-文本数据处理直接调用tokenizer即可输出模型所需输入数据。
+文本数据处理直接调用 tokenizer 即可输出模型所需输入数据。
```python
inputs = tokenizer(text="请输入测试样例", max_seq_len=20)
@@ -132,7 +132,7 @@ inputs = tokenizer(text="请输入测试样例", max_seq_len=20)
```
-### 快速复现基线Step4:定义损失函数和优化器,开始训练
+### 快速复现基线 Step4:定义损失函数和优化器,开始训练
在该基线上,我们选择交叉墒作为损失函数,使用[`paddle.optimizer.AdamW`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/adamw/AdamW_cn.html#adamw)作为优化器。
@@ -158,7 +158,7 @@ sh run_duee_fin.sh enum_predict
```
-### 快速复现基线Step5:数据后处理,提交结果
+### 快速复现基线 Step5:数据后处理,提交结果
按照比赛预测指定格式提交结果至[评测网站](http://aistudio-bce.bcc-bdbl.baidu.com/aistudio/competition/detail/141)。
@@ -176,7 +176,7 @@ sh run_duee_fin.sh pred_2_submit
## 句子级事件抽取基线
-句子级别通用领域的事件抽取数据集([DuEE 1.0](https://aistudio.baidu.com/aistudio/competition/detail/32?isFromCcf=true))上进行事件抽取的基线模型,该模型采用基于[ERNIE](https://github.com/PaddlePaddle/ERNIE)的序列标注(sequence labeling)方案,分为基于序列标注的触发词抽取模型和基于序列标注的论元抽取模型,属于PipeLine模型;基于序列标注的触发词抽取模型采用BIO方式,识别触发词的位置以及对应的事件类型,基于序列标注的论元抽取模型采用BIO方式识别出事件中的论元以及对应的论元角色。模型和数据处理方式与篇章级事件抽取相同,此处不再赘述。句子级别通用领域的事件抽取无枚举角色分类。
+句子级别通用领域的事件抽取数据集([DuEE 1.0](https://aistudio.baidu.com/aistudio/competition/detail/32?isFromCcf=true))上进行事件抽取的基线模型,该模型采用基于[ERNIE](https://github.com/PaddlePaddle/ERNIE)的序列标注(sequence labeling)方案,分为基于序列标注的触发词抽取模型和基于序列标注的论元抽取模型,属于 PipeLine 模型;基于序列标注的触发词抽取模型采用 BIO 方式,识别触发词的位置以及对应的事件类型,基于序列标注的论元抽取模型采用 BIO 方式识别出事件中的论元以及对应的论元角色。模型和数据处理方式与篇章级事件抽取相同,此处不再赘述。句子级别通用领域的事件抽取无枚举角色分类。
启动训练:
```shell
@@ -199,25 +199,25 @@ sh run_duee_1.sh pred_2_submit
### 评测方法
-事件论元结果与人工标注的事件论元结果进行匹配,并按字级别匹配F1进行打分,不区分大小写,如论元有多个表述,则取多个匹配F1中的最高值
+事件论元结果与人工标注的事件论元结果进行匹配,并按字级别匹配 F1进行打分,不区分大小写,如论元有多个表述,则取多个匹配 F1中的最高值
f1_score = (2 * P * R) / (P + R),其中
- P=预测论元得分总和 / 所有预测论元的数量
- R=预测论元得分总和 / 所有人工标注论元的数量
-- 预测论元得分=事件类型是否准确 * 论元角色是否准确 * 字级别匹配F1值 (*是相乘)
-- 字级别匹配F1值 = 2 * 字级别匹配P值 * 字级别匹配R值 / (字级别匹配P值 + 字级别匹配R值)
-- 字级别匹配P值 = 预测论元和人工标注论元共有字的数量/ 预测论元字数
-- 字级别匹配R值 = 预测论元和人工标注论元共有字的数量/ 人工标注论元字数
+- 预测论元得分=事件类型是否准确 * 论元角色是否准确 * 字级别匹配 F1值 (*是相乘)
+- 字级别匹配 F1值 = 2 * 字级别匹配 P 值 * 字级别匹配 R 值 / (字级别匹配 P 值 + 字级别匹配 R 值)
+- 字级别匹配 P 值 = 预测论元和人工标注论元共有字的数量/ 预测论元字数
+- 字级别匹配 R 值 = 预测论元和人工标注论元共有字的数量/ 人工标注论元字数
#### to-do 增加基线效果
## 进阶优化基线效果
-基线采用的预训练模型为ERNIE,PaddleNLP提供了丰富的预训练模型,如BERT,RoBERTa,Electra,XLNet等
-参考[PaddleNLP预训练模型介绍](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer)
+基线采用的预训练模型为 ERNIE,PaddleNLP 提供了丰富的预训练模型,如 BERT,RoBERTa,Electra,XLNet 等
+参考[PaddleNLP 预训练模型介绍](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer)
-如可以选择RoBERTa large中文模型优化模型效果,只需更换模型和tokenizer即可无缝衔接。
+如可以选择 RoBERTa large 中文模型优化模型效果,只需更换模型和 tokenizer 即可无缝衔接。
```python
from paddlenlp.transformers import RobertaForTokenClassification, RobertaTokenizer
diff --git a/legacy/examples/information_extraction/DuEE/classifier.py b/slm/examples/information_extraction/DuEE/classifier.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/classifier.py
rename to slm/examples/information_extraction/DuEE/classifier.py
diff --git a/legacy/examples/information_extraction/DuEE/duee_1_data_prepare.py b/slm/examples/information_extraction/DuEE/duee_1_data_prepare.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/duee_1_data_prepare.py
rename to slm/examples/information_extraction/DuEE/duee_1_data_prepare.py
diff --git a/legacy/examples/information_extraction/DuEE/duee_1_postprocess.py b/slm/examples/information_extraction/DuEE/duee_1_postprocess.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/duee_1_postprocess.py
rename to slm/examples/information_extraction/DuEE/duee_1_postprocess.py
diff --git a/legacy/examples/information_extraction/DuEE/duee_fin_data_prepare.py b/slm/examples/information_extraction/DuEE/duee_fin_data_prepare.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/duee_fin_data_prepare.py
rename to slm/examples/information_extraction/DuEE/duee_fin_data_prepare.py
diff --git a/legacy/examples/information_extraction/DuEE/duee_fin_postprocess.py b/slm/examples/information_extraction/DuEE/duee_fin_postprocess.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/duee_fin_postprocess.py
rename to slm/examples/information_extraction/DuEE/duee_fin_postprocess.py
diff --git a/legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/ee.png b/slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/ee.png
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/ee.png
rename to slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/ee.png
diff --git a/legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/enum_model.png b/slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/enum_model.png
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/enum_model.png
rename to slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/enum_model.png
diff --git a/legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/role_model.png b/slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/role_model.png
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/role_model.png
rename to slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/role_model.png
diff --git a/legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/trigger_model.png b/slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/trigger_model.png
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/pictures/DuEE-Fin/trigger_model.png
rename to slm/examples/information_extraction/DuEE/pictures/DuEE-Fin/trigger_model.png
diff --git a/legacy/examples/information_extraction/DuEE/run_classifier.sh b/slm/examples/information_extraction/DuEE/run_classifier.sh
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/run_classifier.sh
rename to slm/examples/information_extraction/DuEE/run_classifier.sh
diff --git a/legacy/examples/information_extraction/DuEE/run_duee_1.sh b/slm/examples/information_extraction/DuEE/run_duee_1.sh
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/run_duee_1.sh
rename to slm/examples/information_extraction/DuEE/run_duee_1.sh
diff --git a/legacy/examples/information_extraction/DuEE/run_duee_fin.sh b/slm/examples/information_extraction/DuEE/run_duee_fin.sh
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/run_duee_fin.sh
rename to slm/examples/information_extraction/DuEE/run_duee_fin.sh
diff --git a/legacy/examples/information_extraction/DuEE/run_sequence_labeling.sh b/slm/examples/information_extraction/DuEE/run_sequence_labeling.sh
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/run_sequence_labeling.sh
rename to slm/examples/information_extraction/DuEE/run_sequence_labeling.sh
diff --git a/legacy/examples/information_extraction/DuEE/sequence_labeling.py b/slm/examples/information_extraction/DuEE/sequence_labeling.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/sequence_labeling.py
rename to slm/examples/information_extraction/DuEE/sequence_labeling.py
diff --git a/legacy/examples/information_extraction/DuEE/utils.py b/slm/examples/information_extraction/DuEE/utils.py
similarity index 100%
rename from legacy/examples/information_extraction/DuEE/utils.py
rename to slm/examples/information_extraction/DuEE/utils.py
diff --git a/slm/examples/information_extraction/DuIE/README.md b/slm/examples/information_extraction/DuIE/README.md
new file mode 100644
index 000000000000..f4a7c9128e19
--- /dev/null
+++ b/slm/examples/information_extraction/DuIE/README.md
@@ -0,0 +1,142 @@
+# LIC2021 DuIE 关系抽取基线
+
+信息抽取旨在从非结构化自然语言文本中提取结构化知识,如实体、关系、事件等。关系抽取的目标是对于给定的自然语言句子,根据预先定义的 schema 集合,抽取出所有满足 schema 约束的 SPO 三元组。schema 定义了关系 P 以及其对应的主体 S 和客体 O 的类别。
+本基线系统基于预训练语言模型 ERNIE 设计了结构化的标注策略,可以实现多条、交叠的 SPO 抽取。
+
+该示例展示了如何使用 PaddleNLP 快速复现[LIC2021关系抽取比赛](http://lic2021.ccf.org.cn/)基线并进阶优化模型基线。
+
+同时,我们提供了该示例在线运行展示教程:
+[PaddleNLP 实战——LIC2021关系抽取任务基线](https://aistudio.baidu.com/aistudio/projectdetail/1639963)
+
+
+## 目录结构
+
+以下是本项目主要目录结构及说明:
+
+```text
+DuIE/
+├── data_loader.py # 加载数据
+├── extract_chinese_and_punct.py # 文本数据预处理
+├── README.md # 文档说明
+├── re_official_evaluation.py # 比赛评价脚本
+├── run_duie.py # 模型训练脚本
+├── train.sh # 启动脚本
+└── utils.py # 效能函数
+```
+
+## 关系抽取基线
+
+针对 DuIE2.0 任务中多条、交叠 SPO 这一抽取目标,比赛对标准的 'BIO' 标注进行了扩展。
+对于每个 token,根据其在实体 span 中的位置(包括 B、I、O 三种),我们为其打上三类标签,并且根据其所参与构建的 predicate 种类,将 B 标签进一步区分。给定 schema 集合,对于 N 种不同 predicate,以及头实体/尾实体两种情况,我们设计对应的共 2*N 种 B 标签,再合并 I 和 O 标签,故每个 token 一共有 (2*N+2) 个标签,如下图所示。
+
+
+ 
+
+
+### 评价方法
+
+对测试集上参评系统输出的 SPO 结果和人工标注的 SPO 结果进行精准匹配,采用 F1值作为评价指标。注意,对于复杂 O 值类型的 SPO,必须所有槽位都精确匹配才认为该 SPO 抽取正确。针对部分文本中存在实体别名的问题,使用百度知识图谱的别名词典来辅助评测。F1值的计算方式如下:
+
+F1 = (2 * P * R) / (P + R),其中
+
+- P = 测试集所有句子中预测正确的 SPO 个数 / 测试集所有句子中预测出的 SPO 个数
+- R = 测试集所有句子中预测正确的 SPO 个数 / 测试集所有句子中人工标注的 SPO 个数
+
+### 快速复现基线 Step1:构建模型
+
+该任务可以看作一个序列标注任务,所以基线模型采用的是 ERNIE 序列标注模型。
+
+**PaddleNLP 提供了 ERNIE 预训练模型常用序列标注模型,可以通过指定模型名字完成一键加载.PaddleNLP 为了方便用户处理数据,内置了对于各个预训练模型对应的 Tokenizer,可以完成文本 token 化,转 token ID,文本长度截断等操作。**
+
+```python
+from paddlenlp.transformers import AutoModelForTokenClassification, AutoTokenizer
+
+model = AutoModelForTokenClassification.from_pretrained("ernie-3.0-medium-zh", num_classes=(len(label_map) - 2) * 2 + 2)
+tokenizer = AutoTokenizer.from_pretrained("ernie-3.0-medium-zh")
+```
+
+文本数据处理直接调用 tokenizer 即可输出模型所需输入数据。
+
+```python
+inputs = tokenizer(text="请输入测试样例", max_seq_len=20)
+# {'input_ids': [1, 647, 789, 109, 558, 525, 314, 656, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+# 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+# 'seq_len': 9}
+```
+
+### 快速复现基线 Step2:加载并处理
+
+
+
+从比赛官网[下载数据集](https://aistudio.baidu.com/aistudio/competition/detail/65),解压存放于 data/目录下并重命名为 train_data.json, dev_data.json, test_data.json.
+
+我们可以加载自定义数据集。通过继承[`paddle.io.Dataset`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/io/Dataset_cn.html#dataset),自定义实现`__getitem__` 和 `__len__`两个方法。
+
+
+如下代码已完成加载数据集操作:
+
+```python
+train_dataset = DuIEDataset.from_file(
+ os.path.join(args.data_path, 'train_data.json'),
+ tokenizer,
+ args.max_seq_length,
+ True)
+test_dataset = DuIEDataset.from_file(
+ os.path.join(args.data_path, 'dev_data.json'),
+ tokenizer,
+ args.max_seq_length,
+ True)
+```
+
+### 快速复现基线 Step3:定义损失函数和优化器,开始训练
+
+在该基线上,我们选择均方误差作为损失函数,使用[`paddle.optimizer.AdamW`](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/adamw/AdamW_cn.html#adamw)作为优化器。
+
+
+启动训练:
+```shell
+sh train.sh
+```
+
+在训练过程中,模型保存在当前目录 checkpoints 文件夹下。同时在训练的同时使用官方评测脚本进行评估,输出 P/R/F1指标。
+在验证集上 F1可以达到69.42。
+
+
+### 快速复现基线 Step4:提交预测结果
+
+将训练保存的模型加载后进行预测
+
+```shell
+sh predict.sh
+```
+
+预测结果会被保存在 data/predictions.json,data/predictions.json.zip,其格式与原数据集文件一致。
+
+之后可以使用官方评估脚本评估训练模型在 dev_data.json 上的效果。如:
+
+```shell
+python re_official_evaluation.py --golden_file=dev_data.json --predict_file=predicitons.json.zip [--alias_file alias_dict]
+```
+输出指标为 Precision, Recall 和 F1,Alias file 包含了合法的实体别名,最终评测的时候会使用,这里不予提供。
+
+之后在 test_data.json 上预测,然后预测结果(.zip 文件)至[评测网站](http://aistudio-bce.bcc-bdbl.baidu.com/aistudio/competition/detail/141)。
+
+
+## 进阶优化基线效果
+
+基线采用的预训练模型为 ERNIE,PaddleNLP 提供了丰富的预训练模型,如 BERT,RoBERTa,Electra,XLNet 等
+参考[PaddleNLP 预训练模型介绍](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer)
+
+如可以选择 RoBERTa large 中文模型优化模型效果,只需更换模型和 tokenizer 即可无缝衔接。
+
+```python
+from paddlenlp.transformers import RobertaForTokenClassification, RobertaTokenizer
+
+model = RobertaForTokenClassification.from_pretrained(
+ "roberta-wwm-ext-large",
+ num_classes=(len(label_map) - 2) * 2 + 2)
+tokenizer = RobertaTokenizer.from_pretrained("roberta-wwm-ext-large")
+```
+## Reference
+
+- [DuIE: A Large-scale Chinese Dataset for Information Extraction](http://tcci.ccf.org.cn/conference/2019/papers/EV10.pdf)
diff --git a/legacy/examples/information_extraction/DuIE/data/id2spo.json b/slm/examples/information_extraction/DuIE/data/id2spo.json
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/data/id2spo.json
rename to slm/examples/information_extraction/DuIE/data/id2spo.json
diff --git a/legacy/examples/information_extraction/DuIE/data/predicate2id.json b/slm/examples/information_extraction/DuIE/data/predicate2id.json
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/data/predicate2id.json
rename to slm/examples/information_extraction/DuIE/data/predicate2id.json
diff --git a/legacy/examples/information_extraction/DuIE/data_loader.py b/slm/examples/information_extraction/DuIE/data_loader.py
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/data_loader.py
rename to slm/examples/information_extraction/DuIE/data_loader.py
diff --git a/legacy/examples/information_extraction/DuIE/extract_chinese_and_punct.py b/slm/examples/information_extraction/DuIE/extract_chinese_and_punct.py
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/extract_chinese_and_punct.py
rename to slm/examples/information_extraction/DuIE/extract_chinese_and_punct.py
diff --git a/legacy/examples/information_extraction/DuIE/images/tagging_strategy.png b/slm/examples/information_extraction/DuIE/images/tagging_strategy.png
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/images/tagging_strategy.png
rename to slm/examples/information_extraction/DuIE/images/tagging_strategy.png
diff --git a/slm/examples/information_extraction/DuIE/predict.sh b/slm/examples/information_extraction/DuIE/predict.sh
new file mode 100644
index 000000000000..247f5759179a
--- /dev/null
+++ b/slm/examples/information_extraction/DuIE/predict.sh
@@ -0,0 +1,28 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eux
+
+export CUDA_VISIBLE_DEVICES=0
+export BATCH_SIZE=64
+export CKPT=./checkpoints/model_90000.pdparams
+export DATASET_FILE=./data/test1.json
+
+python run_duie.py \
+ --do_predict \
+ --init_checkpoint $CKPT \
+ --predict_data_file $DATASET_FILE \
+ --max_seq_length 128 \
+ --batch_size $BATCH_SIZE
+
diff --git a/legacy/examples/information_extraction/DuIE/re_official_evaluation.py b/slm/examples/information_extraction/DuIE/re_official_evaluation.py
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/re_official_evaluation.py
rename to slm/examples/information_extraction/DuIE/re_official_evaluation.py
diff --git a/legacy/examples/information_extraction/DuIE/run_duie.py b/slm/examples/information_extraction/DuIE/run_duie.py
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/run_duie.py
rename to slm/examples/information_extraction/DuIE/run_duie.py
diff --git a/legacy/examples/information_extraction/DuIE/train.sh b/slm/examples/information_extraction/DuIE/train.sh
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/train.sh
rename to slm/examples/information_extraction/DuIE/train.sh
diff --git a/legacy/examples/information_extraction/DuIE/utils.py b/slm/examples/information_extraction/DuIE/utils.py
similarity index 100%
rename from legacy/examples/information_extraction/DuIE/utils.py
rename to slm/examples/information_extraction/DuIE/utils.py
diff --git a/legacy/examples/information_extraction/DuUIE/README.md b/slm/examples/information_extraction/DuUIE/README.md
similarity index 92%
rename from legacy/examples/information_extraction/DuUIE/README.md
rename to slm/examples/information_extraction/DuUIE/README.md
index b8bfc1edaf4b..57dfce84f056 100644
--- a/legacy/examples/information_extraction/DuUIE/README.md
+++ b/slm/examples/information_extraction/DuUIE/README.md
@@ -1,8 +1,8 @@
-# CCKS 2022 通用信息抽取 -- 基于UIE的基线系统
+# CCKS 2022 通用信息抽取 -- 基于 UIE 的基线系统
信息抽取任务旨在根据特定的抽取需求(Schema,S)从非结构化文本(Text,X)中自动抽取结构化信息(Structure,Y)。
其中,特定的抽取需求是指抽取任务中的抽取框架,主要由抽取类别(人物名称、公司名称、企业上市事件)及目标结构(实体、关系、事件等)组成。
-本任务为中文信息抽取任务,即按照特定的抽取框架S,从给定的一组自由文本X中抽取出所有符合抽取需求的信息结构Y(实体、关系、事件记录等)。
+本任务为中文信息抽取任务,即按照特定的抽取框架 S,从给定的一组自由文本 X 中抽取出所有符合抽取需求的信息结构 Y(实体、关系、事件记录等)。
对于同一输入文本,不同的抽取框架会抽取不同的信息结构。
本例中包含四类抽取任务:实体抽取、关系抽取、事件抽取和情感抽取。
@@ -84,7 +84,7 @@ pip install -r requirements.txt
)
```
-生成SEL表达式后,我们通过解析器将表达式解析成对应的结构化抽取记录。
+生成 SEL 表达式后,我们通过解析器将表达式解析成对应的结构化抽取记录。
```
records = sel2record.sel2record(
@@ -105,7 +105,7 @@ records 为解析后的抽取结果。例如 {类别: 夺冠, 触发词: 金牌,
- 事件抽取:[spot] 事件类别 [asoc] 论元类别 [text]
- 情感抽取:[spot] 评价维度 [asoc] 观点类别 [text]
-以夺冠事件为例,其对应的SSI为 `[spot] 夺冠 [asoc] 夺冠事件 [asoc] 冠军 [asoc] 夺冠赛事 [text] 2月8日上午北京冬奥会自由...`。
+以夺冠事件为例,其对应的 SSI 为 `[spot] 夺冠 [asoc] 夺冠事件 [asoc] 冠军 [asoc] 夺冠赛事 [text] 2月8日上午北京冬奥会自由...`。
本次大赛在框架定义文件([seen_schema.zip](https://aistudio.baidu.com/aistudio/competition/detail/161/0/datasets))中提供了详细的抽取类别定义和模板类型,欢迎选手尝试多种多样不同的输入形式和输出形式。
@@ -151,7 +151,7 @@ python3 run_seq2struct.py \
### 快速基线第三步:使用多任务模型进行预测
该步骤将依据不同任务的抽取框架进行信息抽取,并输出到对应的文件夹中。
-首先下载[测试文件](https://aistudio.baidu.com/aistudio/competition/detail/161/0/datasets)放置在data目录下,然后使用脚本将其自动处理并预测。
+首先下载[测试文件](https://aistudio.baidu.com/aistudio/competition/detail/161/0/datasets)放置在 data 目录下,然后使用脚本将其自动处理并预测。
``` bash
python process_data.py split-test
@@ -169,7 +169,7 @@ python process_data.py merge-test
### 进阶优化,提升模型性能
本次大赛联合多个开源平台,提供大量开源数据集、免费计算资源、预训练语言模型和结构化知识图谱数据,参赛选手可以进一步构建数据集开发模型,提升模型性能。
- [千言中文开源数据集](https://aistudio.baidu.com/aistudio/index)
-- [飞桨AI Studio-人工智能学习实训社区](https://aistudio.baidu.com/aistudio/index)
+- [飞桨 AI Studio-人工智能学习实训社区](https://aistudio.baidu.com/aistudio/index)
- [PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP)
- [OpenKG 开放知识图谱社区](http://openkg.cn)
diff --git a/legacy/examples/information_extraction/DuUIE/config/multi-task-duuie.yaml b/slm/examples/information_extraction/DuUIE/config/multi-task-duuie.yaml
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/config/multi-task-duuie.yaml
rename to slm/examples/information_extraction/DuUIE/config/multi-task-duuie.yaml
diff --git a/legacy/examples/information_extraction/DuUIE/inference.py b/slm/examples/information_extraction/DuUIE/inference.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/inference.py
rename to slm/examples/information_extraction/DuUIE/inference.py
diff --git a/legacy/examples/information_extraction/DuUIE/process_data.py b/slm/examples/information_extraction/DuUIE/process_data.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/process_data.py
rename to slm/examples/information_extraction/DuUIE/process_data.py
diff --git a/legacy/examples/information_extraction/DuUIE/requirements.txt b/slm/examples/information_extraction/DuUIE/requirements.txt
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/requirements.txt
rename to slm/examples/information_extraction/DuUIE/requirements.txt
diff --git a/legacy/examples/information_extraction/DuUIE/run_seq2struct.py b/slm/examples/information_extraction/DuUIE/run_seq2struct.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/run_seq2struct.py
rename to slm/examples/information_extraction/DuUIE/run_seq2struct.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/__init__.py b/slm/examples/information_extraction/DuUIE/uie/__init__.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/__init__.py
rename to slm/examples/information_extraction/DuUIE/uie/__init__.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/evaluation/__init__.py b/slm/examples/information_extraction/DuUIE/uie/evaluation/__init__.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/evaluation/__init__.py
rename to slm/examples/information_extraction/DuUIE/uie/evaluation/__init__.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/evaluation/constants.py b/slm/examples/information_extraction/DuUIE/uie/evaluation/constants.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/evaluation/constants.py
rename to slm/examples/information_extraction/DuUIE/uie/evaluation/constants.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/evaluation/scorer.py b/slm/examples/information_extraction/DuUIE/uie/evaluation/scorer.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/evaluation/scorer.py
rename to slm/examples/information_extraction/DuUIE/uie/evaluation/scorer.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/evaluation/sel2record.py b/slm/examples/information_extraction/DuUIE/uie/evaluation/sel2record.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/evaluation/sel2record.py
rename to slm/examples/information_extraction/DuUIE/uie/evaluation/sel2record.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/seq2struct/__init__.py b/slm/examples/information_extraction/DuUIE/uie/seq2struct/__init__.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/seq2struct/__init__.py
rename to slm/examples/information_extraction/DuUIE/uie/seq2struct/__init__.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/seq2struct/data_collator.py b/slm/examples/information_extraction/DuUIE/uie/seq2struct/data_collator.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/seq2struct/data_collator.py
rename to slm/examples/information_extraction/DuUIE/uie/seq2struct/data_collator.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/seq2struct/t5_bert_tokenizer.py b/slm/examples/information_extraction/DuUIE/uie/seq2struct/t5_bert_tokenizer.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/seq2struct/t5_bert_tokenizer.py
rename to slm/examples/information_extraction/DuUIE/uie/seq2struct/t5_bert_tokenizer.py
diff --git a/legacy/examples/information_extraction/DuUIE/uie/seq2struct/utils.py b/slm/examples/information_extraction/DuUIE/uie/seq2struct/utils.py
similarity index 100%
rename from legacy/examples/information_extraction/DuUIE/uie/seq2struct/utils.py
rename to slm/examples/information_extraction/DuUIE/uie/seq2struct/utils.py
diff --git a/legacy/examples/information_extraction/msra_ner/README.md b/slm/examples/information_extraction/msra_ner/README.md
similarity index 78%
rename from legacy/examples/information_extraction/msra_ner/README.md
rename to slm/examples/information_extraction/msra_ner/README.md
index 3d9e04bf6fe7..4a046d58b4dc 100644
--- a/legacy/examples/information_extraction/msra_ner/README.md
+++ b/slm/examples/information_extraction/msra_ner/README.md
@@ -1,4 +1,4 @@
-# 使用PaddleNLP完成中文命名实体识别
+# 使用 PaddleNLP 完成中文命名实体识别
## 1. 简介
@@ -9,7 +9,7 @@ MSRA-NER 数据集由微软亚研院发布,其目标是识别文本中具有
这\002次\002代\002表\002大\002会\002是\002在\002中\002国\002改\002革\002开\002放\002和\002社\002会\002主\002义\002现\002代\002化\002建\002设\002发\002展\002的\002关\002键\002时\002刻\002召\002开\002的\002历\002史\002性\002会\002议\002。 O\002O\002O\002O\002O\002O\002O\002O\002B-LOC\002I-LOC\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O\002O
```
-PaddleNLP集成的数据集MSRA-NER数据集对文件格式做了调整:每一行文本、标签以特殊字符"\t"进行分隔,每个字之间以特殊字符"\002"分隔。
+PaddleNLP 集成的数据集 MSRA-NER 数据集对文件格式做了调整:每一行文本、标签以特殊字符"\t"进行分隔,每个字之间以特殊字符"\002"分隔。
## 快速开始
@@ -36,16 +36,16 @@ python -u ./train.py \
其中参数释义如下:
- `model_type`: 指定模型的类型,可选的有 bert、ernie、ernie-ctm。
-- `model_name_or_path`: 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer,支持[PaddleNLP Transformer API](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中除ernie-gen以外的所有模型。若使用其他系列模型,需修改脚本导入相应的Task和Tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
+- `model_name_or_path`: 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer,支持[PaddleNLP Transformer API](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 中除 ernie-gen 以外的所有模型。若使用其他系列模型,需修改脚本导入相应的 Task 和 Tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
- `dataset`: 目前支持 msra_ner 和 peoples_daily_ner 数据集。
- `max_seq_length`: 表示最大句子长度,超过该长度将被截断。
- `batch_size`: 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate`: 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate`: 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs`: 表示训练轮数。
- `logging_steps`: 表示日志打印间隔。
- `save_steps`: 表示模型保存及评估间隔。
- `output_dir`: 表示模型保存路径。
-- `device`: 训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU, 'npu'表示使用华为昇腾卡。
+- `device`: 训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU, 'npu'表示使用华为昇腾卡。
#### 多卡训练
```shell
@@ -83,7 +83,7 @@ Recall | 0.926683 |
F1 | 0.917734 |
### 模型评估
-目前支持bert类型模型,其他模型可修改为对应的Task和Tokenizer。支持msra_ner数据集。
+目前支持 bert 类型模型,其他模型可修改为对应的 Task 和 Tokenizer。支持 msra_ner 数据集。
```shell
export CUDA_VISIBLE_DEVICES=0
@@ -99,12 +99,12 @@ python -u ./eval.py \
- `model_name_or_path`: 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
- `max_seq_length`: 表示最大句子长度,超过该长度将被截断。
- `batch_size`: 表示每次迭代**每张卡**上的样本数目。
-- `use_gpu`: 是否使用GPU。
+- `use_gpu`: 是否使用 GPU。
- `init_checkpoint_path`: 模型加载路径。
### 模型预测
-目前支持bert类型模型,其他模型可修改为对应的Task和Tokenizer。支持msra_ner数据集。
+目前支持 bert 类型模型,其他模型可修改为对应的 Task 和 Tokenizer。支持 msra_ner 数据集。
```shell
export CUDA_VISIBLE_DEVICES=0
@@ -118,7 +118,7 @@ python -u ./predict.py \
### 使用其它预训练模型
-请参考[Transformer API文档](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 了解更多PaddleNLP支持的预训练模型信息,并更换`--model_name_or_path`参数即可对比其他预训练模型的效果。
+请参考[Transformer API 文档](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/index.html#transformer) 了解更多 PaddleNLP 支持的预训练模型信息,并更换`--model_name_or_path`参数即可对比其他预训练模型的效果。
## Reference
diff --git a/legacy/examples/information_extraction/msra_ner/eval.py b/slm/examples/information_extraction/msra_ner/eval.py
similarity index 100%
rename from legacy/examples/information_extraction/msra_ner/eval.py
rename to slm/examples/information_extraction/msra_ner/eval.py
diff --git a/legacy/examples/information_extraction/msra_ner/predict.py b/slm/examples/information_extraction/msra_ner/predict.py
similarity index 100%
rename from legacy/examples/information_extraction/msra_ner/predict.py
rename to slm/examples/information_extraction/msra_ner/predict.py
diff --git a/legacy/examples/information_extraction/msra_ner/train.py b/slm/examples/information_extraction/msra_ner/train.py
similarity index 100%
rename from legacy/examples/information_extraction/msra_ner/train.py
rename to slm/examples/information_extraction/msra_ner/train.py
diff --git a/legacy/examples/information_extraction/waybill_ie/README.md b/slm/examples/information_extraction/waybill_ie/README.md
similarity index 67%
rename from legacy/examples/information_extraction/waybill_ie/README.md
rename to slm/examples/information_extraction/waybill_ie/README.md
index c842c91c7242..764ad2f725ca 100644
--- a/legacy/examples/information_extraction/waybill_ie/README.md
+++ b/slm/examples/information_extraction/waybill_ie/README.md
@@ -2,7 +2,7 @@
## 简介
-本示例将通过BiGRU-CRF和ERNIE + FC两类模型,演示如何从用户提供的快递单中,抽取姓名、电话、省、市、区、详细地址等内容,形成结构化信息。辅助物流行业从业者进行有效信息的提取,从而降低客户填单的成本。
+本示例将通过 BiGRU-CRF 和 ERNIE + FC 两类模型,演示如何从用户提供的快递单中,抽取姓名、电话、省、市、区、详细地址等内容,形成结构化信息。辅助物流行业从业者进行有效信息的提取,从而降低客户填单的成本。
## 快速开始
@@ -32,27 +32,27 @@ python download.py --data_dir ./waybill_ie
| A4-B | 详细地址起始位置 | A4-I | 详细地址中间位置或结束位置 |
| O | 无关字符 | | |
-数据标注采用**BIO模式**。其中 B(begin) 表示一个标签类别的开头,比如 P-B 指的是姓名的开头;相应的,I(inside) 表示一个标签的延续。O表示Outside无关字符。更多标注模式介绍请参考[Inside–outside–beginning (tagging)](https://en.wikipedia.org/wiki/Inside%E2%80%93outside%E2%80%93beginning_(tagging))
+数据标注采用**BIO 模式**。其中 B(begin) 表示一个标签类别的开头,比如 P-B 指的是姓名的开头;相应的,I(inside) 表示一个标签的延续。O 表示 Outside 无关字符。更多标注模式介绍请参考[Inside–outside–beginning (tagging)](https://en.wikipedia.org/wiki/Inside%E2%80%93outside%E2%80%93beginning_(tagging))
### 启动训练
-本项目提供了两种模型结构,一种是BiGRU+CRF结构,另一种是ERNIE+FC结构,前者显存占用小,推理速度快;后者能够在更快收敛并取得更高的精度,但推理速度较慢。
+本项目提供了两种模型结构,一种是 BiGRU+CRF 结构,另一种是 ERNIE+FC 结构,前者显存占用小,推理速度快;后者能够在更快收敛并取得更高的精度,但推理速度较慢。
-#### 启动BiGRU + CRF训练
+#### 启动 BiGRU + CRF 训练
```bash
export CUDA_VISIBLE_DEVICES=0
python run_bigru_crf.py
```
-#### 启动ERNIE + FC训练
+#### 启动 ERNIE + FC 训练
```bash
export CUDA_VISIBLE_DEVICES=0
python run_ernie.py
```
##### 模型导出
-使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见export_model.py。静态图参数保存在output_path指定路径中。 运行方式:
+使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见 export_model.py。静态图参数保存在 output_path 指定路径中。 运行方式:
基于 `ERNIE` 的模型结构的导出方式
@@ -75,7 +75,7 @@ python export_bigru_crf_model.py --params_path bigru_crf_ckpt/model_80/model_sta
其中`params_path`是指动态图训练保存的参数路径,`output_path`是指静态图参数导出路径。
#### 模型部署
-导出模型之后,可以用于部署,deploy/python文件提供了python部署预测示例。运行方式:
+导出模型之后,可以用于部署,deploy/python 文件提供了 python 部署预测示例。运行方式:
基于 `ERNIE` 的模型
@@ -97,6 +97,6 @@ python deploy/python/predict_bigru_crf.py --model_dir ./output
## 更多详细教程请参考:
-[基于Bi-GRU+CRF的快递单信息抽取](https://aistudio.baidu.com/aistudio/projectdetail/1317771)
+[基于 Bi-GRU+CRF 的快递单信息抽取](https://aistudio.baidu.com/aistudio/projectdetail/1317771)
-[使用预训练模型ERNIE优化快递单信息抽取](https://aistudio.baidu.com/aistudio/projectdetail/1329361)
+[使用预训练模型 ERNIE 优化快递单信息抽取](https://aistudio.baidu.com/aistudio/projectdetail/1329361)
diff --git a/legacy/examples/information_extraction/waybill_ie/data.py b/slm/examples/information_extraction/waybill_ie/data.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/data.py
rename to slm/examples/information_extraction/waybill_ie/data.py
diff --git a/legacy/examples/information_extraction/waybill_ie/deploy/python/predict_bigru_crf.py b/slm/examples/information_extraction/waybill_ie/deploy/python/predict_bigru_crf.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/deploy/python/predict_bigru_crf.py
rename to slm/examples/information_extraction/waybill_ie/deploy/python/predict_bigru_crf.py
diff --git a/legacy/examples/information_extraction/waybill_ie/deploy/python/predict_ernie.py b/slm/examples/information_extraction/waybill_ie/deploy/python/predict_ernie.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/deploy/python/predict_ernie.py
rename to slm/examples/information_extraction/waybill_ie/deploy/python/predict_ernie.py
diff --git a/legacy/examples/information_extraction/waybill_ie/deploy/python/predict_ernie_crf.py b/slm/examples/information_extraction/waybill_ie/deploy/python/predict_ernie_crf.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/deploy/python/predict_ernie_crf.py
rename to slm/examples/information_extraction/waybill_ie/deploy/python/predict_ernie_crf.py
diff --git a/legacy/examples/information_extraction/waybill_ie/download.py b/slm/examples/information_extraction/waybill_ie/download.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/download.py
rename to slm/examples/information_extraction/waybill_ie/download.py
diff --git a/legacy/examples/information_extraction/waybill_ie/export_bigru_crf_model.py b/slm/examples/information_extraction/waybill_ie/export_bigru_crf_model.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/export_bigru_crf_model.py
rename to slm/examples/information_extraction/waybill_ie/export_bigru_crf_model.py
diff --git a/legacy/examples/information_extraction/waybill_ie/export_ernie_crf_model.py b/slm/examples/information_extraction/waybill_ie/export_ernie_crf_model.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/export_ernie_crf_model.py
rename to slm/examples/information_extraction/waybill_ie/export_ernie_crf_model.py
diff --git a/legacy/examples/information_extraction/waybill_ie/export_ernie_model.py b/slm/examples/information_extraction/waybill_ie/export_ernie_model.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/export_ernie_model.py
rename to slm/examples/information_extraction/waybill_ie/export_ernie_model.py
diff --git a/legacy/examples/information_extraction/waybill_ie/model.py b/slm/examples/information_extraction/waybill_ie/model.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/model.py
rename to slm/examples/information_extraction/waybill_ie/model.py
diff --git a/legacy/examples/information_extraction/waybill_ie/run_bigru_crf.py b/slm/examples/information_extraction/waybill_ie/run_bigru_crf.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/run_bigru_crf.py
rename to slm/examples/information_extraction/waybill_ie/run_bigru_crf.py
diff --git a/legacy/examples/information_extraction/waybill_ie/run_ernie.py b/slm/examples/information_extraction/waybill_ie/run_ernie.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/run_ernie.py
rename to slm/examples/information_extraction/waybill_ie/run_ernie.py
diff --git a/legacy/examples/information_extraction/waybill_ie/run_ernie_crf.py b/slm/examples/information_extraction/waybill_ie/run_ernie_crf.py
similarity index 100%
rename from legacy/examples/information_extraction/waybill_ie/run_ernie_crf.py
rename to slm/examples/information_extraction/waybill_ie/run_ernie_crf.py
diff --git a/legacy/examples/lexical_analysis/README.md b/slm/examples/lexical_analysis/README.md
similarity index 87%
rename from legacy/examples/lexical_analysis/README.md
rename to slm/examples/lexical_analysis/README.md
index 7e06b3c7fd23..c5542f83d97c 100644
--- a/legacy/examples/lexical_analysis/README.md
+++ b/slm/examples/lexical_analysis/README.md
@@ -61,8 +61,8 @@ python train.py \
- `model_save_dir`: 训练期间模型保存路径。
- `epochs`: 模型训练迭代轮数。
- `batch_size`: 表示每次迭代**每张卡**上的样本数目。
-- `device`: 训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
-- `init_checkpoint`: 模型加载路径,通过设置init_checkpoint可以启动增量训练。
+- `device`: 训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
+- `init_checkpoint`: 模型加载路径,通过设置 init_checkpoint 可以启动增量训练。
#### 多卡训练
@@ -93,7 +93,7 @@ python eval.py --data_dir ./lexical_analysis_dataset_tiny \
### 模型导出
-使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见export_model.py。静态图参数保存在`output_path`指定路径中。
+使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见 export_model.py。静态图参数保存在`output_path`指定路径中。
运行方式:
@@ -106,7 +106,7 @@ python export_model.py --data_dir=./lexical_analysis_dataset_tiny --params_path=
* `params_path`是指动态图训练保存的参数路径
* `output_path`是指静态图参数导出路径。
-导出模型之后,可以用于部署,deploy/predict.py文件提供了python部署预测示例。运行方式:
+导出模型之后,可以用于部署,deploy/predict.py 文件提供了 python 部署预测示例。运行方式:
```shell
python deploy/predict.py --model_file=infer_model/static_graph_params.pdmodel --params_file=infer_model/static_graph_params.pdiparams --data_dir lexical_analysis_dataset_tiny
@@ -131,8 +131,8 @@ python predict.py --data_dir ./lexical_analysis_dataset_tiny \
(什么, r)(是, v)(司法, n)(鉴定人, vn)
```
-### Taskflow一键预测
-可以使用PaddleNLP提供的Taskflow工具来对输入的文本进行一键分词,具体使用方法如下:
+### Taskflow 一键预测
+可以使用 PaddleNLP 提供的 Taskflow 工具来对输入的文本进行一键分词,具体使用方法如下:
```python
from paddlenlp import Taskflow
@@ -153,7 +153,7 @@ lac(["LAC是个优秀的分词工具", "三亚是一个美丽的城市"])
任务的默认路径为`$HOME/.paddlenlp/taskflow/lexical_analysis/lac/`,默认路径下包含了执行该任务需要的所有文件。
-如果希望得到定制化的分词及标注结果,用户也可以通过Taskflow来加载自定义的词法分析模型并进行预测。
+如果希望得到定制化的分词及标注结果,用户也可以通过 Taskflow 来加载自定义的词法分析模型并进行预测。
通过`task_path`指定用户自定义路径,自定义路径下的文件需要和默认路径的文件一致。
@@ -166,7 +166,7 @@ custom_task_path/
└── q2b.dic
```
-使用Taskflow加载自定义模型进行一键预测:
+使用 Taskflow 加载自定义模型进行一键预测:
```python
from paddlenlp import Taskflow
@@ -174,12 +174,12 @@ from paddlenlp import Taskflow
my_lac = Taskflow("lexical_analysis", model_path="./custom_task_path/")
```
-更多使用方法请参考[Taskflow文档](../../../docs/model_zoo/taskflow.md)。
+更多使用方法请参考[Taskflow 文档](../../../docs/model_zoo/taskflow.md)。
## 预训练模型
-如果您希望使用已经预训练好了的LAC模型完成词法分析任务,请参考:
+如果您希望使用已经预训练好了的 LAC 模型完成词法分析任务,请参考:
[Lexical Analysis of Chinese](https://github.com/baidu/lac)
-[PaddleHub分词模型](https://www.paddlepaddle.org.cn/hubdetail?name=lac&en_category=LexicalAnalysis)
+[PaddleHub 分词模型](https://www.paddlepaddle.org.cn/hubdetail?name=lac&en_category=LexicalAnalysis)
diff --git a/legacy/examples/lexical_analysis/data.py b/slm/examples/lexical_analysis/data.py
similarity index 100%
rename from legacy/examples/lexical_analysis/data.py
rename to slm/examples/lexical_analysis/data.py
diff --git a/legacy/examples/lexical_analysis/deploy/predict.py b/slm/examples/lexical_analysis/deploy/predict.py
similarity index 100%
rename from legacy/examples/lexical_analysis/deploy/predict.py
rename to slm/examples/lexical_analysis/deploy/predict.py
diff --git a/legacy/examples/lexical_analysis/download.py b/slm/examples/lexical_analysis/download.py
similarity index 100%
rename from legacy/examples/lexical_analysis/download.py
rename to slm/examples/lexical_analysis/download.py
diff --git a/legacy/examples/lexical_analysis/eval.py b/slm/examples/lexical_analysis/eval.py
similarity index 100%
rename from legacy/examples/lexical_analysis/eval.py
rename to slm/examples/lexical_analysis/eval.py
diff --git a/legacy/examples/lexical_analysis/export_model.py b/slm/examples/lexical_analysis/export_model.py
similarity index 100%
rename from legacy/examples/lexical_analysis/export_model.py
rename to slm/examples/lexical_analysis/export_model.py
diff --git a/legacy/examples/lexical_analysis/model.py b/slm/examples/lexical_analysis/model.py
similarity index 100%
rename from legacy/examples/lexical_analysis/model.py
rename to slm/examples/lexical_analysis/model.py
diff --git a/legacy/examples/lexical_analysis/predict.py b/slm/examples/lexical_analysis/predict.py
similarity index 100%
rename from legacy/examples/lexical_analysis/predict.py
rename to slm/examples/lexical_analysis/predict.py
diff --git a/legacy/examples/lexical_analysis/train.py b/slm/examples/lexical_analysis/train.py
similarity index 100%
rename from legacy/examples/lexical_analysis/train.py
rename to slm/examples/lexical_analysis/train.py
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-robust/README.md b/slm/examples/machine_reading_comprehension/DuReader-robust/README.md
similarity index 54%
rename from legacy/examples/machine_reading_comprehension/DuReader-robust/README.md
rename to slm/examples/machine_reading_comprehension/DuReader-robust/README.md
index 7d74fcf6c8ba..64e9ea40e06a 100644
--- a/legacy/examples/machine_reading_comprehension/DuReader-robust/README.md
+++ b/slm/examples/machine_reading_comprehension/DuReader-robust/README.md
@@ -3,16 +3,16 @@
# 简介
## 任务说明
-阅读理解模型的鲁棒性是衡量该技术能否在实际应用中大规模落地的重要指标之一。随着当前技术的进步,模型虽然能够在一些阅读理解测试集上取得较好的性能,但在实际应用中,这些模型所表现出的鲁棒性仍然难以令人满意。DuReader-robust数据集作为首个关注阅读理解模型鲁棒性的中文数据集,旨在考察模型在真实应用场景中的过敏感性、过稳定性以及泛化能力等问题。
+阅读理解模型的鲁棒性是衡量该技术能否在实际应用中大规模落地的重要指标之一。随着当前技术的进步,模型虽然能够在一些阅读理解测试集上取得较好的性能,但在实际应用中,这些模型所表现出的鲁棒性仍然难以令人满意。DuReader-robust 数据集作为首个关注阅读理解模型鲁棒性的中文数据集,旨在考察模型在真实应用场景中的过敏感性、过稳定性以及泛化能力等问题。
## 数据集
-DuReader-robust数据集是单篇章、抽取式阅读理解数据集,具体的任务定义为:
-对于一个给定的问题q和一个篇章p,参赛系统需要根据篇章内容,给出该问题的答案a。数据集中的每个样本,是一个三元组 ,例如:
+DuReader-robust 数据集是单篇章、抽取式阅读理解数据集,具体的任务定义为:
+对于一个给定的问题 q 和一个篇章 p,参赛系统需要根据篇章内容,给出该问题的答案 a。数据集中的每个样本,是一个三元组,例如:
**问题 q**: 乔丹打了多少个赛季
-**篇章 p**: 迈克尔.乔丹在NBA打了15个赛季。他在84年进入nba,期间在1993年10月6日第一次退役改打棒球,95年3月18日重新回归,在99年1月13日第二次退役,后于2001年10月31日复出,在03年最终退役…
+**篇章 p**: 迈克尔.乔丹在 NBA 打了15个赛季。他在84年进入 nba,期间在1993年10月6日第一次退役改打棒球,95年3月18日重新回归,在99年1月13日第二次退役,后于2001年10月31日复出,在03年最终退役…
**参考答案 a**: [‘15个’,‘15个赛季’]
@@ -22,7 +22,7 @@ DuReader-robust数据集是单篇章、抽取式阅读理解数据集,具体
### 数据准备
-为了方便开发者进行测试,我们已将数据集上传至HuggingFace。
+为了方便开发者进行测试,我们已将数据集上传至 HuggingFace。
### Fine-tune
@@ -48,9 +48,9 @@ python -m paddle.distributed.launch --gpus "0" run_du.py \
--device gpu \
```
-* `model_type`: 预训练模型的种类。如bert,ernie,roberta等。
-* `model_name_or_path`: 预训练模型的具体名称。如bert-base-chinese,roberta-wwm-ext等。或者是模型文件的本地路径。
-* `output_dir`: 保存模型checkpoint的路径。
+* `model_type`: 预训练模型的种类。如 bert,ernie,roberta 等。
+* `model_name_or_path`: 预训练模型的具体名称。如 bert-base-chinese,roberta-wwm-ext 等。或者是模型文件的本地路径。
+* `output_dir`: 保存模型 checkpoint 的路径。
* `do_train`: 是否进行训练。
* `do_predict`: 是否进行预测。
@@ -70,4 +70,4 @@ python -m paddle.distributed.launch --gpus "0" run_du.py \
评估结束后模型会自动对测试集进行预测,并将可提交的结果生成在`prediction.json`中。
-**NOTE:** 如需恢复模型训练,则model_name_or_path只需指定到文件夹名即可。如`--model_name_or_path=./tmp/dureader-robust/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型config和tokenizer的config。
+**NOTE:** 如需恢复模型训练,则 model_name_or_path 只需指定到文件夹名即可。如`--model_name_or_path=./tmp/dureader-robust/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型 config 和 tokenizer 的 config。
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-robust/args.py b/slm/examples/machine_reading_comprehension/DuReader-robust/args.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/DuReader-robust/args.py
rename to slm/examples/machine_reading_comprehension/DuReader-robust/args.py
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-robust/run_du.py b/slm/examples/machine_reading_comprehension/DuReader-robust/run_du.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/DuReader-robust/run_du.py
rename to slm/examples/machine_reading_comprehension/DuReader-robust/run_du.py
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-yesno/README.md b/slm/examples/machine_reading_comprehension/DuReader-yesno/README.md
similarity index 56%
rename from legacy/examples/machine_reading_comprehension/DuReader-yesno/README.md
rename to slm/examples/machine_reading_comprehension/DuReader-yesno/README.md
index ac95144f7cec..8b9fb211ffa2 100644
--- a/legacy/examples/machine_reading_comprehension/DuReader-yesno/README.md
+++ b/slm/examples/machine_reading_comprehension/DuReader-yesno/README.md
@@ -3,13 +3,13 @@
## 简介
### 任务说明
-机器阅读理解评测中常用的F1、EM等指标虽然能够很好的衡量抽取式模型所预测的答案和真实答案的匹配程度,但在处理观点类问题时,该类指标难以衡量模型是否真正理解答案所代表的含义,例如答案中包含的观点极性。DuReader-yesno是一个以观点极性判断为目标任务的数据集,通过引入该数据集,可以弥补抽取类数据集的不足,从而更好地评价模型的自然语言理解能力。
+机器阅读理解评测中常用的 F1、EM 等指标虽然能够很好的衡量抽取式模型所预测的答案和真实答案的匹配程度,但在处理观点类问题时,该类指标难以衡量模型是否真正理解答案所代表的含义,例如答案中包含的观点极性。DuReader-yesno 是一个以观点极性判断为目标任务的数据集,通过引入该数据集,可以弥补抽取类数据集的不足,从而更好地评价模型的自然语言理解能力。
### 数据集
该数据集的任务定义如下:
-对于一个给定的问题q、一系列相关文档D=d1, d2, …, dn,以及人工抽取答案段落摘要a,要求参评系统自动对问题q、候选文档D以及答案段落摘要a进行分析,输出每个答案段落摘要所表述的是非观点极性。其中,极性分为三类 {Yes, No, Depends}。其中:
+对于一个给定的问题 q、一系列相关文档 D=d1, d2, …, dn,以及人工抽取答案段落摘要 a,要求参评系统自动对问题 q、候选文档 D 以及答案段落摘要 a 进行分析,输出每个答案段落摘要所表述的是非观点极性。其中,极性分为三类 {Yes, No, Depends}。其中:
* Yes:肯定观点,肯定观点指的是答案给出了较为明确的肯定态度。有客观事实的从客观事实的角度出发,主观态度类的从答案的整体态度来判断。
* No:否定观点,否定观点通常指的是答案较为明确的给出了与问题相反的态度。
@@ -56,9 +56,9 @@ python -m paddle.distributed.launch --gpus "0" run_du.py \
--device gpu \
```
-* `model_type`: 预训练模型的种类。如bert,ernie,roberta等。
-* `model_name_or_path`: 预训练模型的具体名称。如bert-base-uncased,bert-large-cased等。或者是模型文件的本地路径。
-* `output_dir`: 保存模型checkpoint的路径。
+* `model_type`: 预训练模型的种类。如 bert,ernie,roberta 等。
+* `model_name_or_path`: 预训练模型的具体名称。如 bert-base-uncased,bert-large-cased 等。或者是模型文件的本地路径。
+* `output_dir`: 保存模型 checkpoint 的路径。
训练结束后模型会自动对结果进行评估,得到类似如下的输出:
@@ -67,4 +67,4 @@ accu: 0.874954
```
评估结束后模型会自动对测试集进行预测,并将可提交的结果生成在`prediction.json`中。
-**NOTE:** 如需恢复模型训练,则model_name_or_path只需指定到文件夹名即可。如`--model_name_or_path=./tmp/dureader-yesno/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型config和tokenizer的config。
+**NOTE:** 如需恢复模型训练,则 model_name_or_path 只需指定到文件夹名即可。如`--model_name_or_path=./tmp/dureader-yesno/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型 config 和 tokenizer 的 config。
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-yesno/args.py b/slm/examples/machine_reading_comprehension/DuReader-yesno/args.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/DuReader-yesno/args.py
rename to slm/examples/machine_reading_comprehension/DuReader-yesno/args.py
diff --git a/legacy/examples/machine_reading_comprehension/DuReader-yesno/run_du.py b/slm/examples/machine_reading_comprehension/DuReader-yesno/run_du.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/DuReader-yesno/run_du.py
rename to slm/examples/machine_reading_comprehension/DuReader-yesno/run_du.py
diff --git a/legacy/examples/machine_reading_comprehension/SQuAD/README.md b/slm/examples/machine_reading_comprehension/SQuAD/README.md
similarity index 75%
rename from legacy/examples/machine_reading_comprehension/SQuAD/README.md
rename to slm/examples/machine_reading_comprehension/SQuAD/README.md
index 537453318acd..1afb2b027e56 100644
--- a/legacy/examples/machine_reading_comprehension/SQuAD/README.md
+++ b/slm/examples/machine_reading_comprehension/SQuAD/README.md
@@ -3,7 +3,7 @@
## 简介
### 任务说明
-本文主要介绍基于Bert预训练模型的SQuAD(Stanford Question Answering Dataset)数据集的阅读理解任务,给定一篇文章和一个问题,计算答案在文章中的起始位置和结束位置。对于SQuAD2.0数据集,还可以返回答案在文章中不存在的概率。
+本文主要介绍基于 Bert 预训练模型的 SQuAD(Stanford Question Answering Dataset)数据集的阅读理解任务,给定一篇文章和一个问题,计算答案在文章中的起始位置和结束位置。对于 SQuAD2.0数据集,还可以返回答案在文章中不存在的概率。
### 数据集
@@ -22,7 +22,7 @@ SQuAD v2.0
### 数据准备
-为了方便开发者进行测试,我们使用了HuggingFace的数据集,用户可以通过命令行传入`--version_2_with_negative`控制所需要的SQuAD数据集版本。
+为了方便开发者进行测试,我们使用了 HuggingFace 的数据集,用户可以通过命令行传入`--version_2_with_negative`控制所需要的 SQuAD 数据集版本。
### Fine-tune
@@ -47,9 +47,9 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
--do_predict
```
-* `model_type`: 预训练模型的种类。如bert,ernie,roberta等。
-* `model_name_or_path`: 预训练模型的具体名称。如bert-base-uncased,bert-large-cased等。或者是模型文件的本地路径。
-* `output_dir`: 保存模型checkpoint的路径。
+* `model_type`: 预训练模型的种类。如 bert,ernie,roberta 等。
+* `model_name_or_path`: 预训练模型的具体名称。如 bert-base-uncased,bert-large-cased 等。或者是模型文件的本地路径。
+* `output_dir`: 保存模型 checkpoint 的路径。
* `do_train`: 是否进行训练。
* `do_predict`: 是否进行预测。
@@ -88,7 +88,7 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
--version_2_with_negative
```
-* `version_2_with_negative`: 使用squad2.0数据集和评价指标的标志。
+* `version_2_with_negative`: 使用 squad2.0数据集和评价指标的标志。
训练结束后会在模型会自动对结果进行评估,得到类似如下的输出:
@@ -113,11 +113,11 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
其中会输出 `best_f1_thresh` 是最佳阈值,可以使用这个阈值重新训练,或者从 `all_nbest_json`变量中获取最终 `prediction`。
训练方法与前面大体相同,只需要设定 `--null_score_diff_threshold` 参数的值为测评时输出的 `best_f1_thresh` ,通常这个值在 -1.0 到 -5.0 之间。
-**NOTE:** 如需恢复模型训练,则model_name_or_path只需指定到文件夹名即可。如`--model_name_or_path=./tmp/squad/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型config和tokenizer的config。
+**NOTE:** 如需恢复模型训练,则 model_name_or_path 只需指定到文件夹名即可。如`--model_name_or_path=./tmp/squad/model_19000/`,程序会自动加载模型参数`/model_state.pdparams`,也会自动加载词表,模型 config 和 tokenizer 的 config。
### 预测
-如需使用训练好的模型预测并输出结果,需将自己的数据集改成SQuAD格式(以下示例为SQuAD2.0)。
+如需使用训练好的模型预测并输出结果,需将自己的数据集改成 SQuAD 格式(以下示例为 SQuAD2.0)。
```text
{"data": [{'title': 'Beyoncé',
@@ -151,7 +151,7 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
--version_2_with_negative
```
-即可完成预测,预测的答案保存在`prediction.json`中。数据格式如下所示,左边的id与输入中的id对应。
+即可完成预测,预测的答案保存在`prediction.json`中。数据格式如下所示,左边的 id 与输入中的 id 对应。
```text
{
@@ -162,7 +162,7 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
### 静态图预测
-在Fine-tune完成后,我们可以使用如下方式导出希望用来预测的模型:
+在 Fine-tune 完成后,我们可以使用如下方式导出希望用来预测的模型:
```shell
python -u ./export_model.py \
@@ -172,9 +172,9 @@ python -u ./export_model.py \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_path` 表示训练模型的保存路径,与训练时的`output_dir`一致。
-- `output_path` 表示导出预测模型文件的前缀。保存时会添加后缀(`pdiparams`,`pdiparams.info`,`pdmodel`);除此之外,还会在`output_path`包含的目录下保存tokenizer相关内容。
+- `output_path` 表示导出预测模型文件的前缀。保存时会添加后缀(`pdiparams`,`pdiparams.info`,`pdmodel`);除此之外,还会在`output_path`包含的目录下保存 tokenizer 相关内容。
然后按照如下的方式对阅读理解任务进行预测:
@@ -187,9 +187,9 @@ python -u deploy/python/predict.py \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_name_or_path` 表示预测模型文件的前缀,和上一步导出预测模型中的`output_path`一致。
- `batch_size` 表示每个预测批次的样本数目。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断,和训练时一致。
-以上命令将在SQuAD v1.1的验证集上进行预测。此外,同训练时一样,用户可以通过命令行传入`--version_2_with_negative`控制所需要的SQuAD数据集版本。
+以上命令将在 SQuAD v1.1的验证集上进行预测。此外,同训练时一样,用户可以通过命令行传入`--version_2_with_negative`控制所需要的 SQuAD 数据集版本。
diff --git a/legacy/examples/machine_reading_comprehension/SQuAD/args.py b/slm/examples/machine_reading_comprehension/SQuAD/args.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/SQuAD/args.py
rename to slm/examples/machine_reading_comprehension/SQuAD/args.py
diff --git a/legacy/examples/machine_reading_comprehension/SQuAD/deploy/python/predict.py b/slm/examples/machine_reading_comprehension/SQuAD/deploy/python/predict.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/SQuAD/deploy/python/predict.py
rename to slm/examples/machine_reading_comprehension/SQuAD/deploy/python/predict.py
diff --git a/legacy/examples/machine_reading_comprehension/SQuAD/export_model.py b/slm/examples/machine_reading_comprehension/SQuAD/export_model.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/SQuAD/export_model.py
rename to slm/examples/machine_reading_comprehension/SQuAD/export_model.py
diff --git a/legacy/examples/machine_reading_comprehension/SQuAD/run_squad.py b/slm/examples/machine_reading_comprehension/SQuAD/run_squad.py
similarity index 100%
rename from legacy/examples/machine_reading_comprehension/SQuAD/run_squad.py
rename to slm/examples/machine_reading_comprehension/SQuAD/run_squad.py
diff --git a/legacy/examples/machine_translation/README.md b/slm/examples/machine_translation/README.md
similarity index 100%
rename from legacy/examples/machine_translation/README.md
rename to slm/examples/machine_translation/README.md
diff --git a/legacy/examples/machine_translation/preprocessor/prepare-iwslt14.sh b/slm/examples/machine_translation/preprocessor/prepare-iwslt14.sh
similarity index 100%
rename from legacy/examples/machine_translation/preprocessor/prepare-iwslt14.sh
rename to slm/examples/machine_translation/preprocessor/prepare-iwslt14.sh
diff --git a/legacy/examples/machine_translation/preprocessor/prepare-wmt14en2de.sh b/slm/examples/machine_translation/preprocessor/prepare-wmt14en2de.sh
similarity index 100%
rename from legacy/examples/machine_translation/preprocessor/prepare-wmt14en2de.sh
rename to slm/examples/machine_translation/preprocessor/prepare-wmt14en2de.sh
diff --git a/legacy/examples/machine_translation/preprocessor/prepare-wmt14en2fr.sh b/slm/examples/machine_translation/preprocessor/prepare-wmt14en2fr.sh
similarity index 100%
rename from legacy/examples/machine_translation/preprocessor/prepare-wmt14en2fr.sh
rename to slm/examples/machine_translation/preprocessor/prepare-wmt14en2fr.sh
diff --git a/legacy/examples/machine_translation/preprocessor/preprocessor.py b/slm/examples/machine_translation/preprocessor/preprocessor.py
similarity index 100%
rename from legacy/examples/machine_translation/preprocessor/preprocessor.py
rename to slm/examples/machine_translation/preprocessor/preprocessor.py
diff --git a/legacy/examples/machine_translation/requirements.txt b/slm/examples/machine_translation/requirements.txt
similarity index 100%
rename from legacy/examples/machine_translation/requirements.txt
rename to slm/examples/machine_translation/requirements.txt
diff --git a/legacy/examples/machine_translation/seq2seq/README.md b/slm/examples/machine_translation/seq2seq/README.md
similarity index 61%
rename from legacy/examples/machine_translation/seq2seq/README.md
rename to slm/examples/machine_translation/seq2seq/README.md
index 2f271dfb6b4f..f66605c528e9 100644
--- a/legacy/examples/machine_translation/seq2seq/README.md
+++ b/slm/examples/machine_translation/seq2seq/README.md
@@ -18,24 +18,24 @@
## 简介
-Sequence to Sequence (Seq2Seq),使用编码器-解码器(Encoder-Decoder)结构,用编码器将源序列编码成vector,再用解码器将该vector解码为目标序列。Seq2Seq 广泛应用于机器翻译,自动对话机器人,文档摘要自动生成,图片描述自动生成等任务中。
+Sequence to Sequence (Seq2Seq),使用编码器-解码器(Encoder-Decoder)结构,用编码器将源序列编码成 vector,再用解码器将该 vector 解码为目标序列。Seq2Seq 广泛应用于机器翻译,自动对话机器人,文档摘要自动生成,图片描述自动生成等任务中。
-本目录包含Seq2Seq的一个经典样例:机器翻译,带Attention机制的翻译模型。Seq2Seq翻译模型,模拟了人类在进行翻译类任务时的行为:先解析源语言,理解其含义,再根据该含义来写出目标语言的语句。更多关于机器翻译的具体原理和数学表达式,我们推荐参考飞桨官网[机器翻译案例](https://www.paddlepaddle.org.cn/documentation/docs/zh/user_guides/nlp_case/machine_translation/README.cn.html)。
+本目录包含 Seq2Seq 的一个经典样例:机器翻译,带 Attention 机制的翻译模型。Seq2Seq 翻译模型,模拟了人类在进行翻译类任务时的行为:先解析源语言,理解其含义,再根据该含义来写出目标语言的语句。更多关于机器翻译的具体原理和数学表达式,我们推荐参考飞桨官网[机器翻译案例](https://www.paddlepaddle.org.cn/documentation/docs/zh/user_guides/nlp_case/machine_translation/README.cn.html)。
## 模型概览
-本模型中,在编码器方面,我们采用了基于LSTM的多层的RNN encoder;在解码器方面,我们使用了带注意力(Attention)机制的RNN decoder,在预测时我们使用柱搜索(beam search)算法来生成翻译的目标语句。
+本模型中,在编码器方面,我们采用了基于 LSTM 的多层的 RNN encoder;在解码器方面,我们使用了带注意力(Attention)机制的 RNN decoder,在预测时我们使用柱搜索(beam search)算法来生成翻译的目标语句。
## 数据介绍
本教程使用[IWSLT'15 English-Vietnamese data ](https://nlp.stanford.edu/projects/nmt/)数据集中的英语到越南语的数据作为训练语料,tst2012的数据作为开发集,tst2013的数据作为测试集。
### 数据获取
-如果用户在初始化数据集时没有提供路径,数据集会自动下载到`paddlenlp.utils.env.DATA_HOME`的`IWSLT15/`路径下,例如在linux系统下,默认存储路径是`~/.paddlenlp/datasets/IWSLT15`。
+如果用户在初始化数据集时没有提供路径,数据集会自动下载到`paddlenlp.utils.env.DATA_HOME`的`IWSLT15/`路径下,例如在 linux 系统下,默认存储路径是`~/.paddlenlp/datasets/IWSLT15`。
## 模型训练
-执行以下命令即可训练带有注意力机制的Seq2Seq机器翻译模型:
+执行以下命令即可训练带有注意力机制的 Seq2Seq 机器翻译模型:
```sh
python train.py \
@@ -49,13 +49,13 @@ python train.py \
--model_path ./attention_models
```
-各参数的具体说明请参阅 `args.py` 。训练程序会在每个epoch训练结束之后,save一次模型。
+各参数的具体说明请参阅 `args.py` 。训练程序会在每个 epoch 训练结束之后,save 一次模型。
**NOTE:** 如需恢复模型训练,则`init_from_ckpt`只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=attention_models/5`即可,程序会自动加载模型参数`attention_models/5.pdparams`,也会自动加载优化器状态`attention_models/5.pdopt`。
## 模型预测
-训练完成之后,可以使用保存的模型(由 `--init_from_ckpt` 指定)对测试集的数据集进行beam search解码。生成的翻译结果位于`--infer_output_file`指定的路径,预测命令如下:
+训练完成之后,可以使用保存的模型(由 `--init_from_ckpt` 指定)对测试集的数据集进行 beam search 解码。生成的翻译结果位于`--infer_output_file`指定的路径,预测命令如下:
```sh
python predict.py \
@@ -74,7 +74,7 @@ python predict.py \
各参数的具体说明请参阅 `args.py` ,注意预测时所用模型超参数需和训练时一致。
## 预测效果评价
-取第10个epoch的结果,用取beam_size为10的beam search解码,`predict.py`脚本在生成翻译结果之后,会调用`paddlenlp.metrics.BLEU`计算翻译结果的BLEU指标,最终计算出的BLEU分数为0.24329954822714048
+取第10个 epoch 的结果,用取 beam_size 为10的 beam search 解码,`predict.py`脚本在生成翻译结果之后,会调用`paddlenlp.metrics.BLEU`计算翻译结果的 BLEU 指标,最终计算出的 BLEU 分数为0.24329954822714048
## 保存预测模型
这里指定的参数`export_path` 表示导出预测模型文件的前缀。保存时会添加后缀(`pdiparams`,`pdiparams.info`,`pdmodel`)。
@@ -92,7 +92,7 @@ python export_model.py \
```
## 基于预测引擎推理
-然后按照如下的方式对IWSLT15数据集中的测试集(有标注的)进行预测(基于Paddle的[Python预测API](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/python_infer_cn.html)):
+然后按照如下的方式对 IWSLT15数据集中的测试集(有标注的)进行预测(基于 Paddle 的[Python 预测 API](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/python_infer_cn.html)):
```shell
cd deploy/python
diff --git a/legacy/examples/machine_translation/seq2seq/args.py b/slm/examples/machine_translation/seq2seq/args.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/args.py
rename to slm/examples/machine_translation/seq2seq/args.py
diff --git a/legacy/examples/machine_translation/seq2seq/data.py b/slm/examples/machine_translation/seq2seq/data.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/data.py
rename to slm/examples/machine_translation/seq2seq/data.py
diff --git a/legacy/examples/machine_translation/seq2seq/deploy/python/infer.py b/slm/examples/machine_translation/seq2seq/deploy/python/infer.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/deploy/python/infer.py
rename to slm/examples/machine_translation/seq2seq/deploy/python/infer.py
diff --git a/legacy/examples/machine_translation/seq2seq/export_model.py b/slm/examples/machine_translation/seq2seq/export_model.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/export_model.py
rename to slm/examples/machine_translation/seq2seq/export_model.py
diff --git a/legacy/examples/machine_translation/seq2seq/predict.py b/slm/examples/machine_translation/seq2seq/predict.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/predict.py
rename to slm/examples/machine_translation/seq2seq/predict.py
diff --git a/legacy/examples/machine_translation/seq2seq/seq2seq_attn.py b/slm/examples/machine_translation/seq2seq/seq2seq_attn.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/seq2seq_attn.py
rename to slm/examples/machine_translation/seq2seq/seq2seq_attn.py
diff --git a/legacy/examples/machine_translation/seq2seq/train.py b/slm/examples/machine_translation/seq2seq/train.py
similarity index 100%
rename from legacy/examples/machine_translation/seq2seq/train.py
rename to slm/examples/machine_translation/seq2seq/train.py
diff --git a/legacy/examples/machine_translation/transformer/README.md b/slm/examples/machine_translation/transformer/README.md
similarity index 99%
rename from legacy/examples/machine_translation/transformer/README.md
rename to slm/examples/machine_translation/transformer/README.md
index 0523cdf7dbbc..dc34d9524d8e 100644
--- a/legacy/examples/machine_translation/transformer/README.md
+++ b/slm/examples/machine_translation/transformer/README.md
@@ -12,7 +12,7 @@ Transformer 是论文 [Attention Is All You Need](https://arxiv.org/abs/1706.037
图 1. Transformer 网络结构图
-相较于此前 Seq2Seq 模型中广泛使用的循环神经网络(Recurrent Neural Network, RNN),使用Self Attention进行输入序列到输出序列的变换主要具有以下优势:
+相较于此前 Seq2Seq 模型中广泛使用的循环神经网络(Recurrent Neural Network, RNN),使用 Self Attention 进行输入序列到输出序列的变换主要具有以下优势:
- 计算复杂度小
- 特征维度为 d 、长度为 n 的序列,在 RNN 中计算复杂度为 `O(n * d * d)` (n 个时间步,每个时间步计算 d 维的矩阵向量乘法),在 Self-Attention 中计算复杂度为 `O(n * n * d)` (n 个时间步两两计算 d 维的向量点积或其他相关度函数),n 通常要小于 d 。
diff --git a/legacy/examples/machine_translation/transformer/configs/transformer.base.yaml b/slm/examples/machine_translation/transformer/configs/transformer.base.yaml
similarity index 100%
rename from legacy/examples/machine_translation/transformer/configs/transformer.base.yaml
rename to slm/examples/machine_translation/transformer/configs/transformer.base.yaml
diff --git a/legacy/examples/machine_translation/transformer/configs/transformer.big.yaml b/slm/examples/machine_translation/transformer/configs/transformer.big.yaml
similarity index 100%
rename from legacy/examples/machine_translation/transformer/configs/transformer.big.yaml
rename to slm/examples/machine_translation/transformer/configs/transformer.big.yaml
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/CMakeLists.txt b/slm/examples/machine_translation/transformer/deploy/cpp/CMakeLists.txt
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/CMakeLists.txt
rename to slm/examples/machine_translation/transformer/deploy/cpp/CMakeLists.txt
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/README.md b/slm/examples/machine_translation/transformer/deploy/cpp/README.md
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/README.md
rename to slm/examples/machine_translation/transformer/deploy/cpp/README.md
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/helper.h b/slm/examples/machine_translation/transformer/deploy/cpp/helper.h
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/helper.h
rename to slm/examples/machine_translation/transformer/deploy/cpp/helper.h
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/run.sh b/slm/examples/machine_translation/transformer/deploy/cpp/run.sh
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/run.sh
rename to slm/examples/machine_translation/transformer/deploy/cpp/run.sh
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/run_impl.sh b/slm/examples/machine_translation/transformer/deploy/cpp/run_impl.sh
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/run_impl.sh
rename to slm/examples/machine_translation/transformer/deploy/cpp/run_impl.sh
diff --git a/legacy/examples/machine_translation/transformer/deploy/cpp/transformer_e2e.cc b/slm/examples/machine_translation/transformer/deploy/cpp/transformer_e2e.cc
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/cpp/transformer_e2e.cc
rename to slm/examples/machine_translation/transformer/deploy/cpp/transformer_e2e.cc
diff --git a/legacy/examples/machine_translation/transformer/deploy/python/README.md b/slm/examples/machine_translation/transformer/deploy/python/README.md
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/python/README.md
rename to slm/examples/machine_translation/transformer/deploy/python/README.md
diff --git a/legacy/examples/machine_translation/transformer/deploy/python/benchmark.sh b/slm/examples/machine_translation/transformer/deploy/python/benchmark.sh
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/python/benchmark.sh
rename to slm/examples/machine_translation/transformer/deploy/python/benchmark.sh
diff --git a/legacy/examples/machine_translation/transformer/deploy/python/inference.py b/slm/examples/machine_translation/transformer/deploy/python/inference.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/python/inference.py
rename to slm/examples/machine_translation/transformer/deploy/python/inference.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/python/tls/benchmark_utils.py b/slm/examples/machine_translation/transformer/deploy/python/tls/benchmark_utils.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/python/tls/benchmark_utils.py
rename to slm/examples/machine_translation/transformer/deploy/python/tls/benchmark_utils.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/python/tls/recorder.py b/slm/examples/machine_translation/transformer/deploy/python/tls/recorder.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/python/tls/recorder.py
rename to slm/examples/machine_translation/transformer/deploy/python/tls/recorder.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/README.md b/slm/examples/machine_translation/transformer/deploy/serving/README.md
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/README.md
rename to slm/examples/machine_translation/transformer/deploy/serving/README.md
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/benchmark.py b/slm/examples/machine_translation/transformer/deploy/serving/benchmark.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/benchmark.py
rename to slm/examples/machine_translation/transformer/deploy/serving/benchmark.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/benchmark_serving.sh b/slm/examples/machine_translation/transformer/deploy/serving/benchmark_serving.sh
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/benchmark_serving.sh
rename to slm/examples/machine_translation/transformer/deploy/serving/benchmark_serving.sh
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/export_serving_model.py b/slm/examples/machine_translation/transformer/deploy/serving/export_serving_model.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/export_serving_model.py
rename to slm/examples/machine_translation/transformer/deploy/serving/export_serving_model.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/transformer_reader.py b/slm/examples/machine_translation/transformer/deploy/serving/transformer_reader.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/transformer_reader.py
rename to slm/examples/machine_translation/transformer/deploy/serving/transformer_reader.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/transformer_web_client.py b/slm/examples/machine_translation/transformer/deploy/serving/transformer_web_client.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/transformer_web_client.py
rename to slm/examples/machine_translation/transformer/deploy/serving/transformer_web_client.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/transformer_web_server.py b/slm/examples/machine_translation/transformer/deploy/serving/transformer_web_server.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/transformer_web_server.py
rename to slm/examples/machine_translation/transformer/deploy/serving/transformer_web_server.py
diff --git a/legacy/examples/machine_translation/transformer/deploy/serving/utils/recorder.py b/slm/examples/machine_translation/transformer/deploy/serving/utils/recorder.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/deploy/serving/utils/recorder.py
rename to slm/examples/machine_translation/transformer/deploy/serving/utils/recorder.py
diff --git a/legacy/examples/machine_translation/transformer/export_model.py b/slm/examples/machine_translation/transformer/export_model.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/export_model.py
rename to slm/examples/machine_translation/transformer/export_model.py
diff --git a/legacy/examples/machine_translation/transformer/images/multi_head_attention.png b/slm/examples/machine_translation/transformer/images/multi_head_attention.png
similarity index 100%
rename from legacy/examples/machine_translation/transformer/images/multi_head_attention.png
rename to slm/examples/machine_translation/transformer/images/multi_head_attention.png
diff --git a/legacy/examples/machine_translation/transformer/images/transformer_network.png b/slm/examples/machine_translation/transformer/images/transformer_network.png
similarity index 100%
rename from legacy/examples/machine_translation/transformer/images/transformer_network.png
rename to slm/examples/machine_translation/transformer/images/transformer_network.png
diff --git a/legacy/examples/machine_translation/transformer/predict.py b/slm/examples/machine_translation/transformer/predict.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/predict.py
rename to slm/examples/machine_translation/transformer/predict.py
diff --git a/legacy/examples/machine_translation/transformer/reader.py b/slm/examples/machine_translation/transformer/reader.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/reader.py
rename to slm/examples/machine_translation/transformer/reader.py
diff --git a/legacy/examples/machine_translation/transformer/static/predict.py b/slm/examples/machine_translation/transformer/static/predict.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/static/predict.py
rename to slm/examples/machine_translation/transformer/static/predict.py
diff --git a/legacy/examples/machine_translation/transformer/static/train.py b/slm/examples/machine_translation/transformer/static/train.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/static/train.py
rename to slm/examples/machine_translation/transformer/static/train.py
diff --git a/slm/examples/machine_translation/transformer/tls/distributed_utils.py b/slm/examples/machine_translation/transformer/tls/distributed_utils.py
new file mode 100644
index 000000000000..67a9ae4c7cee
--- /dev/null
+++ b/slm/examples/machine_translation/transformer/tls/distributed_utils.py
@@ -0,0 +1,33 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import paddle
+import paddle.distributed as dist
+
+
+def all_gather_tokens(data):
+ """Gathers num of tokens from all nodes.
+ `data` should be a tensor of num of tokens.
+ """
+ if dist.get_world_size() < 2:
+ return data
+ if not hasattr(all_gather_tokens, "_in_buffer") or all_gather_tokens._in_buffer is None:
+ all_gather_tokens._in_buffer = data
+ all_gather_tokens._out_buffers = []
+ in_buffer = all_gather_tokens._in_buffer
+ out_buffers = all_gather_tokens._out_buffers
+
+ dist.all_gather(out_buffers, in_buffer)
+
+ return paddle.add_n(out_buffers)
diff --git a/legacy/examples/machine_translation/transformer/tls/record.py b/slm/examples/machine_translation/transformer/tls/record.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/tls/record.py
rename to slm/examples/machine_translation/transformer/tls/record.py
diff --git a/legacy/examples/machine_translation/transformer/tls/to_static.py b/slm/examples/machine_translation/transformer/tls/to_static.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/tls/to_static.py
rename to slm/examples/machine_translation/transformer/tls/to_static.py
diff --git a/legacy/examples/machine_translation/transformer/train.py b/slm/examples/machine_translation/transformer/train.py
similarity index 100%
rename from legacy/examples/machine_translation/transformer/train.py
rename to slm/examples/machine_translation/transformer/train.py
diff --git a/legacy/examples/model_compression/distill_lstm/README.md b/slm/examples/model_compression/distill_lstm/README.md
similarity index 58%
rename from legacy/examples/model_compression/distill_lstm/README.md
rename to slm/examples/model_compression/distill_lstm/README.md
index f400a1e566f9..667145c79279 100644
--- a/legacy/examples/model_compression/distill_lstm/README.md
+++ b/slm/examples/model_compression/distill_lstm/README.md
@@ -12,43 +12,43 @@
```
## 简介
-本目录下的实验是将特定任务下BERT模型的知识蒸馏到基于Bi-LSTM的小模型中,主要参考论文 [Distilling Task-Specific Knowledge from BERT into Simple Neural Networks](https://arxiv.org/abs/1903.12136)实现。
+本目录下的实验是将特定任务下 BERT 模型的知识蒸馏到基于 Bi-LSTM 的小模型中,主要参考论文 [Distilling Task-Specific Knowledge from BERT into Simple Neural Networks](https://arxiv.org/abs/1903.12136)实现。
-在模型蒸馏中,较大的模型(在本例中是BERT)通常被称为教师模型,较小的模型(在本例中是Bi-LSTM)通常被称为学生模型。知识的蒸馏通常是通过模型学习蒸馏相关的损失函数实现,在本实验中,损失函数是均方误差损失函数,传入函数的两个参数分别是学生模型的输出和教师模型的输出。
+在模型蒸馏中,较大的模型(在本例中是 BERT)通常被称为教师模型,较小的模型(在本例中是 Bi-LSTM)通常被称为学生模型。知识的蒸馏通常是通过模型学习蒸馏相关的损失函数实现,在本实验中,损失函数是均方误差损失函数,传入函数的两个参数分别是学生模型的输出和教师模型的输出。
在[论文](https://arxiv.org/abs/1903.12136)的模型蒸馏阶段,作者为了能让教师模型表达出更多的知识供学生模型学习,对训练数据进行了数据增强。作者使用了三种数据增强方式,分别是:
-1. Masking,即以一定的概率将原数据中的word token替换成`[MASK]`;
+1. Masking,即以一定的概率将原数据中的 word token 替换成`[MASK]`;
-2. POS—guided word replacement,即以一定的概率将原数据中的词用与其有相同POS tag的词替换;
+2. POS—guided word replacement,即以一定的概率将原数据中的词用与其有相同 POS tag 的词替换;
-3. n-gram sampling,即以一定的概率,从每条数据中采样n-gram,其中n的范围可通过人工设置。
+3. n-gram sampling,即以一定的概率,从每条数据中采样 n-gram,其中 n 的范围可通过人工设置。
通过数据增强,可以产生更多无标签的训练数据,在训练过程中,学生模型可借助教师模型的“暗知识”,在更大的数据集上进行训练,产生更好的蒸馏效果。需要指出的是,实验只使用了第1和第3种数据增强方式。
-在英文数据集任务上,本文使用了Google News语料[预训练的Word Embedding](https://code.google.com/archive/p/word2vec/)初始化小模型的Embedding层。
+在英文数据集任务上,本文使用了 Google News 语料[预训练的 Word Embedding](https://code.google.com/archive/p/word2vec/)初始化小模型的 Embedding 层。
-本实验分为三个训练过程:在特定任务上对BERT的fine-tuning、在特定任务上对基于Bi-LSTM的小模型的训练(用于评价蒸馏效果)、将BERT模型的知识蒸馏到基于Bi-LSTM的小模型上。
+本实验分为三个训练过程:在特定任务上对 BERT 的 fine-tuning、在特定任务上对基于 Bi-LSTM 的小模型的训练(用于评价蒸馏效果)、将 BERT 模型的知识蒸馏到基于 Bi-LSTM 的小模型上。
## 数据、预训练模型介绍及获取
-本实验使用GLUE中的SST-2、QQP以及中文情感分类数据集ChnSentiCorp中的训练集作为训练语料,用数据集中的验证集评估模型的效果。运行本目录下的实验,数据集会被自动下载到`paddlenlp.utils.env.DATA_HOME` 路径下,例如在linux系统下,例如对于GLUE中的QQP数据集,默认存储路径是`~/.paddlenlp/datasets/glue/QQP`,对于ChnSentiCorp数据集,则会下载到 `~/.paddlenlp/datasets/chnsenticorp`。
+本实验使用 GLUE 中的 SST-2、QQP 以及中文情感分类数据集 ChnSentiCorp 中的训练集作为训练语料,用数据集中的验证集评估模型的效果。运行本目录下的实验,数据集会被自动下载到`paddlenlp.utils.env.DATA_HOME` 路径下,例如在 linux 系统下,例如对于 GLUE 中的 QQP 数据集,默认存储路径是`~/.paddlenlp/datasets/glue/QQP`,对于 ChnSentiCorp 数据集,则会下载到 `~/.paddlenlp/datasets/chnsenticorp`。
-对于BERT的fine-tuning任务,本实验中使用了预训练模型`bert-bas-uncased`、`bert-wwm-ext-chinese`、`bert-base-chinese`。同样,这几个模型在训练时会被自动下载到`paddlenlp.utils.env.MODEL_HOME`路径下。例如,对于`bert-base-uncased`模型,在linux系统下,会被下载到`~/.paddlenlp/models/bert-base-uncased`下。
+对于 BERT 的 fine-tuning 任务,本实验中使用了预训练模型`bert-bas-uncased`、`bert-wwm-ext-chinese`、`bert-base-chinese`。同样,这几个模型在训练时会被自动下载到`paddlenlp.utils.env.MODEL_HOME`路径下。例如,对于`bert-base-uncased`模型,在 linux 系统下,会被下载到`~/.paddlenlp/models/bert-base-uncased`下。
-在中文数据集上的小模型训练的输入利用jieba分词,其中词表同本repo下[文本分类项目](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_classification/rnn)的词表,可通过运行以下命令进行下载:
+在中文数据集上的小模型训练的输入利用 jieba 分词,其中词表同本 repo 下[文本分类项目](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_classification/rnn)的词表,可通过运行以下命令进行下载:
```shell
wget https://bj.bcebos.com/paddlenlp/data/senta_word_dict.txt
```
-为了节省显存和运行时间,可以对ChnSentiCorp中未出现的词先进行过滤,并将最后的词表文件名和词表大小配置在下面的参数中。
+为了节省显存和运行时间,可以对 ChnSentiCorp 中未出现的词先进行过滤,并将最后的词表文件名和词表大小配置在下面的参数中。
## 蒸馏实验过程
-### 训练BERT fine-tuning模型
-训练BERT的fine-tuning模型,可以去本repo下example中的[glue目录](../../benchmark/glue)下。关于glue的更多详细说明,可见glue目录下的README文档。
+### 训练 BERT fine-tuning 模型
+训练 BERT 的 fine-tuning 模型,可以去本 repo 下 example 中的[glue 目录](../../benchmark/glue)下。关于 glue 的更多详细说明,可见 glue 目录下的 README 文档。
-以GLUE的SST-2任务为例,调用BERT fine-tune的训练脚本,配置如下的参数,训练SST-2任务:
+以 GLUE 的 SST-2任务为例,调用 BERT fine-tune 的训练脚本,配置如下的参数,训练 SST-2任务:
```shell
cd ../../benchmark/glue
@@ -69,14 +69,14 @@ python -u ./run_glue.py \
```
-如果需要训练基于ChnSentiCorp数据集的BERT finetuning模型,可以进入[文本分类目录](../../text_classification/pretrained_models)下,将预训练模型改成BERT,并基于bert-base-chinese和bert-wwm-ext-chinese模型进行fine-tuning训练。
+如果需要训练基于 ChnSentiCorp 数据集的 BERT finetuning 模型,可以进入[文本分类目录](../../text_classification/pretrained_models)下,将预训练模型改成 BERT,并基于 bert-base-chinese 和 bert-wwm-ext-chinese 模型进行 fine-tuning 训练。
训练完成之后,可将训练效果最好的模型保存在本项目下的`pretrained_models/$TASK_NAME/`下。模型目录下有`model_config.json`, `model_state.pdparams`, `tokenizer_config.json`及`vocab.txt`这几个文件。
### 训练小模型
-尝试运行下面的脚本可以分别基于ChnSentiCorp、SST-2、QQP数据集对基于BiLSTM的小模型进行训练。
+尝试运行下面的脚本可以分别基于 ChnSentiCorp、SST-2、QQP 数据集对基于 BiLSTM 的小模型进行训练。
```shell
@@ -124,7 +124,7 @@ CUDA_VISIBLE_DEVICES=0 python small.py \
```
### 蒸馏模型
-这一步是将教师模型BERT的知识蒸馏到基于BiLSTM的学生模型中,可以运行下面的命令分别基于ChnSentiCorp、SST-2、QQP数据集对基于BiLSTM的学生模型进行蒸馏。
+这一步是将教师模型 BERT 的知识蒸馏到基于 BiLSTM 的学生模型中,可以运行下面的命令分别基于 ChnSentiCorp、SST-2、QQP 数据集对基于 BiLSTM 的学生模型进行蒸馏。
```shell
CUDA_VISIBLE_DEVICES=0 python bert_distill.py \
@@ -180,7 +180,7 @@ CUDA_VISIBLE_DEVICES=0 python bert_distill.py \
## 蒸馏实验结果
-本蒸馏实验基于GLUE的SST-2、QQP、中文情感分类ChnSentiCorp数据集。实验效果均使用每个数据集的验证集(dev)进行评价,评价指标是准确率(acc),其中QQP中包含f1值。利用基于BERT的教师模型去蒸馏基于Bi-LSTM的学生模型,对比Bi-LSTM小模型单独训练,在SST-2、QQP、ChnSentiCorp(中文情感分类)任务上分别有3.3%、1.9%、1.4%的提升。
+本蒸馏实验基于 GLUE 的 SST-2、QQP、中文情感分类 ChnSentiCorp 数据集。实验效果均使用每个数据集的验证集(dev)进行评价,评价指标是准确率(acc),其中 QQP 中包含 f1值。利用基于 BERT 的教师模型去蒸馏基于 Bi-LSTM 的学生模型,对比 Bi-LSTM 小模型单独训练,在 SST-2、QQP、ChnSentiCorp(中文情感分类)任务上分别有3.3%、1.9%、1.4%的提升。
| Model | SST-2(dev acc) | QQP(dev acc/f1) | ChnSentiCorp(dev acc) | ChnSentiCorp(dev acc) |
| ----------------- | ----------------- | -------------------------- | --------------------- | --------------------- |
diff --git a/legacy/examples/model_compression/distill_lstm/args.py b/slm/examples/model_compression/distill_lstm/args.py
similarity index 100%
rename from legacy/examples/model_compression/distill_lstm/args.py
rename to slm/examples/model_compression/distill_lstm/args.py
index 07fd4b1bb191..0d0431ea0846 100644
--- a/legacy/examples/model_compression/distill_lstm/args.py
+++ b/slm/examples/model_compression/distill_lstm/args.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
import argparse
+import os
from paddlenlp.utils.env import MODEL_HOME
diff --git a/legacy/examples/model_compression/distill_lstm/bert_distill.py b/slm/examples/model_compression/distill_lstm/bert_distill.py
similarity index 100%
rename from legacy/examples/model_compression/distill_lstm/bert_distill.py
rename to slm/examples/model_compression/distill_lstm/bert_distill.py
diff --git a/legacy/examples/model_compression/distill_lstm/data.py b/slm/examples/model_compression/distill_lstm/data.py
similarity index 100%
rename from legacy/examples/model_compression/distill_lstm/data.py
rename to slm/examples/model_compression/distill_lstm/data.py
diff --git a/legacy/examples/model_compression/distill_lstm/small.py b/slm/examples/model_compression/distill_lstm/small.py
similarity index 100%
rename from legacy/examples/model_compression/distill_lstm/small.py
rename to slm/examples/model_compression/distill_lstm/small.py
diff --git a/legacy/examples/model_compression/distill_lstm/utils.py b/slm/examples/model_compression/distill_lstm/utils.py
similarity index 99%
rename from legacy/examples/model_compression/distill_lstm/utils.py
rename to slm/examples/model_compression/distill_lstm/utils.py
index 0243d97a5a64..045aa0b00cff 100644
--- a/legacy/examples/model_compression/distill_lstm/utils.py
+++ b/slm/examples/model_compression/distill_lstm/utils.py
@@ -13,7 +13,6 @@
# limitations under the License.
import jieba
-
import numpy as np
diff --git a/legacy/examples/model_compression/minilmv2/README.md b/slm/examples/model_compression/minilmv2/README.md
similarity index 72%
rename from legacy/examples/model_compression/minilmv2/README.md
rename to slm/examples/model_compression/minilmv2/README.md
index 62bfc39fa1d4..fdb5c5dfa38d 100644
--- a/legacy/examples/model_compression/minilmv2/README.md
+++ b/slm/examples/model_compression/minilmv2/README.md
@@ -10,11 +10,11 @@
## 简介
本目录下的实验主要参考论文[《MiniLMv2: Multi-Head Self-Attention Relation Distillation for Compressing Pretrained Transformers》](https://arxiv.org/abs/2012.15828)实现。
-MiniLMv2也是从层数深的Transformer类模型到层数较浅的Transformer类模型的蒸馏策略。它的优势是只需要取教师模型和学生模型中的各一层进行蒸馏训练,而不像其他方法需要蒸馏更多的层,避免面对更加复杂的layer mapping问题,并且效果优于TinyBert的蒸馏策略。
+MiniLMv2也是从层数深的 Transformer 类模型到层数较浅的 Transformer 类模型的蒸馏策略。它的优势是只需要取教师模型和学生模型中的各一层进行蒸馏训练,而不像其他方法需要蒸馏更多的层,避免面对更加复杂的 layer mapping 问题,并且效果优于 TinyBert 的蒸馏策略。
-MiniLMv2蒸馏的目标是教师模型某层的q与q, k与k, v与v的矩阵乘结果和学生模型最后一层的q与q, k与k, v与v的矩阵乘之间的kl散度loss。其中教师模型是large size时,选择实验并选取倒数某一层,当教师模型是base size时,选择最后一层进行蒸馏即可。
+MiniLMv2蒸馏的目标是教师模型某层的 q 与 q, k 与 k, v 与 v 的矩阵乘结果和学生模型最后一层的 q 与 q, k 与 k, v 与 v 的矩阵乘之间的 kl 散度 loss。其中教师模型是 large size 时,选择实验并选取倒数某一层,当教师模型是 base size 时,选择最后一层进行蒸馏即可。
-为了防止教师模型是large size时,head size与学生模型不同,蒸馏目标的shape无法匹配,MiniLMv2还需要对head进行重组,先合并再按relation_head_num重新分割head_num和head_size。
+为了防止教师模型是 large size 时,head size 与学生模型不同,蒸馏目标的 shape 无法匹配,MiniLMv2还需要对 head 进行重组,先合并再按 relation_head_num 重新分割 head_num 和 head_size。
## 数据、预训练模型介绍及获取
@@ -56,18 +56,18 @@ python -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" general_distill.py
其中参数释义如下:
- `student_model_type` 学生模型的类型
-- `num_relation_heads` head重新组合之后的head数
+- `num_relation_heads` head 重新组合之后的 head 数
- `student_model_name_or_path` 学生模型的名字(需要与学生模型类型对应),或者是学生模型的路径
-- `init_from_student` 本次蒸馏的学生模型是否用`student_model_name_or_path`中的参数进行初始化,是个bool类型的参数。默认是False
+- `init_from_student` 本次蒸馏的学生模型是否用`student_model_name_or_path`中的参数进行初始化,是个 bool 类型的参数。默认是 False
- `teacher_model_type bert` 教师模型的类型
- `teacher_model_name_or_path` 教师模型的名字
- `max_seq_length 128` 表示最大句子长度,超过该长度将被截断。
-- `warmup_steps` 学习率warmup up的步数
+- `warmup_steps` 学习率 warmup up 的步数
- `save_steps` 保存模型的频率
- `teacher_layer_index`表示学生模型从教师模型学习的教师层
- `student_layer_index` 表示学生模型从教师模型学习的学生层
- `output_dir` 模型输出的目录
-- `device gpu` 表示运行该程序的设备,默认是gpu
+- `device gpu` 表示运行该程序的设备,默认是 gpu
- `input_dir` 预训练数据的存放地址
@@ -75,8 +75,8 @@ python -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" general_distill.py
### 评价方法
假设预训练完成后的模型存储在`${pretrained_models}`下,这里也提供了我们已经预训练完成的一版[模型](https://bj.bcebos.com/paddlenlp/models/general_distill/minilmv2_6l_768d_ch.tar.gz)可供参考,模型与`tinybert-6l-768d-zh`结构相同,因此可以使用`TinyBertForSequenceClassification.from_pretrained()`对模型直接进行加载。
-本示例训练出的通用模型需要在下游任务上Fine-tuning,利用下游任务上的指标进行评价。
-我们可以运行如下脚本在单卡上进行Fine-tuning:
+本示例训练出的通用模型需要在下游任务上 Fine-tuning,利用下游任务上的指标进行评价。
+我们可以运行如下脚本在单卡上进行 Fine-tuning:
```shell
@@ -101,7 +101,7 @@ python -u ./run_clue.py \
```
-其中不同的任务下,`${learning_rate}`、`${num_train_epochs}`、`${max_seq_len}`,我们推荐不同的Fine-tuning的超参数,可以参考以下配置:
+其中不同的任务下,`${learning_rate}`、`${num_train_epochs}`、`${max_seq_len}`,我们推荐不同的 Fine-tuning 的超参数,可以参考以下配置:
| TASK_NAME | AFQMC | TNEWS | IFLYTEK | OCNLI | CMNLI | CLUEWSC2020 | CSL |
| ---------------- | ----- | ----- | ------- | ----- | ----- | ----------- | ---- |
@@ -112,7 +112,7 @@ python -u ./run_clue.py \
### 蒸馏实验结果
-本示例选择的是CLUE中的分类任务,以`bert-base-chinese`作教师模型,利用MiniLMv2策略对6层模型进行蒸馏,可以得到的通用模型在CLUE上的指标为:
+本示例选择的是 CLUE 中的分类任务,以`bert-base-chinese`作教师模型,利用 MiniLMv2策略对6层模型进行蒸馏,可以得到的通用模型在 CLUE 上的指标为:
| CLUE | AFQMC | TNEWS | IFLYTEK | CMNLI | OCNLI | CLUEWSC2020 | CSL |
| ------- | ----- | ----- | ------- | ----- | ----- | ----------- | ----- |
diff --git a/legacy/examples/model_compression/minilmv2/general_distill.py b/slm/examples/model_compression/minilmv2/general_distill.py
similarity index 100%
rename from legacy/examples/model_compression/minilmv2/general_distill.py
rename to slm/examples/model_compression/minilmv2/general_distill.py
diff --git a/legacy/examples/model_compression/minilmv2/run_clue.py b/slm/examples/model_compression/minilmv2/run_clue.py
similarity index 100%
rename from legacy/examples/model_compression/minilmv2/run_clue.py
rename to slm/examples/model_compression/minilmv2/run_clue.py
diff --git a/legacy/examples/model_compression/ofa/README.md b/slm/examples/model_compression/ofa/README.md
similarity index 79%
rename from legacy/examples/model_compression/ofa/README.md
rename to slm/examples/model_compression/ofa/README.md
index 79eccdf15086..bdce6a1d961b 100644
--- a/legacy/examples/model_compression/ofa/README.md
+++ b/slm/examples/model_compression/ofa/README.md
@@ -1,13 +1,13 @@
# BERT Compression Based on PaddleSlim
-BERT-base模型是一个迁移能力很强的通用语义表示模型,但是模型中也有一些参数冗余。本教程将介绍如何使用PaddleSlim对BERT-base模型进行压缩。
+BERT-base 模型是一个迁移能力很强的通用语义表示模型,但是模型中也有一些参数冗余。本教程将介绍如何使用 PaddleSlim 对 BERT-base 模型进行压缩。
## 压缩原理
-1. 对Fine-tuning得到模型通过计算参数及其梯度的乘积得到参数的重要性,把模型参数根据重要性进行重排序。
-2. 超网络中最大的子网络选择和Bert-base模型网络结构一致的网络结构,其他小的子网络是对最大网络的进行不同的宽度选择来得到的,宽度选择具体指的是网络中的参数进行裁剪,所有子网络在整个训练过程中都是参数共享的。
+1. 对 Fine-tuning 得到模型通过计算参数及其梯度的乘积得到参数的重要性,把模型参数根据重要性进行重排序。
+2. 超网络中最大的子网络选择和 Bert-base 模型网络结构一致的网络结构,其他小的子网络是对最大网络的进行不同的宽度选择来得到的,宽度选择具体指的是网络中的参数进行裁剪,所有子网络在整个训练过程中都是参数共享的。
2. 用重排序之后的模型参数作为超网络模型的初始化参数。
-3. Fine-tuning之后的模型作为教师网络,超网络作为学生网络,进行知识蒸馏。
+3. Fine-tuning 之后的模型作为教师网络,超网络作为学生网络,进行知识蒸馏。

@@ -17,7 +17,7 @@ BERT-base模型是一个迁移能力很强的通用语义表示模型,但是
## 压缩结果
-利用`bert-base-uncased`模型首先在GLUE数据集上进行finetune,得到需要压缩的模型,之后基于此模型进行压缩。压缩后模型参数大小减小26%(从110M减少到81M),压缩后模型在GLUE dev数据集上的精度和压缩前模型在GLUE dev数据集上的精度对比如下表所示:
+利用`bert-base-uncased`模型首先在 GLUE 数据集上进行 finetune,得到需要压缩的模型,之后基于此模型进行压缩。压缩后模型参数大小减小26%(从110M 减少到81M),压缩后模型在 GLUE dev 数据集上的精度和压缩前模型在 GLUE dev 数据集上的精度对比如下表所示:
| Task | Metric | Result | Result with PaddleSlim |
|:-----:|:----------------------------:|:-----------------:|:----------------------:|
@@ -31,7 +31,7 @@ BERT-base模型是一个迁移能力很强的通用语义表示模型,但是
| RTE | Accuracy | 0.711191 | 0.718412 |
-表1-1: GLUE数据集精度对比
+表1-1: GLUE 数据集精度对比
压缩前后模型的耗时如下表所示:
@@ -181,23 +181,23 @@ BERT-base模型是一个迁移能力很强的通用语义表示模型,但是
表1-2: 模型速度对比
-压缩后模型在T4机器上相比原始模型在FP32的情况下加速59%,在TensorRT FP16的情况下加速47.3%。
-压缩后模型在V100机器上相比原始模型在FP32的情况下加速52.5%。
-压缩后模型在Intel(R) Xeon(R) Gold 5117 CPU上相比原始模型在FP32的情况下加速41%。
+压缩后模型在 T4机器上相比原始模型在 FP32的情况下加速59%,在 TensorRT FP16的情况下加速47.3%。
+压缩后模型在 V100机器上相比原始模型在 FP32的情况下加速52.5%。
+压缩后模型在 Intel(R) Xeon(R) Gold 5117 CPU 上相比原始模型在 FP32的情况下加速41%。
## 快速开始
-本教程示例以GLUE/SST-2 数据集为例。
+本教程示例以 GLUE/SST-2 数据集为例。
### 环境依赖
-模型压缩功能依赖最新版本的PaddleSlim
+模型压缩功能依赖最新版本的 PaddleSlim
```shell
git clone https://github.com/PaddlePaddle/PaddleSlim
python setup.py build && python setup.py install
```
### Fine-tuing
-首先需要对Pretrain-Model在实际的下游任务上进行Finetuning,得到需要压缩的模型。Fine-tuning流程参考[Fine-tuning教程](../../benchmark/glue)
+首先需要对 Pretrain-Model 在实际的下游任务上进行 Finetuning,得到需要压缩的模型。Fine-tuning 流程参考[Fine-tuning 教程](../../benchmark/glue)
```shell
cd ../../benchmark/glue/
@@ -221,7 +221,7 @@ python -u ./run_glue.py \
--device gpu \
```
参数详细含义参考[README.md](../../benchmark/glue/README.md)
-Fine-tuning 在dev上的结果如压缩结果表1-1中Result那一列所示。
+Fine-tuning 在 dev 上的结果如压缩结果表1-1中 Result 那一列所示。
### 压缩训练
@@ -261,24 +261,24 @@ python -m paddle.distributed.launch --gpus "0,1" run_glue_ofa.py \
其中参数释义如下:
-- `model_type` 指示了模型类型,当前仅支持BERT模型。
+- `model_type` 指示了模型类型,当前仅支持 BERT 模型。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
- `task_name` 表示 Fine-tuning 的任务。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
-- `width_mult_list` 表示压缩训练过程中,对每层Transformer Block的宽度选择的范围。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
+- `width_mult_list` 表示压缩训练过程中,对每层 Transformer Block 的宽度选择的范围。
-压缩训练之后在dev上的结果如压缩结果表格中Result with PaddleSlim那一列所示,延时情况如表1-2所示。
+压缩训练之后在 dev 上的结果如压缩结果表格中 Result with PaddleSlim 那一列所示,延时情况如表1-2所示。
### 导出子模型
-根据传入的config导出相应的子模型并转为静态图模型。
+根据传入的 config 导出相应的子模型并转为静态图模型。
启动命令:
@@ -293,21 +293,21 @@ python -u ./export_model.py --model_type bert \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,当前仅支持BERT模型。
-- `model_name_or_path` 指示了某种特定配置的经过OFA训练后保存的模型,对应有其预训练模型和预训练时使用的tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
+- `model_type` 指示了模型类型,当前仅支持 BERT 模型。
+- `model_name_or_path` 指示了某种特定配置的经过 OFA 训练后保存的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。默认:128.
- `sub_model_output_dir` 指示了导出子模型动态图参数的目录。
-- `static_sub_model` 指示了导出子模型静态图模型及参数的目录,设置为None,则表示不导出静态图模型。默认:None。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `static_sub_model` 指示了导出子模型静态图模型及参数的目录,设置为 None,则表示不导出静态图模型。默认:None。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `width_mult` 表示导出子模型的宽度。默认:1.0.
-### OFA接口介绍
+### OFA 接口介绍
-OFA API介绍参考[API](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/ofa/ofa_api.rst)
+OFA API 介绍参考[API](https://github.com/PaddlePaddle/PaddleSlim/blob/release/2.0.0/docs/zh_cn/api_cn/dygraph/ofa/ofa_api.rst)
-## 另附:基于本代码对TinyBERT(L=4, D=312)进行压缩
-下游任务模型是从TinyBERT官方repo转换得到。
+## 另附:基于本代码对 TinyBERT(L=4, D=312)进行压缩
+下游任务模型是从 TinyBERT 官方 repo 转换得到。
### 压缩结果
diff --git a/legacy/examples/model_compression/ofa/export_model.py b/slm/examples/model_compression/ofa/export_model.py
similarity index 100%
rename from legacy/examples/model_compression/ofa/export_model.py
rename to slm/examples/model_compression/ofa/export_model.py
diff --git a/legacy/examples/model_compression/ofa/imgs/ofa_bert.jpg b/slm/examples/model_compression/ofa/imgs/ofa_bert.jpg
similarity index 100%
rename from legacy/examples/model_compression/ofa/imgs/ofa_bert.jpg
rename to slm/examples/model_compression/ofa/imgs/ofa_bert.jpg
diff --git a/legacy/examples/model_compression/ofa/run_glue_ofa.py b/slm/examples/model_compression/ofa/run_glue_ofa.py
similarity index 100%
rename from legacy/examples/model_compression/ofa/run_glue_ofa.py
rename to slm/examples/model_compression/ofa/run_glue_ofa.py
diff --git a/legacy/examples/model_compression/ofa/run_glue_ofa_depth.py b/slm/examples/model_compression/ofa/run_glue_ofa_depth.py
similarity index 100%
rename from legacy/examples/model_compression/ofa/run_glue_ofa_depth.py
rename to slm/examples/model_compression/ofa/run_glue_ofa_depth.py
diff --git a/legacy/examples/model_compression/pp-minilm/README.md b/slm/examples/model_compression/pp-minilm/README.md
similarity index 95%
rename from legacy/examples/model_compression/pp-minilm/README.md
rename to slm/examples/model_compression/pp-minilm/README.md
index bb3e9598ef02..384553ef6af2 100644
--- a/legacy/examples/model_compression/pp-minilm/README.md
+++ b/slm/examples/model_compression/pp-minilm/README.md
@@ -1,8 +1,8 @@
**目录**
-* [PP-MiniLM 中文小模型](#PP-MiniLM中文小模型)
- * [导入 PP-MiniLM](#导入PP-MiniLM)
- * [在下游任务上使用 PP-MiniLM](#在下游任务上使用PP-MiniLM)
+* [PP-MiniLM 中文小模型](#PP-MiniLM 中文小模型)
+ * [导入 PP-MiniLM](#导入 PP-MiniLM)
+ * [在下游任务上使用 PP-MiniLM](#在下游任务上使用 PP-MiniLM)
* [数据介绍](#数据介绍)
* [环境依赖](#环境依赖)
* [微调](#微调)
@@ -18,14 +18,14 @@
* [原理简介](#原理简介)
* [运行方式](#运行方式)
* [量化后模型精度](#量化后模型精度)
- * [使用 Paddle Inference 进行推理部署](#使用PaddleInference推理部署)
+ * [使用 Paddle Inference 进行推理部署](#使用 PaddleInference 推理部署)
* [环境要求](#环境要求)
* [运行方式](#运行方式)
* [性能测试](#性能测试)
- * [使用 Paddle Serving 进行服务化部署](#使用PaddleServing服务化部署)
+ * [使用 Paddle Serving 进行服务化部署](#使用 PaddleServing 服务化部署)
* [参考文献](#参考文献)
-
+
# PP-MiniLM 中文小模型
[PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP) 联合 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 通过模型蒸馏、剪裁、量化等级联模型压缩技术发布中文特色小模型 PP-MiniLM(6L768H) 及压缩方案,保证模型精度的同时模型推理速度达 BERT(12L768H) 的 8.88 倍,参数量相比减少 52%,模型精度在中文语言理解评测基准 CLUE 高 0.62。
@@ -119,7 +119,7 @@ PP-MiniLM 压缩方案以面向预训练模型的任务无关知识蒸馏(Task-a
```
-
+
## 导入 PP-MiniLM
@@ -139,7 +139,7 @@ PP-MiniLM 是一个 6 层的预训练模型,使用 `from_pretrained`导入 PP-
**NOTE:** 如果对 PP-MiniLM 的训练过程感兴趣,可以查看[任务无关蒸馏文档](general_distill/README.md)了解相关细节。
-
+
## 在下游任务上使用 PP-MiniLM
@@ -339,7 +339,7 @@ cd ..
最后,值得注意的是,PP-MiniLM 是基于 `roberta-wwm-ext-large` 做教师模型蒸馏得到的学生模型,如果你有更好的 24 层中文预训练模型,可以基于[任务无关蒸馏文档](general_distill/README.md)中介绍的蒸馏过程,训练出一个比 PP-MiniLM 精度更高,在下游任务上表现更好的 6 层小模型。
-
+
### 使用 Paddle Inference 进行推理部署
@@ -359,7 +359,7 @@ cd ..
#### 运行方式
-这里使用了动态 shape 功能,因此需要设置 TensorRT 子图输入shape 的范围。用户需要事先根据自己的模型结构和数据 shape 的范围,设置 TensorRT 子图输入的 shape 的最大、最小、以及最优的范围,其中最优范围可以按照数据分布选择最常见的来设置。动态 shape 的设置可以参考[官方文档](https://paddleinference.paddlepaddle.org.cn/optimize/paddle_trt.html#dynamic-shape)中的教程,以及本案例中 infer.py 脚本中的 160 行 - 206 行)。
+这里使用了动态 shape 功能,因此需要设置 TensorRT 子图输入 shape 的范围。用户需要事先根据自己的模型结构和数据 shape 的范围,设置 TensorRT 子图输入的 shape 的最大、最小、以及最优的范围,其中最优范围可以按照数据分布选择最常见的来设置。动态 shape 的设置可以参考[官方文档](https://paddleinference.paddlepaddle.org.cn/optimize/paddle_trt.html#dynamic-shape)中的教程,以及本案例中 infer.py 脚本中的 160 行 - 206 行)。
INT8 预测运行脚本:
@@ -411,7 +411,7 @@ cd ../../
| PP-MiniLM + 裁剪 + 量化 | **8.88x** | **5.36x** |
-
+
### 使用 Paddle Serving 进行服务化部署
diff --git a/legacy/examples/model_compression/pp-minilm/data.py b/slm/examples/model_compression/pp-minilm/data.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/data.py
rename to slm/examples/model_compression/pp-minilm/data.py
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/python/infer.py b/slm/examples/model_compression/pp-minilm/deploy/python/infer.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/python/infer.py
rename to slm/examples/model_compression/pp-minilm/deploy/python/infer.py
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/python/infer_all.sh b/slm/examples/model_compression/pp-minilm/deploy/python/infer_all.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/python/infer_all.sh
rename to slm/examples/model_compression/pp-minilm/deploy/python/infer_all.sh
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/python/infer_perf.sh b/slm/examples/model_compression/pp-minilm/deploy/python/infer_perf.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/python/infer_perf.sh
rename to slm/examples/model_compression/pp-minilm/deploy/python/infer_perf.sh
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/serving/README.md b/slm/examples/model_compression/pp-minilm/deploy/serving/README.md
similarity index 91%
rename from legacy/examples/model_compression/pp-minilm/deploy/serving/README.md
rename to slm/examples/model_compression/pp-minilm/deploy/serving/README.md
index 3fed44ed9d92..c366ed0c7b83 100644
--- a/legacy/examples/model_compression/pp-minilm/deploy/serving/README.md
+++ b/slm/examples/model_compression/pp-minilm/deploy/serving/README.md
@@ -1,6 +1,6 @@
# PP-MiniLM 使用 Paddle Serving 进行服务化部署
-Paddle Serving 可以实现在服务器端部署推理模型,客户端远程通过 RPC/HTTP 方式发送数据进行推理,实现模型推理的服务化,下面以RPC方式为例进行说明。
+Paddle Serving 可以实现在服务器端部署推理模型,客户端远程通过 RPC/HTTP 方式发送数据进行推理,实现模型推理的服务化,下面以 RPC 方式为例进行说明。
## 前提条件
准备好 Inference 模型,需要2个文件:
@@ -18,7 +18,7 @@ Paddle Serving 可以实现在服务器端部署推理模型,客户端远程
pip install paddle-serving-app paddle-serving-client paddle-serving-server
```
-如果服务器端可以使用GPU进行推理,则安装 server 的 gpu 版本,安装时要注意参考服务器当前 CUDA、TensorRT 的版本来安装对应的版本:[Serving readme](https://github.com/PaddlePaddle/Serving/tree/v0.8.0)
+如果服务器端可以使用 GPU 进行推理,则安装 server 的 gpu 版本,安装时要注意参考服务器当前 CUDA、TensorRT 的版本来安装对应的版本:[Serving readme](https://github.com/PaddlePaddle/Serving/tree/v0.8.0)
```shell
pip install paddle-serving-app paddle-serving-client paddle-serving-server-gpu
@@ -59,7 +59,7 @@ python export_to_serving.py \
在启动预测之前,需要按照自己的情况修改 config 文件中的配置,主要需要修改的配置释义如下:
-- `rpc_port` : rpc端口。
+- `rpc_port` : rpc 端口。
- `device_type` : 0 代表 CPU, 1 代表 GPU, 2 代表 TensorRT, 3 代表 Arm CPU, 4 代表 Kunlun XPU。
- `devices` : 计算硬件 ID,当 devices 为 "" 或不写时,为 CPU 预测;当 devices 为"0"、 "0,1,2" 时为 GPU 预测。
- `fetch_list` : fetch 结果列表,以 client_config 中 fetch_var 的 alias_name 为准, 如果没有设置则全部返回。
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/serving/config_nlp.yml b/slm/examples/model_compression/pp-minilm/deploy/serving/config_nlp.yml
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/serving/config_nlp.yml
rename to slm/examples/model_compression/pp-minilm/deploy/serving/config_nlp.yml
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/serving/export_to_serving.py b/slm/examples/model_compression/pp-minilm/deploy/serving/export_to_serving.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/serving/export_to_serving.py
rename to slm/examples/model_compression/pp-minilm/deploy/serving/export_to_serving.py
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/serving/rpc_client.py b/slm/examples/model_compression/pp-minilm/deploy/serving/rpc_client.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/serving/rpc_client.py
rename to slm/examples/model_compression/pp-minilm/deploy/serving/rpc_client.py
diff --git a/legacy/examples/model_compression/pp-minilm/deploy/serving/web_service.py b/slm/examples/model_compression/pp-minilm/deploy/serving/web_service.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/deploy/serving/web_service.py
rename to slm/examples/model_compression/pp-minilm/deploy/serving/web_service.py
diff --git a/legacy/examples/model_compression/pp-minilm/finetuning/export_model.py b/slm/examples/model_compression/pp-minilm/finetuning/export_model.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/finetuning/export_model.py
rename to slm/examples/model_compression/pp-minilm/finetuning/export_model.py
diff --git a/legacy/examples/model_compression/pp-minilm/finetuning/run_all_search.sh b/slm/examples/model_compression/pp-minilm/finetuning/run_all_search.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/finetuning/run_all_search.sh
rename to slm/examples/model_compression/pp-minilm/finetuning/run_all_search.sh
diff --git a/legacy/examples/model_compression/pp-minilm/finetuning/run_clue.py b/slm/examples/model_compression/pp-minilm/finetuning/run_clue.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/finetuning/run_clue.py
rename to slm/examples/model_compression/pp-minilm/finetuning/run_clue.py
diff --git a/legacy/examples/model_compression/pp-minilm/finetuning/run_clue.sh b/slm/examples/model_compression/pp-minilm/finetuning/run_clue.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/finetuning/run_clue.sh
rename to slm/examples/model_compression/pp-minilm/finetuning/run_clue.sh
diff --git a/legacy/examples/model_compression/pp-minilm/finetuning/run_one_search.sh b/slm/examples/model_compression/pp-minilm/finetuning/run_one_search.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/finetuning/run_one_search.sh
rename to slm/examples/model_compression/pp-minilm/finetuning/run_one_search.sh
diff --git a/legacy/examples/model_compression/pp-minilm/general_distill/README.md b/slm/examples/model_compression/pp-minilm/general_distill/README.md
similarity index 77%
rename from legacy/examples/model_compression/pp-minilm/general_distill/README.md
rename to slm/examples/model_compression/pp-minilm/general_distill/README.md
index c4be10fb4d56..c9d871032c20 100644
--- a/legacy/examples/model_compression/pp-minilm/general_distill/README.md
+++ b/slm/examples/model_compression/pp-minilm/general_distill/README.md
@@ -8,11 +8,11 @@
任务无关知识蒸馏是用较大(层数更多、宽度更宽的)的基于 Transformer Layer 的预训练模型对较小(层数更少、宽度更窄的)的基于 Transformer Layer 的预训练模型进行蒸馏,从而得到更小、效果与较大模型更接近的预训练模型。
-PP-MiniLM 参考了 MiniLMv2 提出的 Multi-Head Self-Attention Relation Distillation 蒸馏策略。MiniLMv2 算法是用 24 层 large-size 的教师模型倒数几层的 Q-Q、K-K、V-V 之间的relation对6层学生模型最后一层 Q-Q、K-K、V-V 之间的 relation 进行蒸馏。具体的做法是,首先将学生、教师用于蒸馏的层上的 Q、K、V 的 Head 数进行统一,然后计算各自 Q-Q、K-K、V-V 的点积,最后对教师和学生的点积计算KL散度损失。由于 relation 的 shape 是 `[batch_size, head_num, seq_len, seq_len]`,因此可以认为这里的relation是一种Token与Token之间的关系。
+PP-MiniLM 参考了 MiniLMv2 提出的 Multi-Head Self-Attention Relation Distillation 蒸馏策略。MiniLMv2 算法是用 24 层 large-size 的教师模型倒数几层的 Q-Q、K-K、V-V 之间的 relation 对6层学生模型最后一层 Q-Q、K-K、V-V 之间的 relation 进行蒸馏。具体的做法是,首先将学生、教师用于蒸馏的层上的 Q、K、V 的 Head 数进行统一,然后计算各自 Q-Q、K-K、V-V 的点积,最后对教师和学生的点积计算 KL 散度损失。由于 relation 的 shape 是 `[batch_size, head_num, seq_len, seq_len]`,因此可以认为这里的 relation 是一种 Token 与 Token 之间的关系。
本方案在 MiniLMv2 策略的基础上,做了进一步优化: 通过引入多视角的注意力关系知识来进一步提升模型效果。MiniLMv2 的自注意力关系知识仅建模了 Token 与 Token 之间的关系,PP-MiniLM 在此基础上额外引入了样本与样本间的自注意力关系知识,也就是挖掘出更多教师模型所蕴含的知识,从而进一步优化模型效果。
-具体来说,PP-MiniLM 利用了 `roberta-wwm-ext-large` 第 20 层的 Q-Q、K-K、V-V 之间的 Sample 与 Sampl 之间关系对 6 层学生模型 PP-MiniLM 第 6 层的 Q-Q、K-K、V-V 之间的 Sample 与 Sample 之间的关系进行蒸馏。与MiniLMv2不同的是,PP-MiniLM的策略需要在统一Q、K、V的Head数之后,对Q、K、V转置为 `[seq_len, head_num, batch_size, head_dim]`,这样Q-Q、K-K、V-V 的点积则可以表达样本间的关系。经过我们的实验,这种方法比使用原始 MiniLMv2 算法在 CLUE 上平均准确率高 0.36。
+具体来说,PP-MiniLM 利用了 `roberta-wwm-ext-large` 第 20 层的 Q-Q、K-K、V-V 之间的 Sample 与 Sampl 之间关系对 6 层学生模型 PP-MiniLM 第 6 层的 Q-Q、K-K、V-V 之间的 Sample 与 Sample 之间的关系进行蒸馏。与 MiniLMv2不同的是,PP-MiniLM 的策略需要在统一 Q、K、V 的 Head 数之后,对 Q、K、V 转置为 `[seq_len, head_num, batch_size, head_dim]`,这样 Q-Q、K-K、V-V 的点积则可以表达样本间的关系。经过我们的实验,这种方法比使用原始 MiniLMv2 算法在 CLUE 上平均准确率高 0.36。
### 数据介绍
@@ -41,12 +41,12 @@ cd ..
- `max_steps` 最大迭代次数
- `warmup_steps` 学习率增长得到`learning_rate`所需要的步数
- `save_steps`保存模型的间隔步数
-- `weight_decay` 表示AdamW优化器中使用的 weight_decay 的系数
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数
- `output_dir`训练相关文件以及模型保存的输出路径
- `device`设备选择,推荐使用 gpu
- `input_dir` 训练数据目录
- `use_amp` 是否使用混合精度训练,默认 False
-- `alpha`head间关系的权重,默认 0.0
+- `alpha`head 间关系的权重,默认 0.0
- `beta`样本间关系的权重,默认 0.0
将最终得到的模型绝对路径保存至 `$GENERAL_MODEL_DIR`,例如:
diff --git a/legacy/examples/model_compression/pp-minilm/general_distill/general_distill.py b/slm/examples/model_compression/pp-minilm/general_distill/general_distill.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/general_distill/general_distill.py
rename to slm/examples/model_compression/pp-minilm/general_distill/general_distill.py
diff --git a/legacy/examples/model_compression/pp-minilm/general_distill/run.sh b/slm/examples/model_compression/pp-minilm/general_distill/run.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/general_distill/run.sh
rename to slm/examples/model_compression/pp-minilm/general_distill/run.sh
diff --git a/legacy/examples/model_compression/pp-minilm/pp-minilm.png b/slm/examples/model_compression/pp-minilm/pp-minilm.png
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pp-minilm.png
rename to slm/examples/model_compression/pp-minilm/pp-minilm.png
diff --git a/legacy/examples/model_compression/pp-minilm/pruning/export.sh b/slm/examples/model_compression/pp-minilm/pruning/export.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pruning/export.sh
rename to slm/examples/model_compression/pp-minilm/pruning/export.sh
diff --git a/legacy/examples/model_compression/pp-minilm/pruning/export_all.sh b/slm/examples/model_compression/pp-minilm/pruning/export_all.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pruning/export_all.sh
rename to slm/examples/model_compression/pp-minilm/pruning/export_all.sh
diff --git a/legacy/examples/model_compression/pp-minilm/pruning/export_model.py b/slm/examples/model_compression/pp-minilm/pruning/export_model.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pruning/export_model.py
rename to slm/examples/model_compression/pp-minilm/pruning/export_model.py
diff --git a/legacy/examples/model_compression/pp-minilm/pruning/prune.py b/slm/examples/model_compression/pp-minilm/pruning/prune.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pruning/prune.py
rename to slm/examples/model_compression/pp-minilm/pruning/prune.py
diff --git a/legacy/examples/model_compression/pp-minilm/pruning/prune.sh b/slm/examples/model_compression/pp-minilm/pruning/prune.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/pruning/prune.sh
rename to slm/examples/model_compression/pp-minilm/pruning/prune.sh
diff --git a/legacy/examples/model_compression/pp-minilm/quantization/quant_all.sh b/slm/examples/model_compression/pp-minilm/quantization/quant_all.sh
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/quantization/quant_all.sh
rename to slm/examples/model_compression/pp-minilm/quantization/quant_all.sh
diff --git a/legacy/examples/model_compression/pp-minilm/quantization/quant_post.py b/slm/examples/model_compression/pp-minilm/quantization/quant_post.py
similarity index 100%
rename from legacy/examples/model_compression/pp-minilm/quantization/quant_post.py
rename to slm/examples/model_compression/pp-minilm/quantization/quant_post.py
diff --git a/legacy/examples/model_interpretation/README.md b/slm/examples/model_interpretation/README.md
similarity index 58%
rename from legacy/examples/model_interpretation/README.md
rename to slm/examples/model_interpretation/README.md
index ab3adf4eddab..37e2758c964a 100644
--- a/legacy/examples/model_interpretation/README.md
+++ b/slm/examples/model_interpretation/README.md
@@ -1,9 +1,9 @@
-NLP可解释评估
+NLP 可解释评估
===
-深度学习模型在很多NLP任务上已经取得巨大成功,但其常被当作一个黑盒使用,内部预测机制对使用者是不透明的。这使得深度学习模型结果不被人信任,增加落地难度,尤其是在医疗、法律等特殊领域。同时,当模型出现效果不好或鲁棒性差等问题时,由于不了解其内部机制,导致很难对模型进行优化。近期,深度学习模型的可解释性被越来越多的人关注。但模型的可解释性评估还不够完善,本模块提供了3个NLP任务的评测数据和相关评测指标,旨在评估模型的可解释性。模块包含以下功能:
+深度学习模型在很多 NLP 任务上已经取得巨大成功,但其常被当作一个黑盒使用,内部预测机制对使用者是不透明的。这使得深度学习模型结果不被人信任,增加落地难度,尤其是在医疗、法律等特殊领域。同时,当模型出现效果不好或鲁棒性差等问题时,由于不了解其内部机制,导致很难对模型进行优化。近期,深度学习模型的可解释性被越来越多的人关注。但模型的可解释性评估还不够完善,本模块提供了3个 NLP 任务的评测数据和相关评测指标,旨在评估模型的可解释性。模块包含以下功能:
1. 完善可解释性评估体系,提供了评测数据和对应的评测指标
- 2. 提供了3种典型的证据抽取方法,分别是基于注意力(attention-based)、梯度(gradient-based)和线性模型(LIME)的证据抽取方法,并在LSTM、Transformer(RoBERTa-base和RoBERTa-large)等常用模型网络结构上完成实验验证,分别验证模型结构复杂度、模型参数规模对模型可解释的影响
+ 2. 提供了3种典型的证据抽取方法,分别是基于注意力(attention-based)、梯度(gradient-based)和线性模型(LIME)的证据抽取方法,并在 LSTM、Transformer(RoBERTa-base 和 RoBERTa-large)等常用模型网络结构上完成实验验证,分别验证模型结构复杂度、模型参数规模对模型可解释的影响
3. 提供模型较全面的评估报告,含模型本身准确率等效果、以及在3个可解释评测指标上的结果
@@ -13,7 +13,7 @@ NLP可解释评估
可解释评估体系
---
### 评测数据
-我们提供了情感分析、相似度计算、阅读理解等三个NLP任务上的中英文数据集。对于每一个数据集,人工标注了证据数据和扰动数据。
+我们提供了情感分析、相似度计算、阅读理解等三个 NLP 任务上的中英文数据集。对于每一个数据集,人工标注了证据数据和扰动数据。
证据数据:给出模型预测依赖的证据(从人类认知角度),其由输入中的若干词构成。我们的标注标准包含3个维度:充分性(sufficiency)、简洁性(concision)、可理解性(understandability)。
扰动数据:旨在评估模型在扰动下的证据一致性。我们从抗干扰性、敏感性和泛化性等角度构建了扰动数据,其中,“敏感性”和“泛化性”维度下构建的数据可能会改变证据。
@@ -69,14 +69,14 @@ NLP可解释评估
|
---|
### 评估指标
-__合理性__:评估模型预测依赖的证据与人工标注证据的拟合度,我们这里使用macro-F1作为评估指标,其中模型预测依赖证据可以由本模块提供的证据分析方法(位于/model_interpretation/task/目录下)给出。
+__合理性__:评估模型预测依赖的证据与人工标注证据的拟合度,我们这里使用 macro-F1作为评估指标,其中模型预测依赖证据可以由本模块提供的证据分析方法(位于/model_interpretation/task/目录下)给出。
-其中Sip和Sig分别代表针对第i条输入模型预测证据和人工标注证据,N代表数据集中数据的数量
+其中 Sip和 Sig分别代表针对第 i 条输入模型预测证据和人工标注证据,N 代表数据集中数据的数量
-__一致性__:评估(原始输入,对应扰动输入)对中词重要度排序的一致性。证据分析方法对输入中每个词赋予一个重要度,基于该重要度对输入中所有词进行排序。我们使用搜索排序中的MAP(mean average precision)指标来计算两个排序的一致性。这里给出了MAP的两种计算方式,分别见以下两个公式:
+__一致性__:评估(原始输入,对应扰动输入)对中词重要度排序的一致性。证据分析方法对输入中每个词赋予一个重要度,基于该重要度对输入中所有词进行排序。我们使用搜索排序中的 MAP(mean average precision)指标来计算两个排序的一致性。这里给出了 MAP 的两种计算方式,分别见以下两个公式:
公式一(正在使用):
@@ -85,9 +85,9 @@ __一致性__:评估(原始输入,对应扰动输入)对中词重要度排
-其中Xo和Xd分别代表原始输入和扰动输入的词重要度排序序列。|Xd|代表Xd中词的个数,Xo1:j表示Xo中前j最重要的词。函数G(x, Y)检查词x是否存在于列表Y中,如果存在则G(x, Y)=1。MAP越高表示两个序列排序一致性越高
+其中 Xo和 Xd分别代表原始输入和扰动输入的词重要度排序序列。|Xd|代表 Xd中词的个数,Xo1:j表示 Xo中前 j 最重要的词。函数 G(x, Y)检查词 x 是否存在于列表 Y 中,如果存在则 G(x, Y)=1。MAP 越高表示两个序列排序一致性越高
-__忠诚性__:评估模型给出的证据的忠诚性,即模型是否真的基于给出的证据进行预测的。这里从充分性和完备性两个角度进行评估。充分性,即模型给出的证据是否包含了预测需要的全部信息(即yri = yxi,其中ri表示输入xi的证据,yx表示模型对输入x的预测结果);完备性,即模型对输入x的预测结果(即yxi\ri ≠ yxi,其中xi\ri表示从输入xi中去除证据ri)。基于这两个维度,我们提出了一个新的指标New-P,计算方式如下:
+__忠诚性__:评估模型给出的证据的忠诚性,即模型是否真的基于给出的证据进行预测的。这里从充分性和完备性两个角度进行评估。充分性,即模型给出的证据是否包含了预测需要的全部信息(即 yri = yxi,其中 ri表示输入 xi的证据,yx表示模型对输入 x 的预测结果);完备性,即模型对输入 x 的预测结果(即 yxi\ri ≠ yxi,其中 xi\ri表示从输入 xi中去除证据 ri)。基于这两个维度,我们提出了一个新的指标 New-P,计算方式如下:
@@ -102,19 +102,19 @@ __忠诚性__:评估模型给出的证据的忠诚性,即模型是否真的
Attention-based([Jain and Wallace, 2019](https://arxiv.org/pdf/1902.10186.pdf)):
- 将注意力分数作为词重要度。注意力分数的获取取决于具体模型架构,我们提供了基于LSTM和transformer框架的提取方法,见每个具体任务下的saliency_map目录。
+ 将注意力分数作为词重要度。注意力分数的获取取决于具体模型架构,我们提供了基于 LSTM 和 transformer 框架的提取方法,见每个具体任务下的 saliency_map 目录。
Gradient-based([Sundararajan et al., 2017](https://arxiv.org/pdf/1703.01365.pdf)):
- 基于梯度给出每个词重要度。我们这里给出了integrated gradient计算方式,具体见saliency_map目录或论文[Axiomatic attribution for deep networks](https://arxiv.org/pdf/1703.01365.pdf)。
+ 基于梯度给出每个词重要度。我们这里给出了 integrated gradient 计算方式,具体见 saliency_map 目录或论文[Axiomatic attribution for deep networks](https://arxiv.org/pdf/1703.01365.pdf)。
Linear-based([Ribeiro et al.. 2016](https://arxiv.org/pdf/1602.04938.pdf)):
使用线性模型局部模拟待验证模型,线性模型学习到的词的权重作为该词对预测结果的重要度,详细见论文[" why should i trust you?" explaining the predictions of any classifier](https://arxiv.org/pdf/1602.04938.pdf)。
### 三个任务的被评估模型
-为验证模型复杂度、参数规模对可解释的影响,针对每个任务,我们分别提供了基于LSTM(简单结构)的模型、及Transformer-based预训练模型(复杂结构),其中,对于预训练模型,提供了base版本和large版本。
-模型代码位置:/model_interpretation/task/{task}/,({task}可取值为["senti","similarity","mrc"],其中senti代表情感分析,similarity代表相似度计算,mrc代表阅读理解)
+为验证模型复杂度、参数规模对可解释的影响,针对每个任务,我们分别提供了基于 LSTM(简单结构)的模型、及 Transformer-based 预训练模型(复杂结构),其中,对于预训练模型,提供了 base 版本和 large 版本。
+模型代码位置:/model_interpretation/task/{task}/,({task}可取值为["senti","similarity","mrc"],其中 senti 代表情感分析,similarity 代表相似度计算,mrc 代表阅读理解)
模型运行及依赖环境请参考下方的“平台使用”。
@@ -133,7 +133,7 @@ Linear-based([Ribeiro et al.. 2016](https://arxiv.org/pdf/1602.04938.pdf))
### PaddlePaddle
-需要安装GPU版的PaddlePaddle。
+需要安装 GPU 版的 PaddlePaddle。
```
# GPU 版本
@@ -153,58 +153,58 @@ pip3 install paddlepaddle-gpu
### 模型训练数据
#### 情感分析任务:
-中文推荐使用ChnSentiCorp,英文推荐使用SST-2。本模块提供的中英文情感分析模型就是基于这两个数据集的。若修改训练数据集,请修改/model_interpretation/task/senti/pretrained_models/train.py (RoBERTa) 以及 /model_interpretation/task/senti/rnn/train.py (LSTM)。
+中文推荐使用 ChnSentiCorp,英文推荐使用 SST-2。本模块提供的中英文情感分析模型就是基于这两个数据集的。若修改训练数据集,请修改/model_interpretation/task/senti/pretrained_models/train.py (RoBERTa) 以及 /model_interpretation/task/senti/rnn/train.py (LSTM)。
[//]:数据集会被缓存到/home/work/.paddlenlp/datasets/目录下
#### 相似度计算:
-中文推荐使用LCQMC,英文推荐使用QQP。本模块提供的中英文相似度计算模型就是基于这两个数据集的,若修改训练数据集,请修改/model_interpretation/task/similarity/pretrained_models/train_pointwise.py(RoBERTa)以及/model_interpretation/task/similarity/simnet/train.py(LSTM)。
+中文推荐使用 LCQMC,英文推荐使用 QQP。本模块提供的中英文相似度计算模型就是基于这两个数据集的,若修改训练数据集,请修改/model_interpretation/task/similarity/pretrained_models/train_pointwise.py(RoBERTa)以及/model_interpretation/task/similarity/simnet/train.py(LSTM)。
#### 阅读理解中英文:
-中文推荐使用[DuReader_Checklist](https://dataset-bj.cdn.bcebos.com/lic2021/dureader_checklist.dataset.tar.gz),英文推荐使用[SQUDA2](https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json)。请将阅读理解训练数据放置在/model_interpretation/task/mrc/data目录下。
+中文推荐使用[DuReader_Checklist](https://dataset-bj.cdn.bcebos.com/lic2021/dureader_checklist.dataset.tar.gz),英文推荐使用[SQUDA2](https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json)。请将阅读理解训练数据放置在/model_interpretation/task/mrc/data 目录下。
### 下载预训练模型
-使用paddlenlp框架自动缓存模型文件。
+使用 paddlenlp 框架自动缓存模型文件。
### 其他数据下载
-请运行download.sh自动下载
+请运行 download.sh 自动下载
### 评测数据
-评测数据样例位于/model_interpretation/data/目录下,每一行为一条JSON格式的数据。
+评测数据样例位于/model_interpretation/data/目录下,每一行为一条 JSON 格式的数据。
#### 情感分析数据格式:
- id: 数据的编号,作为该条数据识别key;
+ id: 数据的编号,作为该条数据识别 key;
context:原文本数据;
- sent_token:原文本数据的标准分词,注意:golden证据是基于该分词的,预测证据也需要与该分词对应;
+ sent_token:原文本数据的标准分词,注意:golden 证据是基于该分词的,预测证据也需要与该分词对应;
sample_type: 数据的类性,分为原始数据(ori)和扰动数据(disturb);
- rel_ids:与原始数据关联的扰动数据的id列表(只有原始数据有);
+ rel_ids:与原始数据关联的扰动数据的 id 列表(只有原始数据有);
#### 相似度数据格式:
- id:数据的编号,作为该条数据识别key;
- query(英文中为sentence1):句子1的原文本数据;
- title(英文中为sentence2):句子2的原文本数据;
- text_q_seg:句子1的标准分词,注意:golden证据是基于该分词的,预测证据也需要与该分词对应;
- text_t_seg:句子2的标准分词,注意:golden证据是基于该分词的,预测证据也需要与该分词对应;
+ id:数据的编号,作为该条数据识别 key;
+ query(英文中为 sentence1):句子1的原文本数据;
+ title(英文中为 sentence2):句子2的原文本数据;
+ text_q_seg:句子1的标准分词,注意:golden 证据是基于该分词的,预测证据也需要与该分词对应;
+ text_t_seg:句子2的标准分词,注意:golden 证据是基于该分词的,预测证据也需要与该分词对应;
sample_type: 数据的类性,分为原始数据(ori)和扰动数据(disturb);
- rel_ids:与原始数据关联的扰动数据的id列表(只有原始数据有);
+ rel_ids:与原始数据关联的扰动数据的 id 列表(只有原始数据有);
#### 阅读理解数据格式:
- id:数据的编号,作为该条数据识别key;
+ id:数据的编号,作为该条数据识别 key;
title:文章标题;
context:文章主体;
question:文章的问题;
- sent_token:原文本数据的标准分词,注意:golden证据是基于该分词的,预测证据也需要与该分词对应;
+ sent_token:原文本数据的标准分词,注意:golden 证据是基于该分词的,预测证据也需要与该分词对应;
sample_type: 数据的类性,分为原始数据(ori)和扰动数据(disturb);
- rel_ids:与原始数据关联的扰动数据的id列表(只有原始数据有);
+ rel_ids:与原始数据关联的扰动数据的 id 列表(只有原始数据有);
## 模型运行
### 模型预测:
model_interpretation/task/{task}/run_inter_all.sh (生成所有结果)
model_interpretation/task/{task}/run_inter.sh (生成单个配置的结果,配置可以选择不同的评估模型,以及不同的证据抽取方法、语言)
-(注:{task}可取值为["senti","similarity","mrc"],其中senti代表情感分析,similarity代表相似度计算,mrc代表阅读理解)
+(注:{task}可取值为["senti","similarity","mrc"],其中 senti 代表情感分析,similarity 代表相似度计算,mrc 代表阅读理解)
### 证据抽取:
cd model_interpretation/rationale_extraction
diff --git a/legacy/examples/model_interpretation/data/mrc_ch b/slm/examples/model_interpretation/data/mrc_ch
similarity index 100%
rename from legacy/examples/model_interpretation/data/mrc_ch
rename to slm/examples/model_interpretation/data/mrc_ch
diff --git a/legacy/examples/model_interpretation/data/mrc_en b/slm/examples/model_interpretation/data/mrc_en
similarity index 100%
rename from legacy/examples/model_interpretation/data/mrc_en
rename to slm/examples/model_interpretation/data/mrc_en
diff --git a/legacy/examples/model_interpretation/data/senti_ch b/slm/examples/model_interpretation/data/senti_ch
similarity index 100%
rename from legacy/examples/model_interpretation/data/senti_ch
rename to slm/examples/model_interpretation/data/senti_ch
diff --git a/legacy/examples/model_interpretation/data/senti_en b/slm/examples/model_interpretation/data/senti_en
similarity index 100%
rename from legacy/examples/model_interpretation/data/senti_en
rename to slm/examples/model_interpretation/data/senti_en
diff --git a/legacy/examples/model_interpretation/data/similarity_ch b/slm/examples/model_interpretation/data/similarity_ch
similarity index 100%
rename from legacy/examples/model_interpretation/data/similarity_ch
rename to slm/examples/model_interpretation/data/similarity_ch
diff --git a/legacy/examples/model_interpretation/data/similarity_en b/slm/examples/model_interpretation/data/similarity_en
similarity index 100%
rename from legacy/examples/model_interpretation/data/similarity_en
rename to slm/examples/model_interpretation/data/similarity_en
diff --git a/slm/examples/model_interpretation/download.sh b/slm/examples/model_interpretation/download.sh
new file mode 100755
index 000000000000..50af3c252738
--- /dev/null
+++ b/slm/examples/model_interpretation/download.sh
@@ -0,0 +1,24 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+wget https://paddlenlp.bj.bcebos.com/data/model_interpretation.tar
+wait
+tar -xvf model_interpretation.tar
+wait
+mv ./model_interpretation/vocab.char ./task/similarity/simnet/
+mv ./model_interpretation/vocab_QQP ./task/similarity/simnet/
+mv ./model_interpretation/simnet_vocab.txt ./task/similarity/simnet/
+
+mv ./model_interpretation/vocab.sst2_train ./task/senti/rnn/
+mv ./model_interpretation/vocab.txt ./task/senti/rnn
\ No newline at end of file
diff --git a/legacy/examples/model_interpretation/evaluation/accuracy/cal_acc.py b/slm/examples/model_interpretation/evaluation/accuracy/cal_acc.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/accuracy/cal_acc.py
rename to slm/examples/model_interpretation/evaluation/accuracy/cal_acc.py
diff --git a/legacy/examples/model_interpretation/evaluation/accuracy/mrc_f1_evaluate.py b/slm/examples/model_interpretation/evaluation/accuracy/mrc_f1_evaluate.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/accuracy/mrc_f1_evaluate.py
rename to slm/examples/model_interpretation/evaluation/accuracy/mrc_f1_evaluate.py
diff --git a/legacy/examples/model_interpretation/evaluation/accuracy/run_acc.sh b/slm/examples/model_interpretation/evaluation/accuracy/run_acc.sh
similarity index 58%
rename from legacy/examples/model_interpretation/evaluation/accuracy/run_acc.sh
rename to slm/examples/model_interpretation/evaluation/accuracy/run_acc.sh
index cfa26fa204f0..3e3ae8b5362b 100755
--- a/legacy/examples/model_interpretation/evaluation/accuracy/run_acc.sh
+++ b/slm/examples/model_interpretation/evaluation/accuracy/run_acc.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script evaluates plausibility of the results generated by our models
###
diff --git a/legacy/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh b/slm/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh
similarity index 58%
rename from legacy/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh
rename to slm/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh
index 204bc6b4c207..9ab669914ed3 100755
--- a/legacy/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh
+++ b/slm/examples/model_interpretation/evaluation/accuracy/run_mrc_f1.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script is used to evaluate the performance of the mrc model (F1)
###
diff --git a/legacy/examples/model_interpretation/evaluation/consistency/cal_map.py b/slm/examples/model_interpretation/evaluation/consistency/cal_map.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/consistency/cal_map.py
rename to slm/examples/model_interpretation/evaluation/consistency/cal_map.py
diff --git a/legacy/examples/model_interpretation/evaluation/consistency/run_map.sh b/slm/examples/model_interpretation/evaluation/consistency/run_map.sh
similarity index 58%
rename from legacy/examples/model_interpretation/evaluation/consistency/run_map.sh
rename to slm/examples/model_interpretation/evaluation/consistency/run_map.sh
index 8ed9f114c5a2..84fb986de21d 100755
--- a/legacy/examples/model_interpretation/evaluation/consistency/run_map.sh
+++ b/slm/examples/model_interpretation/evaluation/consistency/run_map.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script evaluates consistency of the results generated by our models
###
diff --git a/legacy/examples/model_interpretation/evaluation/faithfulness/newp_analysis.py b/slm/examples/model_interpretation/evaluation/faithfulness/newp_analysis.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/faithfulness/newp_analysis.py
rename to slm/examples/model_interpretation/evaluation/faithfulness/newp_analysis.py
diff --git a/legacy/examples/model_interpretation/evaluation/faithfulness/run_newp.sh b/slm/examples/model_interpretation/evaluation/faithfulness/run_newp.sh
similarity index 57%
rename from legacy/examples/model_interpretation/evaluation/faithfulness/run_newp.sh
rename to slm/examples/model_interpretation/evaluation/faithfulness/run_newp.sh
index 5110ea61ff71..a6d62d642274 100755
--- a/legacy/examples/model_interpretation/evaluation/faithfulness/run_newp.sh
+++ b/slm/examples/model_interpretation/evaluation/faithfulness/run_newp.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script evaluates faithfulness of the results generated by our models
###
diff --git a/legacy/examples/model_interpretation/evaluation/plausibility/eval_mrc.py b/slm/examples/model_interpretation/evaluation/plausibility/eval_mrc.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/plausibility/eval_mrc.py
rename to slm/examples/model_interpretation/evaluation/plausibility/eval_mrc.py
diff --git a/legacy/examples/model_interpretation/evaluation/plausibility/eval_senti.py b/slm/examples/model_interpretation/evaluation/plausibility/eval_senti.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/plausibility/eval_senti.py
rename to slm/examples/model_interpretation/evaluation/plausibility/eval_senti.py
diff --git a/legacy/examples/model_interpretation/evaluation/plausibility/eval_similarity.py b/slm/examples/model_interpretation/evaluation/plausibility/eval_similarity.py
similarity index 100%
rename from legacy/examples/model_interpretation/evaluation/plausibility/eval_similarity.py
rename to slm/examples/model_interpretation/evaluation/plausibility/eval_similarity.py
diff --git a/legacy/examples/model_interpretation/evaluation/plausibility/run_f1.sh b/slm/examples/model_interpretation/evaluation/plausibility/run_f1.sh
similarity index 60%
rename from legacy/examples/model_interpretation/evaluation/plausibility/run_f1.sh
rename to slm/examples/model_interpretation/evaluation/plausibility/run_f1.sh
index 8d5bd2e7a9f2..40626934ffd0 100755
--- a/legacy/examples/model_interpretation/evaluation/plausibility/run_f1.sh
+++ b/slm/examples/model_interpretation/evaluation/plausibility/run_f1.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script evaluates plausibility of the results generated by our models
###
diff --git a/legacy/examples/model_interpretation/imgs/equation1.png b/slm/examples/model_interpretation/imgs/equation1.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/equation1.png
rename to slm/examples/model_interpretation/imgs/equation1.png
diff --git a/legacy/examples/model_interpretation/imgs/equation2.png b/slm/examples/model_interpretation/imgs/equation2.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/equation2.png
rename to slm/examples/model_interpretation/imgs/equation2.png
diff --git a/legacy/examples/model_interpretation/imgs/equation3.png b/slm/examples/model_interpretation/imgs/equation3.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/equation3.png
rename to slm/examples/model_interpretation/imgs/equation3.png
diff --git a/legacy/examples/model_interpretation/imgs/equation4.png b/slm/examples/model_interpretation/imgs/equation4.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/equation4.png
rename to slm/examples/model_interpretation/imgs/equation4.png
diff --git a/legacy/examples/model_interpretation/imgs/equation5.png b/slm/examples/model_interpretation/imgs/equation5.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/equation5.png
rename to slm/examples/model_interpretation/imgs/equation5.png
diff --git a/legacy/examples/model_interpretation/imgs/example1.png b/slm/examples/model_interpretation/imgs/example1.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/example1.png
rename to slm/examples/model_interpretation/imgs/example1.png
diff --git a/legacy/examples/model_interpretation/imgs/structure.png b/slm/examples/model_interpretation/imgs/structure.png
similarity index 100%
rename from legacy/examples/model_interpretation/imgs/structure.png
rename to slm/examples/model_interpretation/imgs/structure.png
diff --git a/legacy/examples/model_interpretation/punctuations b/slm/examples/model_interpretation/punctuations
similarity index 100%
rename from legacy/examples/model_interpretation/punctuations
rename to slm/examples/model_interpretation/punctuations
diff --git a/legacy/examples/model_interpretation/rationale_extraction/available_gpu.py b/slm/examples/model_interpretation/rationale_extraction/available_gpu.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/available_gpu.py
rename to slm/examples/model_interpretation/rationale_extraction/available_gpu.py
diff --git a/legacy/examples/model_interpretation/rationale_extraction/generate.sh b/slm/examples/model_interpretation/rationale_extraction/generate.sh
similarity index 75%
rename from legacy/examples/model_interpretation/rationale_extraction/generate.sh
rename to slm/examples/model_interpretation/rationale_extraction/generate.sh
index d72b20bda984..18de79ddb89e 100755
--- a/legacy/examples/model_interpretation/rationale_extraction/generate.sh
+++ b/slm/examples/model_interpretation/rationale_extraction/generate.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
TASK=similarity
if [[ $TASK == "mrc" ]]; then
diff --git a/legacy/examples/model_interpretation/rationale_extraction/generate_evaluation_data.py b/slm/examples/model_interpretation/rationale_extraction/generate_evaluation_data.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/generate_evaluation_data.py
rename to slm/examples/model_interpretation/rationale_extraction/generate_evaluation_data.py
diff --git a/legacy/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh b/slm/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh
similarity index 54%
rename from legacy/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh
rename to slm/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh
index fa26d3beb8f9..9f1dbef6c660 100755
--- a/legacy/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh
+++ b/slm/examples/model_interpretation/rationale_extraction/generate_evaluation_data.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script concatenates results from previous running to generate a formated result for evaluation use
###
diff --git a/legacy/examples/model_interpretation/rationale_extraction/mrc_pred.py b/slm/examples/model_interpretation/rationale_extraction/mrc_pred.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/mrc_pred.py
rename to slm/examples/model_interpretation/rationale_extraction/mrc_pred.py
diff --git a/legacy/examples/model_interpretation/rationale_extraction/newp_text_generate.py b/slm/examples/model_interpretation/rationale_extraction/newp_text_generate.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/newp_text_generate.py
rename to slm/examples/model_interpretation/rationale_extraction/newp_text_generate.py
diff --git a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh
similarity index 74%
rename from legacy/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh
rename to slm/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh
index c672ca7a1b60..60a625f86f72 100755
--- a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh
+++ b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_mrc_per.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script generates mrc predictions for texts contains rationales only and contains non-rationales only
###
diff --git a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh
similarity index 82%
rename from legacy/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh
rename to slm/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh
index 06dfea7790d8..0ca3256b3285 100755
--- a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh
+++ b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_senti_per.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script generates sentiment predictions for texts contains rationales only and contains non-rationales only
###
diff --git a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh
similarity index 79%
rename from legacy/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh
rename to slm/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh
index 9f0fecd865b7..8e64b5c7ae90 100755
--- a/legacy/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh
+++ b/slm/examples/model_interpretation/rationale_extraction/run_2_pred_similarity_per.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script generates textual similarity predictions for texts contains rationales only and contains non-rationales only
###
diff --git a/legacy/examples/model_interpretation/rationale_extraction/sentiment_pred.py b/slm/examples/model_interpretation/rationale_extraction/sentiment_pred.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/sentiment_pred.py
rename to slm/examples/model_interpretation/rationale_extraction/sentiment_pred.py
diff --git a/legacy/examples/model_interpretation/rationale_extraction/similarity_pred.py b/slm/examples/model_interpretation/rationale_extraction/similarity_pred.py
similarity index 100%
rename from legacy/examples/model_interpretation/rationale_extraction/similarity_pred.py
rename to slm/examples/model_interpretation/rationale_extraction/similarity_pred.py
diff --git a/legacy/examples/model_interpretation/requirements.txt b/slm/examples/model_interpretation/requirements.txt
similarity index 100%
rename from legacy/examples/model_interpretation/requirements.txt
rename to slm/examples/model_interpretation/requirements.txt
diff --git a/legacy/examples/model_interpretation/task/README.md b/slm/examples/model_interpretation/task/README.md
similarity index 100%
rename from legacy/examples/model_interpretation/task/README.md
rename to slm/examples/model_interpretation/task/README.md
diff --git a/legacy/examples/model_interpretation/task/mrc/roberta/modeling.py b/slm/examples/model_interpretation/task/mrc/roberta/modeling.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/roberta/modeling.py
rename to slm/examples/model_interpretation/task/mrc/roberta/modeling.py
diff --git a/legacy/examples/model_interpretation/task/mrc/run_1_predict_rc.sh b/slm/examples/model_interpretation/task/mrc/run_1_predict_rc.sh
similarity index 78%
rename from legacy/examples/model_interpretation/task/mrc/run_1_predict_rc.sh
rename to slm/examples/model_interpretation/task/mrc/run_1_predict_rc.sh
index 1039a2e08546..3921a10ac15a 100755
--- a/legacy/examples/model_interpretation/task/mrc/run_1_predict_rc.sh
+++ b/slm/examples/model_interpretation/task/mrc/run_1_predict_rc.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to run prediction of a specific baseline model and language on given input data
# The result of this script will be used to evaluate the performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh b/slm/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh
similarity index 81%
rename from legacy/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh
rename to slm/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh
index b504072d49bd..4d8b30a47603 100755
--- a/legacy/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh
+++ b/slm/examples/model_interpretation/task/mrc/run_1_predict_rc_all.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to run predictions of all baseline models and languages on given input data
# The result of this script will be used to evaluate the performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/mrc/run_2_inter_rc.sh b/slm/examples/model_interpretation/task/mrc/run_2_inter_rc.sh
similarity index 76%
rename from legacy/examples/model_interpretation/task/mrc/run_2_inter_rc.sh
rename to slm/examples/model_interpretation/task/mrc/run_2_inter_rc.sh
index 5f038bfcaa98..eef2f26712af 100755
--- a/legacy/examples/model_interpretation/task/mrc/run_2_inter_rc.sh
+++ b/slm/examples/model_interpretation/task/mrc/run_2_inter_rc.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of a specific baseline model and language on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh b/slm/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh
similarity index 80%
rename from legacy/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh
rename to slm/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh
index 5908512f7ba9..c5090dc45839 100755
--- a/legacy/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh
+++ b/slm/examples/model_interpretation/task/mrc/run_2_inter_rc_all.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of all baseline models and languages on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/mrc/run_train_rc.sh b/slm/examples/model_interpretation/task/mrc/run_train_rc.sh
similarity index 70%
rename from legacy/examples/model_interpretation/task/mrc/run_train_rc.sh
rename to slm/examples/model_interpretation/task/mrc/run_train_rc.sh
index ff7d95db9342..c76d2e5b1917 100755
--- a/legacy/examples/model_interpretation/task/mrc/run_train_rc.sh
+++ b/slm/examples/model_interpretation/task/mrc/run_train_rc.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script is used to run fine-tunning of mrc roberta models.
###
diff --git a/legacy/examples/model_interpretation/task/mrc/saliency_map/rc_finetune.py b/slm/examples/model_interpretation/task/mrc/saliency_map/rc_finetune.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/saliency_map/rc_finetune.py
rename to slm/examples/model_interpretation/task/mrc/saliency_map/rc_finetune.py
diff --git a/legacy/examples/model_interpretation/task/mrc/saliency_map/rc_interpretable.py b/slm/examples/model_interpretation/task/mrc/saliency_map/rc_interpretable.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/saliency_map/rc_interpretable.py
rename to slm/examples/model_interpretation/task/mrc/saliency_map/rc_interpretable.py
diff --git a/legacy/examples/model_interpretation/task/mrc/saliency_map/rc_prediction.py b/slm/examples/model_interpretation/task/mrc/saliency_map/rc_prediction.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/saliency_map/rc_prediction.py
rename to slm/examples/model_interpretation/task/mrc/saliency_map/rc_prediction.py
diff --git a/legacy/examples/model_interpretation/task/mrc/saliency_map/squad.py b/slm/examples/model_interpretation/task/mrc/saliency_map/squad.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/saliency_map/squad.py
rename to slm/examples/model_interpretation/task/mrc/saliency_map/squad.py
diff --git a/legacy/examples/model_interpretation/task/mrc/saliency_map/utils.py b/slm/examples/model_interpretation/task/mrc/saliency_map/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/mrc/saliency_map/utils.py
rename to slm/examples/model_interpretation/task/mrc/saliency_map/utils.py
diff --git a/slm/examples/model_interpretation/task/senti/LIME/exceptions.py b/slm/examples/model_interpretation/task/senti/LIME/exceptions.py
new file mode 100644
index 000000000000..7e134f17d477
--- /dev/null
+++ b/slm/examples/model_interpretation/task/senti/LIME/exceptions.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+class LimeError(Exception):
+ """Raise for errors"""
diff --git a/legacy/examples/model_interpretation/task/senti/LIME/explanation.py b/slm/examples/model_interpretation/task/senti/LIME/explanation.py
similarity index 99%
rename from legacy/examples/model_interpretation/task/senti/LIME/explanation.py
rename to slm/examples/model_interpretation/task/senti/LIME/explanation.py
index 6e212b1613ca..09f34aa2b67f 100644
--- a/legacy/examples/model_interpretation/task/senti/LIME/explanation.py
+++ b/slm/examples/model_interpretation/task/senti/LIME/explanation.py
@@ -14,16 +14,16 @@
"""
Explanation class, with visualization functions.
"""
-from io import open
+import json
import os
import os.path
-import json
import string
+from io import open
+
import numpy as np
# from .exceptions import LimeError
from LIME.exceptions import LimeError
-
from sklearn.utils import check_random_state
@@ -193,7 +193,7 @@ def show_in_notebook(self, labels=None, predict_proba=True, show_predicted_value
See as_html() for parameters.
This will throw an error if you don't have IPython installed"""
- from IPython.core.display import display, HTML
+ from IPython.core.display import HTML, display
display(
HTML(
diff --git a/legacy/examples/model_interpretation/task/senti/LIME/lime_base.py b/slm/examples/model_interpretation/task/senti/LIME/lime_base.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/LIME/lime_base.py
rename to slm/examples/model_interpretation/task/senti/LIME/lime_base.py
diff --git a/legacy/examples/model_interpretation/task/senti/LIME/lime_text.py b/slm/examples/model_interpretation/task/senti/LIME/lime_text.py
similarity index 99%
rename from legacy/examples/model_interpretation/task/senti/LIME/lime_text.py
rename to slm/examples/model_interpretation/task/senti/LIME/lime_text.py
index 7ef6d3bc40de..9e987646861c 100644
--- a/legacy/examples/model_interpretation/task/senti/LIME/lime_text.py
+++ b/slm/examples/model_interpretation/task/senti/LIME/lime_text.py
@@ -17,20 +17,19 @@
"""
import itertools
import json
+import math
import re
import time
-import math
-import paddle
from functools import partial
+import LIME.explanation as explanation
+import LIME.lime_base as lime_base
import numpy as np
+import paddle
import scipy as sp
import sklearn
from sklearn.utils import check_random_state
-import LIME.explanation as explanation
-import LIME.lime_base as lime_base
-
class TextDomainMapper(explanation.DomainMapper):
"""Maps feature ids to words or word-positions"""
diff --git a/legacy/examples/model_interpretation/task/senti/pretrained_models/run_train.sh b/slm/examples/model_interpretation/task/senti/pretrained_models/run_train.sh
similarity index 53%
rename from legacy/examples/model_interpretation/task/senti/pretrained_models/run_train.sh
rename to slm/examples/model_interpretation/task/senti/pretrained_models/run_train.sh
index b13d03c6486e..689211b94590 100755
--- a/legacy/examples/model_interpretation/task/senti/pretrained_models/run_train.sh
+++ b/slm/examples/model_interpretation/task/senti/pretrained_models/run_train.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script is used to finetune pretrained models
###
diff --git a/legacy/examples/model_interpretation/task/senti/pretrained_models/train.py b/slm/examples/model_interpretation/task/senti/pretrained_models/train.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/pretrained_models/train.py
rename to slm/examples/model_interpretation/task/senti/pretrained_models/train.py
diff --git a/legacy/examples/model_interpretation/task/senti/pretrained_models/utils.py b/slm/examples/model_interpretation/task/senti/pretrained_models/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/pretrained_models/utils.py
rename to slm/examples/model_interpretation/task/senti/pretrained_models/utils.py
diff --git a/slm/examples/model_interpretation/task/senti/rnn/lstm_train.sh b/slm/examples/model_interpretation/task/senti/rnn/lstm_train.sh
new file mode 100755
index 000000000000..cef91dba9f25
--- /dev/null
+++ b/slm/examples/model_interpretation/task/senti/rnn/lstm_train.sh
@@ -0,0 +1,34 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+###
+ # This script is used to train lstm models
+###
+
+unset CUDA_VISIBLE_DEVICES
+LANGUAGE=en
+
+if [[ $LANGUAGE == 'ch' ]]; then
+ VOCAB_PATH='./vocab.txt'
+else
+ VOCAB_PATH='vocab.sst2_train'
+fi
+python -m paddle.distributed.launch --gpus "5" train.py \
+ --device=gpu \
+ --lr=4e-4 \
+ --batch_size=64 \
+ --epochs=12 \
+ --vocab_path=$VOCAB_PATH \
+ --language=$LANGUAGE \
+ --save_dir="./checkpoints_"${LANGUAGE}
diff --git a/legacy/examples/model_interpretation/task/senti/rnn/model.py b/slm/examples/model_interpretation/task/senti/rnn/model.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/rnn/model.py
rename to slm/examples/model_interpretation/task/senti/rnn/model.py
diff --git a/legacy/examples/model_interpretation/task/senti/rnn/tokenizer_config.json b/slm/examples/model_interpretation/task/senti/rnn/tokenizer_config.json
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/rnn/tokenizer_config.json
rename to slm/examples/model_interpretation/task/senti/rnn/tokenizer_config.json
diff --git a/legacy/examples/model_interpretation/task/senti/rnn/train.py b/slm/examples/model_interpretation/task/senti/rnn/train.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/rnn/train.py
rename to slm/examples/model_interpretation/task/senti/rnn/train.py
diff --git a/legacy/examples/model_interpretation/task/senti/rnn/utils.py b/slm/examples/model_interpretation/task/senti/rnn/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/rnn/utils.py
rename to slm/examples/model_interpretation/task/senti/rnn/utils.py
diff --git a/legacy/examples/model_interpretation/task/senti/roberta/modeling.py b/slm/examples/model_interpretation/task/senti/roberta/modeling.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/roberta/modeling.py
rename to slm/examples/model_interpretation/task/senti/roberta/modeling.py
diff --git a/legacy/examples/model_interpretation/task/senti/run_inter.sh b/slm/examples/model_interpretation/task/senti/run_inter.sh
similarity index 81%
rename from legacy/examples/model_interpretation/task/senti/run_inter.sh
rename to slm/examples/model_interpretation/task/senti/run_inter.sh
index c7b71e78d212..fd240da3b5fc 100755
--- a/legacy/examples/model_interpretation/task/senti/run_inter.sh
+++ b/slm/examples/model_interpretation/task/senti/run_inter.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of a specific baseline model and language on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/senti/run_inter_all.sh b/slm/examples/model_interpretation/task/senti/run_inter_all.sh
similarity index 84%
rename from legacy/examples/model_interpretation/task/senti/run_inter_all.sh
rename to slm/examples/model_interpretation/task/senti/run_inter_all.sh
index 8b0a1d98bf01..dda51b820518 100755
--- a/legacy/examples/model_interpretation/task/senti/run_inter_all.sh
+++ b/slm/examples/model_interpretation/task/senti/run_inter_all.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of all baseline models and languages on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/senti/saliency_map/sentiment_interpretable.py b/slm/examples/model_interpretation/task/senti/saliency_map/sentiment_interpretable.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/saliency_map/sentiment_interpretable.py
rename to slm/examples/model_interpretation/task/senti/saliency_map/sentiment_interpretable.py
diff --git a/legacy/examples/model_interpretation/task/senti/saliency_map/utils.py b/slm/examples/model_interpretation/task/senti/saliency_map/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/senti/saliency_map/utils.py
rename to slm/examples/model_interpretation/task/senti/saliency_map/utils.py
diff --git a/slm/examples/model_interpretation/task/similarity/LIME/exceptions.py b/slm/examples/model_interpretation/task/similarity/LIME/exceptions.py
new file mode 100644
index 000000000000..7e134f17d477
--- /dev/null
+++ b/slm/examples/model_interpretation/task/similarity/LIME/exceptions.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+class LimeError(Exception):
+ """Raise for errors"""
diff --git a/legacy/examples/model_interpretation/task/similarity/LIME/explanation.py b/slm/examples/model_interpretation/task/similarity/LIME/explanation.py
similarity index 99%
rename from legacy/examples/model_interpretation/task/similarity/LIME/explanation.py
rename to slm/examples/model_interpretation/task/similarity/LIME/explanation.py
index 46b3f0463fa6..f8072e389513 100644
--- a/legacy/examples/model_interpretation/task/similarity/LIME/explanation.py
+++ b/slm/examples/model_interpretation/task/similarity/LIME/explanation.py
@@ -14,16 +14,15 @@
"""
Explanation class, with visualization functions.
"""
-from io import open
+import json
import os
import os.path
-import json
import string
-import numpy as np
-
-from sklearn.utils import check_random_state
+from io import open
+import numpy as np
from LIME.exceptions import LimeError
+from sklearn.utils import check_random_state
def id_generator(size=15, random_state=None):
@@ -192,7 +191,7 @@ def show_in_notebook(self, labels=None, predict_proba=True, show_predicted_value
See as_html() for parameters.
This will throw an error if you don't have IPython installed"""
- from IPython.core.display import display, HTML
+ from IPython.core.display import HTML, display
display(
HTML(
diff --git a/legacy/examples/model_interpretation/task/similarity/LIME/lime_base.py b/slm/examples/model_interpretation/task/similarity/LIME/lime_base.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/LIME/lime_base.py
rename to slm/examples/model_interpretation/task/similarity/LIME/lime_base.py
diff --git a/legacy/examples/model_interpretation/task/similarity/LIME/lime_text.py b/slm/examples/model_interpretation/task/similarity/LIME/lime_text.py
similarity index 99%
rename from legacy/examples/model_interpretation/task/similarity/LIME/lime_text.py
rename to slm/examples/model_interpretation/task/similarity/LIME/lime_text.py
index b702a68d8de1..4453ef3dfea5 100644
--- a/legacy/examples/model_interpretation/task/similarity/LIME/lime_text.py
+++ b/slm/examples/model_interpretation/task/similarity/LIME/lime_text.py
@@ -15,22 +15,21 @@
"""
Functions for explaining text classifiers.
"""
-from functools import partial
import itertools
import json
+import math
import re
import time
-import math
-import paddle
+from functools import partial
+import LIME.explanation as explanation
+import LIME.lime_base as lime_base
import numpy as np
+import paddle
import scipy as sp
import sklearn
from sklearn.utils import check_random_state
-import LIME.explanation as explanation
-import LIME.lime_base as lime_base
-
class TextDomainMapper(explanation.DomainMapper):
"""Maps feature ids to words or word-positions"""
diff --git a/legacy/examples/model_interpretation/task/similarity/pretrained_models/data.py b/slm/examples/model_interpretation/task/similarity/pretrained_models/data.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/pretrained_models/data.py
rename to slm/examples/model_interpretation/task/similarity/pretrained_models/data.py
index 37f2c12781f4..7c4811703341 100644
--- a/legacy/examples/model_interpretation/task/similarity/pretrained_models/data.py
+++ b/slm/examples/model_interpretation/task/similarity/pretrained_models/data.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import paddle
import numpy as np
+import paddle
from paddlenlp.datasets import MapDataset
diff --git a/legacy/examples/model_interpretation/task/similarity/pretrained_models/model.py b/slm/examples/model_interpretation/task/similarity/pretrained_models/model.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/pretrained_models/model.py
rename to slm/examples/model_interpretation/task/similarity/pretrained_models/model.py
diff --git a/legacy/examples/model_interpretation/task/similarity/pretrained_models/predict_pointwise.py b/slm/examples/model_interpretation/task/similarity/pretrained_models/predict_pointwise.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/pretrained_models/predict_pointwise.py
rename to slm/examples/model_interpretation/task/similarity/pretrained_models/predict_pointwise.py
diff --git a/legacy/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh b/slm/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh
similarity index 56%
rename from legacy/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh
rename to slm/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh
index 13771c1837ed..7bad3d2ccd29 100755
--- a/legacy/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh
+++ b/slm/examples/model_interpretation/task/similarity/pretrained_models/run_train_pointwise.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This script is used to finetune pretrained models
###
diff --git a/legacy/examples/model_interpretation/task/similarity/pretrained_models/train_pointwise.py b/slm/examples/model_interpretation/task/similarity/pretrained_models/train_pointwise.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/pretrained_models/train_pointwise.py
rename to slm/examples/model_interpretation/task/similarity/pretrained_models/train_pointwise.py
diff --git a/legacy/examples/model_interpretation/task/similarity/roberta/modeling.py b/slm/examples/model_interpretation/task/similarity/roberta/modeling.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/roberta/modeling.py
rename to slm/examples/model_interpretation/task/similarity/roberta/modeling.py
diff --git a/legacy/examples/model_interpretation/task/similarity/run_inter.sh b/slm/examples/model_interpretation/task/similarity/run_inter.sh
similarity index 81%
rename from legacy/examples/model_interpretation/task/similarity/run_inter.sh
rename to slm/examples/model_interpretation/task/similarity/run_inter.sh
index e9de8e11df87..7d8047dedd23 100755
--- a/legacy/examples/model_interpretation/task/similarity/run_inter.sh
+++ b/slm/examples/model_interpretation/task/similarity/run_inter.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of a specific baseline model and language on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/similarity/run_inter_all.sh b/slm/examples/model_interpretation/task/similarity/run_inter_all.sh
similarity index 84%
rename from legacy/examples/model_interpretation/task/similarity/run_inter_all.sh
rename to slm/examples/model_interpretation/task/similarity/run_inter_all.sh
index edabd07d6f41..e1e9083fda63 100755
--- a/legacy/examples/model_interpretation/task/similarity/run_inter_all.sh
+++ b/slm/examples/model_interpretation/task/similarity/run_inter_all.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
###
# This file contains script to generate saliency map of all baseline models and languages on given input data
# The result of this script will be used to evaluate the interpretive performance of the baseline model
diff --git a/legacy/examples/model_interpretation/task/similarity/saliency_map/similarity_interpretable.py b/slm/examples/model_interpretation/task/similarity/saliency_map/similarity_interpretable.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/saliency_map/similarity_interpretable.py
rename to slm/examples/model_interpretation/task/similarity/saliency_map/similarity_interpretable.py
diff --git a/legacy/examples/model_interpretation/task/similarity/saliency_map/utils.py b/slm/examples/model_interpretation/task/similarity/saliency_map/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/saliency_map/utils.py
rename to slm/examples/model_interpretation/task/similarity/saliency_map/utils.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/gen_vocab.py b/slm/examples/model_interpretation/task/similarity/simnet/gen_vocab.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/gen_vocab.py
rename to slm/examples/model_interpretation/task/similarity/simnet/gen_vocab.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/interpreter_attention.py b/slm/examples/model_interpretation/task/similarity/simnet/interpreter_attention.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/interpreter_attention.py
rename to slm/examples/model_interpretation/task/similarity/simnet/interpreter_attention.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/interpreter_grad.py b/slm/examples/model_interpretation/task/similarity/simnet/interpreter_grad.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/interpreter_grad.py
rename to slm/examples/model_interpretation/task/similarity/simnet/interpreter_grad.py
diff --git a/slm/examples/model_interpretation/task/similarity/simnet/lstm_train.sh b/slm/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
new file mode 100755
index 000000000000..1e116b0d30c4
--- /dev/null
+++ b/slm/examples/model_interpretation/task/similarity/simnet/lstm_train.sh
@@ -0,0 +1,35 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+###
+ # This script is used to train lstm models
+###
+
+unset CUDA_VISIBLE_DEVICES
+LANGUAGE=en
+
+if [[ $LANGUAGE == "ch" ]]; then
+ VOCAB_PATH=vocab.char
+elif [[ $LANGUAGE == "en" ]]; then
+ VOCAB_PATH=vocab_QQP
+fi
+
+python -m paddle.distributed.launch --gpus "5" train.py \
+ --device=gpu \
+ --lr=4e-4 \
+ --batch_size=64 \
+ --epochs=12 \
+ --vocab_path=$VOCAB_PATH \
+ --language=$LANGUAGE \
+ --save_dir="./checkpoints_"${LANGUAGE}
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/model.py b/slm/examples/model_interpretation/task/similarity/simnet/model.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/model.py
rename to slm/examples/model_interpretation/task/similarity/simnet/model.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/predict.py b/slm/examples/model_interpretation/task/similarity/simnet/predict.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/predict.py
rename to slm/examples/model_interpretation/task/similarity/simnet/predict.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/train.py b/slm/examples/model_interpretation/task/similarity/simnet/train.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/train.py
rename to slm/examples/model_interpretation/task/similarity/simnet/train.py
diff --git a/legacy/examples/model_interpretation/task/similarity/simnet/utils.py b/slm/examples/model_interpretation/task/similarity/simnet/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/similarity/simnet/utils.py
rename to slm/examples/model_interpretation/task/similarity/simnet/utils.py
diff --git a/legacy/examples/model_interpretation/task/transformer.py b/slm/examples/model_interpretation/task/transformer.py
similarity index 100%
rename from legacy/examples/model_interpretation/task/transformer.py
rename to slm/examples/model_interpretation/task/transformer.py
diff --git a/legacy/examples/model_interpretation/utils.py b/slm/examples/model_interpretation/utils.py
similarity index 100%
rename from legacy/examples/model_interpretation/utils.py
rename to slm/examples/model_interpretation/utils.py
diff --git a/legacy/examples/multimodal/layoutlm/README.md b/slm/examples/multimodal/layoutlm/README.md
similarity index 62%
rename from legacy/examples/multimodal/layoutlm/README.md
rename to slm/examples/multimodal/layoutlm/README.md
index f1f46392d4cd..59734d7b60ba 100644
--- a/legacy/examples/multimodal/layoutlm/README.md
+++ b/slm/examples/multimodal/layoutlm/README.md
@@ -2,7 +2,7 @@
## 模型简介
本项目是 [LayoutLM:Pre-training of Text and Layout for Document Image Understanding](https://arxiv.org/pdf/1912.13318v5.pdf) 在 Paddle 2.2上的开源实现,
-包含了在 [FUNSD数据集](https://guillaumejaume.github.io/FUNSD/) 上的微调代码。
+包含了在 [FUNSD 数据集](https://guillaumejaume.github.io/FUNSD/) 上的微调代码。
## 快速开始
### 配置环境
@@ -19,12 +19,12 @@ pip install yacs
```
### 数据准备
-处理好的FUNSD中文数据集下载地址:https://bj.bcebos.com/v1/paddlenlp/datasets/FUNSD.zip 。
+处理好的 FUNSD 中文数据集下载地址:https://bj.bcebos.com/v1/paddlenlp/datasets/FUNSD.zip 。
下载并解压该数据集,解压后将数据集放置在当前目录下。
-### 执行Fine-tuning
-1. ``Sequence Labeling`` 任务启动Fine-tuning的方式如下:
+### 执行 Fine-tuning
+1. ``Sequence Labeling`` 任务启动 Fine-tuning 的方式如下:
```shell
bash train_funsd.sh
@@ -33,8 +33,8 @@ pip install yacs
```
### 数据处理
-FUNSD数据集是常用的表格理解数据集,原始的数据集下载地址:https://guillaumejaume.github.io/FUNSD/dataset.zip.
-包括training_data和test_dataing两个子文件夹,包括149个训练数据和50个测试数据。数据预处理方式如下:
+FUNSD 数据集是常用的表格理解数据集,原始的数据集下载地址:https://guillaumejaume.github.io/FUNSD/dataset.zip.
+包括 training_data 和 test_dataing 两个子文件夹,包括149个训练数据和50个测试数据。数据预处理方式如下:
```shell
bash preprocess.sh
```
diff --git a/legacy/examples/multimodal/layoutlm/funsd.py b/slm/examples/multimodal/layoutlm/funsd.py
similarity index 100%
rename from legacy/examples/multimodal/layoutlm/funsd.py
rename to slm/examples/multimodal/layoutlm/funsd.py
diff --git a/legacy/examples/multimodal/layoutlm/preprocess.py b/slm/examples/multimodal/layoutlm/preprocess.py
similarity index 91%
rename from legacy/examples/multimodal/layoutlm/preprocess.py
rename to slm/examples/multimodal/layoutlm/preprocess.py
index 28b07e5ca5d8..e5cd0799db01 100644
--- a/legacy/examples/multimodal/layoutlm/preprocess.py
+++ b/slm/examples/multimodal/layoutlm/preprocess.py
@@ -1,8 +1,23 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
import json
import os
from PIL import Image
+
from paddlenlp.transformers import AutoTokenizer
diff --git a/legacy/examples/multimodal/layoutlm/preprocess.sh b/slm/examples/multimodal/layoutlm/preprocess.sh
similarity index 53%
rename from legacy/examples/multimodal/layoutlm/preprocess.sh
rename to slm/examples/multimodal/layoutlm/preprocess.sh
index 2ff8dc4e317a..8f6d4a597e8f 100644
--- a/legacy/examples/multimodal/layoutlm/preprocess.sh
+++ b/slm/examples/multimodal/layoutlm/preprocess.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
python preprocess.py --data_dir data/training_data/annotations \
--data_split train \
--output_dir data \
diff --git a/legacy/examples/multimodal/layoutlm/train_funsd.py b/slm/examples/multimodal/layoutlm/train_funsd.py
similarity index 100%
rename from legacy/examples/multimodal/layoutlm/train_funsd.py
rename to slm/examples/multimodal/layoutlm/train_funsd.py
diff --git a/slm/examples/multimodal/layoutlm/train_funsd.sh b/slm/examples/multimodal/layoutlm/train_funsd.sh
new file mode 100644
index 000000000000..f601ca7fc83c
--- /dev/null
+++ b/slm/examples/multimodal/layoutlm/train_funsd.sh
@@ -0,0 +1,31 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+export CUDA_VISIBLE_DEVICES=7
+
+python3.7 train_funsd.py \
+ --data_dir "./data/" \
+ --model_name_or_path "layoutlm-base-uncased" \
+ --do_lower_case \
+ --max_seq_length 512 \
+ --do_train \
+ --do_eval \
+ --num_train_epochs 100 \
+ --logging_steps 10 \
+ --save_steps 500 \
+ --output_dir "output/" \
+ --labels "./data/labels.txt" \
+ --per_gpu_train_batch_size 16 \
+ --per_gpu_eval_batch_size 16 \
+ --evaluate_during_training
diff --git a/legacy/examples/multimodal/layoutlm/utils.py b/slm/examples/multimodal/layoutlm/utils.py
similarity index 100%
rename from legacy/examples/multimodal/layoutlm/utils.py
rename to slm/examples/multimodal/layoutlm/utils.py
diff --git a/legacy/examples/multimodal/layoutxlm/README.md b/slm/examples/multimodal/layoutxlm/README.md
similarity index 74%
rename from legacy/examples/multimodal/layoutxlm/README.md
rename to slm/examples/multimodal/layoutxlm/README.md
index 03c0a93c6a20..fbe5b1778d2a 100644
--- a/legacy/examples/multimodal/layoutxlm/README.md
+++ b/slm/examples/multimodal/layoutxlm/README.md
@@ -2,7 +2,7 @@
## 模型简介
本项目是 [LayoutXLM: Multimodal Pre-training for Multilingual Visually-rich Document Understanding](https://arxiv.org/pdf/2104.08836.pdf) 在 Paddle 2.2上的开源实现,
-包含了在 [XFUND数据集](https://github.com/doc-analysis/XFUND) 上的微调代码。
+包含了在 [XFUND 数据集](https://github.com/doc-analysis/XFUND) 上的微调代码。
## 快速开始
### 配置环境
@@ -19,12 +19,12 @@ pip install yacs
```
### 数据准备
-处理好的XFUND中文数据集下载地址:https://bj.bcebos.com/v1/paddlenlp/datasets/XFUND.zip 。
+处理好的 XFUND 中文数据集下载地址:https://bj.bcebos.com/v1/paddlenlp/datasets/XFUND.zip 。
下载并解压该数据集,解压后将数据集放置在当前目录下。
-### 执行Fine-tuning
-1. ``Semantic Entity Recognition`` 任务启动Fine-tuning的方式如下:
+### 执行 Fine-tuning
+1. ``Semantic Entity Recognition`` 任务启动 Fine-tuning 的方式如下:
```shell
bash run_xfun_ser.sh
@@ -32,7 +32,7 @@ pip install yacs
# best metrics: {'precision': 0.8514686248331108, 'recall': 0.9354602126879354, 'f1': 0.8914904770225406}
```
-2. ``Relation Extraction`` 任务启动Fine-tuning的方式如下:
+2. ``Relation Extraction`` 任务启动 Fine-tuning 的方式如下:
```shell
bash run_xfun_re.sh
diff --git a/legacy/examples/multimodal/layoutxlm/compare.py b/slm/examples/multimodal/layoutxlm/compare.py
similarity index 100%
rename from legacy/examples/multimodal/layoutxlm/compare.py
rename to slm/examples/multimodal/layoutxlm/compare.py
diff --git a/legacy/examples/multimodal/layoutxlm/run_xfun_re.py b/slm/examples/multimodal/layoutxlm/run_xfun_re.py
similarity index 95%
rename from legacy/examples/multimodal/layoutxlm/run_xfun_re.py
rename to slm/examples/multimodal/layoutxlm/run_xfun_re.py
index 13e31b27b99c..faf786db1374 100644
--- a/legacy/examples/multimodal/layoutxlm/run_xfun_re.py
+++ b/slm/examples/multimodal/layoutxlm/run_xfun_re.py
@@ -1,15 +1,34 @@
-import sys
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import argparse
+import logging
+import numbers
import os
import random
-import numbers
-import logging
+import sys
-import argparse
-import paddle
import numpy as np
-from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer, LayoutXLMForRelationExtraction
+import paddle
from xfun import XFUN
+from paddlenlp.transformers import (
+ LayoutXLMForRelationExtraction,
+ LayoutXLMModel,
+ LayoutXLMTokenizer,
+)
+
# Todo: delete the following line after the release of v2.2
sys.path.insert(0, "../../../")
logger = logging.getLogger(__name__)
diff --git a/legacy/examples/multimodal/layoutxlm/run_xfun_re.sh b/slm/examples/multimodal/layoutxlm/run_xfun_re.sh
similarity index 50%
rename from legacy/examples/multimodal/layoutxlm/run_xfun_re.sh
rename to slm/examples/multimodal/layoutxlm/run_xfun_re.sh
index 4aeea52f5dc9..93dc48c9abef 100644
--- a/legacy/examples/multimodal/layoutxlm/run_xfun_re.sh
+++ b/slm/examples/multimodal/layoutxlm/run_xfun_re.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
export CUDA_VISIBLE_DEVICES=0
python ./run_xfun_re.py \
diff --git a/legacy/examples/multimodal/layoutxlm/run_xfun_ser.py b/slm/examples/multimodal/layoutxlm/run_xfun_ser.py
similarity index 100%
rename from legacy/examples/multimodal/layoutxlm/run_xfun_ser.py
rename to slm/examples/multimodal/layoutxlm/run_xfun_ser.py
diff --git a/legacy/examples/multimodal/layoutxlm/run_xfun_ser.sh b/slm/examples/multimodal/layoutxlm/run_xfun_ser.sh
similarity index 50%
rename from legacy/examples/multimodal/layoutxlm/run_xfun_ser.sh
rename to slm/examples/multimodal/layoutxlm/run_xfun_ser.sh
index 43454abfc264..b8642480e1f8 100644
--- a/legacy/examples/multimodal/layoutxlm/run_xfun_ser.sh
+++ b/slm/examples/multimodal/layoutxlm/run_xfun_ser.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
export CUDA_VISIBLE_DEVICES=0
python ./run_xfun_ser.py \
diff --git a/legacy/examples/multimodal/layoutxlm/xfun.py b/slm/examples/multimodal/layoutxlm/xfun.py
similarity index 96%
rename from legacy/examples/multimodal/layoutxlm/xfun.py
rename to slm/examples/multimodal/layoutxlm/xfun.py
index 3bb5be92e913..ae30d8ff5d99 100644
--- a/legacy/examples/multimodal/layoutxlm/xfun.py
+++ b/slm/examples/multimodal/layoutxlm/xfun.py
@@ -1,9 +1,24 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import copy
import json
import os
+
import cv2
import numpy as np
import paddle
-import copy
from paddle.io import Dataset
__all__ = ["XFUN"]
diff --git a/legacy/examples/multimodal/minigpt4/README.md b/slm/examples/multimodal/minigpt4/README.md
similarity index 62%
rename from legacy/examples/multimodal/minigpt4/README.md
rename to slm/examples/multimodal/minigpt4/README.md
index 48c9f7384076..adfd23c89b48 100644
--- a/legacy/examples/multimodal/minigpt4/README.md
+++ b/slm/examples/multimodal/minigpt4/README.md
@@ -2,15 +2,15 @@
## 1. 模型简介
-MiniGPT4 是一个具有图像理解能力的开源模型,其基于 Vicuna 大语言模型 以及 BLIP-2 中的VIT和Qformer模块进行训练,使得MiniGPT4 拥有类似于GPT4的非凡能力,例如详细的图像描述生成和从手写草稿创建网站。 此外 MiniGPT4 还具备一些的其他新的功能,包括根据给定图像写故事和诗歌,为图像中显示的问题提供解决方案,教用户如何根据食物照片做饭等。下图展示了MiniGPT4的模型结构, 更多信息请参考[MiniGPT4](https://arxiv.org/abs/2304.10592)。
+MiniGPT4 是一个具有图像理解能力的开源模型,其基于 Vicuna 大语言模型 以及 BLIP-2 中的 VIT 和 Qformer 模块进行训练,使得 MiniGPT4 拥有类似于 GPT4的非凡能力,例如详细的图像描述生成和从手写草稿创建网站。 此外 MiniGPT4 还具备一些的其他新的功能,包括根据给定图像写故事和诗歌,为图像中显示的问题提供解决方案,教用户如何根据食物照片做饭等。下图展示了 MiniGPT4的模型结构, 更多信息请参考[MiniGPT4](https://arxiv.org/abs/2304.10592)。
-## 2. 获取MiniGPT4 权重以及相关配置
-这里可以分两步:1. 获取MiniGPT4权重;2. 获取相关配置,包括模型参数说明以及tokenizer相关文件等。
-### 2.1 获取MiniGPT4权重
-目前需要用户手动下载MiniGPT4权重和并转换为相应的 Paddle 版权重,为方便转换,本项目提供了相应的操作说明和转换脚本,详情请参考[MiniGPT4 权重下载和转换说明](./paddle_minigpt4_instrction.md)。
+## 2. 获取 MiniGPT4 权重以及相关配置
+这里可以分两步:1. 获取 MiniGPT4权重;2. 获取相关配置,包括模型参数说明以及 tokenizer 相关文件等。
+### 2.1 获取 MiniGPT4权重
+目前需要用户手动下载 MiniGPT4权重和并转换为相应的 Paddle 版权重,为方便转换,本项目提供了相应的操作说明和转换脚本,详情请参考[MiniGPT4 权重下载和转换说明](./paddle_minigpt4_instrction.md)。
### 2.2 获取相关配置
下载相关的配置文件,这里提供了两版配置文件,请根据你的需要,点击下载即可。
@@ -31,7 +31,7 @@ python run_predict.py \
```
-下图这个示例展示了在使用MiniGPT-7b时的效果:
+下图这个示例展示了在使用 MiniGPT-7b 时的效果:
输入图片:
diff --git a/legacy/examples/multimodal/minigpt4/merge_weight.py b/slm/examples/multimodal/minigpt4/merge_weight.py
similarity index 100%
rename from legacy/examples/multimodal/minigpt4/merge_weight.py
rename to slm/examples/multimodal/minigpt4/merge_weight.py
diff --git a/legacy/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md b/slm/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md
similarity index 80%
rename from legacy/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md
rename to slm/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md
index 8c6ddb7ca93b..5acb46db9043 100644
--- a/legacy/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md
+++ b/slm/examples/multimodal/minigpt4/paddle_minigpt4_instrction.md
@@ -9,17 +9,17 @@
### 1.1 下载 MiniGPT4 的预训练权重
-根据你准备的Vicuna模型版本,下载预训练的MiniGPT4 权重。
+根据你准备的 Vicuna 模型版本,下载预训练的 MiniGPT4 权重。
| Checkpoint Aligned with Vicuna 7B | Checkpoint Aligned with Vicuna 13B |
|:----------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------:|
| [Download](https://drive.google.com/file/d/1RY9jV0dyqLX-o38LrumkKRh6Jtaop58R/view?usp=sharing) | [Download](https://drive.google.com/file/d/1a4zLvaiDBr-36pasffmgpvH5P7CKmpze/view?usp=share_link) |
### 1.2准备 ViT and Qformer 权重
-MiniGPT4中使用的ViT和Qformer Weight来自blip2-flan-t5-xxl,这个weight在PaddleNLP中进行了转换。 所以你可以从 PaddleNLP 下载它,你有两种下载方式进行下载:
+MiniGPT4中使用的 ViT 和 Qformer Weight 来自 blip2-flan-t5-xxl,这个 weight 在 PaddleNLP 中进行了转换。 所以你可以从 PaddleNLP 下载它,你有两种下载方式进行下载:
#### 1.2.1 通过 paddlenlp 方式加载
-直接通过paddlenlp的模型加载方法进行下载,下载后一般会存入 `PPNLP_HOME` 指定的目录。
+直接通过 paddlenlp 的模型加载方法进行下载,下载后一般会存入 `PPNLP_HOME` 指定的目录。
```python
import os
@@ -40,17 +40,17 @@ Blip2Model.from_pretrained("Salesforce/blip2-flan-t5-xxl")
### 1.3 准备 Vicuna 权重
-这里需要下载两个权重:Vicuna delta Weight和huggingface-formated Llama Weight。 然后你应该结合这两个重量来获得可以使用的Vicuna 权重。
+这里需要下载两个权重:Vicuna delta Weight 和 huggingface-formated Llama Weight。 然后你应该结合这两个重量来获得可以使用的 Vicuna 权重。
#### 1.3.1 下载 Vicuna delta 权重
-这里展示两种Vicuna delta 权重,请根据需要选择一种并点击下载。
+这里展示两种 Vicuna delta 权重,请根据需要选择一种并点击下载。
| vicuna-7b-delta-v0 | vicuna-13b-delta-v0 |
|:---------------------------------------------------------------------:|:------------------------------------------------------------:|
| [Download](https://huggingface.co/lmsys/vicuna-7b-delta-v0/tree/main) | [Download](https://huggingface.co/lmsys/vicuna-13b-delta-v0) |
-#### 1.3.2 根据以上选择的vicuna delta 权重,下载 相应的 llama 权重。
+#### 1.3.2 根据以上选择的 vicuna delta 权重,下载 相应的 llama 权重。
| llama-7b | llama-13b |
|:--------------------------------------------------------------------------:|:-----------------------------------------------------------------:|
@@ -63,7 +63,7 @@ Blip2Model.from_pretrained("Salesforce/blip2-flan-t5-xxl")
```shell
pip install git+https://github.com/lm-sys/FastChat.git@v0.1.10
```
-- 运行以下命令,获取最终可用的vicuna 权重
+- 运行以下命令,获取最终可用的 vicuna 权重
```shell
python -m fastchat.model.apply_delta --base /path/to/llama-13bOR7b-hf/ --target /path/to/save/working/vicuna-13b/weight/ --delta /path/to/vicuna-13bOR7b-delta-v0/
@@ -71,9 +71,9 @@ python -m fastchat.model.apply_delta --base /path/to/llama-13bOR7b-hf/ --target
## 2. 将多个 pytorch 子权重文件合并为一个权重文件
-Pytorch版的权重文件可能是由多个子权重文件组合而成,为使用PaddleNLP进行加载并自动转换为Paddle版,需要将其合并为一个文件:
+Pytorch 版的权重文件可能是由多个子权重文件组合而成,为使用 PaddleNLP 进行加载并自动转换为 Paddle 版,需要将其合并为一个文件:
-### 2.1 下载MiniGPT库
+### 2.1 下载 MiniGPT 库
在开始之前,请确保已经下载了 [MiniGPT4](https://github.com/Vision-CAIR/MiniGPT-4.git) 库:
```
@@ -81,7 +81,7 @@ git clone https://github.com/Vision-CAIR/MiniGPT-4.git
```
### 2.2 获取完整的 vicuna 权重
-进入到MiniGPT4文件夹,执行以下代码,获取完整的 vicuna 权重文件:
+进入到 MiniGPT4文件夹,执行以下代码,获取完整的 vicuna 权重文件:
```python
import argparse
import os
diff --git a/legacy/examples/multimodal/minigpt4/run_predict.py b/slm/examples/multimodal/minigpt4/run_predict.py
similarity index 100%
rename from legacy/examples/multimodal/minigpt4/run_predict.py
rename to slm/examples/multimodal/minigpt4/run_predict.py
diff --git a/legacy/examples/question_generation/README.md b/slm/examples/question_generation/README.md
similarity index 61%
rename from legacy/examples/question_generation/README.md
rename to slm/examples/question_generation/README.md
index 796b415797b2..41d62b2a8ee0 100644
--- a/legacy/examples/question_generation/README.md
+++ b/slm/examples/question_generation/README.md
@@ -2,16 +2,16 @@
Question Generation(QG),即问题生成,指的是给定一段上下文和答案,自动生成一个流畅且符合上下文主题的问句。问题生成技术在教育、咨询、搜索、问答等多个领域均有着巨大的应用价值。
-PaddleNLP提供英文和中文问题生成任务示例,分别基于英文预训练语言模型[t5](./t5)和中文预训练语言模型[unimo-text](./unimo-text)。
+PaddleNLP 提供英文和中文问题生成任务示例,分别基于英文预训练语言模型[t5](./t5)和中文预训练语言模型[unimo-text](./unimo-text)。
## 英文
-[t5](./t5) 展示了如何使用英文预训练模型T5完成问题生成任务,支持模型微调预测评估,并提供相关预训练模型。
+[t5](./t5) 展示了如何使用英文预训练模型 T5完成问题生成任务,支持模型微调预测评估,并提供相关预训练模型。
## 中文
-[unimo-text](./unimo-text) 展示了如何使用中文预训练模型UNIMO-Text完成问题生成任务,提供数据准备、训练、预测、推理部署全流程定制化训练,并提供相关预训练模型。
+[unimo-text](./unimo-text) 展示了如何使用中文预训练模型 UNIMO-Text 完成问题生成任务,提供数据准备、训练、预测、推理部署全流程定制化训练,并提供相关预训练模型。
# 参考文献
diff --git a/legacy/examples/question_generation/t5/README.md b/slm/examples/question_generation/t5/README.md
similarity index 71%
rename from legacy/examples/question_generation/t5/README.md
rename to slm/examples/question_generation/t5/README.md
index 0b0578d3cb58..16044bb01558 100644
--- a/legacy/examples/question_generation/t5/README.md
+++ b/slm/examples/question_generation/t5/README.md
@@ -2,9 +2,9 @@
## 简介
-Question Generation(QG),即问题生成,指的是给定一段上下文(passage或sentence),自动生成一个流畅且符合上下文主题的问句。问题生成通常可以分为两个分支,即无答案问题生成(answer-agnostic question generation)和有答案问题生成(answer-aware question generation)。
+Question Generation(QG),即问题生成,指的是给定一段上下文(passage 或 sentence),自动生成一个流畅且符合上下文主题的问句。问题生成通常可以分为两个分支,即无答案问题生成(answer-agnostic question generation)和有答案问题生成(answer-aware question generation)。
-本项目是T5在 PaddlePaddle上开源实现的有答案问题生成的例子,包含了在SQuAD数据集上微调和生成的代码。
+本项目是 T5在 PaddlePaddle 上开源实现的有答案问题生成的例子,包含了在 SQuAD 数据集上微调和生成的代码。
## 快速开始
@@ -34,7 +34,7 @@ Question Generation(QG),即问题生成,指的是给定一段上下文
#### 数据加载
**SQuAD**(Stanford Question Answering Dataset)数据集是一个英文问答数据集,现有的问题生成研究主要在该数据集上进行评价。**SQuAD**中的数据由段落、问题、答案3个主要部分组成,其中段落从维基百科中获取,问题和答案通过众包的方式由人工标注。
-为了方便用户快速测试,PaddleNLP Dataset API内置了Squad数据集,一键即可完成数据集加载,示例代码如下:
+为了方便用户快速测试,PaddleNLP Dataset API 内置了 Squad 数据集,一键即可完成数据集加载,示例代码如下:
```python
from paddlenlp.datasets import load_dataset
@@ -42,7 +42,7 @@ train_set, dev_set, test_set = load_dataset("squad", splits=["train_v1", "dev_v
```
#### 数据处理
-针对**SQuAD**数据集,我们需要将QA任务格式的数据进行转换从而得到text2text形式的数据,默认构造方式如下,其他形式输入数据用户可以在convert_example函数中自行定义
+针对**SQuAD**数据集,我们需要将 QA 任务格式的数据进行转换从而得到 text2text 形式的数据,默认构造方式如下,其他形式输入数据用户可以在 convert_example 函数中自行定义
```text
answer: {answer_text} context: {context_text}
question: {question_text}
@@ -56,7 +56,7 @@ question: What is the name of the process which confirms the primality of a numb
### 模型训练
-运行如下命令即可在训练集上进行finetune,并在验证集上进行验证
+运行如下命令即可在训练集上进行 finetune,并在验证集上进行验证
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -81,11 +81,11 @@ python -m paddle.distributed.launch --gpus 1,2 train.py \
```
其中参数释义如下:
-- `gpus` 指示了训练所用的GPU
+- `gpus` 指示了训练所用的 GPU
-- `model_name_or_path` 指示了finetune使用的预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| t5-base |
| t5-large |
@@ -98,7 +98,7 @@ python -m paddle.distributed.launch --gpus 1,2 train.py \
- `max_target_length` 表示输出的最大长度。
-- `learning_rate` 表示基础学习率大小,将与learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将与 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
@@ -114,7 +114,7 @@ python -m paddle.distributed.launch --gpus 1,2 train.py \
- `eval_batch_size` 表示预测单卡上的样本数目。
-- `warmup_proportion` 表示warmup_steps所占总步数的比例。学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数。
+- `warmup_proportion` 表示 warmup_steps 所占总步数的比例。学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数。
- `device` 表示使用的设备。
@@ -159,9 +159,9 @@ python predict.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了预测使用的模型,可以是PaddleNLP提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle模型参数model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了预测使用的模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的模型。如果使用本地的模型,则配置为本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 模型参数 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| t5-base |
| t5-large |
@@ -177,13 +177,13 @@ python predict.py \
- `decode_strategy` 表示预测解码时采取的策略,可选"sampling"、"greedy_search"和"beam_search"之一。
-- `top_k` 表示采用"sampling"解码策略时,token的概率按从大到小排序,生成的token只从前`top_k`个中进行采样。
+- `top_k` 表示采用"sampling"解码策略时,token 的概率按从大到小排序,生成的 token 只从前`top_k`个中进行采样。
-- `top_p` 表示采用"sampling"解码策略时,从词表中采样并选择概率之和大于给定阈值`top_p`的token。
+- `top_p` 表示采用"sampling"解码策略时,从词表中采样并选择概率之和大于给定阈值`top_p`的 token。
-- `num_beams` 表示besm search的beam size。
+- `num_beams` 表示 besm search 的 beam size。
-- `length_penalty` 表示besm search生成长度的指数惩罚。
+- `length_penalty` 表示 besm search 生成长度的指数惩罚。
- `batch_size` 表示每次迭代**单卡**上的样本数目。
@@ -195,7 +195,7 @@ python predict.py \
程序运行结束后会将预测生成的问题保存在`output_path`中。同时终端中会输出评估结果。
-采用社区微调模型mrm8488/t5-base-finetuned-question-generation-ap在验证集上有如下结果:
+采用社区微调模型 mrm8488/t5-base-finetuned-question-generation-ap 在验证集上有如下结果:
| model_name_or_path | BLEU-1 | BLEU-2 | BLEU-3 | BLEU-4 |
| :----------------------: | :-------------: | :-------------: |:-------------: |:-------------: |
diff --git a/legacy/examples/question_generation/t5/predict.py b/slm/examples/question_generation/t5/predict.py
similarity index 100%
rename from legacy/examples/question_generation/t5/predict.py
rename to slm/examples/question_generation/t5/predict.py
diff --git a/legacy/examples/question_generation/t5/requirements.txt b/slm/examples/question_generation/t5/requirements.txt
similarity index 100%
rename from legacy/examples/question_generation/t5/requirements.txt
rename to slm/examples/question_generation/t5/requirements.txt
diff --git a/legacy/examples/question_generation/t5/train.py b/slm/examples/question_generation/t5/train.py
similarity index 100%
rename from legacy/examples/question_generation/t5/train.py
rename to slm/examples/question_generation/t5/train.py
diff --git a/legacy/examples/question_generation/t5/utils.py b/slm/examples/question_generation/t5/utils.py
similarity index 100%
rename from legacy/examples/question_generation/t5/utils.py
rename to slm/examples/question_generation/t5/utils.py
diff --git a/legacy/examples/question_generation/unimo-text/README.md b/slm/examples/question_generation/unimo-text/README.md
similarity index 70%
rename from legacy/examples/question_generation/unimo-text/README.md
rename to slm/examples/question_generation/unimo-text/README.md
index cc05ef0c9d29..f6a05fdeb7a3 100644
--- a/legacy/examples/question_generation/unimo-text/README.md
+++ b/slm/examples/question_generation/unimo-text/README.md
@@ -18,7 +18,7 @@
- [模型训练](#模型训练)
- [模型预测](#模型预测)
- [模型转换部署](#模型转换部署)
- - [FasterTransformer加速及模型静态图导出](#fastertransformer加速及模型静态图导出)
+ - [FasterTransformer 加速及模型静态图导出](#fastertransformer 加速及模型静态图导出)
- [模型部署](#模型部署)
- [References](#references)
@@ -27,11 +27,11 @@ Question Generation(QG),即问题生成,指的是给定一段上下文
问题生成技术在教育、咨询、搜索、推荐等多个领域均有着巨大的应用价值。具体来说,问题生成可广泛应用于问答系统语料库构建,事实性问题生成,教育行业题库生成,对话提问,聊天机器人意图理解,对话式搜索意图提问,闲聊机器人主动提问等等场景。
-本项目是基于预训练语言模型UNIMO-Text的问题生成,具有以下优势:
+本项目是基于预训练语言模型 UNIMO-Text 的问题生成,具有以下优势:
-- 效果领先。基于百度自研中文预训练语言模型UNIMO-Text,并提供基于模版策略和大规模多领域问题生成数据集训练的通用问题生成预训练模型`unimo-text-1.0-question-generation`。
-- 开箱即用。本项目提供TaskFlow接口,无需训练,仅需几行代码便可预测。
-- 高性能推理。本项目基于FasterTransformer进行推理加速,能够提供更高性能的推理体验,优化后的推理模型在dureader_qg开发集的推理耗时缩短为优化前的1/5。
+- 效果领先。基于百度自研中文预训练语言模型 UNIMO-Text,并提供基于模版策略和大规模多领域问题生成数据集训练的通用问题生成预训练模型`unimo-text-1.0-question-generation`。
+- 开箱即用。本项目提供 TaskFlow 接口,无需训练,仅需几行代码便可预测。
+- 高性能推理。本项目基于 FasterTransformer 进行推理加速,能够提供更高性能的推理体验,优化后的推理模型在 dureader_qg 开发集的推理耗时缩短为优化前的1/5。
- 训练推理部署全流程打通。本项目提供了全面的定制训练流程,从数据准备、模型训练预测,到模型推理部署,一应俱全。
## 开箱即用
-PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,一键预测。
+PaddleNLP 提供开箱即用的产业级 NLP 预置任务能力,无需训练,一键预测。
#### 支持单条、批量预测
```python
>>> from paddlenlp import Taskflow
@@ -72,9 +72,9 @@ PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,
'''
```
关键配置参数说明:
-* `model`:可选模型,默认为unimo-text-1.0-dureader_qg,支持的模型有["unimo-text-1.0", "unimo-text-1.0-dureader_qg", "unimo-text-1.0-question-generation", "unimo-text-1.0-question-generation-dureader_qg"]。
+* `model`:可选模型,默认为 unimo-text-1.0-dureader_qg,支持的模型有["unimo-text-1.0", "unimo-text-1.0-dureader_qg", "unimo-text-1.0-question-generation", "unimo-text-1.0-question-generation-dureader_qg"]。
-具体参数配置可参考[Taskflow文档](../../../../docs/model_zoo/taskflow.md)。
+具体参数配置可参考[Taskflow 文档](../../../../docs/model_zoo/taskflow.md)。
## 训练定制
@@ -109,12 +109,12 @@ PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,
### 问题生成定制训练全流程介绍
接下来,我们将按数据准备、训练、预测、推理部署等四个阶段对问题生成应用的全流程进行介绍。
1. **数据准备**
-- 默认使用中文问题生成数据集DuReader_QG进行实验,该数据集已集成到PaddleNLP。
+- 默认使用中文问题生成数据集 DuReader_QG 进行实验,该数据集已集成到 PaddleNLP。
- 如果已有标注好的本地数据集,我们需要根据将数据集整理为文档要求的格式,请参考[从本地文件创建数据集(可选)](#从本地文件创建数据集(可选))。
2. **模型训练**
-- 数据准备完成后,可以开始使用我们的数据集对预训练模型进行微调训练。我们可以根据任务需求,调整可配置参数,选择使用GPU或CPU进行模型训练,脚本默认保存在开发集最佳表现模型。中文任务默认使用`unimo-text-1.0`模型,unimo-text-1.0还支持large模型。此外本项目还提供基于大规模多领域问题生成数据集训练的通用问题生成预训练模型`unimo-text-1.0-question-generation`,详见[UNIMO模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html),用户可以根据任务和设备需求进行选择。
+- 数据准备完成后,可以开始使用我们的数据集对预训练模型进行微调训练。我们可以根据任务需求,调整可配置参数,选择使用 GPU 或 CPU 进行模型训练,脚本默认保存在开发集最佳表现模型。中文任务默认使用`unimo-text-1.0`模型,unimo-text-1.0还支持 large 模型。此外本项目还提供基于大规模多领域问题生成数据集训练的通用问题生成预训练模型`unimo-text-1.0-question-generation`,详见[UNIMO 模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html),用户可以根据任务和设备需求进行选择。
3. **模型预测**
@@ -122,19 +122,19 @@ PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,
- 训练结束后,我们可以加载保存的最佳模型进行模型测试,打印模型预测结果。
4. **模型转换部署**
-- 在现实部署场景中,我们通常不仅对模型的精度表现有要求,也需要考虑模型性能上的表现。我们可以使用模型裁剪进一步压缩模型体积,问题生成应用已提供裁剪API对上一步微调后的模型进行裁剪,模型裁剪之后会默认导出静态图模型。
+- 在现实部署场景中,我们通常不仅对模型的精度表现有要求,也需要考虑模型性能上的表现。我们可以使用模型裁剪进一步压缩模型体积,问题生成应用已提供裁剪 API 对上一步微调后的模型进行裁剪,模型裁剪之后会默认导出静态图模型。
- 模型部署需要将保存的最佳模型参数(动态图)导出成静态图参数,用于后续的推理部署。
-- 问题生成应用提供了基于Paddle Serving的本地部署predictor,并且支持在GPU设备使用Faster Generation进行加速。
+- 问题生成应用提供了基于 Paddle Serving 的本地部署 predictor,并且支持在 GPU 设备使用 Faster Generation 进行加速。
-- 问题生成应用提供了基于Paddle Serving的服务端部署方案。
+- 问题生成应用提供了基于 Paddle Serving 的服务端部署方案。
### 数据准备
#### 数据加载
-[**DuReader_QG**数据集](https://www.luge.ai/#/luge/dataDetail?id=8)是一个中文问题生成数据集,我们使用该数据集作为应用案例进行实验。**DuReader_QG**中的数据主要由由上下文、问题、答案3个主要部分组成,其任务描述为给定上下文p和答案a,生成自然语言表述的问题q,且该问题符合段落和上下文的限制。
+[**DuReader_QG**数据集](https://www.luge.ai/#/luge/dataDetail?id=8)是一个中文问题生成数据集,我们使用该数据集作为应用案例进行实验。**DuReader_QG**中的数据主要由由上下文、问题、答案3个主要部分组成,其任务描述为给定上下文 p 和答案 a,生成自然语言表述的问题 q,且该问题符合段落和上下文的限制。
-为了方便用户快速测试,PaddleNLP Dataset API内置了DuReader_QG数据集,一键即可完成数据集加载,示例代码如下:
+为了方便用户快速测试,PaddleNLP Dataset API 内置了 DuReader_QG 数据集,一键即可完成数据集加载,示例代码如下:
```python
from paddlenlp.datasets import load_dataset
@@ -142,7 +142,7 @@ train_ds, dev_ds = load_dataset('dureader_qg', splits=('train', 'dev'))
```
#### 数据处理
-针对**DuReader_QG**数据集,我们需要将QA任务格式的数据进行转换从而得到text2text形式的数据,我们默认使用模版的方式构造输入数据,默认模版如下,其他形式输入数据用户可以在convert_example函数中自行定义。
+针对**DuReader_QG**数据集,我们需要将 QA 任务格式的数据进行转换从而得到 text2text 形式的数据,我们默认使用模版的方式构造输入数据,默认模版如下,其他形式输入数据用户可以在 convert_example 函数中自行定义。
```text
答案: 上下文:
问题:
@@ -183,7 +183,7 @@ data/
更多数据集读取格式详见[数据集加载](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_load.html#)和[自定义数据集](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_self_defined.html)。
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证。
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证。
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
# 例如使用1号和2号卡,则:`--gpu 1,2`
@@ -213,11 +213,11 @@ python -m paddle.distributed.launch --gpus "1,2" --log_dir ./unimo/finetune/log
关键参数释义如下:
-- `gpus` 指示了训练所用的GPU,使用多卡训练可以指定多个GPU卡号,例如 --gpus "0,1"。
-- `dataset_name` 数据集名称,当`train_file`和`predict_file`为None时将加载`dataset_name`的训练集和开发集,默认为`dureader_qg`。
-- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为None。
-- `predict_file` 本地测试数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为None。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `gpus` 指示了训练所用的 GPU,使用多卡训练可以指定多个 GPU 卡号,例如 --gpus "0,1"。
+- `dataset_name` 数据集名称,当`train_file`和`predict_file`为 None 时将加载`dataset_name`的训练集和开发集,默认为`dureader_qg`。
+- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为 None。
+- `predict_file` 本地测试数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为 None。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
| 可选预训练模型 |
|---------------------------------|
| unimo-text-1.0 |
@@ -237,16 +237,16 @@ python -m paddle.distributed.launch --gpus "1,2" --log_dir ./unimo/finetune/log
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数占总步数的比例。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数占总步数的比例。
- `max_seq_len` 模型输入序列的最大长度。
- `max_target_len` 模型训练时标签的最大长度。
- `min_dec_len` 模型生成序列的最小长度。
- `max_dec_len` 模型生成序列的最大长度。
- `do_train` 是否进行训练。
- `do_predict` 是否进行预测,在验证集上会自动评估。
-- `device` 表示使用的设备,从gpu和cpu中选择。
+- `device` 表示使用的设备,从 gpu 和 cpu 中选择。
- `template` 表示使用的模版,从[0, 1, 2, 3, 4]中选择,0表示不选择模版,1表示使用默认模版。
程序运行时将会自动进行训练和验证,训练过程中会自动保存模型在指定的`save_dir`中。如:
@@ -264,7 +264,7 @@ python -m paddle.distributed.launch --gpus "1,2" --log_dir ./unimo/finetune/log
**NOTE:** 如需恢复模型训练,`model_name_or_path`配置本地模型的目录地址即可。
-微调的模型在dureader_qg验证集上有如下结果(指标为BLEU-4),其中`unimo-text-1.0-dureader_qg-w/o-template`表示不使用模版策略微调的结果,`unimo-text-1.0-large-dureader_qg`表示使用large模型微调的结果,`unimo-text-1.0-question-generation-dureader_qg`表示在通用问题生成预训练模型`unimo-text-1.0-question-generation`上微调的结果:
+微调的模型在 dureader_qg 验证集上有如下结果(指标为 BLEU-4),其中`unimo-text-1.0-dureader_qg-w/o-template`表示不使用模版策略微调的结果,`unimo-text-1.0-large-dureader_qg`表示使用 large 模型微调的结果,`unimo-text-1.0-question-generation-dureader_qg`表示在通用问题生成预训练模型`unimo-text-1.0-question-generation`上微调的结果:
| model_name | DuReaderQG |
| :-----------------------------: | :-----------: |
@@ -295,13 +295,13 @@ python -u predict.py \
```
关键参数释义如下:
- `output_path` 表示预测输出结果保存的文件路径,默认为./predict.txt。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的微调好的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的微调好的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。
### 模型转换部署
-#### FasterTransformer加速及模型静态图导出
+#### FasterTransformer 加速及模型静态图导出
-使用动态图训练结束之后,可以通过[静态图导出脚本](export_model.py)实现基于FasterTransformer的高性能预测加速,并将动态图参数导出成静态图参数,静态图参数保存在`output_path`指定路径中。运行方式:
+使用动态图训练结束之后,可以通过[静态图导出脚本](export_model.py)实现基于 FasterTransformer 的高性能预测加速,并将动态图参数导出成静态图参数,静态图参数保存在`output_path`指定路径中。运行方式:
```shell
python export_model.py \
@@ -315,7 +315,7 @@ python export_model.py \
* `model_name_or_path`:动态图训练保存的参数路径;默认为"./checkpoint"。
* `inference_model_dir`:静态图图保存的参数路径;默认为"./export_checkpoint"。
* `max_dec_len`:最大输出长度。
-* `use_fp16_decoding`:是否使用fp16解码进行预测。
+* `use_fp16_decoding`:是否使用 fp16解码进行预测。
执行命令后将会自动导出模型到指定的 `inference_model_dir` 中,保存模型文件结构如下所示:
@@ -329,7 +329,7 @@ python export_model.py \
本项目提供多种不同场景的部署方案,请根据实际情况进行选择:
|部署方案|特色|场景|硬件|
|-|-|-|-|
-|Paddle Inference
服务端/云端|通用性|模型算法复杂
硬件高性能|X86 CPU
NVIDIA 全系列 GPU
龙芯/飞腾等国产CPU
昆仑/昇腾/海光DCU等AI加速芯片
+|Paddle Inference
服务端/云端|通用性|模型算法复杂
硬件高性能|X86 CPU
NVIDIA 全系列 GPU
龙芯/飞腾等国产 CPU
昆仑/昇腾/海光 DCU 等 AI 加速芯片
|Paddle Serving
服务化|高并发|大流量、高并发、低延时、高吞吐
资源弹性调控应对服务流量变化
支持模型组合、加密、热更新等|X86/Arm CPU
NVIDIA GPU
昆仑/昇腾等
diff --git a/slm/examples/question_generation/unimo-text/deploy/paddle_inference/README.md b/slm/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
new file mode 100644
index 000000000000..e46081132e4c
--- /dev/null
+++ b/slm/examples/question_generation/unimo-text/deploy/paddle_inference/README.md
@@ -0,0 +1,54 @@
+# Paddle Inference 部署
+本文档将介绍如何使用[Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/guides/introduction/index_intro.html#paddle-inference)工具进行问题生成应用高性能推理推理部署。
+
+**目录**
+ * [背景介绍](#背景介绍)
+ * [导出预测部署模型](#导出预测部署模型)
+ * [基于 Python 预测](#基于 Python 预测)
+
+
+## 背景介绍
+Paddle inference 和主框架的 Model.predict 均可实现推理预测,Paddle Inference 是飞桨的原生推理库, 作用于服务器端和云端,提供高性能的推理能力,主框架的 Model 对象是一个具备训练、测试、推理的神经网络。相比于 Model.predict,inference 可使用 MKLDNN、CUDNN、TensorRT 进行预测加速。Model.predict 适用于训练好的模型直接进行预测,paddle inference 适用于对推理性能、通用性有要求的用户,针对不同平台不同的应用场景进行了深度的适配优化,保证模型在服务器端即训即用,快速部署。由于 Paddle Inference 能力直接基于飞桨的训练算子,因此它支持飞桨训练出的所有模型的推理。
+
+
+
+Paddle Inference Python 端预测部署主要包含两个步骤:
+- 导出预测部署模型
+- 基于 Python 预测
+
+
+## 导出预测部署模型
+部署时需要使用预测格式的模型(即动态图转静态图操作)。预测格式模型相对训练格式模型而言,在拓扑上裁剪掉了预测不需要的算子,并且会做特定部署优化。具体操作详见[FasterTransformer 加速及模型静态图导出](../../README.md)。
+
+## 基于 Python 预测
+
+
+在终端输入以下命令可在 GPU 上进行预测:
+```shell
+python deploy/paddle_inference/inference.py \
+ --inference_model_dir ./export_checkpoint \
+ --model_name_or_path "unimo-text-1.0" \
+ --predict_file predict_file_name \
+ --output_path output_path_name \
+ --device gpu \
+```
+
+
+经静态图转换,FastTransformer 性能优化,Paddle Inference 加速后的部署模型在 dureader_qg devset 的预测时间为27.74秒,相较于未优化前169.24秒,耗时缩减为原来的16.39%。
+关键参数释义如下:
+* `inference_model_dir`:用于高性能推理的静态图模型参数路径,默认为"./export_checkpoint"。
+* `model_name_or_path`:tokenizer 对应模型或路径,默认为"unimo-text-1.0"。
+* `dataset_name`:数据集名称,默认为`dureader_qg`。
+* `predict_file`:本地预测数据地址,数据格式必须与`dataset_name`所指数据集格式相同,默认为 None,当为 None 时默认加载`dataset_name`的 dev 集。
+* `output_path`:表示预测结果的保存路径。
+* `device`:推理时使用的设备,可选项["gpu"],默认为"gpu"。
+* `batch_size`:进行推理时的批大小,默认为16。
+* `precision`:当使用 TensorRT 进行加速推理时,所使用的 TensorRT 精度,可选项["fp32", "fp16"],默认为"fp32"。
+
+
+
+
+
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_inference/infer_utils.py b/slm/examples/question_generation/unimo-text/deploy/paddle_inference/infer_utils.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_inference/infer_utils.py
rename to slm/examples/question_generation/unimo-text/deploy/paddle_inference/infer_utils.py
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_inference/inference.py b/slm/examples/question_generation/unimo-text/deploy/paddle_inference/inference.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_inference/inference.py
rename to slm/examples/question_generation/unimo-text/deploy/paddle_inference/inference.py
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/README.md b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/README.md
similarity index 73%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_serving/README.md
rename to slm/examples/question_generation/unimo-text/deploy/paddle_serving/README.md
index 2bf576da9bdc..dbf049655430 100644
--- a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/README.md
+++ b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/README.md
@@ -1,40 +1,40 @@
-# Paddle Serving服务化部署
+# Paddle Serving 服务化部署
本文档将介绍如何使用[Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/develop/README_CN.md)工具部署问题生成在线服务。
## 目录
-- [Paddle Serving服务化部署](#paddle-serving服务化部署)
+- [Paddle Serving 服务化部署](#paddle-serving 服务化部署)
- [目录](#目录)
- [背景介绍](#背景介绍)
- [环境准备](#环境准备)
- - [安装Paddle Serving](#安装paddle-serving)
+ - [安装 Paddle Serving](#安装 paddle-serving)
- [模型转换](#模型转换)
- - [pipeline部署](#pipeline部署)
+ - [pipeline 部署](#pipeline 部署)
- [修改配置文件](#修改配置文件)
- - [server启动服务](#server启动服务)
- - [client发送服务请求](#client发送服务请求)
+ - [server 启动服务](#server 启动服务)
+ - [client 发送服务请求](#client 发送服务请求)
## 背景介绍
Paddle Serving 依托深度学习框架 PaddlePaddle 旨在帮助深度学习开发者和企业提供高性能、灵活易用的工业级在线推理服务。Paddle Serving 支持 RESTful、gRPC、bRPC 等多种协议,提供多种异构硬件和多种操作系统环境下推理解决方案,和多种经典预训练模型示例。集成高性能服务端推理引擎 Paddle Inference 和端侧引擎 Paddle Lite。设计并实现基于有向无环图(DAG) 的异步流水线高性能推理框架,具有多模型组合、异步调度、并发推理、动态批量、多卡多流推理、请求缓存等特性。
-Paddle Serving Python端预测部署主要包含以下步骤:
+Paddle Serving Python 端预测部署主要包含以下步骤:
- 环境准备
- 模型转换
- 部署模型
## 环境准备
-### 安装Paddle Serving
-安装client和serving app,用于向服务发送请求:
+### 安装 Paddle Serving
+安装 client 和 serving app,用于向服务发送请求:
```shell
pip install paddle_serving_app paddle_serving_client
```
-安装server,用于启动服务,根据服务器设备选择安装CPU server或GPU server:
+安装 server,用于启动服务,根据服务器设备选择安装 CPU server 或 GPU server:
-- 安装CPU server
+- 安装 CPU server
```shell
pip install paddle_serving_server
```
-- 安装GPU server, 注意选择跟本地环境一致的命令
+- 安装 GPU server, 注意选择跟本地环境一致的命令
```shell
# CUDA10.2 + Cudnn7 + TensorRT6
pip install paddle-serving-server-gpu==0.8.3.post102 # -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -46,14 +46,14 @@ pip install paddle-serving-server-gpu==0.8.3.post112 # -i https://pypi.tuna.tsin
**NOTE:**
- 可以开启国内清华镜像源来加速下载
-- 如果要安装最新版本的PaddleServing参考[链接](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)。
+- 如果要安装最新版本的 PaddleServing 参考[链接](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)。
## 模型转换
-使用Paddle Serving做服务化部署时,需要将保存的inference模型转换为serving易于部署的模型。
+使用 Paddle Serving 做服务化部署时,需要将保存的 inference 模型转换为 serving 易于部署的模型。
-用已安装的paddle_serving_client将静态图参数模型转换成serving格式。关于如何使用将训练后的动态图模型转为静态图模型详见[FasterTransformer加速及模型静态图导出](../../README.md)。
+用已安装的 paddle_serving_client 将静态图参数模型转换成 serving 格式。关于如何使用将训练后的动态图模型转为静态图模型详见[FasterTransformer 加速及模型静态图导出](../../README.md)。
模型转换命令如下:
```shell
@@ -67,14 +67,14 @@ python -m paddle_serving_client.convert --dirname ./export_checkpoint \
* `dirname`:静态图模型文件夹地址。
* `model_filename`:模型文件名。
* `params_filename`:模型参数名。
-* `serving_server`:server的模型文件和配置文件路径,默认"serving_server"。
-* `serving_client`:client的配置文件路径,默认"serving_client"。
+* `serving_server`:server 的模型文件和配置文件路径,默认"serving_server"。
+* `serving_client`:client 的配置文件路径,默认"serving_client"。
更多参数可通过以下命令查询:
```shell
python -m paddle_serving_client.convert --help
```
-模型转换完成后,会在./delopy/paddle_serving文件夹多出export_checkpoint_server和export_checkpoint_client的文件夹,文件夹目录格式如下:
+模型转换完成后,会在./delopy/paddle_serving 文件夹多出 export_checkpoint_server 和 export_checkpoint_client 的文件夹,文件夹目录格式如下:
```
export_checkpoint_server/
├── unimo_text.pdiparams
@@ -86,9 +86,9 @@ export_checkpoint_server/
└── serving_client_conf.stream.prototxt
```
-## pipeline部署
+## pipeline 部署
-paddle_serving目录包含启动pipeline服务和发送预测请求的代码,包括:
+paddle_serving 目录包含启动 pipeline 服务和发送预测请求的代码,包括:
```
paddle_serving/
├──config.yml # 启动服务端的配置文件
@@ -99,14 +99,14 @@ paddle_serving/
### 修改配置文件
目录中的`config.yml`文件解释了每一个参数的含义,可以根据实际需要修改其中的配置。
-### server启动服务
+### server 启动服务
修改好配置文件后,执行下面命令启动服务:
```shell
cd deploy/paddle_serving
# 启动服务,运行日志保存在log.txt
python pipeline_service.py &> log.txt &
```
-成功启动服务后,log.txt中会打印类似如下日志
+成功启动服务后,log.txt 中会打印类似如下日志
```
--- Running analysis [ir_graph_to_program_pass]
I0901 12:09:27.248943 12190 analysis_predictor.cc:1035] ======= optimize end =======
@@ -124,13 +124,13 @@ I0901 12:09:27.250090 12190 naive_executor.cc:102] --- skip [transpose_0.tmp_0]
2022/09/01 12:09:27 start proxy service
```
-### client发送服务请求
+### client 发送服务请求
执行以下命令发送文本摘要服务请求:
```shell
cd deploy/paddle_serving
python pipeline_client.py
```
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)
成功运行后,输出打印如下:
```
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/config.yml b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/config.yml
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_serving/config.yml
rename to slm/examples/question_generation/unimo-text/deploy/paddle_serving/config.yml
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/infer_utils.py b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/infer_utils.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_serving/infer_utils.py
rename to slm/examples/question_generation/unimo-text/deploy/paddle_serving/infer_utils.py
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_client.py b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_client.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_client.py
rename to slm/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_client.py
diff --git a/legacy/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_service.py b/slm/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_service.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_service.py
rename to slm/examples/question_generation/unimo-text/deploy/paddle_serving/pipeline_service.py
diff --git a/legacy/examples/question_generation/unimo-text/export_model.py b/slm/examples/question_generation/unimo-text/export_model.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/export_model.py
rename to slm/examples/question_generation/unimo-text/export_model.py
diff --git a/legacy/examples/question_generation/unimo-text/gen_utils.py b/slm/examples/question_generation/unimo-text/gen_utils.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/gen_utils.py
rename to slm/examples/question_generation/unimo-text/gen_utils.py
diff --git a/legacy/examples/question_generation/unimo-text/predict.py b/slm/examples/question_generation/unimo-text/predict.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/predict.py
rename to slm/examples/question_generation/unimo-text/predict.py
diff --git a/legacy/examples/question_generation/unimo-text/requirements.txt b/slm/examples/question_generation/unimo-text/requirements.txt
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/requirements.txt
rename to slm/examples/question_generation/unimo-text/requirements.txt
diff --git a/legacy/examples/question_generation/unimo-text/train.py b/slm/examples/question_generation/unimo-text/train.py
similarity index 100%
rename from legacy/examples/question_generation/unimo-text/train.py
rename to slm/examples/question_generation/unimo-text/train.py
diff --git a/legacy/examples/semantic_indexing/NQdataset.py b/slm/examples/semantic_indexing/NQdataset.py
similarity index 100%
rename from legacy/examples/semantic_indexing/NQdataset.py
rename to slm/examples/semantic_indexing/NQdataset.py
diff --git a/legacy/examples/semantic_indexing/README.md b/slm/examples/semantic_indexing/README.md
similarity index 97%
rename from legacy/examples/semantic_indexing/README.md
rename to slm/examples/semantic_indexing/README.md
index f411744ceb0f..f9cea296ec7a 100644
--- a/legacy/examples/semantic_indexing/README.md
+++ b/slm/examples/semantic_indexing/README.md
@@ -20,8 +20,8 @@
| Model | 训练参数配置 | 硬件 | MD5 |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|----------------------------------------------|----------------------------------|
-| [batch_neg_v1.0](https://bj.bcebos.com/paddlenlp/models/semantic_index/batch_neg_v1.0.tar) | margin:0.2 scale:30 epoch:3 lr:5E-5 bs:128 max_len:64
| 单卡v100-16g
| da1bb1487bd3fd6a53b8ef95c278f3e6 |
-| [hardest_neg_v1.0](https://bj.bcebos.com/paddlenlp/models/semantic_index/hardest_neg_v1.0.tar) | margin:0.2 epoch:3 lr:5E-5 bs:128 max_len:64 | 单卡v100-16g | b535d890110ea608c8562c525a0b84b5 |
+| [batch_neg_v1.0](https://bj.bcebos.com/paddlenlp/models/semantic_index/batch_neg_v1.0.tar) | margin:0.2 scale:30 epoch:3 lr:5E-5 bs:128 max_len:64
| 单卡 v100-16g
| da1bb1487bd3fd6a53b8ef95c278f3e6 |
+| [hardest_neg_v1.0](https://bj.bcebos.com/paddlenlp/models/semantic_index/hardest_neg_v1.0.tar) | margin:0.2 epoch:3 lr:5E-5 bs:128 max_len:64 | 单卡 v100-16g | b535d890110ea608c8562c525a0b84b5 |
## 数据准备
@@ -285,7 +285,7 @@ In-batch negatives 策略的训练数据为语义相似的 Pair 对,如下所
学日语软件手机上的 手机学日语的软件
侠盗飞车罪恶都市怎样改车 侠盗飞车罪恶都市怎么改车
```
-In-batch negatives 策略核心是在 1 个 Batch 内同时基于 N 个负例进行梯度更新,将Batch 内除自身之外其它所有 *Source Text* 的相似文本 *Target Text* 作为负例,例如: 上例中 `我手机丢了,我想换个手机` 有 1 个正例(`1.我想买个新手机,求推荐`),3 个负例(`1.求秋色之空全集漫画`,`2.手机学日语的软件`,`3.侠盗飞车罪恶都市怎么改车`)。
+In-batch negatives 策略核心是在 1 个 Batch 内同时基于 N 个负例进行梯度更新,将 Batch 内除自身之外其它所有 *Source Text* 的相似文本 *Target Text* 作为负例,例如: 上例中 `我手机丢了,我想换个手机` 有 1 个正例(`1.我想买个新手机,求推荐`),3 个负例(`1.求秋色之空全集漫画`,`2.手机学日语的软件`,`3.侠盗飞车罪恶都市怎么改车`)。
### HardestNeg 核心思路
HardestNeg 策略核心是在 1 个 Batch 内的所有负样本中先挖掘出最难区分的负样本,基于最难负样本进行梯度更新。例如: 上例中 *Source Text*: `我手机丢了,我想换个手机` 有 3 个负例(`1.求秋色之空全集漫画`,`2.手机学日语的软件`,`3.侠盗飞车罪恶都市怎么改车`),其中最难区分的负例是 `手机学日语的软件`,模型训练过程中不断挖掘出类似这样的最难负样本,然后基于最难负样本进行梯度更新。
diff --git a/legacy/examples/semantic_indexing/README_gradient_cache.md b/slm/examples/semantic_indexing/README_gradient_cache.md
similarity index 86%
rename from legacy/examples/semantic_indexing/README_gradient_cache.md
rename to slm/examples/semantic_indexing/README_gradient_cache.md
index 1f5223c6dfb7..979655cb605d 100644
--- a/legacy/examples/semantic_indexing/README_gradient_cache.md
+++ b/slm/examples/semantic_indexing/README_gradient_cache.md
@@ -1,4 +1,4 @@
-# Gradient Cache策略 [DPR](https://arxiv.org/abs/2004.04906)
+# Gradient Cache 策略 [DPR](https://arxiv.org/abs/2004.04906)
### 实验结果
@@ -7,8 +7,8 @@
| DPR method | TOP-5 | TOP-10 | TOP-50| 说明 |
| :-----: | :----: | :----: | :----: | :---- |
-| Gradient_cache | 68.1 | 79.4| 86.2 | DPR结合GC策略训练
-| GC_Batch_size_512 | 67.3 | 79.6| 86.3| DPR结合GC策略训练,且batch_size设置为512|
+| Gradient_cache | 68.1 | 79.4| 86.2 | DPR 结合 GC 策略训练
+| GC_Batch_size_512 | 67.3 | 79.6| 86.3| DPR 结合 GC 策略训练,且 batch_size 设置为512|
实验对应的超参数如下:
@@ -17,7 +17,7 @@
| \ | 128/512| 2e-05 | 1237 | 40 | 2| 16/8 |
## 数据准备
-我们使用Dense Passage Retrieval的[原始仓库](https://github.com/Elvisambition/DPR)
+我们使用 Dense Passage Retrieval 的[原始仓库](https://github.com/Elvisambition/DPR)
中提供的数据集进行训练和评估。可以使用[download_data.py](https://github.com/Elvisambition/DPR/blob/main/dpr/data/download_data.py)
脚本下载所需数据集。 数据集详细介绍见[原仓库](https://github.com/Elvisambition/DPR) 。
@@ -87,9 +87,9 @@ python train_gradient_cache_DPR.py \
* `save_dir`: 模型保存位置
* `warmupsteps`: 预热学习率参数
* `epoches`: 训练批次大小
-* `max_grad_norm`: 详见ClipGradByGlobalNorm
+* `max_grad_norm`: 详见 ClipGradByGlobalNorm
* `train_data_path`: 训练数据存放地址
-* `chunk_size`: chunk的大小
+* `chunk_size`: chunk 的大小
## 生成文章稠密向量表示
@@ -103,7 +103,7 @@ python generate_dense_embeddings.py \
参数含义说明
-* `ctx_file`: ctx文件读取地址
+* `ctx_file`: ctx 文件读取地址
* `out_file`: 生成后的文件输出地址
* `que_model_path`: question model path
* `con_model_path`: context model path
@@ -120,10 +120,10 @@ python dense_retriever.py --hnsw_index \
--con_model_path ./save_dir/context_model_40
```
参数含义说明
-* `hnsw_index`:使用hnsw_index
+* `hnsw_index`:使用 hnsw_index
* `outfile`: 输出文件地址
-* `encoded_ctx_file`: 编码后的ctx文件
-* `ctx_file`: ctx文件
-* `qa_file`: qa_file文件
+* `encoded_ctx_file`: 编码后的 ctx 文件
+* `ctx_file`: ctx 文件
+* `qa_file`: qa_file 文件
* `que_model_path`: question encoder model
* `con_model_path`: context encoder model
diff --git a/legacy/examples/semantic_indexing/ance/model.py b/slm/examples/semantic_indexing/ance/model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/ance/model.py
rename to slm/examples/semantic_indexing/ance/model.py
diff --git a/legacy/applications/neural_search/recall/simcse/ann_util.py b/slm/examples/semantic_indexing/ann_util.py
similarity index 99%
rename from legacy/applications/neural_search/recall/simcse/ann_util.py
rename to slm/examples/semantic_indexing/ann_util.py
index 55c608d3e58c..652d38c91010 100644
--- a/legacy/applications/neural_search/recall/simcse/ann_util.py
+++ b/slm/examples/semantic_indexing/ann_util.py
@@ -14,8 +14,9 @@
# coding=UTF-8
-import numpy as np
import hnswlib
+import numpy as np
+
from paddlenlp.utils.log import logger
diff --git a/legacy/examples/semantic_indexing/base_model.py b/slm/examples/semantic_indexing/base_model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/base_model.py
rename to slm/examples/semantic_indexing/base_model.py
diff --git a/legacy/examples/semantic_indexing/batch_negative/model.py b/slm/examples/semantic_indexing/batch_negative/model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/batch_negative/model.py
rename to slm/examples/semantic_indexing/batch_negative/model.py
diff --git a/legacy/examples/semantic_indexing/biencoder_base_model.py b/slm/examples/semantic_indexing/biencoder_base_model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/biencoder_base_model.py
rename to slm/examples/semantic_indexing/biencoder_base_model.py
diff --git a/legacy/examples/semantic_indexing/data.py b/slm/examples/semantic_indexing/data.py
similarity index 100%
rename from legacy/examples/semantic_indexing/data.py
rename to slm/examples/semantic_indexing/data.py
diff --git a/legacy/examples/semantic_indexing/dense_retriever.py b/slm/examples/semantic_indexing/dense_retriever.py
similarity index 100%
rename from legacy/examples/semantic_indexing/dense_retriever.py
rename to slm/examples/semantic_indexing/dense_retriever.py
diff --git a/legacy/examples/semantic_indexing/evaluate.py b/slm/examples/semantic_indexing/evaluate.py
similarity index 100%
rename from legacy/examples/semantic_indexing/evaluate.py
rename to slm/examples/semantic_indexing/evaluate.py
diff --git a/legacy/examples/semantic_indexing/faiss_indexer.py b/slm/examples/semantic_indexing/faiss_indexer.py
similarity index 100%
rename from legacy/examples/semantic_indexing/faiss_indexer.py
rename to slm/examples/semantic_indexing/faiss_indexer.py
diff --git a/legacy/examples/semantic_indexing/fast_predict.py b/slm/examples/semantic_indexing/fast_predict.py
similarity index 100%
rename from legacy/examples/semantic_indexing/fast_predict.py
rename to slm/examples/semantic_indexing/fast_predict.py
diff --git a/legacy/examples/semantic_indexing/generate_dense_embeddings.py b/slm/examples/semantic_indexing/generate_dense_embeddings.py
similarity index 100%
rename from legacy/examples/semantic_indexing/generate_dense_embeddings.py
rename to slm/examples/semantic_indexing/generate_dense_embeddings.py
diff --git a/legacy/examples/semantic_indexing/gradient_cache/model.py b/slm/examples/semantic_indexing/gradient_cache/model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/gradient_cache/model.py
rename to slm/examples/semantic_indexing/gradient_cache/model.py
diff --git a/legacy/examples/semantic_indexing/hardest_negative/model.py b/slm/examples/semantic_indexing/hardest_negative/model.py
similarity index 100%
rename from legacy/examples/semantic_indexing/hardest_negative/model.py
rename to slm/examples/semantic_indexing/hardest_negative/model.py
diff --git a/legacy/examples/semantic_indexing/predict.py b/slm/examples/semantic_indexing/predict.py
similarity index 100%
rename from legacy/examples/semantic_indexing/predict.py
rename to slm/examples/semantic_indexing/predict.py
diff --git a/legacy/examples/semantic_indexing/qa_validation.py b/slm/examples/semantic_indexing/qa_validation.py
similarity index 100%
rename from legacy/examples/semantic_indexing/qa_validation.py
rename to slm/examples/semantic_indexing/qa_validation.py
diff --git a/legacy/examples/semantic_indexing/recall.py b/slm/examples/semantic_indexing/recall.py
similarity index 100%
rename from legacy/examples/semantic_indexing/recall.py
rename to slm/examples/semantic_indexing/recall.py
diff --git a/legacy/examples/semantic_indexing/requirements.txt b/slm/examples/semantic_indexing/requirements.txt
similarity index 100%
rename from legacy/examples/semantic_indexing/requirements.txt
rename to slm/examples/semantic_indexing/requirements.txt
diff --git a/legacy/examples/semantic_indexing/run_ann_data_gen.py b/slm/examples/semantic_indexing/run_ann_data_gen.py
similarity index 100%
rename from legacy/examples/semantic_indexing/run_ann_data_gen.py
rename to slm/examples/semantic_indexing/run_ann_data_gen.py
diff --git a/legacy/examples/semantic_indexing/tokenizers.py b/slm/examples/semantic_indexing/tokenizers.py
similarity index 100%
rename from legacy/examples/semantic_indexing/tokenizers.py
rename to slm/examples/semantic_indexing/tokenizers.py
diff --git a/legacy/examples/semantic_indexing/train_ance.py b/slm/examples/semantic_indexing/train_ance.py
similarity index 100%
rename from legacy/examples/semantic_indexing/train_ance.py
rename to slm/examples/semantic_indexing/train_ance.py
diff --git a/legacy/examples/semantic_indexing/train_batch_neg.py b/slm/examples/semantic_indexing/train_batch_neg.py
similarity index 100%
rename from legacy/examples/semantic_indexing/train_batch_neg.py
rename to slm/examples/semantic_indexing/train_batch_neg.py
diff --git a/legacy/examples/semantic_indexing/train_gradient_cache.py b/slm/examples/semantic_indexing/train_gradient_cache.py
similarity index 100%
rename from legacy/examples/semantic_indexing/train_gradient_cache.py
rename to slm/examples/semantic_indexing/train_gradient_cache.py
diff --git a/legacy/examples/semantic_indexing/train_gradient_cache_DPR.py b/slm/examples/semantic_indexing/train_gradient_cache_DPR.py
similarity index 100%
rename from legacy/examples/semantic_indexing/train_gradient_cache_DPR.py
rename to slm/examples/semantic_indexing/train_gradient_cache_DPR.py
diff --git a/legacy/examples/semantic_indexing/train_hardest_neg.py b/slm/examples/semantic_indexing/train_hardest_neg.py
similarity index 100%
rename from legacy/examples/semantic_indexing/train_hardest_neg.py
rename to slm/examples/semantic_indexing/train_hardest_neg.py
diff --git a/legacy/examples/sentiment_analysis/skep/README.md b/slm/examples/sentiment_analysis/skep/README.md
similarity index 73%
rename from legacy/examples/sentiment_analysis/skep/README.md
rename to slm/examples/sentiment_analysis/skep/README.md
index 2d5183613102..7591f5f61f61 100644
--- a/legacy/examples/sentiment_analysis/skep/README.md
+++ b/slm/examples/sentiment_analysis/skep/README.md
@@ -2,7 +2,7 @@
情感分析旨在自动识别和提取文本中的倾向、立场、评价、观点等主观信息。它包含各式各样的任务,比如句子级情感分类、评价对象级情感分类、观点抽取、情绪分类等。情感分析是人工智能的重要研究方向,具有很高的学术价值。同时,情感分析在消费决策、舆情分析、个性化推荐等领域均有重要的应用,具有很高的商业价值。
-情感预训练模型SKEP(Sentiment Knowledge Enhanced Pre-training for Sentiment Analysis)。SKEP利用情感知识增强预训练模型, 在14项中英情感分析典型任务上全面超越SOTA,此工作已经被ACL 2020录用。SKEP是百度研究团队提出的基于情感知识增强的情感预训练算法,此算法采用无监督方法自动挖掘情感知识,然后利用情感知识构建预训练目标,从而让机器学会理解情感语义。SKEP为各类情感分析任务提供统一且强大的情感语义表示。
+情感预训练模型 SKEP(Sentiment Knowledge Enhanced Pre-training for Sentiment Analysis)。SKEP 利用情感知识增强预训练模型, 在14项中英情感分析典型任务上全面超越 SOTA,此工作已经被 ACL 2020录用。SKEP 是百度研究团队提出的基于情感知识增强的情感预训练算法,此算法采用无监督方法自动挖掘情感知识,然后利用情感知识构建预训练目标,从而让机器学会理解情感语义。SKEP 为各类情感分析任务提供统一且强大的情感语义表示。
论文地址:https://arxiv.org/abs/2005.05635
@@ -10,7 +10,7 @@
-百度研究团队在三个典型情感分析任务,语句级情感分类(Sentence-level Sentiment Classification),评价对象级情感分类(Aspect-level Sentiment Classification)、观点抽取(Opinion Role Labeling),共计14个中英文数据上进一步验证了情感预训练模型SKEP的效果。实验表明,下表展示了在模型分别在数据集SST-2、ChnSentiCorp、SE-ABSA16_PHNS、COTE_DP上的实验结果,同时标明了各项数据集对应的任务类型、语言类别、下载地址等信息。
+百度研究团队在三个典型情感分析任务,语句级情感分类(Sentence-level Sentiment Classification),评价对象级情感分类(Aspect-level Sentiment Classification)、观点抽取(Opinion Role Labeling),共计14个中英文数据上进一步验证了情感预训练模型 SKEP 的效果。实验表明,下表展示了在模型分别在数据集 SST-2、ChnSentiCorp、SE-ABSA16_PHNS、COTE_DP 上的实验结果,同时标明了各项数据集对应的任务类型、语言类别、下载地址等信息。
@@ -80,7 +80,7 @@ skep/
### 语句级情感分类
#### 数据下载
-本示例采用常用开源数据集ChnSenticorp中文数据集、GLUE-SST2英文数据集作为语句级情感分类数据集。这两项数据集已经内置于PaddleNLP。可以通过以下方式进行加载。
+本示例采用常用开源数据集 ChnSenticorp 中文数据集、GLUE-SST2英文数据集作为语句级情感分类数据集。这两项数据集已经内置于 PaddleNLP。可以通过以下方式进行加载。
```python
from paddlenlp.datasets import load_dataset
@@ -91,7 +91,7 @@ train_ds, dev_ds = load_dataset("glue", "sst-2", splits=["train", "dev"])
#### 模型训练
-可以通过如下命令开启语句级情感分析任务训练,需要特别说明的是,如果想要基于数据集ChnSentiCorp训练中文情感分析模型,请指定model_name为:`skep_ernie_1.0_large_ch`; 基于数据集GLUE-SST2训练英文情感分析模型请指定model_name为:`skep_ernie_2.0_large_en`。下面以中文情感分析为例进行说明。
+可以通过如下命令开启语句级情感分析任务训练,需要特别说明的是,如果想要基于数据集 ChnSentiCorp 训练中文情感分析模型,请指定 model_name 为:`skep_ernie_1.0_large_ch`; 基于数据集 GLUE-SST2训练英文情感分析模型请指定 model_name 为:`skep_ernie_2.0_large_en`。下面以中文情感分析为例进行说明。
```shell
unset CUDA_VISIBLE_DEVICES
@@ -107,18 +107,18 @@ python -m paddle.distributed.launch --gpus "0" train_sentence.py \
可支持配置的参数:
-* `model_name`: 使用预训练模型的名称,可选skep_ernie_1.0_large_ch和skep_ernie_2.0_large_en。
- skep_ernie_1.0_large_ch:是SKEP模型在预训练ernie_1.0_large_ch基础之上在海量中文数据上继续预训练得到的中文预训练模型;
- skep_ernie_2.0_large_en:是SKEP模型在预训练ernie_2.0_large_en基础之上在海量英文数据上继续预训练得到的中文预训练模型。
-* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录checkpoints文件夹下。
-* `max_seq_len`:可选,ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `model_name`: 使用预训练模型的名称,可选 skep_ernie_1.0_large_ch 和 skep_ernie_2.0_large_en。
+ skep_ernie_1.0_large_ch:是 SKEP 模型在预训练 ernie_1.0_large_ch 基础之上在海量中文数据上继续预训练得到的中文预训练模型;
+ skep_ernie_2.0_large_en:是 SKEP 模型在预训练 ernie_2.0_large_en 基础之上在海量英文数据上继续预训练得到的中文预训练模型。
+* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录 checkpoints 文件夹下。
+* `max_seq_len`:可选,ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为16。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.00。
* `epochs`: 训练轮次,默认为3。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000.
-* `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
程序运行时将会自动进行训练,评估,测试。同时训练过程中会自动保存模型在指定的`save_dir`中。
@@ -143,8 +143,8 @@ Data: 怀着十分激动的心情放映,可是看着看着发现,在放映
Data: 作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间。 Label: positive
```
-#### 基于Taskflow一键预测
-当前PaddleNLP已将训练好的SKEP中文语句级情感分析模型集成至Taskflow中,可以使用Taskflow对输入的文本进行一键式情感分析,使用方法如下:
+#### 基于 Taskflow 一键预测
+当前 PaddleNLP 已将训练好的 SKEP 中文语句级情感分析模型集成至 Taskflow 中,可以使用 Taskflow 对输入的文本进行一键式情感分析,使用方法如下:
```python
from paddlenlp import Taskflow
@@ -156,7 +156,7 @@ senta("怀着十分激动的心情放映,可是看着看着发现,在放映
'''
```
-如果想使用自己训练好的模型加载进Taskflow进行预测,可以使用参数`task_path`进行指定模型路径,需要注意的是,该路径下需要存放模型文件以及相应的Tokenizer文件(训练过程中,已保存这两者相关文件)。
+如果想使用自己训练好的模型加载进 Taskflow 进行预测,可以使用参数`task_path`进行指定模型路径,需要注意的是,该路径下需要存放模型文件以及相应的 Tokenizer 文件(训练过程中,已保存这两者相关文件)。
```python
from paddlenlp import Taskflow
@@ -170,7 +170,7 @@ senta("怀着十分激动的心情放映,可是看着看着发现,在放映
#### 模型部署
-使用动态图训练结束之后,还可以将动态图参数导出成静态图参数。在进行模型转换时,需要通过参数`ckpt_dir`指定训练好的模型存放目录,通过`output_path`指定静态图模型参数保存路径,详情请参考export_model.py。模型转换命令如下:
+使用动态图训练结束之后,还可以将动态图参数导出成静态图参数。在进行模型转换时,需要通过参数`ckpt_dir`指定训练好的模型存放目录,通过`output_path`指定静态图模型参数保存路径,详情请参考 export_model.py。模型转换命令如下:
```shell
export CUDA_VISIBLE_DEVICES=0
@@ -180,7 +180,7 @@ python export_model.py \
--output_path="./static/static_graph_params"
```
-可以将导出的静态图模型进行部署,deploy/python/predict.py展示了python部署预测示例。运行方式如下:
+可以将导出的静态图模型进行部署,deploy/python/predict.py 展示了 python 部署预测示例。运行方式如下:
```shell
export CUDA_VISIBLE_DEVICES=0
@@ -191,7 +191,7 @@ python deploy/python/predict.py \
```
### 评价对象级情感分类
-本节将以数据集SE-ABSA16_PHNS为例展示评价对象级的情感分类模型训练和测试。该数据集已内置于PaddleNLP中,可以通过语句级情感分类类似方式进行加载。这里不再赘述。下面展示了SE-ABSA16_PHNS数据集中的一条数据。
+本节将以数据集 SE-ABSA16_PHNS 为例展示评价对象级的情感分类模型训练和测试。该数据集已内置于 PaddleNLP 中,可以通过语句级情感分类类似方式进行加载。这里不再赘述。下面展示了 SE-ABSA16_PHNS 数据集中的一条数据。
```text
label text_a text_b
@@ -228,7 +228,7 @@ python predict_aspect.py \
```
### 观点抽取
-本节将以数据集COTE_DP为例展示评价对象级的情感分类模型训练和测试。该数据集已内置于PaddleNLP中,可以通过语句级情感分类类似方式进行加载。这里不再赘述。下面展示了COTE_DP数据中的前3条数据。
+本节将以数据集 COTE_DP 为例展示评价对象级的情感分类模型训练和测试。该数据集已内置于 PaddleNLP 中,可以通过语句级情感分类类似方式进行加载。这里不再赘述。下面展示了 COTE_DP 数据中的前3条数据。
```text
label text_a
@@ -268,4 +268,4 @@ python predict_opinion.py \
**备注**:
1. 评价对象级情感分类和观点抽取两类任务的模型部署方式可参考语句级情感分类,这里不再赘述。
-2. 评级级情感分类以及观点抽取,暂不支持skep模型的Taskflow离线模型加载。如需使用此类功能,请参考:[unified_sentiment_analysis](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/sentiment_analysis/unified_sentiment_extraction)。
+2. 评级级情感分类以及观点抽取,暂不支持 skep 模型的 Taskflow 离线模型加载。如需使用此类功能,请参考:[unified_sentiment_analysis](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/sentiment_analysis/unified_sentiment_extraction)。
diff --git a/legacy/examples/sentiment_analysis/skep/deploy/python/predict.py b/slm/examples/sentiment_analysis/skep/deploy/python/predict.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/deploy/python/predict.py
rename to slm/examples/sentiment_analysis/skep/deploy/python/predict.py
diff --git a/legacy/examples/sentiment_analysis/skep/export_model.py b/slm/examples/sentiment_analysis/skep/export_model.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/export_model.py
rename to slm/examples/sentiment_analysis/skep/export_model.py
diff --git a/legacy/examples/sentiment_analysis/skep/predict_aspect.py b/slm/examples/sentiment_analysis/skep/predict_aspect.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/predict_aspect.py
rename to slm/examples/sentiment_analysis/skep/predict_aspect.py
diff --git a/legacy/examples/sentiment_analysis/skep/predict_opinion.py b/slm/examples/sentiment_analysis/skep/predict_opinion.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/predict_opinion.py
rename to slm/examples/sentiment_analysis/skep/predict_opinion.py
diff --git a/legacy/examples/sentiment_analysis/skep/predict_sentence.py b/slm/examples/sentiment_analysis/skep/predict_sentence.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/predict_sentence.py
rename to slm/examples/sentiment_analysis/skep/predict_sentence.py
diff --git a/legacy/examples/sentiment_analysis/skep/train_aspect.py b/slm/examples/sentiment_analysis/skep/train_aspect.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/train_aspect.py
rename to slm/examples/sentiment_analysis/skep/train_aspect.py
diff --git a/legacy/examples/sentiment_analysis/skep/train_opinion.py b/slm/examples/sentiment_analysis/skep/train_opinion.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/train_opinion.py
rename to slm/examples/sentiment_analysis/skep/train_opinion.py
diff --git a/legacy/examples/sentiment_analysis/skep/train_sentence.py b/slm/examples/sentiment_analysis/skep/train_sentence.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/skep/train_sentence.py
rename to slm/examples/sentiment_analysis/skep/train_sentence.py
diff --git a/legacy/examples/sentiment_analysis/textcnn/README.md b/slm/examples/sentiment_analysis/textcnn/README.md
similarity index 76%
rename from legacy/examples/sentiment_analysis/textcnn/README.md
rename to slm/examples/sentiment_analysis/textcnn/README.md
index d4cd1599322a..f8cf79d77f99 100644
--- a/legacy/examples/sentiment_analysis/textcnn/README.md
+++ b/slm/examples/sentiment_analysis/textcnn/README.md
@@ -1,8 +1,8 @@
-# 使用TextCNN模型完成中文对话情绪识别任务
+# 使用 TextCNN 模型完成中文对话情绪识别任务
情感分析旨在自动识别和提取文本中的倾向、立场、评价、观点等主观信息。情感分析其中的一个任务就是对话情绪识别,针对智能对话中的用户文本,自动判断该文本的情绪类别并给出相应的置信度,情绪类型分为积极(positive)、消极(negative)和中性(neutral)。
-本示例展示了如何用TextCNN预训练模型在机器人聊天数据集上进行Finetune完成中文对话情绪识别任务。
+本示例展示了如何用 TextCNN 预训练模型在机器人聊天数据集上进行 Finetune 完成中文对话情绪识别任务。
## 快速开始
@@ -35,7 +35,7 @@ tar xvf RobotChat.tar.gz
### 词表下载
-在模型训练之前,需要先下载词汇表文件word_dict.txt,用于构造词-id映射关系。
+在模型训练之前,需要先下载词汇表文件 word_dict.txt,用于构造词-id 映射关系。
```shell
wget https://bj.bcebos.com/paddlenlp/robot_chat_word_dict.txt
@@ -45,7 +45,7 @@ wget https://bj.bcebos.com/paddlenlp/robot_chat_word_dict.txt
### 预训练模型下载
-这里我们提供了一个百度基于海量数据训练好的TextCNN模型,用户通过以下方式下载预训练模型。
+这里我们提供了一个百度基于海量数据训练好的 TextCNN 模型,用户通过以下方式下载预训练模型。
```shell
wget https://bj.bcebos.com/paddlenlp/models/textcnn.pdparams
@@ -53,7 +53,7 @@ wget https://bj.bcebos.com/paddlenlp/models/textcnn.pdparams
### 模型训练
-在下载好词表和预训练模型后就可以在机器人聊天数据集上进行finetune,通过运行以下命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证,这里通过`--init_from_ckpt=./textcnn.pdparams`指定TextCNN预训练模型。
+在下载好词表和预训练模型后就可以在机器人聊天数据集上进行 finetune,通过运行以下命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证,这里通过`--init_from_ckpt=./textcnn.pdparams`指定 TextCNN 预训练模型。
CPU 启动:
@@ -83,7 +83,7 @@ python -m paddle.distributed.launch --gpus "0" train.py \
--data_path=./RobotChat
```
-XPU启动:
+XPU 启动:
```shell
python train.py --vocab_path=./robot_chat_word_dict.txt \
@@ -100,9 +100,9 @@ python train.py --vocab_path=./robot_chat_word_dict.txt \
* `vocab_path`: 词汇表文件路径。
* `init_from_ckpt`: 恢复模型训练的断点路径。
-* `device`: 选用什么设备进行训练,可选cpu、gpu或xpu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu 或 xpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
* `lr`: 学习率, 默认为5e-5。
-* `batch_size`: 运行一个batch大小,默认为64。
+* `batch_size`: 运行一个 batch 大小,默认为64。
* `epochs`: 训练轮次,默认为10。
* `save_dir`: 训练保存模型的文件路径。
* `data_path`: 数据集文件路径。
@@ -122,8 +122,8 @@ checkpoints/
**NOTE:**
-* 如需恢复模型训练,则init_from_ckpt只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/0`即可,程序会自动加载模型参数`checkpoints/0.pdparams`,也会自动加载优化器状态`checkpoints/0.pdopt`。
-* 使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见export_model.py。静态图参数保存在`output_path`指定路径中。
+* 如需恢复模型训练,则 init_from_ckpt 只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/0`即可,程序会自动加载模型参数`checkpoints/0.pdparams`,也会自动加载优化器状态`checkpoints/0.pdopt`。
+* 使用动态图训练结束之后,还可以将动态图参数导出成静态图参数,具体代码见 export_model.py。静态图参数保存在`output_path`指定路径中。
运行方式:
```shell
@@ -132,7 +132,7 @@ python export_model.py --vocab_path=./robot_chat_word_dict.txt --params_path=./c
其中`params_path`是指动态图训练保存的参数路径,`output_path`是指静态图参数导出路径。
-导出模型之后,可以用于部署,deploy/python/predict.py文件提供了python部署预测示例。运行方式:
+导出模型之后,可以用于部署,deploy/python/predict.py 文件提供了 python 部署预测示例。运行方式:
```shell
python deploy/python/predict.py --model_file=static_graph_params.pdmodel --params_file=static_graph_params.pdiparams
@@ -142,7 +142,7 @@ python deploy/python/predict.py --model_file=static_graph_params.pdmodel --param
启动预测:
-CPU启动:
+CPU 启动:
```shell
python predict.py --vocab_path=./robot_chat_word_dict.txt \
@@ -150,7 +150,7 @@ python predict.py --vocab_path=./robot_chat_word_dict.txt \
--params_path=./checkpoints/final.pdparams
```
-GPU启动:
+GPU 启动:
```shell
export CUDA_VISIBLE_DEVICES=0
@@ -159,7 +159,7 @@ python predict.py --vocab_path=./robot_chat_word_dict.txt \
--params_path=./checkpoints/final.pdparams
```
-XPU启动:
+XPU 启动:
```shell
python predict.py --vocab_path=./robot_chat_word_dict.txt \
@@ -187,6 +187,6 @@ Data: 我喜欢画画也喜欢唱歌 Label: positive
## Reference
-TextCNN参考论文:
+TextCNN 参考论文:
- [EMNLP2014-Convolutional Neural Networks for Sentence Classification](https://aclanthology.org/D14-1181.pdf)
diff --git a/legacy/examples/sentiment_analysis/textcnn/data.py b/slm/examples/sentiment_analysis/textcnn/data.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/textcnn/data.py
rename to slm/examples/sentiment_analysis/textcnn/data.py
diff --git a/legacy/examples/sentiment_analysis/textcnn/deploy/python/predict.py b/slm/examples/sentiment_analysis/textcnn/deploy/python/predict.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/textcnn/deploy/python/predict.py
rename to slm/examples/sentiment_analysis/textcnn/deploy/python/predict.py
diff --git a/legacy/examples/sentiment_analysis/textcnn/export_model.py b/slm/examples/sentiment_analysis/textcnn/export_model.py
similarity index 99%
rename from legacy/examples/sentiment_analysis/textcnn/export_model.py
rename to slm/examples/sentiment_analysis/textcnn/export_model.py
index 0953a4002053..62c318d391b6 100644
--- a/legacy/examples/sentiment_analysis/textcnn/export_model.py
+++ b/slm/examples/sentiment_analysis/textcnn/export_model.py
@@ -16,9 +16,10 @@
import os
import paddle
-from paddlenlp.data import Vocab
from model import TextCNNModel
+from paddlenlp.data import Vocab
+
# yapf: disable
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--vocab_path", type=str, default="./robot_chat_word_dict.txt", help="The path to vocabulary.")
diff --git a/legacy/examples/sentiment_analysis/textcnn/model.py b/slm/examples/sentiment_analysis/textcnn/model.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/textcnn/model.py
rename to slm/examples/sentiment_analysis/textcnn/model.py
diff --git a/legacy/examples/sentiment_analysis/textcnn/predict.py b/slm/examples/sentiment_analysis/textcnn/predict.py
similarity index 100%
rename from legacy/examples/sentiment_analysis/textcnn/predict.py
rename to slm/examples/sentiment_analysis/textcnn/predict.py
index ba3dd2958149..babccb5cba08 100644
--- a/legacy/examples/sentiment_analysis/textcnn/predict.py
+++ b/slm/examples/sentiment_analysis/textcnn/predict.py
@@ -15,10 +15,10 @@
import paddle
import paddle.nn.functional as F
-from paddlenlp.data import JiebaTokenizer, Pad, Vocab
-
-from model import TextCNNModel
from data import preprocess_prediction_data
+from model import TextCNNModel
+
+from paddlenlp.data import JiebaTokenizer, Pad, Vocab
# yapf: disable
parser = argparse.ArgumentParser(__doc__)
diff --git a/legacy/examples/sentiment_analysis/textcnn/train.py b/slm/examples/sentiment_analysis/textcnn/train.py
similarity index 98%
rename from legacy/examples/sentiment_analysis/textcnn/train.py
rename to slm/examples/sentiment_analysis/textcnn/train.py
index e80d2180af75..249a669dad66 100644
--- a/legacy/examples/sentiment_analysis/textcnn/train.py
+++ b/slm/examples/sentiment_analysis/textcnn/train.py
@@ -12,19 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from functools import partial
import argparse
import os
import random
+from functools import partial
import numpy as np
import paddle
-from paddlenlp.datasets import load_dataset
-from paddlenlp.data import JiebaTokenizer, Pad, Stack, Tuple, Vocab
-
-from data import create_dataloader, convert_example, read_custom_data
+from data import convert_example, create_dataloader, read_custom_data
from model import TextCNNModel
+from paddlenlp.data import JiebaTokenizer, Pad, Stack, Tuple, Vocab
+from paddlenlp.datasets import load_dataset
+
# yapf: disable
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--epochs", type=int, default=10, help="Number of epoches for training.")
diff --git a/legacy/examples/simultaneous_translation/stacl/README.md b/slm/examples/simultaneous_translation/stacl/README.md
similarity index 61%
rename from legacy/examples/simultaneous_translation/stacl/README.md
rename to slm/examples/simultaneous_translation/stacl/README.md
index 743ae223accc..19fffc745c27 100644
--- a/legacy/examples/simultaneous_translation/stacl/README.md
+++ b/slm/examples/simultaneous_translation/stacl/README.md
@@ -2,32 +2,32 @@
同声传译(Simultaneous Translation),即在句子完成之前进行翻译,同声传译的目标是实现同声传译的自动化,它可以与源语言同时翻译,延迟时间只有几秒钟。
-同声传译的难点在于源语言和目标语言之间词序的差异带来的翻译延迟。 例如,考虑将SOV(主宾谓)语言(如日语或德语)翻译为SVO(主谓宾)语言(如英语或汉语),必须等到源语言动词出现才可以准确翻译。因此,翻译系统必须求助于传统的全句翻译,因此造成至少一句话的延迟。
+同声传译的难点在于源语言和目标语言之间词序的差异带来的翻译延迟。 例如,考虑将 SOV(主宾谓)语言(如日语或德语)翻译为 SVO(主谓宾)语言(如英语或汉语),必须等到源语言动词出现才可以准确翻译。因此,翻译系统必须求助于传统的全句翻译,因此造成至少一句话的延迟。
-本项目是基于机器翻译领域主流模型 Transformer[1]网络结构的同传模型STACL的PaddlePaddle 实现,包含模型训练,预测以及使用自定义数据等内容。用户可以基于发布的内容搭建自己的同传翻译模型。
+本项目是基于机器翻译领域主流模型 Transformer[1]网络结构的同传模型 STACL 的 PaddlePaddle 实现,包含模型训练,预测以及使用自定义数据等内容。用户可以基于发布的内容搭建自己的同传翻译模型。
## 模型介绍
### 模型特点
-STACL 是论文 [STACL: Simultaneous Translation with Implicit Anticipation and Controllable Latency using Prefix-to-Prefix Framework](https://www.aclweb.org/anthology/P19-1289/) 中针对同传提出的适用于所有同传场景的翻译架构[2],该架构基于Transformer实现,可参考PaddleNLP的[Transformer](../../machine_translation/transformer)。
+STACL 是论文 [STACL: Simultaneous Translation with Implicit Anticipation and Controllable Latency using Prefix-to-Prefix Framework](https://www.aclweb.org/anthology/P19-1289/) 中针对同传提出的适用于所有同传场景的翻译架构[2],该架构基于 Transformer 实现,可参考 PaddleNLP 的[Transformer](../../machine_translation/transformer)。
STACL 主要具有以下优势:
-- Prefix-to-Prefix架构拥有预测能力,即在未看到源词的情况下仍然可以翻译出对应的目标词,克服了SOV→SVO等词序差异;
+- Prefix-to-Prefix 架构拥有预测能力,即在未看到源词的情况下仍然可以翻译出对应的目标词,克服了 SOV→SVO 等词序差异;
-- Wait-k策略可以不需要全句的源句,直接预测目标句,可以实现任意的字级延迟,同时保持较高的翻译质量。
+- Wait-k 策略可以不需要全句的源句,直接预测目标句,可以实现任意的字级延迟,同时保持较高的翻译质量。
-#### Prefix-to-Prefix架构
+#### Prefix-to-Prefix 架构
图 1. Seq2Seq vs. STACL
-和传统的机器翻译模型主要的区别在于翻译时是否需要利用全句的源句。上图中,Seq2Seq模型需要等到全句的源句(1-5)全部输入Encoder后,Decoder才开始解码进行翻译;而STACL架构采用了Wait-k(图中Wait-2)的策略,当源句只有两个词(1和2)输入到Encoder后,Decoder即可开始解码预测目标句的第一个词。
+和传统的机器翻译模型主要的区别在于翻译时是否需要利用全句的源句。上图中,Seq2Seq 模型需要等到全句的源句(1-5)全部输入 Encoder 后,Decoder 才开始解码进行翻译;而 STACL 架构采用了 Wait-k(图中 Wait-2)的策略,当源句只有两个词(1和2)输入到 Encoder 后,Decoder 即可开始解码预测目标句的第一个词。
#### Wait-k 策略
-Wait-k策略首先等待源句单词,然后与源句的其余部分同时翻译,即输出总是隐藏在输入后面。这是受到同声传译人员的启发,同声传译人员通常会在几秒钟内开始翻译演讲者的演讲,在演讲者结束几秒钟后完成。例如,如果k=2,第一个目标词使用前2个源词预测,第二个目标词使用前3个源词预测,以此类推。下图3中,(a)simultaneous: our wait-2 等到"布什"和"总统"输入后就开始解码预测"pres.",而(b) non-simultaneous baseline 为传统的翻译模型,需要等到整句"布什 总统 在 莫斯科 与 普京 会晤"才开始解码预测。
+Wait-k 策略首先等待源句单词,然后与源句的其余部分同时翻译,即输出总是隐藏在输入后面。这是受到同声传译人员的启发,同声传译人员通常会在几秒钟内开始翻译演讲者的演讲,在演讲者结束几秒钟后完成。例如,如果 k=2,第一个目标词使用前2个源词预测,第二个目标词使用前3个源词预测,以此类推。下图3中,(a)simultaneous: our wait-2 等到"布什"和"总统"输入后就开始解码预测"pres.",而(b) non-simultaneous baseline 为传统的翻译模型,需要等到整句"布什 总统 在 莫斯科 与 普京 会晤"才开始解码预测。
图 2. Wait-k 例子
@@ -44,8 +44,8 @@ Wait-k策略首先等待源句单词,然后与源句的其余部分同时翻
## 数据准备
### 数据分词
-中文需要首先经过jieba分词,然后经过BPE分词(Byte Pair Encoding);英文仅需要经过BPE分词。
-BPE分词需要对应的BPE词典,这里提供下载链接:[中文BPE词典](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.zh) ,[英文BPE词典](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.en) 。
+中文需要首先经过 jieba 分词,然后经过 BPE 分词(Byte Pair Encoding);英文仅需要经过 BPE 分词。
+BPE 分词需要对应的 BPE 词典,这里提供下载链接:[中文 BPE 词典](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.zh) ,[英文 BPE 词典](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.en) 。
我们提供分词的接口,下面给出分词的具体操作:
```python
@@ -79,25 +79,25 @@ python -m paddle.distributed.launch --gpus "0" train.py --config ./config/transf
可以在`config/transformer.yaml` 文件中设置相应的参数。如果执行不提供 `--config` 选项,程序将默认使用`config/transformer.yaml` 的配置。
-建议:如果为了更好的效果,可先在整句模型(即`waik=-1`)进行预训练,然后在此基础上根据不同的waitk进行微调来训练不同的waitk模型,训练的命令都同上,下面给出具体的流程以及主要的参数配置:
+建议:如果为了更好的效果,可先在整句模型(即`waik=-1`)进行预训练,然后在此基础上根据不同的 waitk 进行微调来训练不同的 waitk 模型,训练的命令都同上,下面给出具体的流程以及主要的参数配置:
- Pretrain
用来训练整句模型(即`waik=-1`),可在`config/transformer.yaml`文件中配置参数:
- - `waik`表示waik策略,这里设置为-1
+ - `waik`表示 waik 策略,这里设置为-1
- `training_file`表示训练集,数据格式同上文
- `validation_file`表示验证集,数据格式同上文
- - `init_from_checkpoint`表示模型目录,从该checkpoint恢复训练,这里设置为空
- - `init_from_pretrain_model`表示模型目录,从该checkpoint开始finetune下游任务,这里设置为空
- - `device`选择训练用的设备,支持cpu/gpu/xpu,默认为gpu
- - `use_amp`表示混合精度训练,示例设置为False
+ - `init_from_checkpoint`表示模型目录,从该 checkpoint 恢复训练,这里设置为空
+ - `init_from_pretrain_model`表示模型目录,从该 checkpoint 开始 finetune 下游任务,这里设置为空
+ - `device`选择训练用的设备,支持 cpu/gpu/xpu,默认为 gpu
+ - `use_amp`表示混合精度训练,示例设置为 False
- Finetune
- 用来训练waik模型(即`waitk=1,2,3,4...`),可在`config/transformer.yaml`文件中配置参数:
- - `waik`表示waik策略,这里设置为3(以wait-3模型为例)
+ 用来训练 waik 模型(即`waitk=1,2,3,4...`),可在`config/transformer.yaml`文件中配置参数:
+ - `waik`表示 waik 策略,这里设置为3(以 wait-3模型为例)
- `training_file`表示训练集,数据格式同上文
- `validation_file`表示验证集,数据格式同上文
- - `init_from_checkpoint`表示模型目录,从该checkpoint恢复训练,这里设置`waik=-1`模型的ckeckpoint
- - `init_from_pretrain_model`表示模型目录,从该checkpoint开始finetune下游任务,这里设置为空
- - `device`选择训练用的设备,支持cpu/gpu/xpu,默认为gpu
- - `use_amp`表示混合精度训练,示例设置为False
+ - `init_from_checkpoint`表示模型目录,从该 checkpoint 恢复训练,这里设置`waik=-1`模型的 ckeckpoint
+ - `init_from_pretrain_model`表示模型目录,从该 checkpoint 开始 finetune 下游任务,这里设置为空
+ - `device`选择训练用的设备,支持 cpu/gpu/xpu,默认为 gpu
+ - `use_amp`表示混合精度训练,示例设置为 False
## 模型推理
模型训练完成后可以执行以下命令对指定文件中的文本进行翻译:
@@ -108,9 +108,9 @@ export CUDA_VISIBLE_DEVICES=0
python predict.py --config ./config/transformer.yaml
```
- Predict
- 根据具体的waik策略来进行翻译,可在`config/transformer.yaml`文件中配置参数,预测的命令同上,下面给出主要的参数说明:
- - `waik`表示waik策略,这里设置为3(以wait-3模型为例)
- - `predict_file`表示测试集,数据格式是BPE分词后的源语言(中文为Jieba+BPE分词),按行区分
+ 根据具体的 waik 策略来进行翻译,可在`config/transformer.yaml`文件中配置参数,预测的命令同上,下面给出主要的参数说明:
+ - `waik`表示 waik 策略,这里设置为3(以 wait-3模型为例)
+ - `predict_file`表示测试集,数据格式是 BPE 分词后的源语言(中文为 Jieba+BPE 分词),按行区分
- `output_file`表示输出文件,翻译结果会输出到该参数指定的文件
- `init_from_params`表示模型的所在目录,根据具体的`waik`来设置,这里设置为`wait=3`模型目录
- 更多参数的使用可以在 `config/transformer.yaml`文件中查阅注释说明并进行更改设置。如果执行不提供 `--config` 选项,程序将默认使用 `config/transformer.yaml` 的配置。
@@ -132,8 +132,8 @@ perl mosesdecoder/scripts/generic/multi-bleu.perl newstest2017.tok.en < predict.
```
## 模型下载(更新中)
-我们提供基于NIST(中->英,共2M中英句对)预训练模型,供大家下载,下载后需解压使用。
-| Wait-k策略 | 模型连接 | 4-ref BLEU on NIST 2008 |
+我们提供基于 NIST(中->英,共2M 中英句对)预训练模型,供大家下载,下载后需解压使用。
+| Wait-k 策略 | 模型连接 | 4-ref BLEU on NIST 2008 |
|-------------------|---------------------------------------------------------------------------------|-------------------------|
| Wait-1 | [下载](https://bj.bcebos.com/paddlenlp/models/stacl/nist_zhen_full_w1.tar.gz) | 30.94 |
| Wait-3 | [下载](https://bj.bcebos.com/paddlenlp/models/stacl/nist_zhen_full_w3.tar.gz) | 34.24 |
@@ -142,8 +142,8 @@ perl mosesdecoder/scripts/generic/multi-bleu.perl newstest2017.tok.en < predict.
| Wait_-1(整句模型) | [下载](https://bj.bcebos.com/paddlenlp/models/stacl/nist_zhen_full_sent.tar.gz) | 41.41 |
词表下载:[source vocab](https://bj.bcebos.com/paddlenlp/models/stacl/nist.20k.zh.vocab) ,[target vocab](https://bj.bcebos.com/paddlenlp/models/stacl/nist.10k.en.vocab)
-## Demo展示
-通过GUI界面的Demo来模拟STACL实时翻译的效果,下图为Demo示例,实现细节可查看[demo](./demo)
+## Demo 展示
+通过 GUI 界面的 Demo 来模拟 STACL 实时翻译的效果,下图为 Demo 示例,实现细节可查看[demo](./demo)
图 3. 文本同传
diff --git a/legacy/examples/simultaneous_translation/stacl/config/transformer.yaml b/slm/examples/simultaneous_translation/stacl/config/transformer.yaml
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/config/transformer.yaml
rename to slm/examples/simultaneous_translation/stacl/config/transformer.yaml
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/README.md b/slm/examples/simultaneous_translation/stacl/demo/README.md
similarity index 59%
rename from legacy/examples/simultaneous_translation/stacl/demo/README.md
rename to slm/examples/simultaneous_translation/stacl/demo/README.md
index a0b460ccbd6c..e36b2c1d5cf2 100644
--- a/legacy/examples/simultaneous_translation/stacl/demo/README.md
+++ b/slm/examples/simultaneous_translation/stacl/demo/README.md
@@ -1,6 +1,6 @@
# Demo for STACL
-该Demo模拟同传模型STACL实时翻译的效果。
+该 Demo 模拟同传模型 STACL 实时翻译的效果。
图 1. 文本同传
@@ -10,14 +10,14 @@
图 2. 语音同传
-用户通过Chinese input文本框**打字输入**或者**语音输入即本地麦克风收音**,然后通过Jieba和BPE得到分词结果。
+用户通过 Chinese input 文本框**打字输入**或者**语音输入即本地麦克风收音**,然后通过 Jieba 和 BPE 得到分词结果。
-- Simultaneous Translation (wait 1)是读取1个token(分词后)后开始实时翻译;
-- Simultaneous Translation (wait 3)是读取3个token(分词后)后开始实时翻译;
-- Simultaneous Translation (wait 5)是读取5个token(分词后)后开始实时翻译;
-- Full Sentence Translation(wait -1)是读取所有的token(分词后)即整句后开始翻译。
+- Simultaneous Translation (wait 1)是读取1个 token(分词后)后开始实时翻译;
+- Simultaneous Translation (wait 3)是读取3个 token(分词后)后开始实时翻译;
+- Simultaneous Translation (wait 5)是读取5个 token(分词后)后开始实时翻译;
+- Full Sentence Translation(wait -1)是读取所有的 token(分词后)即整句后开始翻译。
-一般来说,waitk越大(waitk=-1可看作waitk=∞),读入的信息越多,实时翻译效果越好。由上图可见,STACL具有较好的预测性,较小的waitk也能得到较好的翻译结果。
+一般来说,waitk 越大(waitk=-1可看作 waitk=∞),读入的信息越多,实时翻译效果越好。由上图可见,STACL 具有较好的预测性,较小的 waitk 也能得到较好的翻译结果。
### 目录结构
```text
@@ -40,17 +40,17 @@
```
-上述models目录下的模型可以在这里[下载](../README.md#%E6%A8%A1%E5%9E%8B%E4%B8%8B%E8%BD%BD%E6%9B%B4%E6%96%B0%E4%B8%AD) ,下载完后将解压后的`transformer.pdparams`分别放在不同的waitk策略对应的子目录下面。
+上述 models 目录下的模型可以在这里[下载](../README.md#%E6%A8%A1%E5%9E%8B%E4%B8%8B%E8%BD%BD%E6%9B%B4%E6%96%B0%E4%B8%AD) ,下载完后将解压后的`transformer.pdparams`分别放在不同的 waitk 策略对应的子目录下面。
### 参数说明与配置
##### 1. 模型参数配置
可以在`transformer_demo.yaml` 文件中设置相应的参数,下面给出主要的参数配置:
-- `src_bpe_dict`配置源语言(这里是中文)的BPE词表,[中文BPE词表下载](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.zh)
+- `src_bpe_dict`配置源语言(这里是中文)的 BPE 词表,[中文 BPE 词表下载](https://bj.bcebos.com/paddlenlp/models/stacl/2M.zh2en.dict4bpe.zh)
- `src_vocab_fpath`配置源语言(这里是中文)词表,[source vocab](https://bj.bcebos.com/paddlenlp/models/stacl/nist.20k.zh.vocab)
- `trg_vocab_fpath`配置目标语言(这里是英文)词表,[target vocab](https://bj.bcebos.com/paddlenlp/models/stacl/nist.10k.en.vocab)
-- `device`选择预测用的设备,支持cpu/gpu/xpu,默认为cpu
+- `device`选择预测用的设备,支持 cpu/gpu/xpu,默认为 cpu
##### 2. 语音同传参数配置
需要配置`const.py`里面语音识别的应用鉴权信息,只需要将`APPID`和`APPKEY`设置为自己所申请的。
@@ -66,7 +66,7 @@
可通过安装命令:`pip install -r requirements.txt`来进行安装。
-注意:本项目依赖于Python内置包`tkinter >= 8.6`
+注意:本项目依赖于 Python 内置包`tkinter >= 8.6`
- 查看`tkinter`的版本:
```python
python -c "import tkinter; print(tkinter.TkVersion)"
@@ -79,14 +79,14 @@
### 使用说明
-1. 下载[预训练模型](../README.md#%E6%A8%A1%E5%9E%8B%E4%B8%8B%E8%BD%BD%E6%9B%B4%E6%96%B0%E4%B8%AD) ,并放在models目录下对应的子目录里;
-2. 下载词表(源语言词表,目标语言词表,BPE词表),并在配置文件`transformer_demo.yaml`中修改相应的参数;
+1. 下载[预训练模型](../README.md#%E6%A8%A1%E5%9E%8B%E4%B8%8B%E8%BD%BD%E6%9B%B4%E6%96%B0%E4%B8%AD) ,并放在 models 目录下对应的子目录里;
+2. 下载词表(源语言词表,目标语言词表,BPE 词表),并在配置文件`transformer_demo.yaml`中修改相应的参数;
3. 运行`demo.py`;
-4. 出现界面,在Chinese input文本框中输入中文,按【回车键】开始实时翻译,或者按【REC】开始录音并开始实时翻译,遇到【。!?】结束整句,按【CLEAR】清空所有的输入和输出。
+4. 出现界面,在 Chinese input 文本框中输入中文,按【回车键】开始实时翻译,或者按【REC】开始录音并开始实时翻译,遇到【。!?】结束整句,按【CLEAR】清空所有的输入和输出。
### 常见问题
**Q:** 出现`_tkinter.TclError: couldn't recognize data in image file`错误
**A:** 升级`tkinter`,确保`tkinter >= 8.6`
-**Q:** 出现Chinese input文本框无法输入中文
+**Q:** 出现 Chinese input 文本框无法输入中文
**A:** 升级`tkinter`,确保`tkinter >= 8.6`
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/README_ai.md b/slm/examples/simultaneous_translation/stacl/demo/README_ai.md
similarity index 86%
rename from legacy/examples/simultaneous_translation/stacl/demo/README_ai.md
rename to slm/examples/simultaneous_translation/stacl/demo/README_ai.md
index 20ded3903b7b..cc04e0130850 100644
--- a/legacy/examples/simultaneous_translation/stacl/demo/README_ai.md
+++ b/slm/examples/simultaneous_translation/stacl/demo/README_ai.md
@@ -1,6 +1,6 @@
-# AI接入指南
+# AI 接入指南
### 1. 成为开发者
-- 1.1 参考[AI接入指南](https://ai.baidu.com/ai-doc/REFERENCE/Ck3dwjgn3) 完成第一步
+- 1.1 参考[AI 接入指南](https://ai.baidu.com/ai-doc/REFERENCE/Ck3dwjgn3) 完成第一步
### 2.创建应用
- 2.1 进入[控制台](https://console.bce.baidu.com/?fromai=1#/index/overview_v3) ,选择【语音技术】
@@ -36,7 +36,7 @@
### 4.获取密钥
-- 4.1 本项目主要用到AppID和API Key
+- 4.1 本项目主要用到 AppID 和 API Key
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/const.py b/slm/examples/simultaneous_translation/stacl/demo/const.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/const.py
rename to slm/examples/simultaneous_translation/stacl/demo/const.py
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/demo.py b/slm/examples/simultaneous_translation/stacl/demo/demo.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/demo.py
rename to slm/examples/simultaneous_translation/stacl/demo/demo.py
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/paddlenlp.png b/slm/examples/simultaneous_translation/stacl/demo/images/paddlenlp.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/paddlenlp.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/paddlenlp.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/speech_demo_show.gif b/slm/examples/simultaneous_translation/stacl/demo/images/speech_demo_show.gif
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/speech_demo_show.gif
rename to slm/examples/simultaneous_translation/stacl/demo/images/speech_demo_show.gif
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step1.png b/slm/examples/simultaneous_translation/stacl/demo/images/step1.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step1.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step1.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step2.png b/slm/examples/simultaneous_translation/stacl/demo/images/step2.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step2.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step2.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step3.png b/slm/examples/simultaneous_translation/stacl/demo/images/step3.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step3.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step3.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step4.png b/slm/examples/simultaneous_translation/stacl/demo/images/step4.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step4.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step4.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step5.png b/slm/examples/simultaneous_translation/stacl/demo/images/step5.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step5.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step5.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step6.png b/slm/examples/simultaneous_translation/stacl/demo/images/step6.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step6.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step6.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step7.png b/slm/examples/simultaneous_translation/stacl/demo/images/step7.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step7.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step7.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/step8.png b/slm/examples/simultaneous_translation/stacl/demo/images/step8.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/step8.png
rename to slm/examples/simultaneous_translation/stacl/demo/images/step8.png
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/images/text_demo_show.gif b/slm/examples/simultaneous_translation/stacl/demo/images/text_demo_show.gif
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/images/text_demo_show.gif
rename to slm/examples/simultaneous_translation/stacl/demo/images/text_demo_show.gif
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/model_demo.py b/slm/examples/simultaneous_translation/stacl/demo/model_demo.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/model_demo.py
rename to slm/examples/simultaneous_translation/stacl/demo/model_demo.py
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/requirements.txt b/slm/examples/simultaneous_translation/stacl/demo/requirements.txt
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/requirements.txt
rename to slm/examples/simultaneous_translation/stacl/demo/requirements.txt
diff --git a/legacy/examples/simultaneous_translation/stacl/demo/transformer_demo.yaml b/slm/examples/simultaneous_translation/stacl/demo/transformer_demo.yaml
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/demo/transformer_demo.yaml
rename to slm/examples/simultaneous_translation/stacl/demo/transformer_demo.yaml
diff --git a/legacy/examples/simultaneous_translation/stacl/images/STACL_architecture.png b/slm/examples/simultaneous_translation/stacl/images/STACL_architecture.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/images/STACL_architecture.png
rename to slm/examples/simultaneous_translation/stacl/images/STACL_architecture.png
diff --git a/legacy/examples/simultaneous_translation/stacl/images/example.png b/slm/examples/simultaneous_translation/stacl/images/example.png
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/images/example.png
rename to slm/examples/simultaneous_translation/stacl/images/example.png
diff --git a/legacy/examples/simultaneous_translation/stacl/model.py b/slm/examples/simultaneous_translation/stacl/model.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/model.py
rename to slm/examples/simultaneous_translation/stacl/model.py
diff --git a/legacy/examples/simultaneous_translation/stacl/predict.py b/slm/examples/simultaneous_translation/stacl/predict.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/predict.py
rename to slm/examples/simultaneous_translation/stacl/predict.py
diff --git a/legacy/examples/simultaneous_translation/stacl/reader.py b/slm/examples/simultaneous_translation/stacl/reader.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/reader.py
rename to slm/examples/simultaneous_translation/stacl/reader.py
diff --git a/legacy/examples/simultaneous_translation/stacl/requirements.txt b/slm/examples/simultaneous_translation/stacl/requirements.txt
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/requirements.txt
rename to slm/examples/simultaneous_translation/stacl/requirements.txt
diff --git a/legacy/examples/simultaneous_translation/stacl/train.py b/slm/examples/simultaneous_translation/stacl/train.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/train.py
rename to slm/examples/simultaneous_translation/stacl/train.py
diff --git a/legacy/examples/simultaneous_translation/stacl/utils/record.py b/slm/examples/simultaneous_translation/stacl/utils/record.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/utils/record.py
rename to slm/examples/simultaneous_translation/stacl/utils/record.py
diff --git a/legacy/examples/simultaneous_translation/stacl/utils/tokenizer.py b/slm/examples/simultaneous_translation/stacl/utils/tokenizer.py
similarity index 100%
rename from legacy/examples/simultaneous_translation/stacl/utils/tokenizer.py
rename to slm/examples/simultaneous_translation/stacl/utils/tokenizer.py
diff --git a/slm/examples/text_classification/README.md b/slm/examples/text_classification/README.md
new file mode 100644
index 000000000000..2595ac373907
--- /dev/null
+++ b/slm/examples/text_classification/README.md
@@ -0,0 +1,7 @@
+# 文本分类
+
+提供了文本分类任务示例,基于 ERNIE 3.0预训练模型。
+
+## Pretrained Model (PTMs)
+
+[Pretrained Models](./pretrained_models) 展示了如何使用以 ERNIE 3.0 为代表的预模型,在多分类、多标签、层次分类场景下,基于预训练模型微调、提示学习(小样本)、语义索引等三种不同方案进行文本分类。预训练模型文本分类打通数据标注-模型训练-模型调优-模型压缩-预测部署全流程,旨在解决细分场景应用的痛点和难点,快速实现文本分类产品落地。
diff --git a/legacy/examples/text_classification/pretrained_models/README.md b/slm/examples/text_classification/pretrained_models/README.md
similarity index 100%
rename from legacy/examples/text_classification/pretrained_models/README.md
rename to slm/examples/text_classification/pretrained_models/README.md
diff --git a/legacy/examples/text_correction/ernie-csc/README.md b/slm/examples/text_correction/ernie-csc/README.md
similarity index 70%
rename from legacy/examples/text_correction/ernie-csc/README.md
rename to slm/examples/text_correction/ernie-csc/README.md
index 4ff3a8da1441..ea834f24a5ee 100644
--- a/legacy/examples/text_correction/ernie-csc/README.md
+++ b/slm/examples/text_correction/ernie-csc/README.md
@@ -2,7 +2,7 @@
## 简介
-中文文本纠错任务是一项NLP基础任务,其输入是一个可能含有语法错误的中文句子,输出是一个正确的中文句子。语法错误类型很多,有多字、少字、错别字等,目前最常见的错误类型是`错别字`。大部分研究工作围绕错别字这一类型进行研究。本文实现了百度在ACL 2021上提出结合拼音特征的Softmask策略的中文错别字纠错的下游任务网络,并提供预训练模型,模型结构如下:
+中文文本纠错任务是一项 NLP 基础任务,其输入是一个可能含有语法错误的中文句子,输出是一个正确的中文句子。语法错误类型很多,有多字、少字、错别字等,目前最常见的错误类型是`错别字`。大部分研究工作围绕错别字这一类型进行研究。本文实现了百度在 ACL 2021上提出结合拼音特征的 Softmask 策略的中文错别字纠错的下游任务网络,并提供预训练模型,模型结构如下:

@@ -23,7 +23,7 @@
└── utils.py # 通用函数工具
```
-* 注:论文中暂未开源融合字音特征的预训练模型参数(即MLM-phonetics),所以本文提供的纠错模型是在ERNIE-1.0的参数上进行Finetune,纠错模型结构与论文保持一致。
+* 注:论文中暂未开源融合字音特征的预训练模型参数(即 MLM-phonetics),所以本文提供的纠错模型是在 ERNIE-1.0的参数上进行 Finetune,纠错模型结构与论文保持一致。
## 安装依赖项
```
@@ -36,25 +36,25 @@ pip install -r requirements.txt
- `model_name_or_path` 目前支持的预训练模型有:"ernie-1.0-base-zh"。
- `max_seq_length` 表示最大句子长度,超过该长度的部分将被切分成下一个样本。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔步数。
- `save_steps` 表示模型保存及评估间隔步数。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `seed` 表示随机数种子。
-- `weight_decay` 表示AdamW的权重衰减系数。
-- `warmup_proportion` 表示学习率warmup系数。
+- `weight_decay` 表示 AdamW 的权重衰减系数。
+- `warmup_proportion` 表示学习率 warmup 系数。
- `pinyin_vocab_file_path` 拼音字表路径。默认为当前目录下的`pinyin_vocab.txt`文件。
-- `extra_train_ds_dir` 额外纠错训练集目录。用户可在该目录下提供文件名以`txt`为后缀的纠错数据集文件,以增大训练样本。默认为None。
+- `extra_train_ds_dir` 额外纠错训练集目录。用户可在该目录下提供文件名以`txt`为后缀的纠错数据集文件,以增大训练样本。默认为 None。
### 训练数据
-该模型在SIGHAN简体版数据集以及[Automatic Corpus Generation生成的中文纠错数据集](https://github.com/wdimmy/Automatic-Corpus-Generation/blob/master/corpus/train.sgml)上进行Finetune训练。PaddleNLP已经集成SIGHAN简体版数据集,以下将介绍如何使用Automatic Corpus Generation生成的中文纠错数据集。
+该模型在 SIGHAN 简体版数据集以及[Automatic Corpus Generation 生成的中文纠错数据集](https://github.com/wdimmy/Automatic-Corpus-Generation/blob/master/corpus/train.sgml)上进行 Finetune 训练。PaddleNLP 已经集成 SIGHAN 简体版数据集,以下将介绍如何使用 Automatic Corpus Generation 生成的中文纠错数据集。
#### 下载数据集
-Automatic Corpus Generation生成的中文纠错数据集比较大,下载时间比较长,请耐心等候。运行以下命令完成数据集下载:
+Automatic Corpus Generation 生成的中文纠错数据集比较大,下载时间比较长,请耐心等候。运行以下命令完成数据集下载:
```
python download.py --data_dir ./extra_train_ds/ --url https://github.com/wdimmy/Automatic-Corpus-Generation/raw/master/corpus/train.sgml
@@ -62,7 +62,7 @@ python download.py --data_dir ./extra_train_ds/ --url https://github.com/wdimmy/
#### 预处理数据集
-训练脚本要求训练集文件内容以句子对形式呈现,这里提供一个转换脚本,将Automatic Corpus Generation提供的XML文件转换成句子对形式的文件,运行以下命令:
+训练脚本要求训练集文件内容以句子对形式呈现,这里提供一个转换脚本,将 Automatic Corpus Generation 提供的 XML 文件转换成句子对形式的文件,运行以下命令:
```
python change_sgml_to_txt.py -i extra_train_ds/train.sgml -o extra_train_ds/train.txt
@@ -82,15 +82,15 @@ python -m paddle.distributed.launch --gpus "0,1" train.py --batch_size 32 --log
## 模型预测
-### 预测SIGHAN测试集
+### 预测 SIGHAN 测试集
-SIGHAN 13,SIGHAN 14,SIGHAN 15是目前中文错别字纠错任务常用的benchmark数据。由于SIGHAN官方提供的是繁体字数据集,PaddleNLP将提供简体版本的SIGHAN测试数据。以下运行SIGHAN预测脚本:
+SIGHAN 13,SIGHAN 14,SIGHAN 15是目前中文错别字纠错任务常用的 benchmark 数据。由于 SIGHAN 官方提供的是繁体字数据集,PaddleNLP 将提供简体版本的 SIGHAN 测试数据。以下运行 SIGHAN 预测脚本:
```shell
sh run_sighan_predict.sh
```
-该脚本会下载SIGHAN数据集,加载checkpoint的模型参数运行模型,输出SIGHAN测试集的预测结果到predict_sighan文件,并输出预测效果。
+该脚本会下载 SIGHAN 数据集,加载 checkpoint 的模型参数运行模型,输出 SIGHAN 测试集的预测结果到 predict_sighan 文件,并输出预测效果。
**预测效果**
@@ -121,7 +121,7 @@ python export_model.py --params_path checkpoints/best_model.pdparams --output_pa
#### 预测
-导出模型之后,可以用于预测部署,predict.py文件提供了python预测部署示例。运行方式:
+导出模型之后,可以用于预测部署,predict.py 文件提供了 python 预测部署示例。运行方式:
```python
python predict.py --model_file infer_model/static_graph_params.pdmodel --params_file infer_model/static_graph_params.pdiparams
@@ -135,8 +135,8 @@ Source: 人生就是如此,经过磨练才能让自己更加拙壮,才能使
Target: 人生就是如此,经过磨练才能让自己更加茁壮,才能使自己更加乐观。
```
-### Taskflow一键预测
-可以使用PaddleNLP提供的Taskflow工具来对输入的文本进行一键纠错,具体使用方法如下:
+### Taskflow 一键预测
+可以使用 PaddleNLP 提供的 Taskflow 工具来对输入的文本进行一键纠错,具体使用方法如下:
```python
from paddlenlp import Taskflow
diff --git a/legacy/examples/text_correction/ernie-csc/change_sgml_to_txt.py b/slm/examples/text_correction/ernie-csc/change_sgml_to_txt.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/change_sgml_to_txt.py
rename to slm/examples/text_correction/ernie-csc/change_sgml_to_txt.py
diff --git a/legacy/examples/text_correction/ernie-csc/download.py b/slm/examples/text_correction/ernie-csc/download.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/download.py
rename to slm/examples/text_correction/ernie-csc/download.py
diff --git a/legacy/examples/text_correction/ernie-csc/export_model.py b/slm/examples/text_correction/ernie-csc/export_model.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/export_model.py
rename to slm/examples/text_correction/ernie-csc/export_model.py
diff --git a/legacy/examples/text_correction/ernie-csc/model.py b/slm/examples/text_correction/ernie-csc/model.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/model.py
rename to slm/examples/text_correction/ernie-csc/model.py
diff --git a/legacy/examples/text_correction/ernie-csc/pinyin_vocab.txt b/slm/examples/text_correction/ernie-csc/pinyin_vocab.txt
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/pinyin_vocab.txt
rename to slm/examples/text_correction/ernie-csc/pinyin_vocab.txt
diff --git a/legacy/examples/text_correction/ernie-csc/predict.py b/slm/examples/text_correction/ernie-csc/predict.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/predict.py
rename to slm/examples/text_correction/ernie-csc/predict.py
diff --git a/legacy/examples/text_correction/ernie-csc/predict_sighan.py b/slm/examples/text_correction/ernie-csc/predict_sighan.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/predict_sighan.py
rename to slm/examples/text_correction/ernie-csc/predict_sighan.py
diff --git a/legacy/examples/text_correction/ernie-csc/requirements.txt b/slm/examples/text_correction/ernie-csc/requirements.txt
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/requirements.txt
rename to slm/examples/text_correction/ernie-csc/requirements.txt
diff --git a/legacy/examples/text_correction/ernie-csc/run_sighan_predict.sh b/slm/examples/text_correction/ernie-csc/run_sighan_predict.sh
similarity index 56%
rename from legacy/examples/text_correction/ernie-csc/run_sighan_predict.sh
rename to slm/examples/text_correction/ernie-csc/run_sighan_predict.sh
index ef33a20b2947..124156cfbad8 100644
--- a/legacy/examples/text_correction/ernie-csc/run_sighan_predict.sh
+++ b/slm/examples/text_correction/ernie-csc/run_sighan_predict.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
export CUDA_VISIBLE_DEVICES=0
model_name_or_path=ernie-1.0
diff --git a/legacy/examples/text_correction/ernie-csc/sighan_evaluate.py b/slm/examples/text_correction/ernie-csc/sighan_evaluate.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/sighan_evaluate.py
rename to slm/examples/text_correction/ernie-csc/sighan_evaluate.py
diff --git a/legacy/examples/text_correction/ernie-csc/train.py b/slm/examples/text_correction/ernie-csc/train.py
similarity index 100%
rename from legacy/examples/text_correction/ernie-csc/train.py
rename to slm/examples/text_correction/ernie-csc/train.py
diff --git a/legacy/examples/text_correction/ernie-csc/utils.py b/slm/examples/text_correction/ernie-csc/utils.py
similarity index 99%
rename from legacy/examples/text_correction/ernie-csc/utils.py
rename to slm/examples/text_correction/ernie-csc/utils.py
index 83273deff34b..b24fd5c5166f 100644
--- a/legacy/examples/text_correction/ernie-csc/utils.py
+++ b/slm/examples/text_correction/ernie-csc/utils.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from pypinyin import lazy_pinyin, Style
import paddle
+from pypinyin import Style, lazy_pinyin
from paddlenlp.transformers import is_chinese_char
diff --git a/legacy/examples/text_generation/couplet/README.md b/slm/examples/text_generation/couplet/README.md
similarity index 68%
rename from legacy/examples/text_generation/couplet/README.md
rename to slm/examples/text_generation/couplet/README.md
index 0be2fe75cf42..14ba9a3480cb 100644
--- a/legacy/examples/text_generation/couplet/README.md
+++ b/slm/examples/text_generation/couplet/README.md
@@ -1,11 +1,11 @@
-# 使用Seq2Seq模型完成自动对联
+# 使用 Seq2Seq 模型完成自动对联
## 简介
-Sequence to Sequence (Seq2Seq),使用编码器-解码器(Encoder-Decoder)结构,用编码器将源序列编码成vector,再用解码器将该vector解码为目标序列。Seq2Seq 广泛应用于机器翻译,自动对话机器人,文档摘要自动生成,图片描述自动生成等任务中。
+Sequence to Sequence (Seq2Seq),使用编码器-解码器(Encoder-Decoder)结构,用编码器将源序列编码成 vector,再用解码器将该 vector 解码为目标序列。Seq2Seq 广泛应用于机器翻译,自动对话机器人,文档摘要自动生成,图片描述自动生成等任务中。
-本目录包含Seq2Seq的一个经典样例:自动对联生成,带attention机制的文本生成模型。
+本目录包含 Seq2Seq 的一个经典样例:自动对联生成,带 attention 机制的文本生成模型。
上联:未出南阳天下论 下联:先登北斗汉中书
@@ -20,4 +20,3 @@ Sequence to Sequence (Seq2Seq),使用编码器-解码器(Encoder-Decoder)
我们的数据集采用了开源对联数据集[couplet-clean-dataset](https://github.com/v-zich/couplet-clean-dataset),地址:https://github.com/v-zich/couplet-clean-dataset ,该数据集过滤了[couplet-dataset](https://github.com/wb14123/couplet-dataset)(地址:https://github.com/wb14123/couplet-dataset )中的低俗、敏感内容。
使用请[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_generation/couplet)
-
diff --git a/legacy/examples/text_generation/ctrl/README.md b/slm/examples/text_generation/ctrl/README.md
similarity index 82%
rename from legacy/examples/text_generation/ctrl/README.md
rename to slm/examples/text_generation/ctrl/README.md
index d7f3e5291049..d1716c594168 100644
--- a/legacy/examples/text_generation/ctrl/README.md
+++ b/slm/examples/text_generation/ctrl/README.md
@@ -1,7 +1,7 @@
# [CTRL: A Conditional Transformer Language Model for Controllable Generation](https://arxiv.org/pdf/1909.05858.pdf)
## 摘要
-大规模语言模型显示出很有前景的文本生成能力,但用户无法轻松控制生成文本的特定方面。我们发布了CTRL,一个包含 16.3 亿个参数的条件转换器语言模型,经过训练以调节控制样式、内容和特定任务行为的控制代码。 控制代码源自与原始文本自然共同出现的结构,保留了无监督学习的优势,同时对文本生成提供了更明确的控制。 这些代码还允许CTRL预测训练数据的哪些部分最有可能给定序列。 这提供了一种通过基于模型的来源归因分析大量数据的潜在方法。 我们在 https://github.com/salesforce/ctrl 上发布了多个全尺寸、预训练版本的CTRL。
+大规模语言模型显示出很有前景的文本生成能力,但用户无法轻松控制生成文本的特定方面。我们发布了 CTRL,一个包含 16.3 亿个参数的条件转换器语言模型,经过训练以调节控制样式、内容和特定任务行为的控制代码。 控制代码源自与原始文本自然共同出现的结构,保留了无监督学习的优势,同时对文本生成提供了更明确的控制。 这些代码还允许 CTRL 预测训练数据的哪些部分最有可能给定序列。 这提供了一种通过基于模型的来源归因分析大量数据的潜在方法。 我们在 https://github.com/salesforce/ctrl 上发布了多个全尺寸、预训练版本的 CTRL。
## 生成结果样例
diff --git a/legacy/examples/text_generation/ernie-gen b/slm/examples/text_generation/ernie-gen
similarity index 100%
rename from legacy/examples/text_generation/ernie-gen
rename to slm/examples/text_generation/ernie-gen
diff --git a/legacy/examples/text_generation/opt/README.md b/slm/examples/text_generation/opt/README.md
similarity index 84%
rename from legacy/examples/text_generation/opt/README.md
rename to slm/examples/text_generation/opt/README.md
index 506607284944..f59c3321f278 100644
--- a/legacy/examples/text_generation/opt/README.md
+++ b/slm/examples/text_generation/opt/README.md
@@ -2,7 +2,7 @@
## 摘要
-Meta AI 实验室高调宣布,将开放自己的 OPT(Open Pretrained Transformer,预训练变换模型)预训练模型,并贡献出所有代码,此模型对标GPT3,从模型性能、多个下有任务以及小样本中都取得了与GPT-3可比的成绩,PaddleNLP也是及时接入此模型,各位开发者只需要简单的调用即可使用此大模型。
+Meta AI 实验室高调宣布,将开放自己的 OPT(Open Pretrained Transformer,预训练变换模型)预训练模型,并贡献出所有代码,此模型对标 GPT3,从模型性能、多个下有任务以及小样本中都取得了与 GPT-3可比的成绩,PaddleNLP 也是及时接入此模型,各位开发者只需要简单的调用即可使用此大模型。
## 文本生成测试
```sh
diff --git a/legacy/examples/text_generation/opt/demo.py b/slm/examples/text_generation/opt/demo.py
similarity index 100%
rename from legacy/examples/text_generation/opt/demo.py
rename to slm/examples/text_generation/opt/demo.py
diff --git a/legacy/examples/text_generation/reformer/README.md b/slm/examples/text_generation/reformer/README.md
similarity index 100%
rename from legacy/examples/text_generation/reformer/README.md
rename to slm/examples/text_generation/reformer/README.md
diff --git a/legacy/examples/text_generation/unimo-text/README.md b/slm/examples/text_generation/unimo-text/README.md
similarity index 72%
rename from legacy/examples/text_generation/unimo-text/README.md
rename to slm/examples/text_generation/unimo-text/README.md
index 135d9957dcc0..bd146eb0010a 100644
--- a/legacy/examples/text_generation/unimo-text/README.md
+++ b/slm/examples/text_generation/unimo-text/README.md
@@ -2,22 +2,22 @@
## 比赛简介
-自然语言生成旨在让机器能够像人一样使用自然语言进行表达和交互,它是人工智能领域重要的前沿课题,也是全球热点技术AIGC(AI Generated Content,人工智能内容生成)的核心问题之一。
+自然语言生成旨在让机器能够像人一样使用自然语言进行表达和交互,它是人工智能领域重要的前沿课题,也是全球热点技术 AIGC(AI Generated Content,人工智能内容生成)的核心问题之一。
随着神经网络生成模型特别是预训练语言模型的迅速发展,机器生成文本的可读性和流畅性不断提升。然而,自动生成的文本中依然经常出现不符合原文或背景的错误事实描述,这种生成的事实一致性问题是自然语言生成进行落地应用的主要障碍之一,并逐渐受到研究学者的关注。鉴于当前国内外关于事实一致性的生成评测比赛十分匮乏,为了促进自然语言生成的技术发展和实际应用,[千言](https://www.luge.ai/#/)组织了面向事实一致性的生成评测比赛。
-第一届面向事实一致性的生成评测比赛,一共吸引了577名高校、企业的参赛者,其中有57支参赛队提交了有效的正式赛结果,30支参赛队自动评测指标超过基线系统,在排名Top10的队伍中,收到9份参赛系统总结报告。在正式赛的人工评估过程中,我们进一步确认了事实一致性问题的广泛存在性,并且通过与参赛队伍的深入交流,也积累了更多对于事实一致性自动和人工评测的宝贵经验。
+第一届面向事实一致性的生成评测比赛,一共吸引了577名高校、企业的参赛者,其中有57支参赛队提交了有效的正式赛结果,30支参赛队自动评测指标超过基线系统,在排名 Top10的队伍中,收到9份参赛系统总结报告。在正式赛的人工评估过程中,我们进一步确认了事实一致性问题的广泛存在性,并且通过与参赛队伍的深入交流,也积累了更多对于事实一致性自动和人工评测的宝贵经验。
2023年,千言举办[第二届面向事实一致性的生成评测比赛](https://aistudio.baidu.com/aistudio/competition/detail/726/0/introduction),在数据集、自动评测指标等方面均有升级。在此比赛中,将提供三个对事实一致性有较高要求的生成任务,包括文案生成、摘要生成和对话生成。同时,在系统评价中,将结合文本流畅性和事实一致性两项指标综合评估参赛生成系统的水平,同时进一步提升事实一致性评测指标的先进性和丰富性。通过这样的任务设定和评价方式,此评测将有助于研究者和开发者更多关注自然语言生成的事实一致性难题,并为大家提供学术交流平台,从而进一步提升自然语言生成的研究水平,推动相关技术的应用发展。
本比赛得到中国中文信息学会自然语言生成与智能写作专业委员会(筹)支持,将在2023年7月16日第二届中国自然语言生成与智能写作大会(NLGIW 2023)召开评测研讨会,并在大会上对获奖团队颁奖。
## 模型简介
-本次比赛提供的基线系统,基于百度提出的ERNIE-UNIMO统一模态预训练框架。在本次比赛的三个文本生成任务中,我们基于本基线使用的模型是UNIMO-text,是基于[ERNIE-UNIMO](https://arxiv.org/pdf/2012.15409.pdf)框架在文本数据上预训练得到模型。
+本次比赛提供的基线系统,基于百度提出的 ERNIE-UNIMO 统一模态预训练框架。在本次比赛的三个文本生成任务中,我们基于本基线使用的模型是 UNIMO-text,是基于[ERNIE-UNIMO](https://arxiv.org/pdf/2012.15409.pdf)框架在文本数据上预训练得到模型。
## 快速开始
-本基线基于 **PaddleNLP 2.0.8** 版本,该版本包含了基线使用的最新版UNIMO-text模型以及升级后的生成API。更多详细升级信息请查看[Release Note](https://github.com/PaddlePaddle/PaddleNLP/releases/tag/v2.0.8)。请选手们**升级PaddleNLP后使用**。
+本基线基于 **PaddleNLP 2.0.8** 版本,该版本包含了基线使用的最新版 UNIMO-text 模型以及升级后的生成 API。更多详细升级信息请查看[Release Note](https://github.com/PaddlePaddle/PaddleNLP/releases/tag/v2.0.8)。请选手们**升级 PaddleNLP 后使用**。
### 数据准备
@@ -27,7 +27,7 @@
- 摘要生成是为输入文档生成简洁且包含关键信息的简洁文本;
- 问题生成则是根据给定段落以及答案生成适合的问题。
-为了方便用户快速使用基线,PaddleNLP Dataset API内置了数据集,一键即可完成数据集加载,示例代码如下:
+为了方便用户快速使用基线,PaddleNLP Dataset API 内置了数据集,一键即可完成数据集加载,示例代码如下:
```python
from paddlenlp.datasets import load_dataset
@@ -48,7 +48,7 @@ train_ds, dev_ds = load_dataset('dureader_qg', splits=('train', 'dev'))
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证。也可以使用./scripts目录下面的训练脚本分别启动三个任务的训练。
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证。也可以使用./scripts 目录下面的训练脚本分别启动三个任务的训练。
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -72,13 +72,13 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log run_gen.py \
```
关键参数释义如下:
-- `gpus` 指示了训练所用的GPU卡号。
+- `gpus` 指示了训练所用的 GPU 卡号。
- `dataset_name` 数据集名称,`dureader_qg`、`advertisegen`和`lcsts_new`分别对应问题生成、文案生成和摘要生成三个任务。
- `train_file` 本地训练数据地址,数据格式必须与`dataset_name`所指数据集格式相同。
- `predict_file` 本地测试数据地址,数据格式必须与`dataset_name`所指数据集格式相同。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型,或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unimo-text-1.0 |
| unimo-text-1.0-large |
@@ -89,16 +89,16 @@ python -m paddle.distributed.launch --gpus "0" --log_dir ./log run_gen.py \
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_seq_len` 模型输入序列的最大长度。
- `max_target_len` 模型训练时标签的最大长度。
- `min_dec_len` 模型生成序列的最小长度。
- `max_dec_len` 模型生成序列的最大长度。
- `do_train` 是否进行训练。
- `do_predict` 是否进行预测,在验证集上会自动评估。
-- `device` 表示使用的设备,从gpu和cpu中选择。
+- `device` 表示使用的设备,从 gpu 和 cpu 中选择。
更多参数详情和参数的默认值请参考`args.py`。
@@ -137,7 +137,7 @@ python run_gen.py \
程序运行结束后会将预测结果保存在`output_path`中。将预测结果准备成比赛官网要求的格式,提交评估即可得评估结果。
-Finetuned baseline的模型在各任务验证集上有如下结果(指标为BLEU-4):
+Finetuned baseline 的模型在各任务验证集上有如下结果(指标为 BLEU-4):
| model_name | LCSTS_new | DuLeMon | AdvertiseGen |
| :-----------------------------: | :---: | :-----------: | :-------------------: |
diff --git a/legacy/examples/text_generation/unimo-text/gen_utils.py b/slm/examples/text_generation/unimo-text/gen_utils.py
similarity index 91%
rename from legacy/examples/text_generation/unimo-text/gen_utils.py
rename to slm/examples/text_generation/unimo-text/gen_utils.py
index b69f1830754d..f8ece5f86f49 100644
--- a/legacy/examples/text_generation/unimo-text/gen_utils.py
+++ b/slm/examples/text_generation/unimo-text/gen_utils.py
@@ -1,11 +1,25 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import random
from functools import partial
import numpy as np
-
import paddle
import paddle.distributed as dist
-from paddle.io import DataLoader, DistributedBatchSampler, BatchSampler
+from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
+
from paddlenlp.data import Pad
diff --git a/legacy/examples/text_generation/unimo-text/run_gen.py b/slm/examples/text_generation/unimo-text/run_gen.py
similarity index 100%
rename from legacy/examples/text_generation/unimo-text/run_gen.py
rename to slm/examples/text_generation/unimo-text/run_gen.py
diff --git a/legacy/examples/text_generation/unimo-text/scripts/lcsts_train.sh b/slm/examples/text_generation/unimo-text/scripts/lcsts_train.sh
similarity index 100%
rename from legacy/examples/text_generation/unimo-text/scripts/lcsts_train.sh
rename to slm/examples/text_generation/unimo-text/scripts/lcsts_train.sh
diff --git a/legacy/examples/text_generation/unimo-text/scripts/qg_train.sh b/slm/examples/text_generation/unimo-text/scripts/qg_train.sh
similarity index 100%
rename from legacy/examples/text_generation/unimo-text/scripts/qg_train.sh
rename to slm/examples/text_generation/unimo-text/scripts/qg_train.sh
diff --git a/legacy/examples/text_generation/unimo-text/scripts/table_train.sh b/slm/examples/text_generation/unimo-text/scripts/table_train.sh
similarity index 100%
rename from legacy/examples/text_generation/unimo-text/scripts/table_train.sh
rename to slm/examples/text_generation/unimo-text/scripts/table_train.sh
diff --git a/slm/examples/text_generation/vae-seq2seq/README.md b/slm/examples/text_generation/vae-seq2seq/README.md
new file mode 100644
index 000000000000..32382e6cc7d4
--- /dev/null
+++ b/slm/examples/text_generation/vae-seq2seq/README.md
@@ -0,0 +1,30 @@
+# Variational Autoencoder (VAE) for Text Generation
+
+## 简介
+
+本目录下此范例模型的实现,旨在展示如何用 Paddle 构建用于文本生成的 VAE 示例,其中 LSTM 作为编码器和解码器。分别对 PTB 数据集和 Yahoo Answer(采样100k)数据集进行训练。
+
+关于 VAE 的详细介绍参照: [(Bowman et al., 2015) Generating Sentences from a Continuous Space](https://arxiv.org/pdf/1511.06349.pdf)
+
+## 数据介绍
+
+本教程使用了两个文本数据集:
+
+PTB 数据集由华尔街日报的文章组成,包含929k 个训练 tokens,词汇量为10k。下载地址为: [PTB](https://dataset.bj.bcebos.com/imikolov%2Fsimple-examples.tgz)。
+
+Yahoo 数据集来自[(Yang et al., 2017) Improved Variational Autoencoders for Text Modeling using Dilated Convolutions](https://arxiv.org/pdf/1702.08139.pdf),该数据集从原始 Yahoo Answer 数据中采样100k 个文档,数据集的平均文档长度为78,词汇量为200k。下载地址为:[YahooAnswer100k](https://bj.bcebos.com/paddlenlp/datasets/yahoo-answer-100k.tar.gz),运行本例程序后,数据集会自动下载到`~/.paddlenlp/datasets/YahooAnswer100k`目录下。
+
+
+## 生成样例
+
+shareholders were spent about N shares to spend $ N million to ual sell this trust stock last week
+
+new york stock exchange composite trading trading outnumbered closed at $ N a share down N cents
+
+the company cited pressure to pursue up existing facilities in the third quarter was for and four N million briefly stocks for so-called unusual liability
+
+people had down out the kind of and much why your relationship are anyway
+
+there are a historic investment giant chips which ran the benefit the attempting to original maker
+
+使用请[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_generation/vae-seq2seq)
diff --git a/legacy/examples/text_graph/erniesage/README.md b/slm/examples/text_graph/erniesage/README.md
similarity index 60%
rename from legacy/examples/text_graph/erniesage/README.md
rename to slm/examples/text_graph/erniesage/README.md
index a25780be0586..ca88b73e2497 100644
--- a/legacy/examples/text_graph/erniesage/README.md
+++ b/slm/examples/text_graph/erniesage/README.md
@@ -1,21 +1,21 @@
-# 基于PaddleNLP的ErnieSage模型介绍
+# 基于 PaddleNLP 的 ErnieSage 模型介绍
## 背景介绍
-在很多工业应用中,往往出现如下图所示的一种特殊的图:Text Graph。顾名思义,图的节点属性由文本构成,而边的构建提供了结构信息。如搜索场景下的Text Graph,节点可由搜索词、网页标题、网页正文来表达,用户反馈和超链信息则可构成边关系。
+在很多工业应用中,往往出现如下图所示的一种特殊的图:Text Graph。顾名思义,图的节点属性由文本构成,而边的构建提供了结构信息。如搜索场景下的 Text Graph,节点可由搜索词、网页标题、网页正文来表达,用户反馈和超链信息则可构成边关系。
-**ErnieSage** 由飞桨PGL团队提出,是ERNIE SAmple aggreGatE的简称,该模型可以同时建模文本语义与图结构信息,有效提升 Text Graph 的应用效果。其中 [**ERNIE**](https://github.com/PaddlePaddle/ERNIE) 是百度推出的基于知识增强的持续学习语义理解框架。
+**ErnieSage** 由飞桨 PGL 团队提出,是 ERNIE SAmple aggreGatE 的简称,该模型可以同时建模文本语义与图结构信息,有效提升 Text Graph 的应用效果。其中 [**ERNIE**](https://github.com/PaddlePaddle/ERNIE) 是百度推出的基于知识增强的持续学习语义理解框架。
**ErnieSage** 是 ERNIE 与 GraphSAGE 碰撞的结果,是 ERNIE SAmple aggreGatE 的简称,它的结构如下图所示,主要思想是通过 ERNIE 作为聚合函数(Aggregators),建模自身节点和邻居节点的语义与结构关系。ErnieSage 对于文本的建模是构建在邻居聚合的阶段,中心节点文本会与所有邻居节点文本进行拼接;然后通过预训练的 ERNIE 模型进行消息汇聚,捕捉中心节点以及邻居节点之间的相互关系;最后使用 ErnieSage 搭配独特的邻居互相看不见的 Attention Mask 和独立的 Position Embedding 体系,就可以轻松构建 TextGraph 中句子之间以及词之间的关系。
-使用ID特征的GraphSAGE只能够建模图的结构信息,而单独的ERNIE只能处理文本信息。通过飞桨PGL搭建的图与文本的桥梁,**ErnieSage**能够很简单的把GraphSAGE以及ERNIE的优点结合一起。以下面TextGraph的场景,**ErnieSage**的效果能够比单独的ERNIE以及GraphSAGE模型都要好。
+使用 ID 特征的 GraphSAGE 只能够建模图的结构信息,而单独的 ERNIE 只能处理文本信息。通过飞桨 PGL 搭建的图与文本的桥梁,**ErnieSage**能够很简单的把 GraphSAGE 以及 ERNIE 的优点结合一起。以下面 TextGraph 的场景,**ErnieSage**的效果能够比单独的 ERNIE 以及 GraphSAGE 模型都要好。
-**ErnieSage**可以很轻松地在基于PaddleNLP构建基于Ernie的图神经网络,目前PaddleNLP提供了V2版本的ErnieSage模型:
+**ErnieSage**可以很轻松地在基于 PaddleNLP 构建基于 Ernie 的图神经网络,目前 PaddleNLP 提供了 V2版本的 ErnieSage 模型:
-- **ErnieSage V2**: ERNIE 作用在text graph的边上;
+- **ErnieSage V2**: ERNIE 作用在 text graph 的边上;
@@ -25,14 +25,14 @@
安装命令 `pip install pgl\>=2.1`
## 数据准备
-示例数据```data.txt```中使用了NLPCC2016-DBQA的部分数据,格式为每行"query \t answer"。
+示例数据 ```data.txt```中使用了 NLPCC2016-DBQA 的部分数据,格式为每行"query \t answer"。
```text
NLPCC2016-DBQA 是由国际自然语言处理和中文计算会议 NLPCC 于 2016 年举办的评测任务,其目标是从候选中找到合适的文档作为问题的答案。[链接: http://tcci.ccf.org.cn/conference/2016/dldoc/evagline2.pdf]
```
## 如何运行
-我们采用了[PaddlePaddle Fleet](https://github.com/PaddlePaddle/Fleet)作为我们的分布式训练框架,在```config/*.yaml```中,目前支持的[ERNIE](https://github.com/PaddlePaddle/ERNIE)预训练语义模型包括**ernie**以及**ernie_tiny**,通过config/erniesage_link_prediction.yaml中的ernie_name指定。
+我们采用了[PaddlePaddle Fleet](https://github.com/PaddlePaddle/Fleet)作为我们的分布式训练框架,在 ```config/*.yaml```中,目前支持的[ERNIE](https://github.com/PaddlePaddle/ERNIE)预训练语义模型包括**ernie**以及**ernie_tiny**,通过 config/erniesage_link_prediction.yaml 中的 ernie_name 指定。
```sh
@@ -48,12 +48,12 @@ python -m paddle.distributed.launch --gpus "0" link_prediction.py --conf ./confi
- epochs: 训练的轮数
- graph_data: 训练模型时用到的图结构数据,使用“text1 \t text"格式。
-- train_data: 训练时的边,与graph_data格式相同,一般可以直接用graph_data。
-- graph_work_path: 临时存储graph数据中间文件的目录。
+- train_data: 训练时的边,与 graph_data 格式相同,一般可以直接用 graph_data。
+- graph_work_path: 临时存储 graph 数据中间文件的目录。
- samples: 采样邻居数
-- model_type: 模型类型,包括ErnieSageV2。
+- model_type: 模型类型,包括 ErnieSageV2。
- ernie_name: 热启模型类型,支持“ernie”和"ernie_tiny",后者速度更快,指定该参数后会自动从服务器下载预训练模型文件。
- num_layers: 图神经网络层数。
- hidden_size: 隐藏层大小。
-- batch_size: 训练时的batchsize。
-- infer_batch_size: 预测时batchsize。
+- batch_size: 训练时的 batchsize。
+- infer_batch_size: 预测时 batchsize。
diff --git a/legacy/examples/text_graph/erniesage/config/erniesage_link_prediction.yaml b/slm/examples/text_graph/erniesage/config/erniesage_link_prediction.yaml
similarity index 100%
rename from legacy/examples/text_graph/erniesage/config/erniesage_link_prediction.yaml
rename to slm/examples/text_graph/erniesage/config/erniesage_link_prediction.yaml
diff --git a/legacy/examples/text_graph/erniesage/data/__init__.py b/slm/examples/text_graph/erniesage/data/__init__.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/data/__init__.py
rename to slm/examples/text_graph/erniesage/data/__init__.py
diff --git a/legacy/examples/text_graph/erniesage/data/dataset.py b/slm/examples/text_graph/erniesage/data/dataset.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/data/dataset.py
rename to slm/examples/text_graph/erniesage/data/dataset.py
diff --git a/legacy/examples/text_graph/erniesage/data/graph_reader.py b/slm/examples/text_graph/erniesage/data/graph_reader.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/data/graph_reader.py
rename to slm/examples/text_graph/erniesage/data/graph_reader.py
diff --git a/legacy/examples/text_graph/erniesage/example_data/graph_data.txt b/slm/examples/text_graph/erniesage/example_data/graph_data.txt
similarity index 100%
rename from legacy/examples/text_graph/erniesage/example_data/graph_data.txt
rename to slm/examples/text_graph/erniesage/example_data/graph_data.txt
diff --git a/legacy/examples/text_graph/erniesage/example_data/train_data.txt b/slm/examples/text_graph/erniesage/example_data/train_data.txt
similarity index 100%
rename from legacy/examples/text_graph/erniesage/example_data/train_data.txt
rename to slm/examples/text_graph/erniesage/example_data/train_data.txt
diff --git a/legacy/examples/text_graph/erniesage/link_prediction.py b/slm/examples/text_graph/erniesage/link_prediction.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/link_prediction.py
rename to slm/examples/text_graph/erniesage/link_prediction.py
diff --git a/legacy/examples/text_graph/erniesage/models/__init__.py b/slm/examples/text_graph/erniesage/models/__init__.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/models/__init__.py
rename to slm/examples/text_graph/erniesage/models/__init__.py
diff --git a/legacy/examples/text_graph/erniesage/models/conv.py b/slm/examples/text_graph/erniesage/models/conv.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/models/conv.py
rename to slm/examples/text_graph/erniesage/models/conv.py
diff --git a/legacy/examples/text_graph/erniesage/models/encoder.py b/slm/examples/text_graph/erniesage/models/encoder.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/models/encoder.py
rename to slm/examples/text_graph/erniesage/models/encoder.py
diff --git a/legacy/examples/text_graph/erniesage/models/loss.py b/slm/examples/text_graph/erniesage/models/loss.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/models/loss.py
rename to slm/examples/text_graph/erniesage/models/loss.py
diff --git a/legacy/examples/text_graph/erniesage/models/model.py b/slm/examples/text_graph/erniesage/models/model.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/models/model.py
rename to slm/examples/text_graph/erniesage/models/model.py
diff --git a/legacy/examples/text_graph/erniesage/preprocessing/dump_graph.py b/slm/examples/text_graph/erniesage/preprocessing/dump_graph.py
similarity index 100%
rename from legacy/examples/text_graph/erniesage/preprocessing/dump_graph.py
rename to slm/examples/text_graph/erniesage/preprocessing/dump_graph.py
diff --git a/legacy/examples/text_matching/README.md b/slm/examples/text_matching/README.md
similarity index 92%
rename from legacy/examples/text_matching/README.md
rename to slm/examples/text_matching/README.md
index 5f82c98c009f..d759e9f35150 100644
--- a/legacy/examples/text_matching/README.md
+++ b/slm/examples/text_matching/README.md
@@ -24,8 +24,8 @@
## SimNet
-[SimNet](./simnet) 展示了如何使用CNN、LSTM、GRU等网络完成文本匹配任务。
+[SimNet](./simnet) 展示了如何使用 CNN、LSTM、GRU 等网络完成文本匹配任务。
## Sentence Transformers
-[Sentence Transformers](./sentence_transformers) 展示了如何使用以 ERNIE 为代表的模型Fine-tune完成文本匹配任务。
+[Sentence Transformers](./sentence_transformers) 展示了如何使用以 ERNIE 为代表的模型 Fine-tune 完成文本匹配任务。
diff --git a/legacy/examples/text_matching/ernie_matching/README.md b/slm/examples/text_matching/ernie_matching/README.md
similarity index 92%
rename from legacy/examples/text_matching/ernie_matching/README.md
rename to slm/examples/text_matching/ernie_matching/README.md
index dd24b9a664b8..7d0f0bb86148 100644
--- a/legacy/examples/text_matching/ernie_matching/README.md
+++ b/slm/examples/text_matching/ernie_matching/README.md
@@ -46,18 +46,18 @@ python -u -m paddle.distributed.launch --gpus "0" train_pointwise.py \
可支持配置的参数:
-* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录checkpoints文件夹下。
+* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录 checkpoints 文件夹下。
* `max_seq_length`:可选,ERNIE-Gram 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.0。
* `epochs`: 训练轮次,默认为3。
-* `warmup_proption`:可选,学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.0。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `warmup_proption`:可选,学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.0。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000.
-* `device`: 选用什么设备进行训练,可选cpu、gpu或npu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu 或 npu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
-代码示例中使用的预训练模型是 ERNIE-Gram,如果想要使用其他预训练模型如 ERNIE, BERT,RoBERTa,Electra等,只需更换`model` 和 `tokenizer`即可。
+代码示例中使用的预训练模型是 ERNIE-Gram,如果想要使用其他预训练模型如 ERNIE, BERT,RoBERTa,Electra 等,只需更换`model` 和 `tokenizer`即可。
```python
@@ -118,7 +118,7 @@ checkpoints/
**NOTE:**
* 如需恢复模型训练,则可以设置`init_from_ckpt`, 如`init_from_ckpt=checkpoints/model_100/model_state.pdparams`。
-* 如需使用ernie-tiny模型,则需要提前先安装sentencepiece依赖,如`pip install sentencepiece`
+* 如需使用 ernie-tiny 模型,则需要提前先安装 sentencepiece 依赖,如`pip install sentencepiece`
### 基于动态图模型预测
diff --git a/legacy/examples/text_matching/ernie_matching/data.py b/slm/examples/text_matching/ernie_matching/data.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/data.py
rename to slm/examples/text_matching/ernie_matching/data.py
index aabe8f71a29b..7baa82e6476e 100644
--- a/legacy/examples/text_matching/ernie_matching/data.py
+++ b/slm/examples/text_matching/ernie_matching/data.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import paddle
import numpy as np
+import paddle
from paddlenlp.datasets import MapDataset
diff --git a/legacy/examples/text_matching/ernie_matching/deploy/python/predict.py b/slm/examples/text_matching/ernie_matching/deploy/python/predict.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/deploy/python/predict.py
rename to slm/examples/text_matching/ernie_matching/deploy/python/predict.py
diff --git a/legacy/examples/text_matching/ernie_matching/export_model.py b/slm/examples/text_matching/ernie_matching/export_model.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/export_model.py
rename to slm/examples/text_matching/ernie_matching/export_model.py
diff --git a/legacy/examples/text_matching/ernie_matching/model.py b/slm/examples/text_matching/ernie_matching/model.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/model.py
rename to slm/examples/text_matching/ernie_matching/model.py
diff --git a/legacy/examples/text_matching/ernie_matching/predict_pairwise.py b/slm/examples/text_matching/ernie_matching/predict_pairwise.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/predict_pairwise.py
rename to slm/examples/text_matching/ernie_matching/predict_pairwise.py
diff --git a/legacy/examples/text_matching/ernie_matching/predict_pointwise.py b/slm/examples/text_matching/ernie_matching/predict_pointwise.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/predict_pointwise.py
rename to slm/examples/text_matching/ernie_matching/predict_pointwise.py
diff --git a/legacy/examples/text_matching/ernie_matching/train_pairwise.py b/slm/examples/text_matching/ernie_matching/train_pairwise.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/train_pairwise.py
rename to slm/examples/text_matching/ernie_matching/train_pairwise.py
diff --git a/legacy/examples/text_matching/ernie_matching/train_pointwise.py b/slm/examples/text_matching/ernie_matching/train_pointwise.py
similarity index 100%
rename from legacy/examples/text_matching/ernie_matching/train_pointwise.py
rename to slm/examples/text_matching/ernie_matching/train_pointwise.py
diff --git a/legacy/examples/text_matching/question_matching/README.md b/slm/examples/text_matching/question_matching/README.md
similarity index 90%
rename from legacy/examples/text_matching/question_matching/README.md
rename to slm/examples/text_matching/question_matching/README.md
index 24f037843a4d..1275cccce0d4 100644
--- a/legacy/examples/text_matching/question_matching/README.md
+++ b/slm/examples/text_matching/question_matching/README.md
@@ -15,10 +15,10 @@
| 心率过`快`有什么问题 | 心率过`慢`有什么问题 | 0 | 1 |
| 黑色`裤子`配什么`上衣` | 黑色`上衣`配什么`裤子` | 0 | 1 |
-当前大多数问题匹配任务采用单一指标,在同分布的测试集上评测模型的好坏,这种评测方式可能夸大了模型能力,并且缺乏对模型鲁棒性的细粒度优劣势评估。本次评测关注问题匹配模型在真实应用场景中的鲁棒性,从词汇理解、句法结构、错别字、口语化、对话理解五个维度检测模型的能力,从而发现模型的不足之处,推动语义匹配技术的发展。本次竞赛主要基于[千言数据集](https://luge.ai),采用的数据集包括哈尔滨工业大学(深圳)的LCQMC和BQ数据集、OPPO的小布对话短文本数据集以及百度的DuQM数据集,期望从多维度、多领域出发,全面评价模型的鲁棒性,进一步提升问题匹配技术的研究水平。本次竞赛将在第九届“CCF大数据与计算智能大赛”举办技术交流论坛和颁奖仪式,诚邀学术界和工业界的研究者和开发者参加本次竞赛!
+当前大多数问题匹配任务采用单一指标,在同分布的测试集上评测模型的好坏,这种评测方式可能夸大了模型能力,并且缺乏对模型鲁棒性的细粒度优劣势评估。本次评测关注问题匹配模型在真实应用场景中的鲁棒性,从词汇理解、句法结构、错别字、口语化、对话理解五个维度检测模型的能力,从而发现模型的不足之处,推动语义匹配技术的发展。本次竞赛主要基于[千言数据集](https://luge.ai),采用的数据集包括哈尔滨工业大学(深圳)的 LCQMC 和 BQ 数据集、OPPO 的小布对话短文本数据集以及百度的 DuQM 数据集,期望从多维度、多领域出发,全面评价模型的鲁棒性,进一步提升问题匹配技术的研究水平。本次竞赛将在第九届“CCF 大数据与计算智能大赛”举办技术交流论坛和颁奖仪式,诚邀学术界和工业界的研究者和开发者参加本次竞赛!
## 基线评测效果
-本项目分别基于ERNIE-1.0、Bert-base-chinese、ERNIE-Gram 3 个中文预训练模型训练了单塔 Point-wise 的匹配模型, 基于 ERNIE-Gram 的模型效果显著优于其它 2 个预训练模型。
+本项目分别基于 ERNIE-1.0、Bert-base-chinese、ERNIE-Gram 3 个中文预训练模型训练了单塔 Point-wise 的匹配模型, 基于 ERNIE-Gram 的模型效果显著优于其它 2 个预训练模型。
此外,在 ERNIE-Gram 模型基础上我们也对最新的正则化策略 [R-Drop](https://arxiv.org/abs/2106.14448) 进行了相关评测, [R-Drop](https://arxiv.org/abs/2106.14448) 策略的核心思想是针对同 1 个训练样本过多次前向网络得到的输出加上正则化的 Loss 约束。
@@ -91,13 +91,13 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3" train.py \
* `dev_set`:验证集数据文件。
* `rdrop_coef`:可选,控制 R-Drop 策略正则化 KL-Loss 的系数;默认为 0.0, 即不使用 R-Drop 策略。
* `train_batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.0。
* `epochs`: 训练轮次,默认为3。
* `warmup_proption`:可选,学习率 warmup 策略的比例,如果 0.1,则学习率会在前 10% 训练 step 的过程中从 0 慢慢增长到 learning_rate, 而后再缓慢衰减,默认为 0.0。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000。
-* `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
程序运行时将会自动进行训练,评估。同时训练过程中会自动保存模型在指定的`save_dir`中。
diff --git a/legacy/examples/text_matching/question_matching/data.py b/slm/examples/text_matching/question_matching/data.py
similarity index 100%
rename from legacy/examples/text_matching/question_matching/data.py
rename to slm/examples/text_matching/question_matching/data.py
diff --git a/legacy/examples/text_matching/question_matching/model.py b/slm/examples/text_matching/question_matching/model.py
similarity index 100%
rename from legacy/examples/text_matching/question_matching/model.py
rename to slm/examples/text_matching/question_matching/model.py
diff --git a/legacy/examples/text_matching/question_matching/predict.py b/slm/examples/text_matching/question_matching/predict.py
similarity index 100%
rename from legacy/examples/text_matching/question_matching/predict.py
rename to slm/examples/text_matching/question_matching/predict.py
diff --git a/legacy/examples/text_matching/question_matching/train.py b/slm/examples/text_matching/question_matching/train.py
similarity index 100%
rename from legacy/examples/text_matching/question_matching/train.py
rename to slm/examples/text_matching/question_matching/train.py
diff --git a/legacy/examples/text_matching/sentence_transformers/README.md b/slm/examples/text_matching/sentence_transformers/README.md
similarity index 53%
rename from legacy/examples/text_matching/sentence_transformers/README.md
rename to slm/examples/text_matching/sentence_transformers/README.md
index 53133e788470..5f377f2341ca 100644
--- a/legacy/examples/text_matching/sentence_transformers/README.md
+++ b/slm/examples/text_matching/sentence_transformers/README.md
@@ -1,47 +1,47 @@
-# 使用预训练模型Fine-tune完成中文文本匹配任务
+# 使用预训练模型 Fine-tune 完成中文文本匹配任务
-随着深度学习的发展,模型参数的数量飞速增长。为了训练这些参数,需要更大的数据集来避免过拟合。然而,对于大部分NLP任务来说,构建大规模的标注数据集非常困难(成本过高),特别是对于句法和语义相关的任务。相比之下,大规模的未标注语料库的构建则相对容易。为了利用这些数据,我们可以先从其中学习到一个好的表示,再将这些表示应用到其他任务中。最近的研究表明,基于大规模未标注语料库的预训练模型(Pretrained Models, PTM) 在NLP任务上取得了很好的表现。
+随着深度学习的发展,模型参数的数量飞速增长。为了训练这些参数,需要更大的数据集来避免过拟合。然而,对于大部分 NLP 任务来说,构建大规模的标注数据集非常困难(成本过高),特别是对于句法和语义相关的任务。相比之下,大规模的未标注语料库的构建则相对容易。为了利用这些数据,我们可以先从其中学习到一个好的表示,再将这些表示应用到其他任务中。最近的研究表明,基于大规模未标注语料库的预训练模型(Pretrained Models, PTM) 在 NLP 任务上取得了很好的表现。
-近年来,大量的研究表明基于大型语料库的预训练模型(Pretrained Models, PTM)可以学习通用的语言表示,有利于下游NLP任务,同时能够避免从零开始训练模型。随着计算能力的发展,深度模型的出现(即 Transformer)和训练技巧的增强使得 PTM 不断发展,由浅变深。
+近年来,大量的研究表明基于大型语料库的预训练模型(Pretrained Models, PTM)可以学习通用的语言表示,有利于下游 NLP 任务,同时能够避免从零开始训练模型。随着计算能力的发展,深度模型的出现(即 Transformer)和训练技巧的增强使得 PTM 不断发展,由浅变深。
-百度的预训练模型ERNIE经过海量的数据训练后,其特征抽取的工作已经做的非常好。借鉴迁移学习的思想,我们可以利用其在海量数据中学习的语义信息辅助小数据集(如本示例中的医疗文本数据集)上的任务。
+百度的预训练模型 ERNIE 经过海量的数据训练后,其特征抽取的工作已经做的非常好。借鉴迁移学习的思想,我们可以利用其在海量数据中学习的语义信息辅助小数据集(如本示例中的医疗文本数据集)上的任务。
-使用预训练模型ERNIE完成文本匹配任务,大家可能会想到将query和title文本拼接,之后输入ERNIE中,取`CLS`特征(pooled_output),之后输出全连接层,进行二分类。如下图ERNIE用于句对分类任务的用法:
+使用预训练模型 ERNIE 完成文本匹配任务,大家可能会想到将 query 和 title 文本拼接,之后输入 ERNIE 中,取`CLS`特征(pooled_output),之后输出全连接层,进行二分类。如下图 ERNIE 用于句对分类任务的用法:
-然而,以上用法的问题在于,**ERNIE的模型参数非常庞大,导致计算量非常大,预测的速度也不够理想**。从而达不到线上业务的要求。针对该问题,可以使用PaddleNLP工具搭建Sentence Transformer网络。
+然而,以上用法的问题在于,**ERNIE 的模型参数非常庞大,导致计算量非常大,预测的速度也不够理想**。从而达不到线上业务的要求。针对该问题,可以使用 PaddleNLP 工具搭建 Sentence Transformer 网络。
-Sentence Transformer采用了双塔(Siamese)的网络结构。Query和Title分别输入ERNIE,共享一个ERNIE参数,得到各自的token embedding特征。之后对token embedding进行pooling(此处教程使用mean pooling操作),之后输出分别记作u,v。之后将三个表征(u,v,|u-v|)拼接起来,进行二分类。网络结构如上图所示。
+Sentence Transformer 采用了双塔(Siamese)的网络结构。Query 和 Title 分别输入 ERNIE,共享一个 ERNIE 参数,得到各自的 token embedding 特征。之后对 token embedding 进行 pooling(此处教程使用 mean pooling 操作),之后输出分别记作 u,v。之后将三个表征(u,v,|u-v|)拼接起来,进行二分类。网络结构如上图所示。
-更多关于Sentence Transformer的信息可以参考论文:https://arxiv.org/abs/1908.10084
+更多关于 Sentence Transformer 的信息可以参考论文:https://arxiv.org/abs/1908.10084
-**同时,不仅可以使用ERNIR作为文本语义特征提取器,可以利用BERT/RoBerta/Electra等模型作为文本语义特征提取器**
+**同时,不仅可以使用 ERNIR 作为文本语义特征提取器,可以利用 BERT/RoBerta/Electra 等模型作为文本语义特征提取器**
-**那么Sentence Transformer采用Siamese的网路结构,是如何提升预测速度呢?**
+**那么 Sentence Transformer 采用 Siamese 的网路结构,是如何提升预测速度呢?**
-**Siamese的网络结构好处在于query和title分别输入同一套网络。如在信息搜索任务中,此时就可以将数据库中的title文本提前计算好对应sequence_output特征,保存在数据库中。当用户搜索query时,只需计算query的sequence_output特征与保存在数据库中的title sequence_output特征,通过一个简单的mean_pooling和全连接层进行二分类即可。从而大幅提升预测效率,同时也保障了模型性能。**
+**Siamese 的网络结构好处在于 query 和 title 分别输入同一套网络。如在信息搜索任务中,此时就可以将数据库中的 title 文本提前计算好对应 sequence_output 特征,保存在数据库中。当用户搜索 query 时,只需计算 query 的 sequence_output 特征与保存在数据库中的 title sequence_output 特征,通过一个简单的 mean_pooling 和全连接层进行二分类即可。从而大幅提升预测效率,同时也保障了模型性能。**
-关于匹配任务常用的Siamese网络结构可以参考:https://blog.csdn.net/thriving_fcl/article/details/73730552
+关于匹配任务常用的 Siamese 网络结构可以参考:https://blog.csdn.net/thriving_fcl/article/details/73730552
-PaddleNLP提供了丰富的预训练模型,并且可以便捷地获取PaddlePaddle生态下的所有预训练模型。下面展示如何使用PaddleNLP一键加载ERNIE,优化文本匹配任务。
+PaddleNLP 提供了丰富的预训练模型,并且可以便捷地获取 PaddlePaddle 生态下的所有预训练模型。下面展示如何使用 PaddleNLP 一键加载 ERNIE,优化文本匹配任务。
## 模型简介
本项目针对中文文本匹配问题,开源了一系列模型,供用户可配置地使用:
-+ BERT([Bidirectional Encoder Representations from Transformers](https://arxiv.org/abs/1810.04805))中文模型,简写`bert-base-chinese`, 其由12层Transformer网络组成。
-+ ERNIE([Enhanced Representation through Knowledge Integration](https://arxiv.org/abs/1904.09223)),支持ERNIE 1.0中文模型(简写`ernie-1.0`)和ERNIE Tiny中文模型(简写`ernie-tiny`)。
- 其中`ernie`由12层Transformer网络组成,`ernie-tiny`由3层Transformer网络组成。
-+ RoBERTa([A Robustly Optimized BERT Pretraining Approach](https://arxiv.org/abs/1907.11692)),支持12层Transformer网络的`roberta-wwm-ext`。
++ BERT([Bidirectional Encoder Representations from Transformers](https://arxiv.org/abs/1810.04805))中文模型,简写`bert-base-chinese`, 其由12层 Transformer 网络组成。
++ ERNIE([Enhanced Representation through Knowledge Integration](https://arxiv.org/abs/1904.09223)),支持 ERNIE 1.0中文模型(简写`ernie-1.0`)和 ERNIE Tiny 中文模型(简写`ernie-tiny`)。
+ 其中`ernie`由12层 Transformer 网络组成,`ernie-tiny`由3层 Transformer 网络组成。
++ RoBERTa([A Robustly Optimized BERT Pretraining Approach](https://arxiv.org/abs/1907.11692)),支持12层 Transformer 网络的`roberta-wwm-ext`。
| 模型 | dev acc | test acc |
| ---- | ------- | -------- |
@@ -69,7 +69,7 @@ sentence_transformers/
### 模型训练
-我们以中文文本匹配公开数据集LCQMC为示例数据集,可以运行下面的命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证
+我们以中文文本匹配公开数据集 LCQMC 为示例数据集,可以运行下面的命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证
```shell
$ unset CUDA_VISIBLE_DEVICES
$ python -m paddle.distributed.launch --gpus "0" train.py --device gpu --save_dir ./checkpoints
@@ -77,18 +77,18 @@ $ python -m paddle.distributed.launch --gpus "0" train.py --device gpu --save_di
可支持配置的参数:
-* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录checkpoints文件夹下。
-* `max_seq_length`:可选,ERNIE/BERT模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
+* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录 checkpoints 文件夹下。
+* `max_seq_length`:可选,ERNIE/BERT 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.00。
* `epochs`: 训练轮次,默认为3。
-* `warmup_proption`:可选,学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.1。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `warmup_proption`:可选,学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.1。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000.
-* `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
-代码示例中使用的预训练模型是ERNIE,如果想要使用其他预训练模型如BERT,RoBERTa,Electra等,只需更换`model` 和 `tokenizer`即可。
+代码示例中使用的预训练模型是 ERNIE,如果想要使用其他预训练模型如 BERT,RoBERTa,Electra 等,只需更换`model` 和 `tokenizer`即可。
```python
# 使用 ERNIE 预训练模型
@@ -145,7 +145,7 @@ checkpoints/
**NOTE:**
* 如需恢复模型训练,则可以设置`init_from_ckpt`, 如`init_from_ckpt=checkpoints/model_100/model_state.pdparams`。
-* 如需使用ernie-tiny模型,则需要提前先安装sentencepiece依赖,如`pip install sentencepiece`
+* 如需使用 ernie-tiny 模型,则需要提前先安装 sentencepiece 依赖,如`pip install sentencepiece`
### 模型预测
@@ -176,7 +176,7 @@ Data: ['小蝌蚪找妈妈怎么样', '小蝌蚪找妈妈是谁画的'] Lab
## Reference
-关于Sentence Transformer更多信息参考[www.SBERT.net](https://www.sbert.net)以及论文:
+关于 Sentence Transformer 更多信息参考[www.SBERT.net](https://www.sbert.net)以及论文:
- [Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks](https://arxiv.org/abs/1908.10084) (EMNLP 2019)
- [Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation](https://arxiv.org/abs/2004.09813) (EMNLP 2020)
- [Augmented SBERT: Data Augmentation Method for Improving Bi-Encoders for Pairwise Sentence Scoring Tasks](https://arxiv.org/abs/2010.08240) (arXiv 2020)
diff --git a/legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md b/slm/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md
similarity index 72%
rename from legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md
rename to slm/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md
index 37f76205b1e7..f40a4a38522a 100644
--- a/legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md
+++ b/slm/examples/text_matching/sentence_transformers/deploy/simple_serving/README.md
@@ -1,16 +1,16 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server启动服务](#Server服务启动)
+- [Server 启动服务](#Server 服务启动)
- [其他参数设置](#其他参数设置)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本
+使用有 SimpleServing 功能的 PaddleNLP 版本
```shell
pip install paddlenlp >= 2.4.4
```
-## Server服务启动
+## Server 服务启动
### 分类任务启动
#### 启动分类 Server 服务
```bash
@@ -23,7 +23,7 @@ python client.py
```
## 其他参数设置
-可以在client端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
+可以在 client 端设置 `max_seq_len`, `batch_size`, `prob_limit` 参数
```python
data = {
'data': {
diff --git a/legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/client.py b/slm/examples/text_matching/sentence_transformers/deploy/simple_serving/client.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/client.py
rename to slm/examples/text_matching/sentence_transformers/deploy/simple_serving/client.py
diff --git a/legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/server.py b/slm/examples/text_matching/sentence_transformers/deploy/simple_serving/server.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/deploy/simple_serving/server.py
rename to slm/examples/text_matching/sentence_transformers/deploy/simple_serving/server.py
diff --git a/legacy/examples/text_matching/sentence_transformers/export_model.py b/slm/examples/text_matching/sentence_transformers/export_model.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/export_model.py
rename to slm/examples/text_matching/sentence_transformers/export_model.py
diff --git a/legacy/examples/text_matching/sentence_transformers/model.py b/slm/examples/text_matching/sentence_transformers/model.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/model.py
rename to slm/examples/text_matching/sentence_transformers/model.py
diff --git a/legacy/examples/text_matching/sentence_transformers/predict.py b/slm/examples/text_matching/sentence_transformers/predict.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/predict.py
rename to slm/examples/text_matching/sentence_transformers/predict.py
diff --git a/legacy/examples/text_matching/sentence_transformers/train.py b/slm/examples/text_matching/sentence_transformers/train.py
similarity index 100%
rename from legacy/examples/text_matching/sentence_transformers/train.py
rename to slm/examples/text_matching/sentence_transformers/train.py
diff --git a/legacy/examples/text_matching/simbert/README.md b/slm/examples/text_matching/simbert/README.md
similarity index 69%
rename from legacy/examples/text_matching/simbert/README.md
rename to slm/examples/text_matching/simbert/README.md
index 751cfaa17067..e000e12b4b84 100644
--- a/legacy/examples/text_matching/simbert/README.md
+++ b/slm/examples/text_matching/simbert/README.md
@@ -1,7 +1,7 @@
-# SimBERT模型
+# SimBERT 模型
## 模型简介
-[SimBERT](https://github.com/ZhuiyiTechnology/simbert)的模型权重是以Google开源的BERT模型为基础,基于微软的UniLM思想设计了融检索与生成于一体的任务,来进一步微调后得到的模型,所以它同时具备相似问生成和相似句检索能力。
+[SimBERT](https://github.com/ZhuiyiTechnology/simbert)的模型权重是以 Google 开源的 BERT 模型为基础,基于微软的 UniLM 思想设计了融检索与生成于一体的任务,来进一步微调后得到的模型,所以它同时具备相似问生成和相似句检索能力。
## 快速开始
@@ -33,7 +33,7 @@ python predict.py --input_file ./datasets/lcqmc/dev.tsv
小蝌蚪找妈妈怎么样 小蝌蚪找妈妈是谁画的
```
-按照predict.py.py进行预测得到相似度
+按照 predict.py.py 进行预测得到相似度
如
@@ -45,6 +45,6 @@ python predict.py --input_file ./datasets/lcqmc/dev.tsv
## Reference
-关于SimBERT更多信息参考[科学空间](https://spaces.ac.cn/archives/7427)
+关于 SimBERT 更多信息参考[科学空间](https://spaces.ac.cn/archives/7427)
-SimBERT项目地址 https://github.com/ZhuiyiTechnology/simbert
+SimBERT 项目地址 https://github.com/ZhuiyiTechnology/simbert
diff --git a/legacy/examples/text_matching/simbert/data.py b/slm/examples/text_matching/simbert/data.py
similarity index 100%
rename from legacy/examples/text_matching/simbert/data.py
rename to slm/examples/text_matching/simbert/data.py
diff --git a/legacy/examples/text_matching/simbert/predict.py b/slm/examples/text_matching/simbert/predict.py
similarity index 100%
rename from legacy/examples/text_matching/simbert/predict.py
rename to slm/examples/text_matching/simbert/predict.py
diff --git a/legacy/examples/text_matching/simcse/README.md b/slm/examples/text_matching/simcse/README.md
similarity index 91%
rename from legacy/examples/text_matching/simcse/README.md
rename to slm/examples/text_matching/simcse/README.md
index 10ed7c5f5f63..81aab499ab86 100644
--- a/legacy/examples/text_matching/simcse/README.md
+++ b/slm/examples/text_matching/simcse/README.md
@@ -64,16 +64,16 @@ python -u -m paddle.distributed.launch --gpus '0' \
* `dup_rate`: 可选,word reptition 的比例,默认是0.32,根据论文 Word Repetition 比例采用 0.32 效果最佳。
* `scale`:可选,在计算 cross_entropy loss 之前对 cosine 相似度进行缩放的因子;默认为 20。
* `dropout`:可选,SimCSE 网络前向使用的 dropout 取值;默认 0.1。
-* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录checkpoints文件夹下。
+* `save_dir`:可选,保存训练模型的目录;默认保存在当前目录 checkpoints 文件夹下。
* `max_seq_length`:可选,ERNIE-Gram 模型使用的最大序列长度,最大不能超过512, 若出现显存不足,请适当调低这一参数;默认为128。
* `batch_size`:可选,批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为32。
-* `learning_rate`:可选,Fine-tune的最大学习率;默认为5e-5。
+* `learning_rate`:可选,Fine-tune 的最大学习率;默认为5e-5。
* `weight_decay`:可选,控制正则项力度的参数,用于防止过拟合,默认为0.0。
* `epochs`: 训练轮次,默认为1。
-* `warmup_proption`:可选,学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.0。
-* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为None。
+* `warmup_proption`:可选,学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.0。
+* `init_from_ckpt`:可选,模型参数路径,热启动模型训练;默认为 None。
* `seed`:可选,随机种子,默认为1000.
-* `device`: 选用什么设备进行训练,可选cpu、gpu或npu。如使用gpu训练则参数gpus指定GPU卡号。
+* `device`: 选用什么设备进行训练,可选 cpu、gpu 或 npu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
程序运行时将会自动进行训练,评估。同时训练过程中会自动保存模型在指定的`save_dir`中。
如:
diff --git a/legacy/examples/text_matching/simcse/data.py b/slm/examples/text_matching/simcse/data.py
similarity index 100%
rename from legacy/examples/text_matching/simcse/data.py
rename to slm/examples/text_matching/simcse/data.py
diff --git a/legacy/examples/text_matching/simcse/model.py b/slm/examples/text_matching/simcse/model.py
similarity index 100%
rename from legacy/examples/text_matching/simcse/model.py
rename to slm/examples/text_matching/simcse/model.py
diff --git a/legacy/examples/text_matching/simcse/predict.py b/slm/examples/text_matching/simcse/predict.py
similarity index 100%
rename from legacy/examples/text_matching/simcse/predict.py
rename to slm/examples/text_matching/simcse/predict.py
diff --git a/legacy/examples/text_matching/simcse/train.py b/slm/examples/text_matching/simcse/train.py
similarity index 100%
rename from legacy/examples/text_matching/simcse/train.py
rename to slm/examples/text_matching/simcse/train.py
diff --git a/slm/examples/text_matching/simcse/train.sh b/slm/examples/text_matching/simcse/train.sh
new file mode 100644
index 000000000000..d0e094b0a899
--- /dev/null
+++ b/slm/examples/text_matching/simcse/train.sh
@@ -0,0 +1,29 @@
+# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+python -u -m paddle.distributed.launch --gpus '4' \
+ train.py \
+ --device gpu \
+ --save_dir ./checkpoints/ \
+ --batch_size 64 \
+ --learning_rate 5E-5 \
+ --epochs 8 \
+ --save_steps 2000 \
+ --eval_steps 100 \
+ --max_seq_length 64 \
+ --dropout 0.3 \
+ --output_emb_size 256 \
+ --dup_rate 0.32 \
+ --train_set_file "./senteval_cn/STS-B/train.txt" \
+ --test_set_file "./senteval_cn/STS-B/dev.tsv"
\ No newline at end of file
diff --git a/legacy/examples/text_matching/simnet/README.md b/slm/examples/text_matching/simnet/README.md
similarity index 78%
rename from legacy/examples/text_matching/simnet/README.md
rename to slm/examples/text_matching/simnet/README.md
index 3237d7c76c2d..de00334d98d1 100644
--- a/legacy/examples/text_matching/simnet/README.md
+++ b/slm/examples/text_matching/simnet/README.md
@@ -1,14 +1,14 @@
-# 使用SimNet完成文本匹配任务
+# 使用 SimNet 完成文本匹配任务
短文本语义匹配(SimilarityNet, SimNet)是一个计算短文本相似度的框架,可以根据用户输入的两个文本,计算出相似度得分。
-SimNet框架在百度各产品上广泛应用,主要包括BOW、CNN、RNN、MMDNN等核心网络结构形式,提供语义相似度计算训练和预测框架,
+SimNet 框架在百度各产品上广泛应用,主要包括 BOW、CNN、RNN、MMDNN 等核心网络结构形式,提供语义相似度计算训练和预测框架,
适用于信息检索、新闻推荐、智能客服等多个应用场景,帮助企业解决语义匹配问题。
-可通过[AI开放平台-短文本相似度](https://ai.baidu.com/tech/nlp_basic/simnet)线上体验。
+可通过[AI 开放平台-短文本相似度](https://ai.baidu.com/tech/nlp_basic/simnet)线上体验。
## 模型简介
-本项目通过调用[Seq2Vec](../../../../paddlenlp/seq2vec/)中内置的模型进行序列建模,完成句子的向量表示。包含最简单的词袋模型和一系列经典的RNN类模型。
+本项目通过调用[Seq2Vec](../../../../paddlenlp/seq2vec/)中内置的模型进行序列建模,完成句子的向量表示。包含最简单的词袋模型和一系列经典的 RNN 类模型。
| 模型 | 模型介绍 |
|--------------------------------|----------------------------------------------------|
@@ -44,7 +44,7 @@ simnet/
### 数据准备
-#### 使用PaddleNLP内置数据集
+#### 使用 PaddleNLP 内置数据集
```python
from paddlenlp.datasets import load_dataset
@@ -66,7 +66,7 @@ query title label
### 模型训练
-在模型训练之前,需要先下载词汇表文件simnet_vocab.txt,用于构造词-id映射关系。
+在模型训练之前,需要先下载词汇表文件 simnet_vocab.txt,用于构造词-id 映射关系。
```shell
wget https://bj.bcebos.com/paddlenlp/data/simnet_vocab.txt
@@ -74,9 +74,9 @@ wget https://bj.bcebos.com/paddlenlp/data/simnet_vocab.txt
**NOTE:** 词表的选择和实际应用数据相关,需根据实际数据选择词表。
-我们以中文文本匹配数据集LCQMC为示例数据集,可以运行下面的命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证
+我们以中文文本匹配数据集 LCQMC 为示例数据集,可以运行下面的命令,在训练集(train.tsv)上进行模型训练,并在开发集(dev.tsv)验证
-CPU启动:
+CPU 启动:
```shell
python train.py --vocab_path='./simnet_vocab.txt' \
@@ -88,7 +88,7 @@ python train.py --vocab_path='./simnet_vocab.txt' \
--save_dir='./checkpoints'
```
-GPU启动:
+GPU 启动:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -104,10 +104,10 @@ python -m paddle.distributed.launch --gpus "0" train.py --vocab_path='./simnet_v
以上参数表示:
* `vocab_path`: 词汇表文件路径。
-* `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
-* `network`: 模型网络名称,默认为`lstm`, 可更换为lstm, gru, rnn,bow,cnn等。
+* `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
+* `network`: 模型网络名称,默认为`lstm`, 可更换为 lstm, gru, rnn,bow,cnn 等。
* `lr`: 学习率, 默认为5e-4。
-* `batch_size`: 运行一个batch大小,默认为64。
+* `batch_size`: 运行一个 batch 大小,默认为64。
* `epochs`: 训练轮次,默认为5。
* `save_dir`: 训练保存模型的文件路径。
* `init_from_ckpt`: 恢复模型训练的断点路径。
@@ -125,13 +125,13 @@ checkpoints/
└── final.pdparams
```
-**NOTE:** 如需恢复模型训练,则init_from_ckpt只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/0`即可,程序会自动加载模型参数`checkpoints/0.pdparams`,也会自动加载优化器状态`checkpoints/0.pdopt`。
+**NOTE:** 如需恢复模型训练,则 init_from_ckpt 只需指定到文件名即可,不需要添加文件尾缀。如`--init_from_ckpt=checkpoints/0`即可,程序会自动加载模型参数`checkpoints/0.pdparams`,也会自动加载优化器状态`checkpoints/0.pdopt`。
### 模型预测
启动预测
-CPU启动:
+CPU 启动:
```shell
python predict.py --vocab_path='./simnet_vocab.txt' \
@@ -140,7 +140,7 @@ python predict.py --vocab_path='./simnet_vocab.txt' \
--params_path=checkpoints/final.pdparams
```
-GPU启动:
+GPU 启动:
```shell
CUDA_VISIBLE_DEVICES=0 python predict.py --vocab_path='./simnet_vocab.txt' \
diff --git a/legacy/examples/text_matching/simnet/model.py b/slm/examples/text_matching/simnet/model.py
similarity index 100%
rename from legacy/examples/text_matching/simnet/model.py
rename to slm/examples/text_matching/simnet/model.py
diff --git a/legacy/examples/text_matching/simnet/predict.py b/slm/examples/text_matching/simnet/predict.py
similarity index 100%
rename from legacy/examples/text_matching/simnet/predict.py
rename to slm/examples/text_matching/simnet/predict.py
diff --git a/legacy/examples/text_matching/simnet/train.py b/slm/examples/text_matching/simnet/train.py
similarity index 100%
rename from legacy/examples/text_matching/simnet/train.py
rename to slm/examples/text_matching/simnet/train.py
diff --git a/legacy/examples/text_matching/simnet/utils.py b/slm/examples/text_matching/simnet/utils.py
similarity index 100%
rename from legacy/examples/text_matching/simnet/utils.py
rename to slm/examples/text_matching/simnet/utils.py
diff --git a/slm/examples/text_summarization/bart/README.md b/slm/examples/text_summarization/bart/README.md
new file mode 100644
index 000000000000..82dd27d59751
--- /dev/null
+++ b/slm/examples/text_summarization/bart/README.md
@@ -0,0 +1,9 @@
+# BART
+
+## 模型简介
+
+BART 是一种 Seq2Seq 结构的降噪自编码器,通过增加噪声来破环文本然后重建原文本来训练模型。它使用一个标准的 Transformer 结构,可以被看作泛化的 BERT(由于是双向编码器),GPT(由于是从左到右解码器),和一些其他的预训练模型结构。
+
+本项目是 BART 在 PaddlePaddle 2.2上开源实现的文本摘要的例子,包含了在[CNN/DailyMail](https://arxiv.org/pdf/1704.04368.pdf)数据集上微调和生成的代码。
+
+使用请[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_summarization/bart)
diff --git a/legacy/examples/text_summarization/pointer_summarizer/.gitignore b/slm/examples/text_summarization/pointer_summarizer/.gitignore
similarity index 100%
rename from legacy/examples/text_summarization/pointer_summarizer/.gitignore
rename to slm/examples/text_summarization/pointer_summarizer/.gitignore
diff --git a/legacy/examples/text_summarization/pointer_summarizer/README.md b/slm/examples/text_summarization/pointer_summarizer/README.md
similarity index 100%
rename from legacy/examples/text_summarization/pointer_summarizer/README.md
rename to slm/examples/text_summarization/pointer_summarizer/README.md
diff --git a/legacy/examples/text_summarization/prophetnet/README.md b/slm/examples/text_summarization/prophetnet/README.md
similarity index 98%
rename from legacy/examples/text_summarization/prophetnet/README.md
rename to slm/examples/text_summarization/prophetnet/README.md
index 3797368bf6cd..6d5543e04b43 100644
--- a/legacy/examples/text_summarization/prophetnet/README.md
+++ b/slm/examples/text_summarization/prophetnet/README.md
@@ -8,4 +8,3 @@ local correlation)过拟合。
本项目是 Prophetnet 在 PaddlePaddle 2.4 上开源实现的文本摘要的例子,包含了在 CNN/DailyMail 数据集,Gigaword 数据集上微调和生成的代码。
具体实现[参考](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/text_summarization/pointer_summarizer)
-
diff --git a/legacy/examples/text_summarization/unimo-text/README.md b/slm/examples/text_summarization/unimo-text/README.md
similarity index 79%
rename from legacy/examples/text_summarization/unimo-text/README.md
rename to slm/examples/text_summarization/unimo-text/README.md
index 9fde6d55ec40..338ca81a7ce5 100644
--- a/legacy/examples/text_summarization/unimo-text/README.md
+++ b/slm/examples/text_summarization/unimo-text/README.md
@@ -18,7 +18,7 @@
- [模型训练](#模型训练)
- [模型预测](#模型预测)
- [模型推理部署](#模型推理部署)
- - [FastGeneration加速及模型静态图导出](#fastgeneration加速及模型静态图导出)
+ - [FastGeneration 加速及模型静态图导出](#fastgeneration 加速及模型静态图导出)
- [模型部署](#模型部署)
- [References](#references)
@@ -27,9 +27,9 @@
文本摘要的目标是自动地将输入文本转换成简短摘要,为用户提供简明扼要的内容描述,是缓解文本信息过载的一个重要手段。
文本摘要也是自然语言生成领域中的一个重要任务,有很多应用场景,如新闻摘要、论文摘要、财报摘要、传记摘要、专利摘要、对话摘要、评论摘要、观点摘要、电影摘要、文章标题生成、商品名生成、自动报告生成、搜索结果预览等。
-本项目是基于预训练语言模型UNIMO-Text的文本摘要,具有以下优势:
+本项目是基于预训练语言模型 UNIMO-Text 的文本摘要,具有以下优势:
- 效果领先。
-- 开箱即用。本项目提供TaskFlow接口,无需训练,仅需几行代码便可预测。
+- 开箱即用。本项目提供 TaskFlow 接口,无需训练,仅需几行代码便可预测。
- 训练推理全流程打通。本项目提供了全面的定制训练流程,从数据准备、模型训练预测,到模型推理部署,一应俱全。
### 基于预训练语言模型的文本摘要
@@ -37,7 +37,7 @@
基于预训练语言模型(Pretrained Language Models, PLMs)范式的自动文本摘要是目前最常用、效果最好(SOTA)的方式。
预训练模型是在超大规模的语料采用无监督(unsupervised)或者弱监督(weak-supervised)的方式进行预训练,能够学习如何准确地理解自然语言并以自然语言的形式流畅表达,这两项都是完成文本摘要任务的重要能力。
-PaddleNLP提供了方便易用的接口,可指定模型名或模型参数文件路径通过from_pretrained()方法加载不同网络结构的预训练模型,且相应预训练模型权重下载速度快速、稳定。下面以中文unimo-text-1.0-summary模型为例,演示如何加载预训练模型和分词器:
+PaddleNLP 提供了方便易用的接口,可指定模型名或模型参数文件路径通过 from_pretrained()方法加载不同网络结构的预训练模型,且相应预训练模型权重下载速度快速、稳定。下面以中文 unimo-text-1.0-summary 模型为例,演示如何加载预训练模型和分词器:
```
from paddlenlp.transformers import UNIMOLMHeadModel, UNIMOTokenizer
model_name = "unimo-text-1.0-summary"
@@ -48,7 +48,7 @@ tokenizer = UNIMOTokenizer.from_pretrained(model_name)
## 效果展示
## 开箱即用
-PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,一键预测。
+PaddleNLP 提供开箱即用的产业级 NLP 预置任务能力,无需训练,一键预测。
### 支持单条、批量预测
```python
@@ -80,7 +80,7 @@ PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,
2. **模型训练**
-- 数据准备完成后,可以开始使用我们的数据集对预训练模型进行微调训练。我们可以根据任务需求,调整可配置参数,选择使用GPU或CPU进行模型训练,脚本默认保存在开发集最佳表现模型。中文任务默认使用"unimo-text-1.0-summary"模型,unimo-text-1.0-summary还支持large模型,详见[UNIMO模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html),可以根据任务和设备需求进行选择。
+- 数据准备完成后,可以开始使用我们的数据集对预训练模型进行微调训练。我们可以根据任务需求,调整可配置参数,选择使用 GPU 或 CPU 进行模型训练,脚本默认保存在开发集最佳表现模型。中文任务默认使用"unimo-text-1.0-summary"模型,unimo-text-1.0-summary 还支持 large 模型,详见[UNIMO 模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html),可以根据任务和设备需求进行选择。
3. **模型预测**
@@ -91,9 +91,9 @@ PaddleNLP提供开箱即用的产业级NLP预置任务能力,无需训练,
- 模型部署需要将保存的最佳模型参数(动态图)导出成静态图参数,用于后续的推理部署。
-- 文本摘要应用提供了基于Paddle Inference的本地部署predictor,并且支持在GPU设备使用FastGeneration进行加速。
+- 文本摘要应用提供了基于 Paddle Inference 的本地部署 predictor,并且支持在 GPU 设备使用 FastGeneration 进行加速。
-- 文本摘要应用提供了基于Paddle Serving的服务端部署方案。
+- 文本摘要应用提供了基于 Paddle Serving 的服务端部署方案。
### 环境依赖
@@ -148,7 +148,7 @@ data/
### 模型训练
-运行如下命令即可在样例训练集上进行finetune,并在样例验证集上进行验证。
+运行如下命令即可在样例训练集上进行 finetune,并在样例验证集上进行验证。
```shell
# GPU启动,参数`--gpus`指定训练所用的GPU卡号,可以是单卡,也可以多卡
@@ -181,13 +181,13 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" --log_dir ${log_dir} train.
也可以直接使用`train.sh`.
关键参数释义如下:
-- `gpus` 指示了训练所用的GPU卡号。
+- `gpus` 指示了训练所用的 GPU 卡号。
- `dataset_name` 数据集名称。
- `train_file` 本地训练数据地址。
- `eval_file` 本地测试数据地址。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型,可以是PaddleNLP提供的预训练模型(详见[UNIMO模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html)),或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含paddle预训练模型model_state.pdparams。如果使用PaddleNLP提供的预训练模型,可以选择下面其中之一。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型,可以是 PaddleNLP 提供的预训练模型(详见[UNIMO 模型汇总](https://paddlenlp.readthedocs.io/zh/latest/model_zoo/transformers/UNIMO/contents.html)),或者是本地的预训练模型。如果使用本地的预训练模型,可以配置本地模型的目录地址,例如: ./checkpoints/model_xx/,目录中需包含 paddle 预训练模型 model_state.pdparams。如果使用 PaddleNLP 提供的预训练模型,可以选择下面其中之一。
- | PaddleNLP提供的预训练模型 |
+ | PaddleNLP 提供的预训练模型 |
|---------------------------------|
| unimo-text-1.0-summary |
| unimo-text-1.0 |
@@ -199,16 +199,16 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" --log_dir ${log_dir} train.
- `seed` 表示随机数生成器的种子。
- `epochs` 表示训练轮数。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_proportion` 表示学习率逐渐升高到基础学习率(即上面配置的 learning_rate)所需要的迭代数占总步数的比例,最早的使用可以参考[这篇论文](https://arxiv.org/pdf/1706.02677.pdf)。
- `max_seq_len` 模型输入序列的最大长度。
- `max_target_len` 模型训练时标签的最大长度。
- `min_dec_len` 模型生成序列的最小长度。
- `max_dec_len` 模型生成序列的最大长度。
- `do_train` 是否进行训练。
- `do_eval` 是否进行预测,在验证集上会自动评估。
-- `device` 表示使用的设备,从gpu和cpu中选择。
+- `device` 表示使用的设备,从 gpu 和 cpu 中选择。
更多参数详情和参数的默认值请参考`train.py`。
@@ -250,7 +250,7 @@ python train.py \
程序运行结束后会将预测结果保存在`output_path`中。
-Finetuned baseline的模型在[LCSTS](https://aclanthology.org/D15-1229/)测试集上有如下结果:
+Finetuned baseline 的模型在[LCSTS](https://aclanthology.org/D15-1229/)测试集上有如下结果:
| model_name | Rouge-1 | Rouge-2 | Rouge-L | BLEU-4 |
| :-----------------------------: | :---: | :-----------: | :-------------------: |:-------------------: |
| finetuned unimo-text-1.0-summary | 39.56 | 26.24 | 36.35 | 21.48 |
@@ -258,9 +258,9 @@ Finetuned baseline的模型在[LCSTS](https://aclanthology.org/D15-1229/)测试
### 模型推理部署
-#### FastGeneration加速及模型静态图导出
+#### FastGeneration 加速及模型静态图导出
-使用动态图训练结束之后,可以通过[静态图导出脚本](export_model.py)实现基于FastGeneration的高性能预测加速,并将动态图参数导出成静态图参数,静态图参数保存在`output_path`指定路径中。运行方式:
+使用动态图训练结束之后,可以通过[静态图导出脚本](export_model.py)实现基于 FastGeneration 的高性能预测加速,并将动态图参数导出成静态图参数,静态图参数保存在`output_path`指定路径中。运行方式:
```shell
python export_model.py \
diff --git a/slm/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md b/slm/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
new file mode 100644
index 000000000000..7bf919e48365
--- /dev/null
+++ b/slm/examples/text_summarization/unimo-text/deploy/paddle_inference/README.md
@@ -0,0 +1,31 @@
+# Paddle Inference 部署
+本文档将介绍如何使用[Paddle Inference](https://paddle-inference.readthedocs.io/en/latest/guides/introduction/index_intro.html#paddle-inference)工具进行自动文本摘要应用高性能推理推理部署。
+
+**目录**
+ * [背景介绍](#背景介绍)
+ * [导出预测部署模型](#导出预测部署模型)
+ * [基于 Python 预测](#基于 Python 预测)
+
+
+## 背景介绍
+Paddle inference 和主框架的 Model.predict 均可实现推理预测,Paddle Inference 是飞桨的原生推理库, 作用于服务器端和云端,提供高性能的推理能力,主框架的 Model 对象是一个具备训练、测试、推理的神经网络。相比于 Model.predict,inference 可使用 MKLDNN、CUDNN、TensorRT 进行预测加速。Model.predict 适用于训练好的模型直接进行预测,paddle inference 适用于对推理性能、通用性有要求的用户,针对不同平台不同的应用场景进行了深度的适配优化,保证模型在服务器端即训即用,快速部署。由于 Paddle Inference 能力直接基于飞桨的训练算子,因此它支持飞桨训练出的所有模型的推理。
+
+
+Paddle Inference Python 端预测部署主要包含两个步骤:
+- 导出预测部署模型
+- 基于 Python 预测
+
+
+## 导出预测部署模型
+部署时需要使用预测格式的模型(即动态图转静态图操作)。预测格式模型相对训练格式模型而言,在拓扑上裁剪掉了预测不需要的算子,并且会做特定部署优化。具体操作详见[FastGeneration 加速及模型静态图导出](../../README.md)。
+
+## 基于 Python 预测
+
+
+在终端输入以下命令可在 GPU 上进行预测:
+```shell
+python inference_unimo_text.py --inference_model_dir ../../inference_model
+```
+
+关键参数释义如下:
+* `inference_model_dir`:用于高性能推理的静态图模型参数路径;默认为"../../inference_model"。
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/inference_unimo_text.py b/slm/examples/text_summarization/unimo-text/deploy/paddle_inference/inference_unimo_text.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_inference/inference_unimo_text.py
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_inference/inference_unimo_text.py
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md
similarity index 73%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md
index 31061c513704..6e6d9a8a2efc 100644
--- a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md
+++ b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/README.md
@@ -1,36 +1,36 @@
-# Paddle Serving服务化部署
+# Paddle Serving 服务化部署
本文档将介绍如何使用[Paddle Serving](https://github.com/PaddlePaddle/Serving/blob/develop/README_CN.md)工具部署自动文本摘要在线服务。
## 目录
-- [Paddle Serving服务化部署](#paddle-serving服务化部署)
+- [Paddle Serving 服务化部署](#paddle-serving 服务化部署)
- [目录](#目录)
- [背景介绍](#背景介绍)
- [环境准备](#环境准备)
- - [安装Paddle Serving](#安装paddle-serving)
+ - [安装 Paddle Serving](#安装 paddle-serving)
- [模型转换](#模型转换)
- - [pipeline部署](#pipeline部署)
+ - [pipeline 部署](#pipeline 部署)
- [修改配置文件](#修改配置文件)
- - [server启动服务](#server启动服务)
- - [client发送服务请求](#client发送服务请求)
+ - [server 启动服务](#server 启动服务)
+ - [client 发送服务请求](#client 发送服务请求)
## 背景介绍
Paddle Serving 依托深度学习框架 PaddlePaddle 旨在帮助深度学习开发者和企业提供高性能、灵活易用的工业级在线推理服务。Paddle Serving 支持 RESTful、gRPC、bRPC 等多种协议,提供多种异构硬件和多种操作系统环境下推理解决方案,和多种经典预训练模型示例。集成高性能服务端推理引擎 Paddle Inference 和端侧引擎 Paddle Lite。设计并实现基于有向无环图(DAG) 的异步流水线高性能推理框架,具有多模型组合、异步调度、并发推理、动态批量、多卡多流推理、请求缓存等特性。
-Paddle Serving Python端预测部署主要包含以下步骤:
+Paddle Serving Python 端预测部署主要包含以下步骤:
- 环境准备
- 模型转换
- 部署模型
## 环境准备
-### 安装Paddle Serving
-安装client和serving app,用于向服务发送请求:
+### 安装 Paddle Serving
+安装 client 和 serving app,用于向服务发送请求:
```shell
pip install paddle_serving_app paddle_serving_client
```
-安装GPU server,用于启动服务:
+安装 GPU server,用于启动服务:
-- 安装GPU server, 注意选择跟本地环境一致的命令
+- 安装 GPU server, 注意选择跟本地环境一致的命令
```shell
# CUDA10.2 + Cudnn7 + TensorRT6
pip install paddle-serving-server-gpu==0.8.3.post102 # -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -42,14 +42,14 @@ pip install paddle-serving-server-gpu==0.8.3.post112 # -i https://pypi.tuna.tsin
**NOTE:**
- 可以开启国内清华镜像源来加速下载
-- 如果要安装最新版本的PaddleServing参考[链接](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)。
+- 如果要安装最新版本的 PaddleServing 参考[链接](https://github.com/PaddlePaddle/Serving/blob/develop/doc/Latest_Packages_CN.md)。
## 模型转换
-使用Paddle Serving做服务化部署时,需要将保存的inference模型转换为serving易于部署的模型。
+使用 Paddle Serving 做服务化部署时,需要将保存的 inference 模型转换为 serving 易于部署的模型。
-用已安装的paddle_serving_client将静态图参数模型转换成serving格式。关于如何使用将训练后的动态图模型转为静态图模型详见[FastGeneration加速及模型静态图导出](../../README.md)。
+用已安装的 paddle_serving_client 将静态图参数模型转换成 serving 格式。关于如何使用将训练后的动态图模型转为静态图模型详见[FastGeneration 加速及模型静态图导出](../../README.md)。
模型转换命令如下:
```shell
@@ -63,8 +63,8 @@ python -m paddle_serving_client.convert --dirname ../../inference_model \
* `dirname`:模型文件夹地址。
* `model_filename`:模型文件名。
* `params_filename`:模型参数名。
-* `serving_server`:server的模型文件和配置文件路径,默认"serving_server"。
-* `serving_client`:client的配置文件路径,默认"serving_client"。
+* `serving_server`:server 的模型文件和配置文件路径,默认"serving_server"。
+* `serving_client`:client 的配置文件路径,默认"serving_client"。
也可以直接使用`export_serving.sh`.
@@ -72,7 +72,7 @@ python -m paddle_serving_client.convert --dirname ../../inference_model \
```shell
python -m paddle_serving_client.convert --help
```
-模型转换完成后,会在paddle_serving文件夹多出inference_model_server和inference_model_client的文件夹,文件夹目录格式如下:
+模型转换完成后,会在 paddle_serving 文件夹多出 inference_model_server 和 inference_model_client 的文件夹,文件夹目录格式如下:
```
inference_model_server/
├── unimo_text.pdiparams
@@ -85,9 +85,9 @@ inference_model_client/
└── serving_client_conf.stream.prototxt
```
-## pipeline部署
+## pipeline 部署
-paddle_serving目录包含启动pipeline服务和发送预测请求的代码,包括:
+paddle_serving 目录包含启动 pipeline 服务和发送预测请求的代码,包括:
```
paddle_serving/
├──config.yml # 启动服务端的配置文件
@@ -98,13 +98,13 @@ paddle_serving/
### 修改配置文件
目录中的`config.yml`文件解释了每一个参数的含义,可以根据实际需要修改其中的配置。
-### server启动服务
+### server 启动服务
修改好配置文件后,执行下面命令启动服务:
```shell
# 启动服务
python pipeline_service.py
```
-成功启动服务后,log.txt中会打印类似如下日志
+成功启动服务后,log.txt 中会打印类似如下日志
```
--- Running analysis [ir_graph_to_program_pass]
I0831 12:29:41.132828 28269 analysis_predictor.cc:1035] ======= optimize end =======
@@ -132,9 +132,9 @@ I0831 12:29:41.134049 28269 naive_executor.cc:102] --- skip [gather_tree_0.tmp_
2022/08/31 12:29:41 start proxy service
```
-### client发送服务请求
+### client 发送服务请求
执行以下命令发送文本摘要服务请求:
```shell
python pipeline_client.py
```
-注意执行客户端请求时关闭代理,并根据实际情况修改server_url地址(启动服务所在的机器)。
+注意执行客户端请求时关闭代理,并根据实际情况修改 server_url 地址(启动服务所在的机器)。
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/config.yml b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/config.yml
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/config.yml
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_serving/config.yml
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/export_serving.sh b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/export_serving.sh
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/export_serving.sh
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_serving/export_serving.sh
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_client.py b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_client.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_client.py
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_client.py
diff --git a/legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_service.py b/slm/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_service.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_service.py
rename to slm/examples/text_summarization/unimo-text/deploy/paddle_serving/pipeline_service.py
diff --git a/legacy/examples/text_summarization/unimo-text/export_model.py b/slm/examples/text_summarization/unimo-text/export_model.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/export_model.py
rename to slm/examples/text_summarization/unimo-text/export_model.py
diff --git a/legacy/examples/text_summarization/unimo-text/export_model.sh b/slm/examples/text_summarization/unimo-text/export_model.sh
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/export_model.sh
rename to slm/examples/text_summarization/unimo-text/export_model.sh
diff --git a/legacy/examples/text_summarization/unimo-text/train.py b/slm/examples/text_summarization/unimo-text/train.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/train.py
rename to slm/examples/text_summarization/unimo-text/train.py
diff --git a/legacy/examples/text_summarization/unimo-text/train.sh b/slm/examples/text_summarization/unimo-text/train.sh
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/train.sh
rename to slm/examples/text_summarization/unimo-text/train.sh
diff --git a/legacy/examples/text_summarization/unimo-text/utils.py b/slm/examples/text_summarization/unimo-text/utils.py
similarity index 100%
rename from legacy/examples/text_summarization/unimo-text/utils.py
rename to slm/examples/text_summarization/unimo-text/utils.py
diff --git a/legacy/examples/text_to_knowledge/README.md b/slm/examples/text_to_knowledge/README.md
similarity index 58%
rename from legacy/examples/text_to_knowledge/README.md
rename to slm/examples/text_to_knowledge/README.md
index 39d41248a007..3d9719963eeb 100644
--- a/legacy/examples/text_to_knowledge/README.md
+++ b/slm/examples/text_to_knowledge/README.md
@@ -12,13 +12,13 @@
**解语由以下三部分构成:**
-- [百科知识树(TermTree)](./termtree) :包括能够描述所有中文词汇的TermType词类体系,以及Term关系和属性值。
+- [百科知识树(TermTree)](./termtree) :包括能够描述所有中文词汇的 TermType 词类体系,以及 Term 关系和属性值。
- 中文知识标注工具集:包括[词类知识标注工具(WordTag)](./wordtag) 和[名词短语标注工具(NPTag)](./nptag),[适用于中文文本挖掘的预训练语言模型(ERNIE-CTM)](./ernie-ctm),为中文文本解析提供词类序列标注框架,结合百科知识树可实现定制化词类序列标注。
- 中文知识挖掘方案:包括[知识模板挖掘工具](./wordtag-ie),旨在提供灵活可配置,可快速定制的中文知识挖掘方案。
**本次发布的解语开源试用版包括:**
-- 百科知识树(TermTree)V1.0试用版:包括简化版的TermType词类体系,和约100w的term集。
+- 百科知识树(TermTree)V1.0试用版:包括简化版的 TermType 词类体系,和约100w 的 term 集。
- 中文词类知识标注工具(WordTag)V1.0版。
- 名词短语标注工具(NPTag)V1.0版。
- 中文预训练语言模型(ERNIE-CTM)V1.0版。
@@ -35,11 +35,11 @@

-### 应用场景A:文本挖掘/解析模板生成与匹配
+### 应用场景 A:文本挖掘/解析模板生成与匹配
-虽然近年来,深度学习模型尤其是预训练语言模型的广泛使用大幅提升了各项中文NLP任务效果,但在实际的工业应用中,单独使用深度学习模型往往达不到应用需求,还需要结合规则模型以提升精度以及解决恶劣case,如,知识图谱构建、query解析、语义一致性判定等应用。
+虽然近年来,深度学习模型尤其是预训练语言模型的广泛使用大幅提升了各项中文 NLP 任务效果,但在实际的工业应用中,单独使用深度学习模型往往达不到应用需求,还需要结合规则模型以提升精度以及解决恶劣 case,如,知识图谱构建、query 解析、语义一致性判定等应用。
-在这些应用中,文本挖掘/解析模板是最常用的规则模型。WordTag包含了覆盖中文所有词汇的词类标注体系,在生成模板以及模板匹配上有着天然的优势。用户可以根据WordTag标注的样本词类序列,自动生成或配置更加丰富、精准的挖掘/解析模板,然后对目标文本使用WordTag标注,即可利用模板进行匹配,从而大大降低人工配置模板的代价,显著提升生产效率。
+在这些应用中,文本挖掘/解析模板是最常用的规则模型。WordTag 包含了覆盖中文所有词汇的词类标注体系,在生成模板以及模板匹配上有着天然的优势。用户可以根据 WordTag 标注的样本词类序列,自动生成或配置更加丰富、精准的挖掘/解析模板,然后对目标文本使用 WordTag 标注,即可利用模板进行匹配,从而大大降低人工配置模板的代价,显著提升生产效率。
例如,输入文本:*美人鱼是周星驰执导的电影*,得到预测结果:
@@ -99,7 +99,7 @@
[作品类_实体][肯定词|是][人物类_实体][场景事件|执导][作品类_概念|电影]
```
-利用该模板,以及结合TermTree进行概念扩展,可以匹配出所有该句式的文本,例如:
+利用该模板,以及结合 TermTree 进行概念扩展,可以匹配出所有该句式的文本,例如:
> 《狂人日记》是鲁迅创作的第一个短篇白话日记体小说
>
@@ -109,43 +109,43 @@
>
> 《射雕英雄传》是金庸创作的长篇武侠小说
-WordTag的标注结果中,区分了“人物类\_实体”和“人物类\_概念”,以及“作品类\_实体”和“作品类\_概念”,使得模板生成更为精准。同时,TermTree中也区分了命名实体词(eb: entity base)与非实体词(cb: concept base),这样,可以利用TermTree分别进行实体扩展(e.g., 周星驰->王晶)和概念扩展(e.g., 电影->小说),生成更加丰富多样的模板,支持更细化的应用场景。
+WordTag 的标注结果中,区分了“人物类\_实体”和“人物类\_概念”,以及“作品类\_实体”和“作品类\_概念”,使得模板生成更为精准。同时,TermTree 中也区分了命名实体词(eb: entity base)与非实体词(cb: concept base),这样,可以利用 TermTree 分别进行实体扩展(e.g., 周星驰->王晶)和概念扩展(e.g., 电影->小说),生成更加丰富多样的模板,支持更细化的应用场景。
-### 应用场景B:词类知识增强的深度学习模型
+### 应用场景 B:词类知识增强的深度学习模型
-词类特征同时也是一类重要的文本特征,可为原始文本token提供有效的边界信息、归组信息,减少样本中的噪音,防止模型过拟合;还可作为层次泛化特征,弥补统计共现特征的不足。
+词类特征同时也是一类重要的文本特征,可为原始文本 token 提供有效的边界信息、归组信息,减少样本中的噪音,防止模型过拟合;还可作为层次泛化特征,弥补统计共现特征的不足。
-在深度学习模型应用中,可将WordTag产出的词类作为embedding特征,直接叠加到文本token上,作为深度学习模型的输入;在BERT等模型中,也可以将词类作为文本序列中的一部分,利用position id和可见性矩阵控制token和词类特征之间的可见性,作为深度学习模型的输入。
+在深度学习模型应用中,可将 WordTag 产出的词类作为 embedding 特征,直接叠加到文本 token 上,作为深度学习模型的输入;在 BERT 等模型中,也可以将词类作为文本序列中的一部分,利用 position id 和可见性矩阵控制 token 和词类特征之间的可见性,作为深度学习模型的输入。
-### 应用场景C:知识图谱关联(term-linking)
+### 应用场景 C:知识图谱关联(term-linking)
-随着知识图谱技术的普及和越来越多应用知识图谱数据的发布,如何利用知识提升NLP任务效果,成为近年来NLP研究的热点方向。文本与图谱知识结合的前提是将图谱中的实体准确link到文本上,这是知识图谱应用的一大难点。现有的方案多是基于某个特定图谱实现的,缺乏通用的图谱关联解决方案。我们尝试使用“**WordTag+TermTree**”提供一套通用的图谱关联(term-linking)技术框架。
+随着知识图谱技术的普及和越来越多应用知识图谱数据的发布,如何利用知识提升 NLP 任务效果,成为近年来 NLP 研究的热点方向。文本与图谱知识结合的前提是将图谱中的实体准确 link 到文本上,这是知识图谱应用的一大难点。现有的方案多是基于某个特定图谱实现的,缺乏通用的图谱关联解决方案。我们尝试使用“**WordTag+TermTree**”提供一套通用的图谱关联(term-linking)技术框架。
-**NOTE:** 为了避免歧义,我们 **用term统一指代图谱收录的各类实体、概念、术语**。
+**NOTE:** 为了避免歧义,我们 **用 term 统一指代图谱收录的各类实体、概念、术语**。
-为了能够适配应用中的不同实体集(例如,不同的企业有不同的人物实体集合,不同的小说站有不同的小说实体集合),我们将term-linking拆分为两个步骤:
+为了能够适配应用中的不同实体集(例如,不同的企业有不同的人物实体集合,不同的小说站有不同的小说实体集合),我们将 term-linking 拆分为两个步骤:
-- 第一步是基于词类的linking,主要解决“同名概念词/实体词”、“不同类的同名词”消歧问题,这一步只使用文本本身特征和词类特征,不使用图谱中的实体属性值(SPO)知识,从而支持切换不同应用图谱;
-- 第二步是同类同名实体词的linking,主要解决同类下不同属性值的实体消歧问题,这一步需要使用实体词的SPO知识(一般用于实体特征表示计算,以及文本-实体相似度计算)。
+- 第一步是基于词类的 linking,主要解决“同名概念词/实体词”、“不同类的同名词”消歧问题,这一步只使用文本本身特征和词类特征,不使用图谱中的实体属性值(SPO)知识,从而支持切换不同应用图谱;
+- 第二步是同类同名实体词的 linking,主要解决同类下不同属性值的实体消歧问题,这一步需要使用实体词的 SPO 知识(一般用于实体特征表示计算,以及文本-实体相似度计算)。
-“WordTag+TermTree”的开源版提供了第一步的解决示例,第二步由于依赖于特定图谱的SPO知识,暂时无法提供通用工具,未来可能提供通用解决方案。
+“WordTag+TermTree”的开源版提供了第一步的解决示例,第二步由于依赖于特定图谱的 SPO 知识,暂时无法提供通用工具,未来可能提供通用解决方案。
-### 应用场景D:文本分类和文本挖掘样本优化
+### 应用场景 D:文本分类和文本挖掘样本优化
-工业NLP应用场景中,文本分类、文本挖掘是最常见的任务。虽然,预训练语言模型的技术进步大幅提升了小样本学习的效果,但要达到理想的工业应用效果,还是需要大规模高精度监督训练样本。
+工业 NLP 应用场景中,文本分类、文本挖掘是最常见的任务。虽然,预训练语言模型的技术进步大幅提升了小样本学习的效果,但要达到理想的工业应用效果,还是需要大规模高精度监督训练样本。
人工标注可以产出高精度小规模训练样本。半监督学习等技术可以帮助用户基于人工标准样本快速扩充样本规模,但无法保证样本精度。这种情况下,可以使用“WordTag+TermTree”辅助筛选和修正样本,提升样本精度,例如:
-- 使用WordTag产出样本模板,再利用TermTree进行泛化约束,筛选出高置信度的样本,或者过滤不合格的样本;
+- 使用 WordTag 产出样本模板,再利用 TermTree 进行泛化约束,筛选出高置信度的样本,或者过滤不合格的样本;
-- 利用词类关系检测类别与样本的一致性,比如,医疗类文本与“疾病损伤、药物、医疗卫生机构”等词类相关,可以利用TermTree知识筛选出该类别高置信度的样本。
+- 利用词类关系检测类别与样本的一致性,比如,医疗类文本与“疾病损伤、药物、医疗卫生机构”等词类相关,可以利用 TermTree 知识筛选出该类别高置信度的样本。
-此外,统计模型容易拟合高频term,导致在低频term上泛化效果不好,这时可以利用TermTree筛选样本,提升样本平衡性,从而提升模型泛化能力。
+此外,统计模型容易拟合高频 term,导致在低频 term 上泛化效果不好,这时可以利用 TermTree 筛选样本,提升样本平衡性,从而提升模型泛化能力。
## 后续计划
-1. 发布百科知识树(TermTree)正式版数据,建立知识共建社区,支持用户提交应用词表/应用图谱 & 定制化TermTree, [TermTree下载链接](https://kg-concept.bj.bcebos.com/TermTree/TermTree.V1.0.tar.gz);
-2. 持续优化ERNIE-CTM预训练模型,支持多种参数规模模型发布,探索更好的适配中文解析挖掘任务的预训练模型;
+1. 发布百科知识树(TermTree)正式版数据,建立知识共建社区,支持用户提交应用词表/应用图谱 & 定制化 TermTree, [TermTree 下载链接](https://kg-concept.bj.bcebos.com/TermTree/TermTree.V1.0.tar.gz);
+2. 持续优化 ERNIE-CTM 预训练模型,支持多种参数规模模型发布,探索更好的适配中文解析挖掘任务的预训练模型;
3. 持续优化中文文本知识标注工具集,提供更加精准的知识标注服务;发布多粒度标注工具,支持更加丰富的应用场景。
## 在论文中引用解语
@@ -165,4 +165,4 @@ WordTag的标注结果中,区分了“人物类\_实体”和“人物类\_概
## 问题与反馈
-解语在持续优化中,如果您有任何建议或问题,欢迎提交issue到Github。
+解语在持续优化中,如果您有任何建议或问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/doc/img/ernie_ctm_inputs.png b/slm/examples/text_to_knowledge/doc/img/ernie_ctm_inputs.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/ernie_ctm_inputs.png
rename to slm/examples/text_to_knowledge/doc/img/ernie_ctm_inputs.png
diff --git a/legacy/examples/text_to_knowledge/doc/img/ernie_ctm_model.png b/slm/examples/text_to_knowledge/doc/img/ernie_ctm_model.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/ernie_ctm_model.png
rename to slm/examples/text_to_knowledge/doc/img/ernie_ctm_model.png
diff --git a/legacy/examples/text_to_knowledge/doc/img/text_to_knowledge.png b/slm/examples/text_to_knowledge/doc/img/text_to_knowledge.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/text_to_knowledge.png
rename to slm/examples/text_to_knowledge/doc/img/text_to_knowledge.png
diff --git a/legacy/examples/text_to_knowledge/doc/img/text_to_knowledge_example.png b/slm/examples/text_to_knowledge/doc/img/text_to_knowledge_example.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/text_to_knowledge_example.png
rename to slm/examples/text_to_knowledge/doc/img/text_to_knowledge_example.png
diff --git a/legacy/examples/text_to_knowledge/doc/img/wordtag_example.png b/slm/examples/text_to_knowledge/doc/img/wordtag_example.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/wordtag_example.png
rename to slm/examples/text_to_knowledge/doc/img/wordtag_example.png
diff --git a/legacy/examples/text_to_knowledge/doc/img/wordtag_model.png b/slm/examples/text_to_knowledge/doc/img/wordtag_model.png
similarity index 100%
rename from legacy/examples/text_to_knowledge/doc/img/wordtag_model.png
rename to slm/examples/text_to_knowledge/doc/img/wordtag_model.png
diff --git a/slm/examples/text_to_knowledge/ernie-ctm/README.md b/slm/examples/text_to_knowledge/ernie-ctm/README.md
new file mode 100644
index 000000000000..2715e6693b87
--- /dev/null
+++ b/slm/examples/text_to_knowledge/ernie-ctm/README.md
@@ -0,0 +1,167 @@
+
+# 解语:ERNIE-CTM(ERNIE for **Chinese Text Mining**)
+
+ERNIE-CTM 是适用于中文文本挖掘任务的预训练语言模型,拥有更全面的汉字字表集合,更优的中文文本挖掘任务表现,与 PaddleNLP 深度结合,提供更加便捷的应用实践。
+
+## ERNIE-CTM 特点
+
+- 全面的中文汉字字表扩充
+ - ERNIE-CTM 的字符集包含2万+汉字,以及中文常用符号(常用标点、汉语拼音、编号)、部分外语符号(假名、单位)等,大幅减少中文解析挖掘任务中 UNK(未识别字符)引发的标注问题。同时,ERNIE-CTM 使用了 embedding 分解,可以更加灵活地扩充应用字表。
+- 更加适配中文文本挖掘任务
+ - ERNIE-CTM 中在每个表示后面添加了全局信息,在序列特征上叠加了全局的信息,使得在文本挖掘任务上有更加强力的表现。
+- 支持多种特征训练的模型结构
+ - ERNIE-CTM 的模型结构中,支持多种特征训练,用户可按照自己的需求任意添加任务及对应特征训练模型,而无需考虑任务之间的冲突所造成的灾难性遗忘。
+
+
+
+## ERNIE-CTM 模型介绍
+
+### 模型结构
+
+ERNIE-CTM 的模型结构大体与 BERT 相同,都是双向 transformer 结构。区别是,ERNIE-CTM 为能灵活扩充字表,采用了 ALBERT 的 embedding 分解,将 embedding 层分解为128维,参数列表如下:
+
+| 模型 | embedding size | hidden size | hidden layers | vocab size |
+| -------------- | -------------- | ----------- | ------------- | ---------- |
+| ERNIE-CTM-base | 128 | 768 | 12 | 23000 |
+
+ERNIE-CTM 以字粒度建模,英文区分大小写,其输入表示如下:
+
+
+
+其中,`[CLS{n}]`是 ERNIE-CTM 预留出的全局观察位,其中`n`从0开始计数,该全局观察位用于不同的训练任务,建模不同的语义特征,在下游任务中,可以结合使用,如使用 attention 筛选/融合特征,以达到更好的效果。而在灵活使用`[CLS{n}]`的时候,为中途增减任务 token 时不影响文本输入,所有的`[CLS{n}]`的位置编码均为0,且可以使用可见性矩阵(visible matrix)控制`[CLS{n}]`位置的特征对序列中其他位置,以及其他的全局观察位的可见性,以获得更加灵活、独立的特征表示。
+
+本次开源的 ERNIE-CTM-base 模型中,使用了两个全局观察位`[CLS0]`和`[CLS1]`,具体作用见下文预训练任务介绍。
+
+### 预训练任务
+
+ERNIE-CTM 使用的预训练任务为掩码语言模型(Masked Language Model,MLM)及 ALBERT 所使用的句子顺序预测(Sentence Order Prediction,SOP)。
+
+其中`[CLS0]`用于训练 SOP 任务,训练方式如 ALBERT 中描述,正例为同一篇文章中的两个连续的句子,负例为用一篇文章中两个连续的句子顺序翻转。
+
+`[CLS1]`做为全局的监督信号,应用于 MLM 任务中。训练 MLM 任务前,将`[CLS1]`特征表示拼接在所有的序列表示之后,通过线性层融合,成为最终的序列表示,之后预测 MLM 任务。所以,ERNIE-CTM 最终输出的文本序列表示中,都融合了`[CLS1]`的特征表示。最终的序列表示中,带有全句的特征,一定程度可避免序列中全局特征捕捉不足,同时,`[CLS1]`最终的表示中也充分融合了句子内容的信息,弥补了 SOP 任务对文本主题信息捕捉不足的缺陷。
+
+
+
+### WordTag 增量训练
+
+在 Ernie-Ctm 微调任务中我们提供了一个基于[WordTag](../wordtag)的百科知识标注任务,该任务旨在解析中文词汇的知识标注,在该词性体系中覆盖了所有中文词汇的词类体系,包括各类实体词与非实体词(如概念、实体/专名、语法词等)。除了使用已有的 WordTag 工具对通用中文文本进行词类知识标注,WordTag 同样支持用户使用自己的数据进行增量训练,下面是在 WordTag 模型上进行增量训练的具体示例流程。
+
+#### 代码结构说明
+
+```text
+wordtag/
+├── data.py # 训练数据处理脚本
+├── metric.py # 模型效果验证指标脚本
+├── predict.py # 预测脚本
+├── README.md # 使用说明
+├── train.py # 训练脚本
+└── utils.py # 工具函数
+```
+
+#### 数据准备
+
+我们提供了少数样本用以示例增量训练。执行以下命令,下载并解压示例数据集:
+
+```bash
+wget https://bj.bcebos.com/paddlenlp/datasets/wordtag_dataset_v3.tar.gz && tar -zxvf wordtag_dataset_v3.tar.gz
+```
+解压之后
+
+```text
+data/
+├── dev.txt # 验证集
+├── tags.txt # WordTag标签集合
+└── train.json # 训练数据
+```
+
+训练样本示例如下,每个单词以"/type"的形式标记其词性或实体类别,单词之间使用空格作为切分标记
+
+```text
+砚台/物体类 与/连词 笔/物体类 、/w 墨/物体类 、/w 纸/物体类 是/肯定词 中国/世界地区类 传统/修饰词 的/助词 文房四宝/词汇用语 。/w
+《/w 全球化与中国:理论与发展趋势/作品类_实体 》/w 是/肯定词 2010年/时间类 经济管理出版社/组织机构类 出版/场景事件 的/助词 图书/作品类_概念 ,/w 作者/人物类_概念 是/肯定词 余永定/人物类_实体 、/w 路爱国/人物类_实体 、/w 高海红/人物类_实体 。/w
+```
+
+#### 模型训练
+
+```shell
+python -m paddle.distributed.launch --gpus "0" train.py \
+ --max_seq_len 128 \
+ --batch_size 32 \
+ --learning_rate 5e-5 \
+ --num_train_epochs 3 \
+ --logging_steps 10 \
+ --save_steps 100 \
+ --output_dir ./output \
+ --device "gpu"
+```
+
+其中参数释义如下:
+- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
+- `batch_size` 表示每次迭代**每张卡**上的样本数目。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `num_train_epochs` 表示训练轮数。
+- `logging_steps` 表示日志打印间隔。
+- `save_steps` 表示模型保存及评估间隔。
+- `output_dir` 表示模型保存路径。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
+
+
+
+### 模型预测
+
+```shell
+export CUDA_VISIBLE_DEVICES=0
+python -m paddle.distributed.launch --gpus "0" predict.py \
+ --params_path ./output/model_300/model_state.pdparams \
+ --batch_size 32 \
+ --device "gpu"
+```
+
+## 自定义模型一键预测
+
+Taskflow 支持加载增量训练后的模型进行一键预测,通过`task_path`定义用户自定义路径即可。
+
+文件组成:
+```text
+custom_task_path/
+├── model_state.pdparams
+├── model_config.json
+└── tags.txt
+```
+
+```python
+from paddlenlp import Taskflow
+
+my_wordtag = Taskflow("knowledge_mining", task_path="./custom_task_path/")
+
+my_wordtag("美人鱼是周星驰执导的一部电影")
+# [{'text': '美人鱼是周星驰执导的一部电影', 'items': [{'item': '美人鱼', 'offset': 0, 'wordtag_label': '作品类_实体', 'length': 3, 'termid': '作品与出版物_eb_美人鱼'}, {'item': '是', 'offset': 3, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '周星驰', 'offset': 4, 'wordtag_label': '人物类_实体', 'length': 3, 'termid': '人物_eb_周星驰'}, {'item': '执导', 'offset': 7, 'wordtag_label': '场景事件', 'length': 2, 'termid': '场景事件_cb_执导'}, {'item': '的', 'offset': 9, 'wordtag_label': '助词', 'length': 1, 'termid': '助词_cb_的'}, {'item': '一部', 'offset': 10, 'wordtag_label': '数量词', 'length': 2}, {'item': '电影', 'offset': 12, 'wordtag_label': '作品类_概念', 'length': 2, 'termid': '影视作品_cb_电影'}]}]
+```
+
+
+## ERNIE-CTM 后续计划
+
+
+1. 提升预训练语料的多样性(开源版主要使用了百度百科语料),持续优化预训练模型
+2. 发布其他参数量的预训练模型(tiny、large 等),便于不同场景应用
+3. 维护开源社区,探索模型优化方向,整合优秀 idea
+
+
+
+## 在论文中引用 ERNIE-CTM
+
+如果您的工作成果中使用了 ERNIE-CTM,请增加下述引用。我们非常乐于看到 ERNIE-CTM 对您的工作带来帮助。
+```
+@article{zhao2020TermTree,
+ title={TermTree and Knowledge Annotation Framework for Chinese Language Understanding},
+ author={Zhao, Min and Qin, Huapeng and Zhang, Guoxin and Lyu, Yajuan and Zhu, Yong},
+ technical report={Baidu, Inc. TR:2020-KG-TermTree},
+ year={2020}
+}
+```
+
+
+
+## 问题与反馈
+
+ERNIE-CTM 在持续优化中,如果您有任何建议或问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/data_process.py b/slm/examples/text_to_knowledge/ernie-ctm/data_process.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/ernie-ctm/data_process.py
rename to slm/examples/text_to_knowledge/ernie-ctm/data_process.py
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/metric.py b/slm/examples/text_to_knowledge/ernie-ctm/metric.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/ernie-ctm/metric.py
rename to slm/examples/text_to_knowledge/ernie-ctm/metric.py
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/predict.py b/slm/examples/text_to_knowledge/ernie-ctm/predict.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/ernie-ctm/predict.py
rename to slm/examples/text_to_knowledge/ernie-ctm/predict.py
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/train.py b/slm/examples/text_to_knowledge/ernie-ctm/train.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/ernie-ctm/train.py
rename to slm/examples/text_to_knowledge/ernie-ctm/train.py
diff --git a/legacy/examples/text_to_knowledge/ernie-ctm/utils.py b/slm/examples/text_to_knowledge/ernie-ctm/utils.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/ernie-ctm/utils.py
rename to slm/examples/text_to_knowledge/ernie-ctm/utils.py
diff --git a/legacy/examples/text_to_knowledge/nptag/README.md b/slm/examples/text_to_knowledge/nptag/README.md
similarity index 64%
rename from legacy/examples/text_to_knowledge/nptag/README.md
rename to slm/examples/text_to_knowledge/nptag/README.md
index aece4d724dfc..23c2d76cfa61 100644
--- a/legacy/examples/text_to_knowledge/nptag/README.md
+++ b/slm/examples/text_to_knowledge/nptag/README.md
@@ -1,19 +1,19 @@
# 解语:NPTag(名词短语标注工具)
-NPTag(名词短语标注工具)是首个能够覆盖所有中文名词性词汇及短语的细粒度知识标注工具,旨在解决NLP中,名词性短语收录不足,导致的OOV(out-of-vocabulary,超出收录词表)问题。可直接应用构造知识特征,辅助NLP任务。
+NPTag(名词短语标注工具)是首个能够覆盖所有中文名词性词汇及短语的细粒度知识标注工具,旨在解决 NLP 中,名词性短语收录不足,导致的 OOV(out-of-vocabulary,超出收录词表)问题。可直接应用构造知识特征,辅助 NLP 任务。
-## NPTag特点
+## NPTag 特点
- 包含2000+细粒度类别,覆盖所有中文名词性短语的词类体系,更丰富的知识标注结果
- - NPTag试用的词类体系未覆盖所有中文名词性短语的词类体系,对所有类目做了更细类目的识别(如注射剂、鱼类、博物馆等),共包含2000+细粒度类别,且可以直接关联百科知识树。
+ - NPTag 试用的词类体系未覆盖所有中文名词性短语的词类体系,对所有类目做了更细类目的识别(如注射剂、鱼类、博物馆等),共包含2000+细粒度类别,且可以直接关联百科知识树。
- 可自由定制的分类框架
- - NPTag开源版标注使用的词类体系是我们在实践中对**百科词条**分类应用较好的一个版本,用户可以自由定制自己的词类体系和训练样本,构建自己的NPTag,以获得更好的适配效果。例如,可按照自定义的类别构造训练样本,使用小学习率、短训练周期微调NPTag模型,即可获得自己定制的NPTag工具。
+ - NPTag 开源版标注使用的词类体系是我们在实践中对**百科词条**分类应用较好的一个版本,用户可以自由定制自己的词类体系和训练样本,构建自己的 NPTag,以获得更好的适配效果。例如,可按照自定义的类别构造训练样本,使用小学习率、短训练周期微调 NPTag 模型,即可获得自己定制的 NPTag 工具。
-## NPTag模型介绍
+## NPTag 模型介绍
-NPTag使用[ERNIE-CTM](../ernie-ctm)+prompt训练而成,使用启发式搜索解码,保证分类结果都在标签体系之内。
+NPTag 使用[ERNIE-CTM](../ernie-ctm)+prompt 训练而成,使用启发式搜索解码,保证分类结果都在标签体系之内。
-### finetune任务
+### finetune 任务
在微调任务中提供了一个中文名词短语标注的任务,旨在对中文名词短语进行细粒度分类。
@@ -56,7 +56,7 @@ data/
罗伯特·布雷森 人
```
-标签文件`name_category_map.json`格式示例,其中key为细粒度标签,即NPTag的预测结果;value为粗粒度标签,示例中对应WordTag的标签集合,用户可以根据场景需要自定义修改该标签映射
+标签文件`name_category_map.json`格式示例,其中 key 为细粒度标签,即 NPTag 的预测结果;value 为粗粒度标签,示例中对应 WordTag 的标签集合,用户可以根据场景需要自定义修改该标签映射
```
{
"植物": "生物类_植物",
@@ -78,20 +78,20 @@ python -m paddle.distributed.launch --gpus "0" train.py \
```
可支持配置的参数:
-- `data_dir`: 数据集文件路径,默认数据集存放在当前目录data文件夹下。
-- `init_from_ckpt`: 模型参数路径,热启动模型训练,默认为None。
-- `output_dir`: 模型保存路径,默认保存在当前目录的output文件夹下。
+- `data_dir`: 数据集文件路径,默认数据集存放在当前目录 data 文件夹下。
+- `init_from_ckpt`: 模型参数路径,热启动模型训练,默认为 None。
+- `output_dir`: 模型保存路径,默认保存在当前目录的 output 文件夹下。
- `max_seq_len`: 模型使用的最大序列长度,默认为64。
-- `learning_rate`: finetune的最大学习率;默认为1e-6。
+- `learning_rate`: finetune 的最大学习率;默认为1e-6。
- `num_train_epochs`: 表示训练轮数,默认为3。
- `logging_steps`: 日志打印步数间隔,默认为10。
- `save_steps`: 模型保存的步数间隔, 默认为100。
- `batch_size`: 批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为64。
- `weight_decay`: 控制正则项力度的参数,用于防止过拟合,默认为0.0。
-- `warmup_proportion`: 学习率warmup策略的比例,如果0.1,则学习率会在前10%训练step的过程中从0慢慢增长到learning_rate, 而后再缓慢衰减,默认为0.0。
-- `adam_epsilon`: Adam优化器的参数,避免分母为零,默认为1e-8。
+- `warmup_proportion`: 学习率 warmup 策略的比例,如果0.1,则学习率会在前10%训练 step 的过程中从0慢慢增长到 learning_rate, 而后再缓慢衰减,默认为0.0。
+- `adam_epsilon`: Adam 优化器的参数,避免分母为零,默认为1e-8。
- `seed`: 随机种子,默认为1000。
-- `device`: 选用什么设备进行训练,可选cpu或gpu。如使用gpu训练则参数gpus指定GPU卡号。
+- `device`: 选用什么设备进行训练,可选 cpu 或 gpu。如使用 gpu 训练则参数 gpus 指定 GPU 卡号。
### 基于动态图的预测
@@ -109,14 +109,14 @@ python -m paddle.distributed.launch --gpus "0" predict.py \
python export_model.py --params_path=./output/model_100/model_state.pdparams --output_path=./export
```
-导出静态图模型之后,可以用于部署,`deploy/python/predict.py`脚本提供了python部署预测示例。运行方式:
+导出静态图模型之后,可以用于部署,`deploy/python/predict.py`脚本提供了 python 部署预测示例。运行方式:
```shell
python deploy/python/predict.py --model_dir=./export
```
-## Taskflow一键预测
+## Taskflow 一键预测
-除了以上的finetune示例,Taskflow内置了一个百度基于大规模标注汉语短语数据集训练的名词短语标注工具`NPTag`。用户可以方便地使用该工具完成对中文名词短语的一键预测。
+除了以上的 finetune 示例,Taskflow 内置了一个百度基于大规模标注汉语短语数据集训练的名词短语标注工具`NPTag`。用户可以方便地使用该工具完成对中文名词短语的一键预测。
```python
from paddlenlp import Taskflow
@@ -141,9 +141,9 @@ nptag(["糖醋排骨", "红曲霉菌"])
'''
```
-## 在论文中引用NPTag
+## 在论文中引用 NPTag
-如果您的工作成果中使用了NPTag,请增加下述引用。我们非常乐于看到解语对您的工作带来帮助。
+如果您的工作成果中使用了 NPTag,请增加下述引用。我们非常乐于看到解语对您的工作带来帮助。
```
@article{zhao2020TermTree,
@@ -157,4 +157,4 @@ nptag(["糖醋排骨", "红曲霉菌"])
## 问题与反馈
-解语在持续优化中,如果您有任何建议或问题,欢迎提交issue到Github。
+解语在持续优化中,如果您有任何建议或问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/nptag/data.py b/slm/examples/text_to_knowledge/nptag/data.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/nptag/data.py
rename to slm/examples/text_to_knowledge/nptag/data.py
diff --git a/legacy/examples/text_to_knowledge/nptag/deploy/python/predict.py b/slm/examples/text_to_knowledge/nptag/deploy/python/predict.py
similarity index 99%
rename from legacy/examples/text_to_knowledge/nptag/deploy/python/predict.py
rename to slm/examples/text_to_knowledge/nptag/deploy/python/predict.py
index 8afc4d4f2f09..a0094b4d4673 100644
--- a/legacy/examples/text_to_knowledge/nptag/deploy/python/predict.py
+++ b/slm/examples/text_to_knowledge/nptag/deploy/python/predict.py
@@ -131,7 +131,7 @@ def predict(self, data, tokenizer):
result["label"] = labels_can[0][0]
else:
result["label"] = None
-
+
if result["label"] in name_dict:
result["category"] = name_dict[result["label"]]
else:
diff --git a/legacy/examples/text_to_knowledge/nptag/export_model.py b/slm/examples/text_to_knowledge/nptag/export_model.py
similarity index 99%
rename from legacy/examples/text_to_knowledge/nptag/export_model.py
rename to slm/examples/text_to_knowledge/nptag/export_model.py
index 7956b0032260..7a76f842c2bc 100644
--- a/legacy/examples/text_to_knowledge/nptag/export_model.py
+++ b/slm/examples/text_to_knowledge/nptag/export_model.py
@@ -16,6 +16,7 @@
import os
import paddle
+
from paddlenlp.transformers import ErnieCtmNptagModel
# yapf: disable
diff --git a/legacy/examples/text_to_knowledge/nptag/metric.py b/slm/examples/text_to_knowledge/nptag/metric.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/nptag/metric.py
rename to slm/examples/text_to_knowledge/nptag/metric.py
diff --git a/legacy/examples/text_to_knowledge/nptag/predict.py b/slm/examples/text_to_knowledge/nptag/predict.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/nptag/predict.py
rename to slm/examples/text_to_knowledge/nptag/predict.py
diff --git a/legacy/examples/text_to_knowledge/nptag/train.py b/slm/examples/text_to_knowledge/nptag/train.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/nptag/train.py
rename to slm/examples/text_to_knowledge/nptag/train.py
diff --git a/legacy/examples/text_to_knowledge/nptag/utils.py b/slm/examples/text_to_knowledge/nptag/utils.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/nptag/utils.py
rename to slm/examples/text_to_knowledge/nptag/utils.py
diff --git a/legacy/examples/text_to_knowledge/termtree/README.md b/slm/examples/text_to_knowledge/termtree/README.md
similarity index 52%
rename from legacy/examples/text_to_knowledge/termtree/README.md
rename to slm/examples/text_to_knowledge/termtree/README.md
index 7fd126b43fed..c2e1f7aae61f 100644
--- a/legacy/examples/text_to_knowledge/termtree/README.md
+++ b/slm/examples/text_to_knowledge/termtree/README.md
@@ -1,36 +1,36 @@
# 解语:TermTree(百科知识树)
-TermTree(百科知识树)是一个描述所有中文词汇(包括概念、实体/专名、领域术语、语法词等,统一称之为Term)的树状知识库,完整的TermTree由两部分构成:
+TermTree(百科知识树)是一个描述所有中文词汇(包括概念、实体/专名、领域术语、语法词等,统一称之为 Term)的树状知识库,完整的 TermTree 由两部分构成:
-> I. TermType词类体系:覆盖所有中文词汇词类的树状知识体系,是对中文词汇集合的一种全划分层次表示;
+> I. TermType 词类体系:覆盖所有中文词汇词类的树状知识体系,是对中文词汇集合的一种全划分层次表示;
>
-> II. Term关系和属性值:描述具体Term之间关系和Term属性值网状图谱,用于整合各应用知识图谱;
+> II. Term 关系和属性值:描述具体 Term 之间关系和 Term 属性值网状图谱,用于整合各应用知识图谱;
-本次发布的TermTreeV1.0试用版是TermTree的一个常用子集,包括两部分内容:
+本次发布的 TermTreeV1.0试用版是 TermTree 的一个常用子集,包括两部分内容:
-> A. 简化版的TermType词类体系,由160+ termtype(三层结构)和 7000+ subtype构成。
+> A. 简化版的 TermType 词类体系,由160+ termtype(三层结构)和 7000+ subtype 构成。
>
-> B. 约100w的term集(挂接在TermType词类体系下),包括大多数常用概念(src=cb,基础概念库,termtype准确率为98%)和一部分高频百科实体(src=eb,基础实体库,termtype准确率为95%)。
+> B. 约100w 的 term 集(挂接在 TermType 词类体系下),包括大多数常用概念(src=cb,基础概念库,termtype 准确率为98%)和一部分高频百科实体(src=eb,基础实体库,termtype 准确率为95%)。
>
-> 开源版不包括Term关系和属性值,但给出了实体的百科词条链接,应用方可以利用百科链接整合其他知识图谱使用。
+> 开源版不包括 Term 关系和属性值,但给出了实体的百科词条链接,应用方可以利用百科链接整合其他知识图谱使用。
-我们提供了TermTreeV1.0试用版的下载链接供大家使用,[下载链接](https://kg-concept.bj.bcebos.com/TermTree/TermTree.V1.0.tar.gz) 。
+我们提供了 TermTreeV1.0试用版的下载链接供大家使用,[下载链接](https://kg-concept.bj.bcebos.com/TermTree/TermTree.V1.0.tar.gz) 。
-**注:** 与其他常见应用知识图谱不同,TermTree的核心是概念词,而非专名实体词。因为,在中文文本中,概念词的含义是相对稳定的,而专名实体词随应用变化(例如,不同电商有不同的商品实体集,不同的小说站有不同的小说实体集),因此,TermTree通过 “提供常用概念集 + 可插拔的应用实体集/应用知识图谱” 来达到支持不同的应用适配。
+**注:** 与其他常见应用知识图谱不同,TermTree 的核心是概念词,而非专名实体词。因为,在中文文本中,概念词的含义是相对稳定的,而专名实体词随应用变化(例如,不同电商有不同的商品实体集,不同的小说站有不同的小说实体集),因此,TermTree 通过 “提供常用概念集 + 可插拔的应用实体集/应用知识图谱” 来达到支持不同的应用适配。
-## 自定义TermTree
+## 自定义 TermTree
-`termtree.py`文件中的TermTree类支持TermTree的加载、增加、保存操作,因为涉及到数据结构整体性和一致性,暂不支持删除和修改操作。下面提供了离线维护自定义TermTree的代码示例
+`termtree.py`文件中的 TermTree 类支持 TermTree 的加载、增加、保存操作,因为涉及到数据结构整体性和一致性,暂不支持删除和修改操作。下面提供了离线维护自定义 TermTree 的代码示例
### 文件准备
-首先下载已有的TermTreeV1.0
+首先下载已有的 TermTreeV1.0
```shell
wget https://kg-concept.bj.bcebos.com/TermTree/TermTree.V1.0.tar.gz && tar -zxvf TermTree.V1.0.tar.gz
```
-### TermTree维护与修改
+### TermTree 维护与修改
-加载TermTreeV1.0,增加新的term
+加载 TermTreeV1.0,增加新的 term
```python
from termtree import TermTree
@@ -46,26 +46,26 @@ termtree.add_term(term="平原上的火焰",
termtree.save("./")
```
-#### API说明
+#### API 说明
- ```python
def add_term()
```
- **参数**
- - term (str): 待增加的term名称。
- - base (str): term属于概念词(cb)还是实体词(eb)。
- - term_type (str): term的主类别。
- - sub_type (Optional[List[str]], optional): term的辅助类别或细分类别,非必选。
- - sub_terms (Optional[List[str]], optional): 用于描述同类同名的term集,非必选。
- - alias (Optional[List[str]], optional): term的常用别名,非必选。
- - alias_ext (Optional[List[str]], optional): term的常用扩展别名,非必选。
- - data (Optional[Dict[str, Any]], optional): 以dict形式构造该term节点,非必选。
+ - term (str): 待增加的 term 名称。
+ - base (str): term 属于概念词(cb)还是实体词(eb)。
+ - term_type (str): term 的主类别。
+ - sub_type (Optional[List[str]], optional): term 的辅助类别或细分类别,非必选。
+ - sub_terms (Optional[List[str]], optional): 用于描述同类同名的 term 集,非必选。
+ - alias (Optional[List[str]], optional): term 的常用别名,非必选。
+ - alias_ext (Optional[List[str]], optional): term 的常用扩展别名,非必选。
+ - data (Optional[Dict[str, Any]], optional): 以 dict 形式构造该 term 节点,非必选。
-### 自定义Term-Linking
+### 自定义 Term-Linking
-Taskflow支持使用自定义TermTree实现自定义Term-Linking,该示例中"平原上的火焰"的Term-Linking如下:
+Taskflow 支持使用自定义 TermTree 实现自定义 Term-Linking,该示例中"平原上的火焰"的 Term-Linking 如下:
作品类_实体(wordtag_label) -> 影视作品_eb_平原上的火焰(term_id)
通过`task_path`定义用户自定义路径,文件组成:
@@ -75,7 +75,7 @@ custom_task_path/
└── termtree_data
```
-使用Taskflow加载自定义TermTree来进行预测:
+使用 Taskflow 加载自定义 TermTree 来进行预测:
```python
from paddlenlp import Taskflow
@@ -88,38 +88,38 @@ wordtag("《平原上的火焰》是今年新上映的电影")
## 常见问题
-**常见问题1:为什么TermTree采用树状结构(Tree),而不是网状结构(Net/Graph)?**
+**常见问题1:为什么 TermTree 采用树状结构(Tree),而不是网状结构(Net/Graph)?**
- 树结构是对知识空间的全划分,网状结构是对相关关系的描述和提炼。树结构更方便做到对词类体系的全面描述。
- 树结构适合概念层次的泛化推理,网状结构适合相关性的泛化推理。树结构的知识对统计相关知识有很好的互补作用,在应用中能够更好地弥补统计模型的不足。
-- 两者可以结合表示和使用:Term集合整体以树结构组织(TermType词类体系),Term间的关系用网状结构描述(Term关系和属性值)。可以将TermTree视为中文词汇的层次描述框架,应用知识图谱可以基于TermType词类体系方便地整合到TermTree。
+- 两者可以结合表示和使用:Term 集合整体以树结构组织(TermType 词类体系),Term 间的关系用网状结构描述(Term 关系和属性值)。可以将 TermTree 视为中文词汇的层次描述框架,应用知识图谱可以基于 TermType 词类体系方便地整合到 TermTree。
-**常见问题2:为什么TermTree叫做百科知识树?是否只能用于描述百科知识?**
+**常见问题2:为什么 TermTree 叫做百科知识树?是否只能用于描述百科知识?**
-- 一方面,Term可以泛指任意概念、实体/专名、领域术语、语法词等,用“百科”是为了表达Term的多样性,而不是限定Term的来源,Term可以来自任意中文文本;
+- 一方面,Term 可以泛指任意概念、实体/专名、领域术语、语法词等,用“百科”是为了表达 Term 的多样性,而不是限定 Term 的来源,Term 可以来自任意中文文本;
- 另一方面,各类别的词汇都可以在百科词条中找到样例,用“百科”也是为了表示对所有中文词汇词类的描述能力。
**常见问题3:中文词汇词类描述体系有很多,为什么采用这个体系?**
-- TermTree的词类体系是在大规模工业应用实践(如百科文本解析挖掘、query理解)中打磨出来的中文词类体系,在理论上可能不是一个完备体系,但很适合通用领域中文解析挖掘任务。
+- TermTree 的词类体系是在大规模工业应用实践(如百科文本解析挖掘、query 理解)中打磨出来的中文词类体系,在理论上可能不是一个完备体系,但很适合通用领域中文解析挖掘任务。
-## TermTree字段说明
+## TermTree 字段说明
| 字段 | 说明 | 备注 |
| ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| id | 【必有】唯一标识符 | 可基于termid生成 |
-| term | 【必有】term的名字 | |
-| termid | 【必有】term的id(唯一),构造方式为termtype_src_term | 采用显式构造id的方式,便于应用数据扩展和整合 |
-| src | 【必有】term的来源库,当前包括两个基础库cb和eb。其中cb为基础概念库(concept base,收录常用词汇用语,可作为各类应用的基础集),eb为基础实体库(entity base, 收录常见命名实体,可根据应用需求扩展) | cb、eb的划分标准不同应用不一样,可根据需求调整;应用方也可以构造自己的应用库,与cb、eb整合使用。 |
-| termtype | 【必有】term的主类别,详细描述参见 [termtree\_type](./termtree_type.csv) | 多上位的term会选择其中一个作为termtype,其他上位作为subtype,方便应用筛选 |
-| subtype | 【非必须】term的辅助类别或细分类别 | 如果应用特别关注某个subtype,也可以将其升级为termtype使用(需要相应更新termid和id) |
-| subterms | 【非必须】用于描述同类同名的term集,若“termtype+src”下term只对应一个实例,则subterms为空;若“termtype+src”下term对应多个实例,则subterms记录这些实例,其字段与term相同 | 不需要区分subterm的两种常见场景:1. 应用只需词类特征;2. 上下文信息不足,无法区分具体实例 |
-| subterms_num | 【非必须】subterms中的subterm数量 | 如果没有subterm,则值为0 |
-| alias | 【非必须】term的常用别名 | 通常为歧义小的别名 |
-| alias\_ext | 【非必须】term的常用扩展别名,经常是term或alias的一个子片段,单独出现有其他含义,结合上下文可识别为别名。 | 通常为歧义大的别名,便于应用筛选使用。e.g., 四维彩超的alias_ext“四维” |
-| links | 【非必须】该term对应的其他term的id,可以是本知识库中的id,也可以是其他知识库如百度百科id | 如果是本知识库中的id,则表示两者可以指代同一实体 |
+| id | 【必有】唯一标识符 | 可基于 termid 生成 |
+| term | 【必有】term 的名字 | |
+| termid | 【必有】term 的 id(唯一),构造方式为 termtype_src_term | 采用显式构造 id 的方式,便于应用数据扩展和整合 |
+| src | 【必有】term 的来源库,当前包括两个基础库 cb 和 eb。其中 cb 为基础概念库(concept base,收录常用词汇用语,可作为各类应用的基础集),eb 为基础实体库(entity base, 收录常见命名实体,可根据应用需求扩展) | cb、eb 的划分标准不同应用不一样,可根据需求调整;应用方也可以构造自己的应用库,与 cb、eb 整合使用。 |
+| termtype | 【必有】term 的主类别,详细描述参见 [termtree\_type](./termtree_type.csv) | 多上位的 term 会选择其中一个作为 termtype,其他上位作为 subtype,方便应用筛选 |
+| subtype | 【非必须】term 的辅助类别或细分类别 | 如果应用特别关注某个 subtype,也可以将其升级为 termtype 使用(需要相应更新 termid 和 id) |
+| subterms | 【非必须】用于描述同类同名的 term 集,若“termtype+src”下 term 只对应一个实例,则 subterms 为空;若“termtype+src”下 term 对应多个实例,则 subterms 记录这些实例,其字段与 term 相同 | 不需要区分 subterm 的两种常见场景:1. 应用只需词类特征;2. 上下文信息不足,无法区分具体实例 |
+| subterms_num | 【非必须】subterms 中的 subterm 数量 | 如果没有 subterm,则值为0 |
+| alias | 【非必须】term 的常用别名 | 通常为歧义小的别名 |
+| alias\_ext | 【非必须】term 的常用扩展别名,经常是 term 或 alias 的一个子片段,单独出现有其他含义,结合上下文可识别为别名。 | 通常为歧义大的别名,便于应用筛选使用。e.g., 四维彩超的 alias_ext“四维” |
+| links | 【非必须】该 term 对应的其他 term 的 id,可以是本知识库中的 id,也可以是其他知识库如百度百科 id | 如果是本知识库中的 id,则表示两者可以指代同一实体 |
## 数据示例
```json
@@ -209,19 +209,19 @@ wordtag("《平原上的火焰》是今年新上映的电影")
}
```
-## TermTree特点
+## TermTree 特点
1. 将所有中文词汇放在一个统一类别体系下表示,包括**概念、实体/专名、领域术语、语法词**。
- 解决传统标注技术下(e.g., 词性标注、命名实体识别),概念、实体、词性特征难以统一计算的问题。
- 2. 为中文精准解析挖掘服务的词汇类别体系,以全面覆盖**百科词条、搜索query、新闻资讯**中出现的中文词汇为目标,支持通用场景文本理解。
- - 应用可以通过指定词表的TermType,方便地整合到TermTree中,定制应用特化版。
+ 2. 为中文精准解析挖掘服务的词汇类别体系,以全面覆盖**百科词条、搜索 query、新闻资讯**中出现的中文词汇为目标,支持通用场景文本理解。
+ - 应用可以通过指定词表的 TermType,方便地整合到 TermTree 中,定制应用特化版。
3. 尽可能收录常用概念词,并区分常用概念词(src=cb)和专名实体词(src=eb),以解决专名实体与概念在计算中容易混淆的问题。为此,特别补充收录了很多百科中缺少的概念词。
- 例:“琴房(歌曲类实体)” VS. “琴房(区域场所类概念)”
- 例:“甩掉(歌曲类实体)” VS. “甩掉(场景事件类概念)”
- 4. 将同类同名实体拆分为term和subterm两层(参见数据示例),term作为给定termtype下所有同名实体的表示,subterm作为同类同名实体集中每一个具体实体的表示:
+ 4. 将同类同名实体拆分为 term 和 subterm 两层(参见数据示例),term 作为给定 termtype 下所有同名实体的表示,subterm 作为同类同名实体集中每一个具体实体的表示:
- 一方面解决文本中信息不足无法区分具体实体时的标注问题;
- 一方面减少同名词汇的消歧计算代价(只需要计算同类下的同名实体,有效解决概念词和实体词识别混淆的问题)
@@ -232,7 +232,7 @@ wordtag("《平原上的火焰》是今年新上映的电影")
|苹果 | 植物类|cb|苹果 → 苹果属 → 蔷薇科 → 蔷薇目 → 双子叶植物纲 → 被子植物门 → 种子植物 → 植物界 → 真核生物域 → 生物|
| 黄香蕉苹果| 饮食类|cb|黄香蕉苹果 →苹果 →水果 → 蔬果和菌藻类 →食材 →食物 →饮食|
|甲型流感 | 疾病类|cb|甲型流感 → 流行性感冒 → 感冒 → 呼吸道感染 → 呼吸系统疾病 → 疾病损伤 → 生物疾病|
- |甲型流感病毒| 微生物类|cb|甲型流感病毒 → 流行性感冒病毒 → 正粘病毒科 → RNA病毒 → 生物病毒 → 病原微生物 → 微生物 → 生物|
+ |甲型流感病毒| 微生物类|cb|甲型流感病毒 → 流行性感冒病毒 → 正粘病毒科 → RNA 病毒 → 生物病毒 → 病原微生物 → 微生物 → 生物|
|琴房| 区域场所类|cb|琴房 → 音乐室 → 活动室 →活动场所 →区域场所|
|琴房| 音乐类|eb|琴房 → 歌曲 →音乐作品 →艺术作品 →作品 → 作品与出版物|
|认同感 | 生活用语类|cb|认同感 →正面感受 → 感受 → 知觉感受 → 个体描述 → 生活用语|
@@ -241,22 +241,22 @@ wordtag("《平原上的火焰》是今年新上映的电影")
|佛罗伦萨市 | 世界地区类|cb|佛罗伦萨市 →托斯卡纳大区 →意大利 →南欧 →欧洲 →地球区域 →世界地区|
|言情小说 | 小说类|cb|言情小说 →情感小说 →小说 →文学作品 →作品 →作品与出版物|
| 言情小说| 音乐类|eb|言情小说 → 歌曲 →音乐作品 →艺术作品 →作品 → 作品与出版物|
-> **注:** TermType词类体系可视为所有上位归类路径的集合。
+> **注:** TermType 词类体系可视为所有上位归类路径的集合。
-## TermTree应用方式
+## TermTree 应用方式
-1. 直接作为词表使用,利用termtype和subtype筛选应用所需的词表(停用词表、黑白名单、概念扩展词表等)。
-2. 结合中文文本知识标注工具(WordTag等)使用,用于文本词类特征生成、挖掘/解析pattern生成、样本构建和优化等等,参见"[解语的应用场景](../)"。
+1. 直接作为词表使用,利用 termtype 和 subtype 筛选应用所需的词表(停用词表、黑白名单、概念扩展词表等)。
+2. 结合中文文本知识标注工具(WordTag 等)使用,用于文本词类特征生成、挖掘/解析 pattern 生成、样本构建和优化等等,参见"[解语的应用场景](../)"。
3. 整合应用知识图谱,为应用知识图谱提供通用词汇知识补充。
-## TermTree后续规划
+## TermTree 后续规划
-1. 数据覆盖扩展到全量百度百科词条,提升TermType归类准确率,便于应用方筛选构建应用适配的TermTree;
-2. 建立知识共建社区,支持用户提交自己的term词表,生成定制版TermTree。
+1. 数据覆盖扩展到全量百度百科词条,提升 TermType 归类准确率,便于应用方筛选构建应用适配的 TermTree;
+2. 建立知识共建社区,支持用户提交自己的 term 词表,生成定制版 TermTree。
-## 在论文中引用TermTree
-如果您的工作成果中使用了TermTree,请增加下述引用。我们非常乐于看到TermTree对您的工作带来帮助。
+## 在论文中引用 TermTree
+如果您的工作成果中使用了 TermTree,请增加下述引用。我们非常乐于看到 TermTree 对您的工作带来帮助。
```
@article{zhao2020TermTree,
title={TermTree and Knowledge Annotation Framework for Chinese Language Understanding},
@@ -268,4 +268,4 @@ wordtag("《平原上的火焰》是今年新上映的电影")
## 问题与反馈
-百科知识树在持续扩充优化中,如果您有任何建议或发现数据问题,欢迎提交issue到Github。
+百科知识树在持续扩充优化中,如果您有任何建议或发现数据问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/termtree/termtree.py b/slm/examples/text_to_knowledge/termtree/termtree.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/termtree/termtree.py
rename to slm/examples/text_to_knowledge/termtree/termtree.py
diff --git a/legacy/examples/text_to_knowledge/termtree/termtree_type.csv b/slm/examples/text_to_knowledge/termtree/termtree_type.csv
similarity index 100%
rename from legacy/examples/text_to_knowledge/termtree/termtree_type.csv
rename to slm/examples/text_to_knowledge/termtree/termtree_type.csv
diff --git a/legacy/examples/text_to_knowledge/wordtag-ie/README.md b/slm/examples/text_to_knowledge/wordtag-ie/README.md
similarity index 85%
rename from legacy/examples/text_to_knowledge/wordtag-ie/README.md
rename to slm/examples/text_to_knowledge/wordtag-ie/README.md
index fd75d6670da3..8099665f06a0 100644
--- a/legacy/examples/text_to_knowledge/wordtag-ie/README.md
+++ b/slm/examples/text_to_knowledge/wordtag-ie/README.md
@@ -1,17 +1,17 @@
-# 解语:WordTag-IE(基于中文词类知识的信息抽取工具)
-
-WordTag-IE(基于中文词类知识的信息抽取工具)是在WordTag标注结果之上实现的信息抽取工具,旨在提供一个灵活、可配置,能够精准、全面覆盖简单句式的**规则信息抽取工具**。我们已提供了通用配置,可覆盖一些常见的抽取句式。用户也可以根据我们提供的配置方法,完成自己的配置,应用于自己的领域、专业文本。其产出数据,可作为模型的训练样本,也可以直接当作挖掘结果使用。
-
-
-
-## WordTag-IE特点
-
-- **灵活、方便的配置,即时生效**
- - WordTag-IE是在WordTag标注结果的基础上,完全使用规则实现的关系抽取工具。其配置完全基于WordTag的词类知识以及TermTree中的词表实现,实现了灵活、简单配置,且保证了产出数据的一致性
-
-## 使用示例
-
-在WordTag的任务中基础上可以打开`with_ie` 开关即可输出信息抽取的结果, 下面是使用PaddleNLP Taskflow使用WordTag-IE的使用示例。
+# 解语:WordTag-IE(基于中文词类知识的信息抽取工具)
+
+WordTag-IE(基于中文词类知识的信息抽取工具)是在 WordTag 标注结果之上实现的信息抽取工具,旨在提供一个灵活、可配置,能够精准、全面覆盖简单句式的**规则信息抽取工具**。我们已提供了通用配置,可覆盖一些常见的抽取句式。用户也可以根据我们提供的配置方法,完成自己的配置,应用于自己的领域、专业文本。其产出数据,可作为模型的训练样本,也可以直接当作挖掘结果使用。
+
+
+
+## WordTag-IE 特点
+
+- **灵活、方便的配置,即时生效**
+ - WordTag-IE 是在 WordTag 标注结果的基础上,完全使用规则实现的关系抽取工具。其配置完全基于 WordTag 的词类知识以及 TermTree 中的词表实现,实现了灵活、简单配置,且保证了产出数据的一致性
+
+## 使用示例
+
+在 WordTag 的任务中基础上可以打开`with_ie` 开关即可输出信息抽取的结果, 下面是使用 PaddleNLP Taskflow 使用 WordTag-IE 的使用示例。
```python
>>> from paddlenlp import Taskflow
>>> wordtag_ie = Taskflow("knowledge_mining", with_ie=True)
@@ -55,81 +55,81 @@ WordTag-IE(基于中文词类知识的信息抽取工具)是在WordTag标注
'TAIL_ROLE': [{'item': '王杰', 'offset': 10, 'type': '人物类_实体'}],
'TRIG': [{'item': '作词', 'offset': 12}]}]]
```
-
-## 配置示例
-
-我们提供了配置示例文件[demo_config.json](./demo_config.json),用户可以直接基于这个文件实现自己想要的配置。
-
-我们以“出版方”这个关系为例:
-
-```json
-{
- "head_role": "作品类_实体", //头实体词类
- "group": "出版方", //关系名
- "tail_role": [
- {
- "main": [
- "组织机构类"
- ], //尾实体词类
- "support": [
- "时间类_具体时间"
- ] //相关词类,可作为该关系的补充,不可作为尾实体独立存在
- }
- ], //尾实体配置
- "trig_word": [
- "出版"
- ], //触发词,对于没有触发词,而是由头尾实体直接触发的关系,可为null
- "trig_direction": "L", //触发P的方向,表示在自然表达中,尾实体在触发词的哪一边,L为左,R为右,B为双向都有可能,默认为B
- "trig_type": "trigger", //trigger表明由触发词触发,tail表明为尾实体触发
- "reverse": false, //是否为反向配置,即尾实体实际是头,头实体实际是尾
- "rel_group": "出版" //对应的反关系,即头尾实体对调后,对应的关系,用于逻辑推断
-}
-```
-
-### 配置原则
-
-1. 文本中的头实体(head_role)一定在尾实体(tail_role)的前面(即左边),可以通过配置反向标记(reverse)和反向关系名(rel_group)生成反关系
-2. 两种触发模式:触发词触发(trig_type为trigger)和尾实体触发(trig_type为tail),两者的触发方向(trig_direction)配置不同
-
- - 触发词的触发方向约束的是文本中尾实体在触发词的左边还是右边,默认是双向触发(B),可以配置向左触发(L)或向右(R)触发,以提升挖掘精度
-
- - 尾实体触发不用配置方向,因为必然在头实体之后
-## 实现方法
-
-使用WordTag的标注结果,相当于已实现将**无限的词收拢到了有限的词类体系中**,而待抽取的关系,则变成了仅发生在词类与词类之间,便可以枚举出来。例如,`人物类_实体`与`作品类_实体`之间的关系可以是“创作”,而“创作”的触发词(如作词、作曲、演唱、执导、出演等)或触发pattern,则可以通过知识库枚举得到,如此,则实现了灵活配置。
-
-那么,接下来一个问题则是,我们如何从现在的序列解析结果中,得到关系三元组数据呢?
-
-要解决这个问题,我们依旧要从中文语言学的成果中寻找答案:中文更偏孤立语,注重**意合**,依靠词序和词之间的意义联系成句,词性、句法特征弱。也就是说,我们在解析的时候,可以尝试摒弃所谓句法特征,只是从次序上下手。于是,我们发现,只需要覆盖好 SPO 的几种常用表达顺序,单向搜索,即可覆盖大部分简单句。
-
-例如,对于`<张艺谋,创作,十面埋伏>`这一 SPO 三元组,常用表达顺序有如下几种:
-
-- S-P-O:张艺谋执导了《十面埋伏》。
-- S-O-P:张艺谋是《十面埋伏》的导演。
-- O-S-P:《十面埋伏》是张艺谋执导的电影。
-- O-P-S:《十面埋伏》的导演是张艺谋。
-
-然而,这种模式仍然过于复杂,如遇到多组 SPO 关系并存的文本,如果要完全照顾到这四种表达顺序,则很容易发生混乱,难以得到严格对应的三元组。所以,我们设计了**互反关系**的概念,即头实体和尾实体对调后,对应的反向关系。例如三元组`<张艺谋,创作,十面埋伏>`,则存在一个反向三元组`<十面埋伏,创作者,三元组>`。那么,当我们找到一个头实体之后,只需要考虑它之后的部分(即 `S-P-O` 和 `S-O-P` 两种表达顺序)就行了。
-
-另外,我们认为,规范表达中,关系触发和尾实体一定实在同一个短语中出现,所以,触发关系之后,寻找尾实体的过程中,我们仅搜索与触发在同一个短语中的实体及相关元素。
-
-## 后续计划
-
-- 实现基于语义结构的抽取,覆盖复杂句式
-
-## 在论文中引用WordTag-IE
-
-如果您的工作成果中使用了WordTag-IE,请增加下述引用。我们非常乐于看到WordTag-IE对您的工作带来帮助。
-
-```
-@article{qin2022WordTag-IE,
- title={WordTag-IE: a Rule-based Tool for Chinese Information Extraction},
- author={Qin, Huapeng and Zhao, Min and Tang, Wei},
- technical report={Baidu, Inc. TR:2022-KG-WordTag-IE},
- year={2022}
-}
-```
-
-## 问题与反馈
-
-WordTag-IE在持续优化中,如果您有任何建议或问题,欢迎提交issue到Github。
+
+## 配置示例
+
+我们提供了配置示例文件[demo_config.json](./demo_config.json),用户可以直接基于这个文件实现自己想要的配置。
+
+我们以“出版方”这个关系为例:
+
+```json
+{
+ "head_role": "作品类_实体", //头实体词类
+ "group": "出版方", //关系名
+ "tail_role": [
+ {
+ "main": [
+ "组织机构类"
+ ], //尾实体词类
+ "support": [
+ "时间类_具体时间"
+ ] //相关词类,可作为该关系的补充,不可作为尾实体独立存在
+ }
+ ], //尾实体配置
+ "trig_word": [
+ "出版"
+ ], //触发词,对于没有触发词,而是由头尾实体直接触发的关系,可为null
+ "trig_direction": "L", //触发P的方向,表示在自然表达中,尾实体在触发词的哪一边,L为左,R为右,B为双向都有可能,默认为B
+ "trig_type": "trigger", //trigger表明由触发词触发,tail表明为尾实体触发
+ "reverse": false, //是否为反向配置,即尾实体实际是头,头实体实际是尾
+ "rel_group": "出版" //对应的反关系,即头尾实体对调后,对应的关系,用于逻辑推断
+}
+```
+
+### 配置原则
+
+1. 文本中的头实体(head_role)一定在尾实体(tail_role)的前面(即左边),可以通过配置反向标记(reverse)和反向关系名(rel_group)生成反关系
+2. 两种触发模式:触发词触发(trig_type 为 trigger)和尾实体触发(trig_type 为 tail),两者的触发方向(trig_direction)配置不同
+
+ - 触发词的触发方向约束的是文本中尾实体在触发词的左边还是右边,默认是双向触发(B),可以配置向左触发(L)或向右(R)触发,以提升挖掘精度
+
+ - 尾实体触发不用配置方向,因为必然在头实体之后
+## 实现方法
+
+使用 WordTag 的标注结果,相当于已实现将**无限的词收拢到了有限的词类体系中**,而待抽取的关系,则变成了仅发生在词类与词类之间,便可以枚举出来。例如,`人物类_实体`与`作品类_实体`之间的关系可以是“创作”,而“创作”的触发词(如作词、作曲、演唱、执导、出演等)或触发 pattern,则可以通过知识库枚举得到,如此,则实现了灵活配置。
+
+那么,接下来一个问题则是,我们如何从现在的序列解析结果中,得到关系三元组数据呢?
+
+要解决这个问题,我们依旧要从中文语言学的成果中寻找答案:中文更偏孤立语,注重**意合**,依靠词序和词之间的意义联系成句,词性、句法特征弱。也就是说,我们在解析的时候,可以尝试摒弃所谓句法特征,只是从次序上下手。于是,我们发现,只需要覆盖好 SPO 的几种常用表达顺序,单向搜索,即可覆盖大部分简单句。
+
+例如,对于`<张艺谋,创作,十面埋伏>`这一 SPO 三元组,常用表达顺序有如下几种:
+
+- S-P-O:张艺谋执导了《十面埋伏》。
+- S-O-P:张艺谋是《十面埋伏》的导演。
+- O-S-P:《十面埋伏》是张艺谋执导的电影。
+- O-P-S:《十面埋伏》的导演是张艺谋。
+
+然而,这种模式仍然过于复杂,如遇到多组 SPO 关系并存的文本,如果要完全照顾到这四种表达顺序,则很容易发生混乱,难以得到严格对应的三元组。所以,我们设计了**互反关系**的概念,即头实体和尾实体对调后,对应的反向关系。例如三元组`<张艺谋,创作,十面埋伏>`,则存在一个反向三元组`<十面埋伏,创作者,三元组>`。那么,当我们找到一个头实体之后,只需要考虑它之后的部分(即 `S-P-O` 和 `S-O-P` 两种表达顺序)就行了。
+
+另外,我们认为,规范表达中,关系触发和尾实体一定实在同一个短语中出现,所以,触发关系之后,寻找尾实体的过程中,我们仅搜索与触发在同一个短语中的实体及相关元素。
+
+## 后续计划
+
+- 实现基于语义结构的抽取,覆盖复杂句式
+
+## 在论文中引用 WordTag-IE
+
+如果您的工作成果中使用了 WordTag-IE,请增加下述引用。我们非常乐于看到 WordTag-IE 对您的工作带来帮助。
+
+```
+@article{qin2022WordTag-IE,
+ title={WordTag-IE: a Rule-based Tool for Chinese Information Extraction},
+ author={Qin, Huapeng and Zhao, Min and Tang, Wei},
+ technical report={Baidu, Inc. TR:2022-KG-WordTag-IE},
+ year={2022}
+}
+```
+
+## 问题与反馈
+
+WordTag-IE 在持续优化中,如果您有任何建议或问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/wordtag-ie/demo_config.json b/slm/examples/text_to_knowledge/wordtag-ie/demo_config.json
similarity index 100%
rename from legacy/examples/text_to_knowledge/wordtag-ie/demo_config.json
rename to slm/examples/text_to_knowledge/wordtag-ie/demo_config.json
diff --git a/legacy/examples/text_to_knowledge/wordtag/README.md b/slm/examples/text_to_knowledge/wordtag/README.md
similarity index 70%
rename from legacy/examples/text_to_knowledge/wordtag/README.md
rename to slm/examples/text_to_knowledge/wordtag/README.md
index ce194b26e07b..66a6427c1da5 100644
--- a/legacy/examples/text_to_knowledge/wordtag/README.md
+++ b/slm/examples/text_to_knowledge/wordtag/README.md
@@ -2,47 +2,47 @@
WordTag(中文词类知识标注工具)是首个能够覆盖所有中文词汇的词类知识标注工具,旨在为中文文本解析提供全面、丰富的知识标注结果,可以应用于模板(挖掘模板、解析模板)生成与匹配、知识挖掘(新词发现、关系挖掘)等自然语言处理任务中,提升文本解析与挖掘精度;也可以作为中文文本特征生成器,为各类机器学习模型提供文本特征。
-
+
-## WordTag特点
+## WordTag 特点
- **覆盖所有中文词汇的词类体系,更丰富的知识标注结果**
- - WordTag使用的词类体系为覆盖所有中文词汇的词类体系,包括各类实体词与非实体词(如概念、实体/专名、语法词等)。WordTag开源版对部分类目(如组织机构等),做了更细类目的划分识别(如,医疗卫生机构、体育组织机构),对仅使用文本信息难以细分的类目(如人物类、作品类、品牌名等),不做更细粒度的词类识别。用户需要细粒度的词类识别时,可利用百科知识树的类别体系自行定制。
+ - WordTag 使用的词类体系为覆盖所有中文词汇的词类体系,包括各类实体词与非实体词(如概念、实体/专名、语法词等)。WordTag 开源版对部分类目(如组织机构等),做了更细类目的划分识别(如,医疗卫生机构、体育组织机构),对仅使用文本信息难以细分的类目(如人物类、作品类、品牌名等),不做更细粒度的词类识别。用户需要细粒度的词类识别时,可利用百科知识树的类别体系自行定制。
- **整合百科知识树链接结果,获得更丰富的标注知识**
- - 如上图示例所示,各个切分标注结果中,除词类标注外,还整合了百科知识树的链接结果,用户可以结合百科知识树数据共同使用:如,利用百科知识树中的subtype获得更细的上位粒度,利用term的百科信息获得更加丰富的知识等。
+ - 如上图示例所示,各个切分标注结果中,除词类标注外,还整合了百科知识树的链接结果,用户可以结合百科知识树数据共同使用:如,利用百科知识树中的 subtype 获得更细的上位粒度,利用 term 的百科信息获得更加丰富的知识等。
- **可定制的词类序列标注框架**
- - WordTag开源版标注使用的词类体系是我们在实践中对**百科文本**解析应用较好的一个版本,不同类型文本(如,搜索query、新闻资讯)的词类分布不同,用户可以利用百科知识树定制自己的词类体系和训练样本,构建自己的WordTag应用版,以获得更好的适配效果。例如,可将自定义的词表按照百科知识树的字段定义好,挂接/整合到百科知识树上,即可使用自己的Term数据定制标注样本和标注任务。
+ - WordTag 开源版标注使用的词类体系是我们在实践中对**百科文本**解析应用较好的一个版本,不同类型文本(如,搜索 query、新闻资讯)的词类分布不同,用户可以利用百科知识树定制自己的词类体系和训练样本,构建自己的 WordTag 应用版,以获得更好的适配效果。例如,可将自定义的词表按照百科知识树的字段定义好,挂接/整合到百科知识树上,即可使用自己的 Term 数据定制标注样本和标注任务。
## 模型结构
-模型使用[ERNIE-CTM](../ernie-ctm)+CRF训练而成,预测时使用viterbi解码,模型结构如下:
+模型使用[ERNIE-CTM](../ernie-ctm)+CRF 训练而成,预测时使用 viterbi 解码,模型结构如下:
-
+
-## Term-Linking实现
+## Term-Linking 实现
-WordTag提供从文本到百科知识树的链接方法,即Term-Linking,只需将term词类体系与百科知识树数据加载到工具中,即可在解析结果中得到term-linking结果。
+WordTag 提供从文本到百科知识树的链接方法,即 Term-Linking,只需将 term 词类体系与百科知识树数据加载到工具中,即可在解析结果中得到 term-linking 结果。
-为了能够适配应用中的不同实体集(例如,不同的企业有不同的人物实体集合,不同的小说站有不同的小说实体集合),我们将term-linking拆分为两个步骤:
+为了能够适配应用中的不同实体集(例如,不同的企业有不同的人物实体集合,不同的小说站有不同的小说实体集合),我们将 term-linking 拆分为两个步骤:
-- 第一步是基于词类的linking,主要解决“同名概念词/实体词”、“不同类的同名词”消歧问题,这一步只使用文本本身特征和词类特征,不使用图谱中的实体属性值(SPO)知识,从而支持切换不同应用知识图谱;
-- 第二步是同类同名实体词的linking,主要解决同类下不同属性值的实体消歧问题,这一步需要使用实体词的SPO知识(一般用于实体特征表示计算,以及文本-实体相似度计算)。
+- 第一步是基于词类的 linking,主要解决“同名概念词/实体词”、“不同类的同名词”消歧问题,这一步只使用文本本身特征和词类特征,不使用图谱中的实体属性值(SPO)知识,从而支持切换不同应用知识图谱;
+- 第二步是同类同名实体词的 linking,主要解决同类下不同属性值的实体消歧问题,这一步需要使用实体词的 SPO 知识(一般用于实体特征表示计算,以及文本-实体相似度计算)。
-“WordTag+百科知识树”的开源版提供了第一步的解决示例,第二步由于依赖于特定图谱的SPO知识,无法提供通用工具,未来可能提供通用解决方案。
+“WordTag+百科知识树”的开源版提供了第一步的解决示例,第二步由于依赖于特定图谱的 SPO 知识,无法提供通用工具,未来可能提供通用解决方案。
-WordTag模型对所有的词预测到上位词类之后,会直接根据预测到的词类,映射到term体系(映射表参见代码配置),查找相应的term,进行link。用户也可根据自己的数据分布,定制term-linking策略:
+WordTag 模型对所有的词预测到上位词类之后,会直接根据预测到的词类,映射到 term 体系(映射表参见代码配置),查找相应的 term,进行 link。用户也可根据自己的数据分布,定制 term-linking 策略:
-- link到自己定制的term词表:只需将term词表按照TermTree挂接好之后更换数据即可;
-- 调整WordTag预测词类与term词表的映射关系(如,增加自定义类别):在代码配置中直接调整映射表即可。
+- link 到自己定制的 term 词表:只需将 term 词表按照 TermTree 挂接好之后更换数据即可;
+- 调整 WordTag 预测词类与 term 词表的映射关系(如,增加自定义类别):在代码配置中直接调整映射表即可。
-## WordTag类别标签集合
+## WordTag 类别标签集合
-WordTag共包含91种词性及专名类别标签,标签集合如下表
+WordTag 共包含91种词性及专名类别标签,标签集合如下表
- WordTag标签集合 |
+ WordTag 标签集合 |
@@ -166,17 +166,17 @@ WordTag共包含91种词性及专名类别标签,标签集合如下表
-## WordTag应用场景
+## WordTag 应用场景
参见"[解语的应用场景](../)"
-## WordTag示例代码
-下面提供了WordTag模型进行文本到百科知识树链接的示例程序。
+## WordTag 示例代码
+下面提供了 WordTag 模型进行文本到百科知识树链接的示例程序。
-### Term-Linking示例程序
+### Term-Linking 示例程序
-Term-Linking示例程序可以对无标签数据启动模型预测, 例如想对下面几段文本进行百科知识树的链接解析
+Term-Linking 示例程序可以对无标签数据启动模型预测, 例如想对下面几段文本进行百科知识树的链接解析
```
"《孤女》是2010年九州出版社出版的小说,作者是余兼羽。",
"热梅茶是一道以梅子为主要原料制作的茶饮"
@@ -193,14 +193,14 @@ wordtag(["热梅茶是一道以梅子为主要原料制作的茶饮",
wordtag("热梅茶是一道以梅子为主要原料制作的茶饮")
```
-下面是运行WordTag工具后的知识链接的预测结果
+下面是运行 WordTag 工具后的知识链接的预测结果
```json
[{'text': '《孤女》是2010年九州出版社出版的小说,作者是余兼羽。', 'items': [{'item': '《', 'offset': 0, 'wordtag_label': 'w', 'length': 1}, {'item': '孤女', 'offset': 1, 'wordtag_label': '作品类_实体', 'length': 2, 'termid': '小说_eb_孤女'}, {'item': '》', 'offset': 3, 'wordtag_label': 'w', 'length': 1}, {'item': '是', 'offset': 4, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '2010年', 'offset': 5, 'wordtag_label': '时间类', 'length': 5, 'termid': '时间阶段_cb_2010年'}, {'item': '九州出版社', 'offset': 10, 'wordtag_label': '组织机构类', 'length': 5, 'termid': '组织机构_eb_九州出版社'}, {'item': '出版', 'offset': 15, 'wordtag_label': '场景事件', 'length': 2, 'termid': '场景事件_cb_出版'}, {'item': '的', 'offset': 17, 'wordtag_label': '助词', 'length': 1, 'termid': '助词_cb_的'}, {'item': '小说', 'offset': 18, 'wordtag_label': '作品类_概念', 'length': 2, 'termid': '小说_cb_小说'}, {'item': ',', 'offset': 20, 'wordtag_label': 'w', 'length': 1}, {'item': '作者', 'offset': 21, 'wordtag_label': '人物类_概念', 'length': 2, 'termid': '人物_cb_作者'}, {'item': '是', 'offset': 23, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '余兼羽', 'offset': 24, 'wordtag_label': '人物类_实体', 'length': 3}, {'item': '。', 'offset': 27, 'wordtag_label': 'w', 'length': 1}]}, {'text': '热梅茶是一道以梅子为主要原料制作的茶饮', 'items': [{'item': '热梅茶', 'offset': 0, 'wordtag_label': '饮食类_饮品', 'length': 3}, {'item': '是', 'offset': 3, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '一道', 'offset': 4, 'wordtag_label': '数量词', 'length': 2}, {'item': '以', 'offset': 6, 'wordtag_label': '介词', 'length': 1, 'termid': '介词_cb_以'}, {'item': '梅子', 'offset': 7, 'wordtag_label': '饮食类', 'length': 2, 'termid': '饮食_cb_梅'}, {'item': '为', 'offset': 9, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_为'}, {'item': '主要原料', 'offset': 10, 'wordtag_label': '物体类', 'length': 4, 'termid': '物品_cb_主要原料'}, {'item': '制作', 'offset': 14, 'wordtag_label': '场景事件', 'length': 2, 'termid': '场景事件_cb_制作'}, {'item': '的', 'offset': 16, 'wordtag_label': '助词', 'length': 1, 'termid': '助词_cb_的'}, {'item': '茶饮', 'offset': 17, 'wordtag_label': '饮食类_饮品', 'length': 2, 'termid': '饮品_cb_茶饮'}]}]
{'text': '热梅茶是一道以梅子为主要原料制作的茶饮', 'items': [{'item': '热梅茶', 'offset': 0, 'wordtag_label': '饮食类_饮品', 'length': 3}, {'item': '是', 'offset': 3, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_是'}, {'item': '一道', 'offset': 4, 'wordtag_label': '数量词', 'length': 2}, {'item': '以', 'offset': 6, 'wordtag_label': '介词', 'length': 1, 'termid': '介词_cb_以'}, {'item': '梅子', 'offset': 7, 'wordtag_label': '饮食类', 'length': 2, 'termid': '饮食_cb_梅'}, {'item': '为', 'offset': 9, 'wordtag_label': '肯定词', 'length': 1, 'termid': '肯定否定词_cb_为'}, {'item': '主要原料', 'offset': 10, 'wordtag_label': '物体类', 'length': 4, 'termid': '物品_cb_主要原料'}, {'item': '制作', 'offset': 14, 'wordtag_label': '场景事件', 'length': 2, 'termid': '场景事件_cb_制作'}, {'item': '的', 'offset': 16, 'wordtag_label': '助词', 'length': 1, 'termid': '助词_cb_的'}, {'item': '茶饮', 'offset': 17, 'wordtag_label': '饮食类_饮品', 'length': 2, 'termid': '饮品_cb_茶饮'}]}
```
-同时我们也提供了基于上述taskflow的python执行脚本,具体的执行方式如下:
+同时我们也提供了基于上述 taskflow 的 python 执行脚本,具体的执行方式如下:
```shell
python predict.py --max_seq_len 128 --batch_size 2
```
@@ -208,30 +208,30 @@ python predict.py --max_seq_len 128 --batch_size 2
- `max_seq_len` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每个预测批次的样本数目。
-## WordTag进阶使用
+## WordTag 进阶使用
### 自定义模型一键预测
-用户可以使用自有数据对WordTag模型进行增量训练,然后使用Taskflow进行一键预测,参见[WordTag增量训练示例](../ernie-ctm)。
+用户可以使用自有数据对 WordTag 模型进行增量训练,然后使用 Taskflow 进行一键预测,参见[WordTag 增量训练示例](../ernie-ctm)。
-### 自定义Term-Linking
+### 自定义 Term-Linking
-Taskflow默认使用TermTreeV1.0实现Term-Linking, 用户也可以基于自己的TermTree实现Term-Linking,参见[自定义TermTree](../termtree)。
+Taskflow 默认使用 TermTreeV1.0实现 Term-Linking, 用户也可以基于自己的 TermTree 实现 Term-Linking,参见[自定义 TermTree](../termtree)。
## Release Note
- 2022.06:新增25个细化词类,用于下游挖掘任务
-## WordTag后续计划
+## WordTag 后续计划
1. 持续优化知识标注模型,获得更加精准的标注结果;
2. 发布多粒度、多种参数规模的知识标注模型;
-3. 提供细粒度term及subterm消歧的解决方案。
+3. 提供细粒度 term 及 subterm 消歧的解决方案。
-## 在论文中引用WordTag
+## 在论文中引用 WordTag
-如果您的工作成果中使用了WordTag,请增加下述引用。我们非常乐于看到WordTag对您的工作带来帮助。
+如果您的工作成果中使用了 WordTag,请增加下述引用。我们非常乐于看到 WordTag 对您的工作带来帮助。
```
@article{zhao2020TermTree,
title={TermTree and Knowledge Annotation Framework for Chinese Language Understanding},
@@ -245,4 +245,4 @@ Taskflow默认使用TermTreeV1.0实现Term-Linking, 用户也可以基于自己
## 问题与反馈
-WordTag在持续优化中,如果您有任何建议或问题,欢迎提交issue到Github。
+WordTag 在持续优化中,如果您有任何建议或问题,欢迎提交 issue 到 Github。
diff --git a/legacy/examples/text_to_knowledge/wordtag/predict.py b/slm/examples/text_to_knowledge/wordtag/predict.py
similarity index 100%
rename from legacy/examples/text_to_knowledge/wordtag/predict.py
rename to slm/examples/text_to_knowledge/wordtag/predict.py
diff --git a/legacy/examples/torch_migration/README.md b/slm/examples/torch_migration/README.md
similarity index 74%
rename from legacy/examples/torch_migration/README.md
rename to slm/examples/torch_migration/README.md
index 603f040ed114..c77bf2c6c183 100644
--- a/legacy/examples/torch_migration/README.md
+++ b/slm/examples/torch_migration/README.md
@@ -9,13 +9,13 @@ Reproduction process of BERT on SST2 dataset
git clone https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/torch_migration
```
-* 进入文件夹,安装requirements
+* 进入文件夹,安装 requirements
```shell
pip install -r requirements.txt
```
-* 安装PaddlePaddle与PyTorch
+* 安装 PaddlePaddle 与 PyTorch
```shell
# CPU版本的PaddlePaddle
@@ -26,11 +26,11 @@ pip install paddlepaddle==2.2.0 -i https://mirror.baidu.com/pypi/simple
pip install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
```
-**注意**: 本项目依赖于paddlepaddle-2.2.0版本,安装时需要注意。
+**注意**: 本项目依赖于 paddlepaddle-2.2.0版本,安装时需要注意。
-* 验证PaddlePaddle是否安装成功
+* 验证 PaddlePaddle 是否安装成功
-运行python,输入下面的命令。
+运行 python,输入下面的命令。
```shell
import paddle
@@ -38,7 +38,7 @@ paddle.utils.run_check()
print(paddle.__version__)
```
-如果输出下面的内容,则说明PaddlePaddle安装成功。
+如果输出下面的内容,则说明 PaddlePaddle 安装成功。
```
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
@@ -46,9 +46,9 @@ PaddlePaddle is installed successfully! Let's start deep learning with PaddlePad
```
-* 验证PyTorch是否安装成功
+* 验证 PyTorch 是否安装成功
-运行python,输入下面的命令,如果可以正常输出,则说明torch安装成功。
+运行 python,输入下面的命令,如果可以正常输出,则说明 torch 安装成功。
```shell
import torch
diff --git a/slm/examples/torch_migration/docs/ThesisReproduction_NLP.md b/slm/examples/torch_migration/docs/ThesisReproduction_NLP.md
new file mode 100644
index 000000000000..98ae8c2d127a
--- /dev/null
+++ b/slm/examples/torch_migration/docs/ThesisReproduction_NLP.md
@@ -0,0 +1,928 @@
+# 论文复现指南
+
+## 目录
+
+- [1. 总览](#1)
+ - [1.1 背景](#1.1)
+ - [1.2 前序工作](#1.2)
+- [2. 整体框图](#2)
+ - [2.1 流程概览](#2.1)
+ - [2.2 reprod_log whl 包](#2.2)
+- [3. 论文复现理论知识及实战](#3)
+ - [3.1 模型结构对齐](#3.1)
+ - [3.2 验证/测试集数据读取对齐](#3.2)
+ - [3.3 评估指标对齐](#3.3)
+ - [3.4 损失函数对齐](#3.4)
+ - [3.5 优化器对齐](#3.5)
+ - [3.6 学习率对齐](#3.6)
+ - [3.7 正则化策略对齐](#3.7)
+ - [3.8 反向对齐](#3.8)
+ - [3.9 训练集数据读取对齐](#3.9)
+ - [3.10 网络初始化对齐](#3.10)
+ - [3.11 模型训练对齐](#3.11)
+ - [3.12 单机多卡训练](#3.12)
+- [4. 论文复现注意事项与 FAQ](#4)
+ - [4.0 通用注意事项](#4.0)
+ - [4.1 模型结构对齐](#4.1)
+ - [4.2 验证/测试集数据读取对齐](#4.2)
+ - [4.3 评估指标对齐](#4.3)
+ - [4.4 损失函数对齐](#4.4)
+ - [4.5 优化器对齐](#4.5)
+ - [4.6 学习率对齐](#4.6)
+ - [4.7 正则化策略对齐](#4.7)
+ - [4.8 反向对齐](#4.8)
+ - [4.9 训练集数据读取对齐](#4.9)
+ - [4.10 网络初始化对齐](#4.10)
+ - [4.11 模型训练对齐](#4.11)
+
+
+## 1. 总览
+
+
+### 1.1 背景
+
+* 以深度学习为核心的人工智能技术仍在高速发展,通过论文复现,开发者可以获得
+ * 学习成长:自我能力提升
+ * 技术积累:对科研或工作有所帮助和启发
+ * 社区荣誉:成果被开发者广泛使用
+
+
+### 1.2 前序工作
+
+基于本指南复现论文过程中,建议开发者准备以下内容。
+
+* 了解该模型输入输出格式。以 BERT 的情感分类任务为例,通过阅读论文与参考代码,了解到模型输入为`[batch_size, sequence_length]`的 tensor,类型为`int64`,label 为`[batch, ]`的 label,类型为`int64`。
+* 准备好训练/验证数据集,用于模型训练与评估
+* 准备好 fake input data 以及 label,与模型输入 shape、type 等保持一致,用于后续模型前向对齐。
+ * 在对齐模型前向过程中,我们不需要考虑数据集模块等其他模块,此时使用 fake data 是将模型结构和数据部分解耦非常合适的一种方式。
+ * 将 fake data 以文件的形式存储下来,也可以保证 PaddlePaddle 与参考代码的模型结构输入是完全一致的,更便于排查问题。
+ * 在该步骤中,以 BERT 为例,生成 fake data 的脚本可以参考:[gen_fake_data.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/fake_data/gen_fake_data.py)。
+* 在特定设备(CPU/GPU)上,跑通参考代码的预测过程(前向)以及至少2轮(iteration)迭代过程,保证后续基于 PaddlePaddle 复现论文过程中可对比。
+* 本文档基于 `BERT-SST2-Prod` 代码以及`reprod_log` whl 包进行说明与测试。如果希望体验,建议参考[BERT-SST2-Prod 文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/README.md)进行安装与测试。
+* 在复现的过程中,只需要将 PaddlePaddle 的复现代码以及打卡日志上传至 github,不能在其中添加参考代码的实现,在验收通过之后,需要删除打卡日志。建议在初期复现的时候,就将复现代码与参考代码分成2个文件夹进行管理。
+
+
+## 2. 整体框图
+
+
+### 2.1 流程概览
+
+面对一篇自然语言处理的论文,复现该论文的整体流程如下图所示。
+
+
+
+总共包含11个步骤。为了高效复现论文,设置了5个验收节点。如上图中黄色框所示。后续章节会详细介绍上述步骤和验收节点,具体内容安排如下:
+
+* 第3章:介绍11个复现步骤的理论知识、实战以及验收流程。
+* 第4章:针对复现流程过程中每个步骤可能出现的问题,本章会进行详细介绍。如果还是不能解决问题,可以提 ISSUE 进行讨论,提 ISSUE 地址:[https://github.com/PaddlePaddle/Paddle/issues/new/choose](https://github.com/PaddlePaddle/Paddle/issues/new/choose)
+
+
+### 2.2 reprod_log whl 包
+
+#### 2.2.1 reprod_log 工具简介
+`reprod_log`是用于论文复现赛中辅助自查和验收工具。该工具源代码地址在:[https://github.com/WenmuZhou/reprod_log](https://github.com/WenmuZhou/reprod_log)。主要功能如下:
+
+* 存取指定节点的输入输出 tensor
+* 基于文件的 tensor 读写
+* 2个字典的对比验证
+* 对比结果的输出与记录
+
+更多 API 与使用方法可以参考:[reprod_log API 使用说明](https://github.com/WenmuZhou/reprod_log/blob/master/README.md)。
+
+#### 2.2.2 reprod_log 使用 demo
+
+下面基于代码:[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/reprod_log_demo](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/reprod_log_demo),给出如何使用该工具。
+
+文件夹中包含`write_log.py`和`check_log_diff.py`文件,其中`write_log.py`中给出了`ReprodLogger`类的使用方法,`check_log_diff.py`给出了`ReprodDiffHelper`类的使用方法,依次运行两个 python 文件,使用下面的方式运行代码。
+
+```shell
+# 进入文件夹
+cd pipeline/reprod_log_demo
+# 随机生成矩阵,写入文件中
+python write_log.py
+# 进行文件对比,输出日志
+python check_log_diff.py
+```
+
+最终会输出以下内容
+
+```
+[2021/11/18 09:29:31] root INFO: demo_test_1:
+[2021/11/18 09:29:31] root INFO: mean diff: check passed: True, value: 0.0
+[2021/11/18 09:29:31] root INFO: demo_test_2:
+[2021/11/18 09:29:31] root INFO: mean diff: check passed: False, value: 0.33387675881385803
+[2021/11/18 09:29:31] root INFO: diff check failed
+```
+
+可以看出:对于 key 为`demo_test_1`的矩阵,由于 diff 为0,小于设置的阈值`1e-6`,核验成功;对于 key 为`demo_test_2`的矩阵,由于 diff 为0.33,大于设置的阈值`1e-6`,核验失败。
+
+#### 2.2.3 reprod_log 在论文复现中应用
+
+在论文复现中,基于 reprod_log 的结果记录模块,产出下面若干文件
+```
+log_reprod
+├── forward_paddle.npy
+├── forward_torch.npy # 与forward_paddle.npy作为一并核查的文件对
+├── metric_paddle.npy
+├── metric_torch.npy # 与metric_paddle.npy作为一并核查的文件对
+├── loss_paddle.npy
+├── loss_torch.npy # 与loss_paddle.npy作为一并核查的文件对
+├── bp_align_paddle.npy
+├── bp_align_torch.npy # 与bp_align_paddle.npy作为一并核查的文件对
+├── train_align_paddle.npy
+├── train_align_torch.npy # pytorch运行得到的参考评估指标
+```
+
+基于 reprod_log 的`ReprodDiffHelper`模块,产出下面5个日志文件。
+
+```
+├── forward_diff.log # forward_paddle.npy与forward_torch.npy生成的diff结果文件
+├── metric_diff.log # metric_paddle.npy与metric_torch.npy生成的diff结果文件
+├── loss_diff.log # loss_paddle.npy与loss_torch.npy生成的diff结果文件
+├── bp_align_diff.log # bp_align_paddle.npy与bp_align_torch.npy生成的diff结果文件
+├── train_align_diff.log # train_align_paddle.train_align_torch.npy生成的diff结果文件
+```
+
+上述文件的生成代码都需要开发者进行开发,验收时需要提供上面罗列的所有文件(不需要提供产生这些文件的可运行程序)以及完整的模型训练评估程序和日志。
+BERT-SST2-Prod 项目提供了基于 reprod_log 的5个验收点对齐验收示例,具体代码地址为:[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline),
+每个文件夹中的 README.md 文档提供了使用说明。
+
+
+## 3. 论文复现理论知识及实战
+
+
+### 3.1 模型结构对齐
+
+对齐模型结构时,一般有3个主要步骤:
+
+* 网络结构代码转换
+* 权重转换
+* 模型组网正确性验证
+
+下面详细介绍这3个部分。
+
+#### 3.1.1 网络结构代码转换
+
+**【基本流程】**
+
+由于 PyTorch 的 API 和 PaddlePaddle 的 API 非常相似,可以参考[PyTorch-PaddlePaddle API 映射表](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/08_api_mapping/pytorch_api_mapping_cn.html)
+,组网部分代码直接进行手动转换即可。
+
+**【注意事项】**
+
+如果遇到 PaddlePaddle 没有的 API,可以尝试用多种 API 来组合,也可以给 PaddlePaddle 团队提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues),获得支持。
+
+**【实战】**
+
+BERT 网络结构的 PyTorch 实现: [transformers-bert](https://github.com/huggingface/transformers/blob/master/src/transformers/models/bert/modeling_bert.py)
+
+对应转换后的 PaddlePaddle 实现: [paddlenlp-bert](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/transformers/bert/modeling.py)
+
+
+#### 3.1.2 权重转换
+
+**【基本流程】**
+
+组网代码转换完成之后,需要对模型权重进行转换,如果 PyTorch repo 中已经提供权重,那么可以直接下载并进行后续的转换;如果没有提供,则可以基于 PyTorch 代码,随机生成一个初始化权重(定义完 model 以后,使用`torch.save()` API 保存模型权重),然后进行权重转换。
+
+**【注意事项】**
+
+在权重转换的时候,需要注意`paddle.nn.Linear`等 API 的权重保存格式和名称等与 PyTorch 稍有 diff,具体内容可以参考`4.1章节`。
+
+**【实战】**
+
+BERT 的代码转换脚本可以在这里查看:[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py),
+
+注意:运行该代码需要首先下载 Huggingface 的 BERT 预训练模型到该目录下,下载地址为:[https://huggingface.co/bert-base-uncased/blob/main/pytorch_model.bin](https://huggingface.co/bert-base-uncased/blob/main/pytorch_model.bin)
+
+```python
+# https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py
+
+from collections import OrderedDict
+
+import numpy as np
+import paddle
+import torch
+from paddlenlp.transformers import BertForPretraining as PDBertForMaskedLM
+from transformers import BertForMaskedLM as PTBertForMaskedLM
+
+
+def convert_pytorch_checkpoint_to_paddle(
+ pytorch_checkpoint_path="pytorch_model.bin",
+ paddle_dump_path="model_state.pdparams",
+ version="old", ):
+ hf_to_paddle = {
+ "embeddings.LayerNorm": "embeddings.layer_norm",
+ "encoder.layer": "encoder.layers",
+ "attention.self.query": "self_attn.q_proj",
+ "attention.self.key": "self_attn.k_proj",
+ "attention.self.value": "self_attn.v_proj",
+ "attention.output.dense": "self_attn.out_proj",
+ "intermediate.dense": "linear1",
+ "output.dense": "linear2",
+ "attention.output.LayerNorm": "norm1",
+ "output.LayerNorm": "norm2",
+ "predictions.decoder.": "predictions.decoder_",
+ "predictions.transform.dense": "predictions.transform",
+ "predictions.transform.LayerNorm": "predictions.layer_norm",
+ }
+ do_not_transpose = []
+ if version == "old":
+ hf_to_paddle.update({
+ "predictions.bias": "predictions.decoder_bias",
+ ".gamma": ".weight",
+ ".beta": ".bias",
+ })
+ do_not_transpose = do_not_transpose + ["predictions.decoder.weight"]
+
+ pytorch_state_dict = torch.load(
+ pytorch_checkpoint_path, map_location="cpu")
+ paddle_state_dict = OrderedDict()
+ for k, v in pytorch_state_dict.items():
+ is_transpose = False
+ if k[-7:] == ".weight":
+ # embeddings.weight and LayerNorm.weight do not transpose
+ if all(d not in k for d in do_not_transpose):
+ if ".embeddings." not in k and ".LayerNorm." not in k:
+ if v.ndim == 2:
+ v = v.transpose(0, 1)
+ is_transpose = True
+ oldk = k
+ for hf_name, pd_name in hf_to_paddle.items():
+ k = k.replace(hf_name, pd_name)
+
+ # add prefix `bert.`
+ if "bert." not in k and "cls." not in k and "classifier" not in k:
+ k = "bert." + k
+
+ print(f"Converting: {oldk} => {k} | is_transpose {is_transpose}")
+ paddle_state_dict[k] = v.data.numpy()
+
+ paddle.save(paddle_state_dict, paddle_dump_path)
+
+
+def compare(out_torch, out_paddle):
+ out_torch = out_torch.detach().numpy()
+ out_paddle = out_paddle.detach().numpy()
+ assert out_torch.shape == out_paddle.shape
+ abs_dif = np.abs(out_torch - out_paddle)
+ mean_dif = np.mean(abs_dif)
+ max_dif = np.max(abs_dif)
+ min_dif = np.min(abs_dif)
+ print("mean_dif:{}".format(mean_dif))
+ print("max_dif:{}".format(max_dif))
+ print("min_dif:{}".format(min_dif))
+
+
+def test_forward():
+ paddle.set_device("cpu")
+ model_torch = PTBertForMaskedLM.from_pretrained("./bert-base-uncased")
+ model_paddle = PDBertForMaskedLM.from_pretrained("./bert-base-uncased")
+ model_torch.eval()
+ model_paddle.eval()
+ np.random.seed(42)
+ x = np.random.randint(
+ 1, model_paddle.bert.config["vocab_size"], size=(4, 64))
+ input_torch = torch.tensor(x, dtype=torch.int64)
+ out_torch = model_torch(input_torch)[0]
+
+ input_paddle = paddle.to_tensor(x, dtype=paddle.int64)
+ out_paddle = model_paddle(input_paddle)[0]
+
+ print("torch result shape:{}".format(out_torch.shape))
+ print("paddle result shape:{}".format(out_paddle.shape))
+ compare(out_torch, out_paddle)
+
+
+if __name__ == "__main__":
+ convert_pytorch_checkpoint_to_paddle(
+ "./bert-base-uncased/pytorch_model.bin",
+ "./bert-base-uncased/model_state.pdparams")
+ test_forward()
+ # torch result shape:torch.Size([4, 64, 30522])
+ # paddle result shape:[4, 64, 30522]
+ # mean_dif:1.666686512180604e-05
+ # max_dif:0.00015211105346679688
+ # min_dif:0.0
+```
+
+运行完成之后,会在当前目录生成`model_state.pdparams`文件,即为转换后的 PaddlePaddle 预训练模型。
+**Tips**: 由于 paddlenlp 中已有转换后的 bert-base-uncased 模型,因此可以一键加载,程序会自动下载对应权重!
+
+
+#### 3.1.3 模型组网正确性验证
+
+**【基本流程】**
+
+1. 定义 PyTorch 模型,加载权重,固定 seed,基于 numpy 生成随机数,转换为 PyTorch 可以处理的 tensor,送入网络,获取输出,使用 reprod_log 保存结果。
+2. 定义 PaddlePaddle 模型,加载权重,固定 seed,基于 numpy 生成随机数,转换为 PaddlePaddle 可以处理的 tensor,送入网络,获取输出,使用 reprod_log 保存结果。
+3. 使用 reprod_log 排查 diff,小于阈值,即可完成自测。
+
+**【注意事项】**
+
+* 模型在前向对齐验证时,需要调用`model.eval()`方法,保证组网中的随机量被关闭,比如 BatchNorm、Dropout 等。
+* 给定相同的输入数据,为保证可复现性,如果有随机数生成,固定相关的随机种子。
+* 输出 diff 可以使用`np.mean(np.abs(o1 - o2))`进行计算,一般小于1e-6的话,可以认为前向没有问题。如果最终输出结果 diff 较大,可以使用二分的方法进行排查,比如说 BERT,包含1个 embdding 层、12个 transformer-block 以及最后的 MLM head 层,那么完成模型组网和权重转换之后,如果模型输出没有对齐,可以尝试输出中间某一个 transformer-block 的 tensor 进行对比,如果相同,则向后进行排查;如果不同,则继续向前进行排查,以此类推,直到找到导致没有对齐的操作。
+
+**【实战】**
+
+BERT 模型组网正确性验证可以参考如下示例代码:
+[https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/Step1](https://github.com/JunnYu/BERT-SST2-Prod/tree/main/pipeline/Step1
+
+**【验收】**
+
+对于待复现的项目,前向对齐验收流程如下。
+
+1. 准备输入:fake data
+ * 使用参考代码的 dataloader,生成一个 batch 的数据,保存下来,在前向对齐时,直接从文件中读入。
+ * 固定随机数种子,生成 numpy 随机矩阵,转化 tensor
+2. 保存输出:
+ * PaddlePaddle/PyTorch:dict,key 为 tensor 的 name(自定义),value 为 tensor 的值。最后将 dict 保存到文件中。建议命名为`forward_paddle.npy`和`forward_torch.npy`。
+3. 自测:使用 reprod_log 加载2个文件,使用 report 功能,记录结果到日志文件中,建议命名为`forward_diff_log.txt`,观察 diff,二者 diff 小于特定的阈值即可。
+4. 提交内容:新建文件夹,将`forward_paddle.npy`、`forward_torch.npy`与`forward_diff_log.txt`文件放在文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
+5. 注意:
+ * PaddlePaddle 与 PyTorch 保存的 dict 的 key 需要保持相同,否则 report 过程可能会提示 key 无法对应,从而导致 report 失败,之后的`【验收】`环节也是如此。
+ * 如果是固定随机数种子,建议将 fake data 保存到 dict 中,方便 check 参考代码和 PaddlePaddle 的输入是否一致。
+
+
+### 3.2 验证/测试集数据读取对齐
+
+**【基本流程】**
+
+对于一个数据集,一般有以下一些信息需要重点关注
+
+* 数据集名称、下载地址
+* 训练集/验证集/测试集
+
+PaddlePaddle 中数据集相关的 API 为`paddle.io.Dataset`,PyTorch 中对应为`torch.utils.data.Dataset`,二者功能一致,在绝大多数情况下,可以使用该类构建数据集。它是描述 Dataset 方法和行为的抽象类,在具体实现的时候,需要继承这个基类,实现其中的`__getitem__`和`__len__`方法。除了参考代码中相关实现,也可以参考待复现论文中的说明。
+
+复现完 Dataset 之后,可以构建 Dataloader,对数据进行组 batch、批处理,送进网络进行计算。
+
+`paddle.io.DataLoader`可以进行数据加载,将数据分成批数据,并提供加载过程中的采样。PyTorch 对应的实现为`torch.utils.data.DataLoader`,二者在功能上一致,只是在参数方面稍有 diff:(1)PaddlePaddle 缺少对`pin_memory`等参数的支持;(2)PaddlePaddle 增加了`use_shared_memory`参数来选择是否使用共享内存加速数据加载过程。
+
+**【注意事项】**
+
+论文中一般会提供数据集的名称以及基本信息。复现过程中,我们在下载完数据之后,建议先检查下是否和论文中描述一致,否则可能存在的问题有:
+
+* 数据集版本不同,比如论文中使用了 cnn_dailymail 的 v3.0.0版本数据集,但是我们下载的是 cnn_dailymail 的 v1.0.0版本数据集,如果不对其进行检查,可能会导致我们最终训练的数据量等与论文中有 diff
+* 数据集使用方式不同,有些论文中,可能只是抽取了该数据集的子集进行方法验证,此时需要注意抽取方法,需要保证抽取出的子集完全相同。
+* 在评估指标对齐时,我们可以固定 batch size,关闭 Dataloader 的 shuffle 操作。
+
+构建数据集时,可以使用 paddlenlp 中的数据集加载方式,具体可以参考:[如何自定义数据集](https://paddlenlp.readthedocs.io/zh/latest/data_prepare/dataset_self_defined.html)。对应地,PyTorch 中的数据处理 api 可以参考:[huggingface 的 datasets 自定义数据集](https://huggingface.co/docs/datasets/about_dataset_load.html#building-a-dataset)。对于其中之一,可以找到另一个平台的实现。
+
+此外,
+* 有些自定义的数据处理方法,如果不涉及到深度学习框架的部分,可以直接复用。
+* 对于特定任务中的数据预处理方法,比如说 Tokenizer,如果没有现成的 API 可以调用,可以参考官方模型套件中的一些实现方法,比如 PaddleClas、PaddleDetection、PaddleSeg 等。
+
+**【实战】**
+
+BERT 模型复现过程中,数据预处理和 Dataset、Dataloader 的检查可以参考该文件:
+[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/test_data.py](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/test_data.py)
+
+
+使用方法可以参考[数据检查文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/README.md)。
+
+
+### 3.3 评估指标对齐
+
+**【基本流程】**
+
+PaddlePaddle 提供了一系列 Metric 计算类,比如说`Accuracy`, `Auc`, `Precision`, `Recall`等,而 PyTorch 中,目前可以通过组合的方式实现 metric 计算,或者调用[huggingface-datasets](https://huggingface.co/docs/datasets/about_metrics.html?highlight=metric),在论文复现的过程中,需要注意保证对于该模块,给定相同的输入,二者输出完全一致。具体流程如下。
+
+1. 构建 fake 数据
+1. 使用 PyTorch 的指标获取评估结果,使用 reprod_log 保存结果。
+2. 使用 PaddlePaddle 的指标获取评估结果,使用 reprod_log 保存结果。
+3. 使用 reprod_log 排查 diff,小于阈值,即可完成自测。
+
+**【注意事项】**
+
+在评估指标对齐之前,需要注意保证对于该模块,给定相同的输入,二者输出完全一致。
+
+
+**【实战】**
+
+评估指标对齐检查方法可以参考文档:[评估指标对齐检查方法文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step2/README.md#%E6%95%B0%E6%8D%AE%E8%AF%84%E4%BC%B0%E5%AF%B9%E9%BD%90%E6%B5%81%E7%A8%8B)
+
+
+**【验收】**
+
+对于待复现的项目,评估指标对齐验收流程如下。
+
+1. 输入:dataloader, model
+2. 输出:
+ * PaddlePaddle/PyTorch:dict,key 为 tensor 的 name(自定义),value 为具体评估指标的值。最后将 dict 使用 reprod_log 保存到各自的文件中,建议命名为`metric_paddle.npy`和`metric_torch.npy`。
+ * 自测:使用 reprod_log 加载2个文件,使用 report 功能,记录结果到日志文件中,建议命名为`metric_diff_log.txt`,观察 diff,二者 diff 小于特定的阈值即可。
+3. 提交内容:将`metric_paddle.npy`、`metric_torch.npy`与`metric_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
+4. 注意:
+ * 数据需要是真实数据
+ * 需要检查论文是否只是抽取了验证集/测试集中的部分文件,如果是的话,则需要保证 PaddlePaddle 和参考代码中 dataset 使用的数据集一致。
+
+
+
+### 3.4 损失函数对齐
+
+**【基本流程】**
+
+PaddlePaddle 与 PyTorch 均提供了很多 loss function,用于模型训练,具体的 API 映射表可以参考:[Loss 类 API 映射列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/08_api_mapping/pytorch_api_mapping_cn.html#lossapi)。以 CrossEntropyLoss 为例,主要区别为:
+* PaddlePaddle 提供了对软标签、指定 softmax 计算纬度的支持。
+
+如果论文中使用的 loss function 没有指定的 API,则可以尝试通过组合 API 的方式,实现自定义的 loss function。
+
+具体流程如下。
+
+1. 定义 PyTorch 模型,加载权重,加载 fake data 和 fake label(或者固定 seed,基于 numpy 生成随机数),转换为 PyTorch 可以处理的 tensor,送入网络,获取 loss 结果,使用 reprod_log 保存结果。
+2. 定义 PaddlePaddle 模型,加载 fake data 和 fake label(或者固定 seed,基于 numpy 生成随机数),转换为 PaddlePaddle 可以处理的 tensor,送入网络,获取 loss 结果,使用 reprod_log 保存结果。
+3. 使用 reprod_log 排查 diff,小于阈值,即可完成自测。
+
+**【注意事项】**
+
+* 计算 loss 的时候,建议设置`model.eval()`,避免模型中随机量的问题。
+
+**【实战】**
+
+本部分可以参考文档:[https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step3/README.md](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step3/README.md)。
+
+**【验收】**
+
+对于待复现的项目,损失函数对齐验收流程如下。
+
+1. 输入:fake data & label
+2. 输出:
+ * PaddlePaddle/PyTorch:dict,key 为 tensor 的 name(自定义),value 为具体评估指标的值。最后将 dict 使用 reprod_log 保存到各自的文件中,建议命名为`loss_paddle.npy`和`loss_torch.npy`。
+3. 自测:使用 reprod_log 加载2个文件,使用 report 功能,记录结果到日志文件中,建议命名为`loss_diff_log.txt`,观察 diff,二者 diff 小于特定的阈值即可。
+4. 提交内容:将`loss_paddle.npy`、`loss_torch.npy`与`loss_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
+
+
+### 3.5 优化器对齐
+
+**【基本流程】**
+
+PaddlePaddle 中的 optimizer 有`paddle.optimizer`等一系列实现,PyTorch 中则有`torch.Optim`等一系列实现。
+
+**【注意事项】**
+
+以 SGD 等优化器为例,PaddlePaddle 与 Pytorch 的优化器区别主要如下。
+
+* PaddlePaddle 在优化器中增加了对梯度裁剪的支持,在训练 GAN 或者一些 NLP、多模态任务中,这个用到的比较多。
+* PaddlePaddle 的 SGD 不支持动量更新、动量衰减和 Nesterov 动量,这里需要使用`paddle.optimizer.Momentum` API 实现这些功能。
+
+**【实战】**
+
+本部分对齐建议对照[PaddlePaddle 优化器 API 文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html)与参考代码的优化器实现进行对齐,用之后的反向对齐统一验证该模块的正确性。
+
+
+
+### 3.6 学习率对齐
+
+**【基本流程】**
+
+* 学习率策略主要用于指定训练过程中的学习率变化曲线,这里可以将定义好的学习率策略,不断 step,即可得到对应的学习率值,可以将学习率值保存在列表或者矩阵中,使用`reprod_log`工具判断二者是否对齐。
+
+**【注意事项】**
+
+PaddlePaddle 中,需要首先构建学习率策略,再传入优化器对象中;对于 PyTorch,如果希望使用更丰富的学习率策略,需要先构建优化器,再传入学习率策略类 API。
+
+**【实战】**
+
+学习率复现对齐,可以参考代码:[学习率对齐验证文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step4/README.md#%E5%AD%A6%E4%B9%A0%E7%8E%87%E5%AF%B9%E9%BD%90%E9%AA%8C%E8%AF%81)。
+
+
+### 3.7 正则化策略对齐
+
+**【基本流程】**
+
+L2正则化策略用于模型训练,可以防止模型对训练数据过拟合,L1正则化可以用于得到稀疏化的权重矩阵,PaddlePaddle 中有`paddle.regularizer.L1Decay`与`paddle.regularizer.L2Decay` API。PyTorch 中,torch.optim 集成的优化器只有 L2正则化方法,直接在构建 optimizer 的时候,传入`weight_decay`参数即可。
+
+**【注意事项】**
+
+* PaddlePaddle 的 optimizer 中支持 L1Decat/L2Decay。
+* PyTorch 的 optimizer 支持不同参数列表的学习率分别设置,params 传入字典即可,而 PaddlePaddle 的2.1.0版本目前尚未支持这种行为,可以通过设置`ParamAttr`的`learning_rate`参数,来确定相对学习率倍数。PaddlePaddle 的2.2.0版本中虽然实现该功能,但是模型收敛速度较慢,不建议使用。[优化器收敛速度慢](https://github.com/PaddlePaddle/Paddle/issues/36915)
+
+**【实战】**
+
+本部分对齐建议对照[PaddlePaddle 正则化 API 文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/regularizer/L2Decay_cn.html)与参考代码的优化器实现进行对齐,用之后的反向对齐统一验证该模块的正确性。
+
+
+### 3.8 反向对齐
+
+**【基本流程】**
+
+此处可以通过 numpy 生成假的数据和 label(推荐),也可以准备固定的真实数据。具体流程如下。
+
+1. 检查两个代码的训练超参数全部一致,如优化器及其超参数、学习率、LayerNorm 中的 eps 等。
+2. 将 PaddlePaddle 与 PyTorch 网络中涉及的所有随机操作全部关闭,如 dropout、drop_path 等,推荐将模型设置为 eval 模式(`model.eval()`)
+3. 加载相同的 weight dict(可以通过 PyTorch 来存储随机的权重),将准备好的数据分别传入网络并迭代,观察二者 loss 是否一致(此处 batch-size 要一致,如果使用多个真实数据,要保证传入网络的顺序一致)
+4. 如果经过2轮以上,loss 均可以对齐,则基本可以认为反向对齐。
+
+
+**【注意事项】**
+
+* 如果第一轮 loss 就没有对齐,则需要仔细排查一下模型前向部分。
+* 如果第二轮开始,loss 开始无法对齐,则首先需要排查下超参数的差异,没问题的话,在`loss.backward()`方法之后,使用`tensor.grad`获取梯度值,二分的方法查找 diff,定位出 PaddlePaddle 与 PyTorch 梯度无法对齐的 API 或者操作,然后进一步验证并反馈。
+
+梯度的打印方法示例代码如下所示,注释掉的内容即为打印网络中所有参数的梯度 shape。
+
+```python
+ # 代码地址:https://github.com/JunnYu/BERT-SST2-Prod/blob/2c372656bb1b077b0073c50161771d9fa9d8de5a/pipeline/Step4/test_bp.py#L12
+ def pd_train_some_iters(model,
+ criterion,
+ optimizer,
+ fake_data,
+ fake_label,
+ max_iter=2):
+ model = PDBertForSequenceClassification.from_pretrained("bert-base-uncased", num_classes=2)
+ classifier_weights = paddle.load("../classifier_weights/paddle_classifier_weights.bin")
+ model.load_dict(classifier_weights)
+ model.eval()
+ criterion = paddle.nn.CrossEntropy()
+ decay_params = [
+ p.name for n, p in model.named_parameters()
+ if not any(nd in n for nd in ["bias", "norm"])
+ ]
+ optimizer = paddle.optimizer.AdamW(learning_rate=3e-5, parameters=model.parameters(),
+ weight_decay=1e-2,
+ epsilon=1e-6,
+ apply_decay_param_fun=lambda x: x in decay_params)
+ loss_list = []
+ for idx in range(max_iter):
+ input_ids = paddle.to_tensor(fake_data)
+ labels = paddle.to_tensor(fake_label)
+
+ output = model(input_ids)
+ loss = criterion(output, labels)
+ loss.backward()
+ optimizer.step()
+ optimizer.clear_grad()
+ loss_list.append(loss)
+ return loss_list
+```
+
+
+
+
+**【实战】**
+
+本部分可以参考文档:[反向对齐操作文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step4/README.md#%E5%8F%8D%E5%90%91%E5%AF%B9%E9%BD%90%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95)。
+
+**【验收】**
+
+对于待复现的项目,反向对齐验收流程如下。
+
+1. 输入:fake data & label
+2. 输出:
+ * PaddlePaddle/PyTorch:dict,key 为 tensor 的 name(自定义),value 为具体 loss 的值。最后将 dict 使用 reprod_log 保存到各自的文件中,建议命名为`bp_align_paddle.npy`和`bp_align_torch.npy`。
+3. 自测:使用 reprod_log 加载2个文件,使用 report 功能,记录结果到日志文件中,建议命名为`bp_align_diff_log.txt`,观察 diff,二者 diff 小于特定的阈值即可。
+4. 提交内容:将`bp_align_paddle.npy`、`bp_align_torch.npy`与`bp_align_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,后续的输出结果和自查日志也放在该文件夹中,一并打包上传即可。
+5. 注意:
+ * loss 需要保存至少2轮以上。
+ * 在迭代的过程中,需要保证模型的 batch size 等超参数完全相同
+ * 在迭代的过程中,需要设置`model.eval()`,使用固定的假数据,同时加载相同权重的预训练模型。
+
+
+### 3.9 训练集数据读取对齐
+
+**【基本流程】**
+
+该部分内容与3.2节内容基本一致,参考 PyTorch 的代码,实现训练集数据读取与预处理模块即可。
+
+**【注意事项】**
+
+该部分内容,可以参考3.8节的自测方法,将输入的`fake data & label`替换为训练的 dataloader,但是需要注意的是:
+* 在使用 train dataloader 的时候,建议设置 random seed,对于 PyTorch 来说
+
+```python
+#initialize random seed
+torch.manual_seed(config.SEED)
+torch.cuda.manual_seed_all(config.SEED)
+np.random.seed(config.SEED)
+random.seed(config.SEED)
+```
+
+对于 PaddlePaddle 来说
+
+```python
+paddle.seed(config.SEED)
+np.random.seed(config.SEED)
+random.seed(config.SEED)
+```
+
+
+
+### 3.10 网络初始化对齐
+
+**【基本流程】**
+
+* 下面给出了部分初始化 API 的映射表。
+
+|PaddlePaddle API | PyTorch API |
+|---|---|
+| paddle.nn.initializer.KaimingNormal | torch.nn.init.kaiming_normal_ |
+| paddle.nn.initializer.KaimingUniform | torch.nn.init.kaiming_uniform_ |
+| paddle.nn.initializer.XavierNormal | torch.nn.init.xavier_normal_ |
+| paddle.nn.initializer.XavierUniform | torch.nn.init.xavier_uniform_ |
+
+**【注意事项】**
+
+* 更多初始化 API 可以参考[PyTorch 初始化 API 文档](https://pytorch.org/docs/stable/nn.init.html)以及[PaddlePaddle 初始化 API 文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Overview_cn.html#chushihuaxiangguan)。
+
+**【实战】**
+
+本部分对齐建议对照[PaddlePaddle 初始化 API 文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Overview_cn.html#chushihuaxiangguan)与参考代码的初始化实现对齐。
+
+
+### 3.11 模型训练对齐
+
+**【基本流程】**
+
+完成前面的步骤之后,就可以开始全量数据的训练对齐任务了。按照下面的步骤进行训练对齐。
+
+1. 准备 train/eval data, loader, model
+2. 对 model 按照论文所述进行初始化(如果论文中提到加载了预训练模型,则按需加载 pretrained model)
+3. 加载配置,开始训练,迭代得到最终模型与评估指标,将评估指标使用 reprod_log 保存到文件中。
+4. 将 PaddlePaddle 提供的参考指标使用 reprod_log 提交到另一个文件中。
+5. 使用 reprod_log 排查 diff,小于阈值,即可完成自测。
+
+**【注意事项】**
+
+* 【强烈】建议先做完反向对齐之后再进行模型训练对齐,二者之间的不确定量包括:数据集、PaddlePaddle 与参考代码在模型 training mode 下的区别,初始化参数。
+* 在训练对齐过程中,受到较多随机量的影响,精度有少量 diff 是正常的,以 SST-2数据集的分类为例,diff 在0.15%以内可以认为是正常的,这里可以根据不同的任务,适当调整对齐检查的阈值(`ReprodDiffHelper.report`函数中的`diff_threshold`参数)。
+* 训练过程中的波动是正常的,如果最终收敛结果不一致,可以
+ * 仔细排查 Dropout、BatchNorm 以及其他组网模块及超参是否无误。
+ * 基于参考代码随机生成一份预训练模型,转化为 PaddlePaddle 的模型,并使用 PaddlePaddle 加载训练,对比二者的收敛曲线与最终结果,排查初始化影响。
+ * 使用参考代码的 Dataloader 生成的数据,进行模型训练,排查 train dataloader 的影响。
+
+**【实战】**
+
+本部分可以参考文档:[训练对齐操作文档](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/Step5/README.md)。
+
+**【验收】**
+
+对于待复现的项目,训练对齐验收流程如下。
+
+1. 输入:train/eval dataloader, model
+2. 输出:
+ * PaddlePaddle:dict,key 为保存值的 name(自定义),value 为具体评估指标的值。最后将 dict 使用 reprod_log 保存到文件中,建议命名为`train_align_paddle.npy`。
+ * benchmark:dict,key 为保存值的 name(自定义),value 为论文复现赛的评估指标要求的值。最后将 dict 使用 reprod_log 保存到文件中,建议命名为`train_align_benchmark.npy`。
+3. 自测:使用 reprod_log 加载2个文件,使用 report 功能,记录结果到日志文件中,建议命名为`train_align_diff_log.txt`,观察 diff,二者 diff 小于特定的阈值即可。
+4. 提交内容:将`train_align_paddle.npy`、`train_align_benchmark.npy`与`train_align_diff_log.txt`文件备份到`3.1节验收环节`新建的文件夹中,最终一并打包上传即可。
+
+
+### 3.12 单机多卡训练
+
+如果希望使用单机多卡提升训练效率,可以从以下几个过程对代码进行修改。
+
+#### 3.12.1 数据读取
+
+对于 PaddlePaddle 来说,多卡数据读取这块主要的变化在 sampler
+
+对于单机单卡,sampler 实现方式如下所示。
+
+```python
+train_sampler = paddle.io.RandomSampler(dataset)
+train_batch_sampler = paddle.io.BatchSampler(
+ sampler=train_sampler, batch_size=args.batch_size)
+```
+
+对于单机多卡任务,sampler 实现方式如下所示。
+
+```python
+train_batch_sampler = paddle.io.DistributedBatchSampler(
+ dataset=dataset,
+ batch_size=args.batch_size,
+ shuffle=True,
+ drop_last=False
+ )
+```
+
+注意:在这种情况下,单机多卡的代码仍然能够以单机单卡的方式运行,因此建议以这种 sampler 方式进行论文复现。
+
+
+#### 3.12.2 多卡模型初始化
+
+如果以多卡的方式运行,需要初始化并行训练环境,代码如下所示。
+
+```python
+if paddle.distributed.get_world_size() > 1:
+ paddle.distributed.init_parallel_env()
+```
+
+在模型组网并初始化参数之后,需要使用`paddle.DataParallel()`对模型进行封装,使得模型可以通过数据并行的模式被执行。代码如下所示。
+
+```python
+if paddle.distributed.get_world_size() > 1:
+ model = paddle.DataParallel(model)
+```
+
+
+#### 3.12.3 模型保存、日志保存等其他模块
+
+以模型保存为例,我们只需要在0号卡上保存即可,否则多个 trainer 同时保存的话,可能会造成写冲突,导致最终保存的模型不可用。
+
+
+#### 3.12.4 程序启动方式
+
+对于单机单卡,启动脚本如下所示。[单机单卡](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/benchmark/glue)
+
+```shell
+unset CUDA_VISIBLE_DEVICES
+python -m paddle.distributed.launch --gpus "0" run_glue.py \
+ --model_type bert \
+ --model_name_or_path bert-base-uncased \
+ --task_name SST-2 \
+ --max_seq_length 128 \
+ --batch_size 32 \
+ --learning_rate 2e-5 \
+ --num_train_epochs 3 \
+ --logging_steps 1 \
+ --save_steps 500 \
+ --output_dir ./tmp/ \
+ --device gpu \
+ --use_amp False
+```
+
+
+对于单机多卡(示例中为4卡训练),启动脚本如下所示。
+
+```shell
+unset CUDA_VISIBLE_DEVICES
+python -m paddle.distributed.launch --gpus "0,1,2,3" run_glue.py \
+ --model_type bert \
+ --model_name_or_path bert-base-uncased \
+ --task_name SST-2 \
+ --max_seq_length 128 \
+ --batch_size 32 \
+ --learning_rate 2e-5 \
+ --num_train_epochs 3 \
+ --logging_steps 1 \
+ --save_steps 500 \
+ --output_dir ./tmp/ \
+ --device gpu \
+ --use_amp False
+```
+
+注意:这里8卡训练时,虽然单卡的 batch size 没有变化(32),但是总卡的 batch size 相当于是单卡的8倍,因此学习率也设置为了单卡时的8倍。
+
+
+**【实战】**
+
+本部分可以参考 paddlenlp 库中的例子:[单机多卡训练](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/model_zoo/bert)。
+
+
+## 4. 论文复现注意事项与 FAQ
+
+本部分主要总结大家在论文复现赛过程中遇到的问题,如果本章内容没有能够解决你的问题,欢迎给该文档提出优化建议或者给 Paddle 提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose)。
+
+
+### 4.0 通用注意事项
+
+* 需要仔细对照 PaddlePaddle 与参考代码的优化器参数实现,确保优化器参数严格对齐。
+* 如果遇到一些 Paddle 不支持的 API 操作,可以尝试使用替代实现进行复现。如下面的 PyTorch 代码,PaddlePaddle 中可以通过 slice + concat API 的组合形式进行功能实现。同时,对于这个问题,建议优先给 Paddle 提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),列出 Paddle 不支持的实现,开发人员会根据优先级进行开发。
+
+```python
+torch.stack([
+ per_locations[:, 0] - per_box_regression[:, 0],
+ per_locations[:, 1] - per_box_regression[:, 1],
+ per_locations[:, 0] + per_box_regression[:, 2],
+ per_locations[:, 1] + per_box_regression[:, 3],
+], dim=1)
+```
+* 如果遇到 Paddle 不包含的 OP 或者 API,比如(1) 如果是某些算法实现存在调用了外部 OP,而且 Paddle 也不包含该 OP 实现;(2) 其他框架存在的 API 或者 OP,但是 Paddle 中没有这些 OP。此时:
+ * 对于 Paddle 资深用户来说,可以尝试使用 Paddle 的自定义算子功能,存在一定的代码开发量。
+ * 对于初学者来说,可以给 Paddle 提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),列出 Paddle 不支持的实现,Paddle 开发人员会根据优先级进行实现。
+* PaddlePaddle 与 PyTorch 对于不同名称的 API,实现的功能可能是相同的,复现的时候注意,比如[paddle.optimizer.lr.StepDecay](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/lr/StepDecay_cn.html#stepdecay)与[torch.optim.lr_scheduler.StepLR](https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.StepLR.html#torch.optim.lr_scheduler.StepLR) 。
+* 对于 PaddlePaddle 来说,通过`paddle.set_device`函数(全局)来确定模型结构是运行在什么设备上,对于 torch 来说,是通过`model.to("device")` (局部)来确定模型结构的运行设备,这块在复现的时候需要注意。
+
+
+
+### 4.1 模型结构对齐
+
+#### 4.1.1 API
+* 对于 `paddle.nn.Linear` 层的 weight 参数,PaddlePaddle 与 PyTorch 的保存方式不同,在转换时需要进行转置,示例代码可以参考[BERT 权重转换脚本](https://github.com/JunnYu/BERT-SST2-Prod/blob/main/pipeline/weights/torch2paddle.py)。
+* `torch.masked_fill`函数的功能目前可以使用`paddle.where`进行实现,可以参考:[链接](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/faq/train_cn.html#paddletorch-masked-fillapi)。
+* `pack_padded_sequence`和`pad_packed_sequence`这两个 API 目前 PaddlePaddle 中没有实现,可以直接在 RNN 或者 LSTM 的输入中传入`sequence_length`来实现等价的功能。
+
+
+#### 4.1.2 权重转换
+
+* 在权重转换的时候,不能只关注参数的名称,比如说有些`paddle.nn.Linear`层,但是定义的变量名称为`conv`,这种也是需要进行权重转置的。
+* 权重转换时,建议同时打印 Paddle 和 PyTorch 对应权重的 shape,以防止名称相似但是 shape 不同的参数权重转换报错。
+
+#### 4.1.3 模型组网正确性验证
+
+* 在论文复现的过程中,可能会遇到一些经典的模型结构,比如 Transformer 等,Paddle 官方也提供了 Transformer 的实现,但是这里建议自己根据 PyTorch 代码重新实现一遍,一方面是对整体的模型结构更加熟悉,另一方面也保证模型结构和权重完全对齐。
+* 在复杂的网络结构中,如果前向结果对不齐,可以按照模块排查问题,比如依次获取 embedding、transformer-block、mlm-head 输出等,看下问题具体出现在哪个子模块,再进到子模块详细排查。
+* 网络结构对齐后,尽量使用训练好的预训练模型和真实的数据进行前向 diff 计算,这样更准确。
+
+
+### 4.2 验证/测试集数据读取对齐
+
+* 需要仔细排查数据预处理,不仅包含的预处理方法相同,也需要保证预处理的流程相同,比如先 padding 策略不同和截断策略的不同会导致得到最终的结果是不同的。
+
+
+### 4.3 评估指标对齐
+
+* 真实数据评估时,需要注意评估时 `paddle.io.DataLoader` 的 ``drop_last`` 参数是否打开(文档[链接](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/io/DataLoader_cn.html#dataloader)),复现代码需要与参考代码保持一致,否则最后不够 batch-size 的数据的评估会有 diff。
+* 在识别或者检索过程中,为了加速评估过程,往往会将评估函数由 CPU 实现改为 GPU 实现,由此会带来评估函数输出的不一致。这是由于 sort 函数对于相同值的排序结果不同带来的。在复现的过程中,如果可以接受轻微的指标不稳定,可以使用 PaddlePaddle 的 sort 函数,如果对于指标非常敏感,同时对速度性能要求很高,可以给 PaddlePaddle 提[ISSUE](https://github.com/PaddlePaddle/Paddle/issues/new/choose),由研发人员高优开发。
+
+
+
+### 4.4 损失函数对齐
+
+* 部分算法的损失函数中会用到 bool 索引,这时候可以使用[paddle.where](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/where_cn.html#where) 代替。
+* `paddle.nn.CrossEntropyLoss` 默认是在最后一维(axis=-1)计算损失函数,而 `torch.nn.CrossEntropyLoss` 是在 axis=1的地方计算损失函数,因此如果输入的维度大于2,这里需要保证计算的维(axis)相同,否则可能会出错。
+* 在生成模型中会遇到梯度损失,需要对模型中的算子求二次梯度,目前`MaxPooling`暂时不支持二次梯度,如果复现的过程中遇到了需要对`MaxPooling`求二次梯度的情况,可以和 Paddle 官方开发同学反馈,进一步确认解决方案。
+* 在保存损失函数值的时候,注意要使用`paddle.no_grad`,或者仅仅保存转换成 numpy 的数组,避免损失没有析构导致内存泄漏问题。
+
+```python
+# 错误示范
+loss = celoss(pred, label)
+avg_loss += loss
+# 正确示范1
+loss = celoss(pred, label)
+avg_loss += loss.numpy()
+# 正确示范2
+loss = celoss(pred, label)
+with paddle.no_grad()
+ avg_loss += loss
+```
+
+
+### 4.5 优化器对齐
+
+* Paddle 目前支持在 ``optimizer`` 中通过设置 ``params_groups`` 的方式设置不同参数的更新方式,可以参考[代码示例](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/optimizer/optimizer.py#L107) 。
+* 有些模型训练时,会使用梯度累加策略,即累加到一定 step 数量之后才进行参数更新,这时在实现上需要注意对齐。
+* 在某些任务中,比如说深度学习可视化、可解释性等任务中,一般只要求模型前向过程,不需要训练,此时优化器、学习率等用于模型训练的模块对于该类论文复现是不需要的。
+* 在文本分类领域,大多数 Transformer 模型都采用了 AdamW 优化器,并且会设置 weigh decay,同时部分参数设置为 no weight decay,例如位置编码的参数通常设置为 no weight decay,no weight decay 参数设置不正确,最终会有明显的精度损失,需要特别注意。一般可以通过分析模型权重来发现该问题,分别计算官方模型和复现模型每层参数权重的平均值、方差,对每一层依次对比,有显著差异的层可能存在问题,因为在 weight decay 的作用下,参数权重数值会相对较小,而未正确设置 no weight decay,则会造成该层参数权重数值异常偏小。
+
+
+
+### 4.6 学习率对齐
+
+* PaddlePaddle 中参数的学习率受到优化器学习率和`ParamAttr`中设置的学习率影响,因此跟踪学习率需要将二者结合进行跟踪。
+* 对于复现代码和参考代码,学习率在整个训练过程中在相同的轮数相同的 iter 下应该保持一致,可以通过`reprod_log`工具、打印学习率值或者可视化二者学习率的 log 来查看 diff。
+* 有些网络的学习率策略比较细致,比如带 warmup 的学习率策略,这里需要保证起始学习率等参数都完全一致。
+
+
+
+### 4.7 正则化策略对齐
+
+* 在如 Transformer 或者少部分 CNN 模型中,存在一些参数不做正则化(正则化系数为0)的情况。这里需要找到这些参数并对齐取消实施正则化策略,可以参考[这里](https://github.com/PaddlePaddle/PaddleClas/blob/release%2F2.3/ppcls/arch/backbone/model_zoo/resnest.py#L72),对特定参数进行修改。
+
+
+### 4.8 反向对齐
+
+* 反向对齐时,如果第二轮开始,loss 开始无法对齐,则首先需要排查下超参数的差异,没问题的话,在`loss.backward()`方法之后,使用`tensor.grad`获取梯度值,二分的方法查找 diff,定位出 PaddlePaddle 与 PyTorch 梯度无法对齐的 API 或者操作,然后进一步验证。第3章中给出了获取所有参数的梯度方法,如果只希望打印特定参数的梯度,可以用下面的方式。
+
+
+```python
+import paddle
+
+def print_hook_fn(grad):
+ print(grad)
+
+x = paddle.to_tensor([0., 1., 2., 3.], stop_gradient=False)
+h = x.register_hook(print_hook_fn)
+w = x * 4
+w.backward()
+# backward之后会输出下面的内容
+# Tensor(shape=[4], dtype=float32, place=CPUPlace, stop_gradient=False,
+# [4., 4., 4., 4.])
+```
+
+
+
+### 4.9 训练集数据读取对齐
+
+#### 4.9.1 API
+
+* 在前向过程中,如果数据预处理过程运行出错,请先将 ``paddle.io.DataLoader`` 的 ``num_workers`` 参数设为0,然后根据单个进程下的报错日志定位出具体的 bug。
+
+#### 4.9.2 数据预处理
+
+
+* 如果数据处理过程中涉及到随机数生成,建议固定 seed (`np.random.seed(0)`, `random.seed(0)`),查看复现代码和参考代码处理后的数据是否有 diff。
+* 对文本进行 tokenizer 处理时,需要确定文本的截断策略,padding 策略。
+
+
+### 4.10 网络初始化对齐
+
+* 对于不同的深度学习框架,网络初始化在大多情况下,即使值的分布完全一致,也无法保证值完全一致,这里也是论文复现中不确定性比较大的地方。如果十分怀疑初始化导致的问题,建议将参考的初始化权重转成 paddle 模型,加载该初始化模型训练,看下收敛精度。
+* CNN 对于模型初始化相对来说没有那么敏感,在迭代轮数与数据集足够的情况下,最终精度指标基本接近;而 transformer 系列模型对于初始化比较敏感,在 transformer 系列模型训练对齐过程中,建议对这一块进行重点检查。
+
+
+
+### 4.11 模型训练对齐
+
+#### 4.11.1 训练对齐通用问题
+
+* 有条件的话,复现工作之前最好先基于官方代码完成训练,保证与官方指标能够对齐,并且将训练策略和训练过程中的关键指标记录保存下来,比如每个 epoch 的学习率、Train Loss、Eval Loss、Eval Acc 等,在复现网络的训练过程中,将关键指标保存下来,这样可以将两次训练中关键指标的变化曲线绘制出来,能够很方便的进行对比。
+* 训练过程中可以对 loss 或者 acc 进行可视化,和竞品 loss 或者 acc 进行直观的对比;如果训练较大的数据集,1次完整训练的成本比较高,此时可以隔一段时间查看一下,如果精度差异比较大,建议先停掉实验,排查原因。
+* 如果训练的过程中出 nan,一般是因为除0或者 log0的情况, 可以着重看下几个部分:
+ * 如果有预训练模型的话,可以确认下是否加载正确
+ * 模型结构中计算 loss 的部分是否有考虑到正样本为0的情况
+ * 也可能是某个 API 的数值越界导致的,可以测试较小的输入是否还会出现 nan。
+* 如果训练过程中如果出现不收敛的情况,可以
+ * 简化网络和数据,实验是否收敛;
+ * 如果是基于原有实现进行改动,可以尝试控制变量法,每次做一个改动,逐个排查;
+ * 检查学习率是否过大、优化器设置是否合理,排查下 weight decay 是否设置正确;
+ * 保存不同 step 之间的模型参数,观察模型参数是否更新。
diff --git a/legacy/examples/torch_migration/pipeline/Step1/README.md b/slm/examples/torch_migration/pipeline/Step1/README.md
similarity index 90%
rename from legacy/examples/torch_migration/pipeline/Step1/README.md
rename to slm/examples/torch_migration/pipeline/Step1/README.md
index b3db11238110..fe605919cec4 100644
--- a/legacy/examples/torch_migration/pipeline/Step1/README.md
+++ b/slm/examples/torch_migration/pipeline/Step1/README.md
@@ -21,7 +21,7 @@ python pt_forward_bert.py
python check_step1.py
```
-具体地,以PaddlePaddle为例,`pd_forward_bert.py`的具体代码如下所示。
+具体地,以 PaddlePaddle 为例,`pd_forward_bert.py`的具体代码如下所示。
```python
import numpy as np
@@ -61,7 +61,7 @@ reprod_logger.add("logits", out.cpu().detach().numpy())
reprod_logger.save("forward_paddle.npy")
```
-diff检查的代码可以参考:[check_step1.py](./check_step1.py),具体代码如下所示。
+diff 检查的代码可以参考:[check_step1.py](./check_step1.py),具体代码如下所示。
```python
# https://github.com/littletomatodonkey/AlexNet-Prod/blob/master/pipeline/Step1/check_step1.py
@@ -75,7 +75,7 @@ if __name__ == "__main__":
diff_helper.report(path="forward_diff.log")
```
-产出日志如下,同时会将check的结果保存在`forward_diff.log`文件中。
+产出日志如下,同时会将 check 的结果保存在`forward_diff.log`文件中。
```
[2021/11/17 20:15:50] root INFO: logits:
diff --git a/legacy/examples/torch_migration/pipeline/Step1/check_step1.py b/slm/examples/torch_migration/pipeline/Step1/check_step1.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step1/check_step1.py
rename to slm/examples/torch_migration/pipeline/Step1/check_step1.py
diff --git a/legacy/examples/torch_migration/pipeline/Step1/pd_forward_bert.py b/slm/examples/torch_migration/pipeline/Step1/pd_forward_bert.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step1/pd_forward_bert.py
rename to slm/examples/torch_migration/pipeline/Step1/pd_forward_bert.py
diff --git a/legacy/examples/torch_migration/pipeline/Step1/pt_forward_bert.py b/slm/examples/torch_migration/pipeline/Step1/pt_forward_bert.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step1/pt_forward_bert.py
rename to slm/examples/torch_migration/pipeline/Step1/pt_forward_bert.py
diff --git a/legacy/examples/torch_migration/pipeline/Step1/torch2paddle.py b/slm/examples/torch_migration/pipeline/Step1/torch2paddle.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step1/torch2paddle.py
rename to slm/examples/torch_migration/pipeline/Step1/torch2paddle.py
diff --git a/legacy/examples/torch_migration/pipeline/Step2/README.md b/slm/examples/torch_migration/pipeline/Step2/README.md
similarity index 94%
rename from legacy/examples/torch_migration/pipeline/Step2/README.md
rename to slm/examples/torch_migration/pipeline/Step2/README.md
index 029761c85e47..658295f4fb49 100644
--- a/legacy/examples/torch_migration/pipeline/Step2/README.md
+++ b/slm/examples/torch_migration/pipeline/Step2/README.md
@@ -8,7 +8,7 @@
python test_data.py
```
-显示出以下内容,Dataset以及Dataloader的长度和内容diff均满足小于指定阈值,可以认为复现成功。
+显示出以下内容,Dataset 以及 Dataloader 的长度和内容 diff 均满足小于指定阈值,可以认为复现成功。
```
[2021/11/17 20:57:06] root INFO: length:
@@ -81,7 +81,7 @@ python test_data.py
### 评估代码和修改内容说明
-Pytorch准确率评估指标使用的是huggingface的datasets库。
+Pytorch 准确率评估指标使用的是 huggingface 的 datasets 库。
```python
import torch
@@ -95,7 +95,7 @@ hf_accuracy = hf_metric.compute()["accuracy"]
print(hf_accuracy)
```
-对应地,PaddlePaddle评估指标代码如下
+对应地,PaddlePaddle 评估指标代码如下
```python
import paddle
@@ -122,7 +122,7 @@ python test_metric.py
python check_step2.py
```
-最终结果输出如下,accuracy精度diff为0,小于阈值,结果前向验证,
+最终结果输出如下,accuracy 精度 diff 为0,小于阈值,结果前向验证,
```
[2021/11/17 21:15:05] root INFO: accuracy:
[2021/11/17 21:15:05] root INFO: mean diff: check passed: True, value: 0.0
diff --git a/legacy/examples/torch_migration/pipeline/Step2/accuracy.py b/slm/examples/torch_migration/pipeline/Step2/accuracy.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/accuracy.py
rename to slm/examples/torch_migration/pipeline/Step2/accuracy.py
diff --git a/legacy/examples/torch_migration/pipeline/Step2/check_step2.py b/slm/examples/torch_migration/pipeline/Step2/check_step2.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/check_step2.py
rename to slm/examples/torch_migration/pipeline/Step2/check_step2.py
diff --git a/legacy/examples/torch_migration/pipeline/Step2/demo_sst2_sentence/demo.tsv b/slm/examples/torch_migration/pipeline/Step2/demo_sst2_sentence/demo.tsv
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/demo_sst2_sentence/demo.tsv
rename to slm/examples/torch_migration/pipeline/Step2/demo_sst2_sentence/demo.tsv
diff --git a/legacy/examples/torch_migration/pipeline/Step2/predict.py b/slm/examples/torch_migration/pipeline/Step2/predict.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/predict.py
rename to slm/examples/torch_migration/pipeline/Step2/predict.py
diff --git a/legacy/examples/torch_migration/pipeline/Step2/test_data.py b/slm/examples/torch_migration/pipeline/Step2/test_data.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/test_data.py
rename to slm/examples/torch_migration/pipeline/Step2/test_data.py
diff --git a/legacy/examples/torch_migration/pipeline/Step2/test_metric.py b/slm/examples/torch_migration/pipeline/Step2/test_metric.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step2/test_metric.py
rename to slm/examples/torch_migration/pipeline/Step2/test_metric.py
diff --git a/legacy/examples/torch_migration/pipeline/Step3/README.md b/slm/examples/torch_migration/pipeline/Step3/README.md
similarity index 89%
rename from legacy/examples/torch_migration/pipeline/Step3/README.md
rename to slm/examples/torch_migration/pipeline/Step3/README.md
index 4e6e79ae1bf1..4ef877310bc9 100644
--- a/legacy/examples/torch_migration/pipeline/Step3/README.md
+++ b/slm/examples/torch_migration/pipeline/Step3/README.md
@@ -2,7 +2,7 @@
## 代码解析
-以PaddlePaddle为例,下面为定义模型、计算loss并保存的代码。
+以 PaddlePaddle 为例,下面为定义模型、计算 loss 并保存的代码。
```python
# paddle_loss.py
@@ -36,7 +36,7 @@ if __name__ == "__main__":
```
-记录loss并保存在`loss_paddle.npy`文件中。
+记录 loss 并保存在`loss_paddle.npy`文件中。
## 操作步骤
@@ -64,4 +64,4 @@ python check_step3.py
```
-diff为5.96e-8,check通过。
+diff 为5.96e-8,check 通过。
diff --git a/legacy/examples/torch_migration/pipeline/Step3/check_step3.py b/slm/examples/torch_migration/pipeline/Step3/check_step3.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step3/check_step3.py
rename to slm/examples/torch_migration/pipeline/Step3/check_step3.py
diff --git a/legacy/examples/torch_migration/pipeline/Step3/paddle_loss.py b/slm/examples/torch_migration/pipeline/Step3/paddle_loss.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step3/paddle_loss.py
rename to slm/examples/torch_migration/pipeline/Step3/paddle_loss.py
diff --git a/legacy/examples/torch_migration/pipeline/Step3/torch_loss.py b/slm/examples/torch_migration/pipeline/Step3/torch_loss.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step3/torch_loss.py
rename to slm/examples/torch_migration/pipeline/Step3/torch_loss.py
diff --git a/legacy/examples/torch_migration/pipeline/Step4/README.md b/slm/examples/torch_migration/pipeline/Step4/README.md
similarity index 90%
rename from legacy/examples/torch_migration/pipeline/Step4/README.md
rename to slm/examples/torch_migration/pipeline/Step4/README.md
index 695b0728a773..053f90e31a57 100644
--- a/legacy/examples/torch_migration/pipeline/Step4/README.md
+++ b/slm/examples/torch_migration/pipeline/Step4/README.md
@@ -45,14 +45,14 @@ python test_lr_scheduler.py
```
-linear和polynomial方式衰减的学习率diff为0,check通过,cosine方式衰减学习率可能由于计算误差未通过。
+linear 和 polynomial 方式衰减的学习率 diff 为0,check 通过,cosine 方式衰减学习率可能由于计算误差未通过。
### 反向对齐操作方法
#### 代码讲解
-以PaddlePaddle为例,训练流程核心代码如下所示。每个iter中输入相同的fake data与fake label,计算loss,进行梯度反传与参数更新,将loss批量返回,用于后续的验证。
+以 PaddlePaddle 为例,训练流程核心代码如下所示。每个 iter 中输入相同的 fake data 与 fake label,计算 loss,进行梯度反传与参数更新,将 loss 批量返回,用于后续的验证。
```python
def pd_train_some_iters(model,
@@ -96,7 +96,7 @@ def pd_train_some_iters(model,
#### 操作方法
-运行下面的命令,基于fake data与fake label,依次生成若干轮loss数据并保存,使用`reprod_log`工具进行diff排查。
+运行下面的命令,基于 fake data 与 fake label,依次生成若干轮 loss 数据并保存,使用`reprod_log`工具进行 diff 排查。
```shell
# 生成paddle和torch的前向数据
@@ -133,4 +133,4 @@ python check_step4.py
```
-前面10轮的loss diff均等于0,check通过。
+前面10轮的 loss diff 均等于0,check 通过。
diff --git a/legacy/examples/torch_migration/pipeline/Step4/check_step4.py b/slm/examples/torch_migration/pipeline/Step4/check_step4.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step4/check_step4.py
rename to slm/examples/torch_migration/pipeline/Step4/check_step4.py
diff --git a/legacy/examples/torch_migration/pipeline/Step4/test_bp.py b/slm/examples/torch_migration/pipeline/Step4/test_bp.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step4/test_bp.py
rename to slm/examples/torch_migration/pipeline/Step4/test_bp.py
diff --git a/legacy/examples/torch_migration/pipeline/Step4/test_lr_scheduler.py b/slm/examples/torch_migration/pipeline/Step4/test_lr_scheduler.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step4/test_lr_scheduler.py
rename to slm/examples/torch_migration/pipeline/Step4/test_lr_scheduler.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/README.md b/slm/examples/torch_migration/pipeline/Step5/README.md
similarity index 61%
rename from legacy/examples/torch_migration/pipeline/Step5/README.md
rename to slm/examples/torch_migration/pipeline/Step5/README.md
index bab96301cac7..887a8d81b8e8 100644
--- a/legacy/examples/torch_migration/pipeline/Step5/README.md
+++ b/slm/examples/torch_migration/pipeline/Step5/README.md
@@ -1,6 +1,6 @@
# 使用方法
-首先运行下面的python代码,生成`train_align_torch.npy`和`train_align_paddle.npy`文件。
+首先运行下面的 python 代码,生成`train_align_torch.npy`和`train_align_paddle.npy`文件。
```python
# 运行生成paddle结果
@@ -11,14 +11,14 @@ cd bert_torch/
sh train.sh
```
-然后运行下面的代码,运行训练脚本;之后使用`check_step5.py`进行精度diff验证。
+然后运行下面的代码,运行训练脚本;之后使用`check_step5.py`进行精度 diff 验证。
```shell
# 对比生成log
python check_step5.py
```
-这里需要注意的是,由于是精度对齐,SST-2数据集的精度diff在0.15%以内时,可以认为对齐,因此将`diff_threshold`参数修改为了`0.0015`。
+这里需要注意的是,由于是精度对齐,SST-2数据集的精度 diff 在0.15%以内时,可以认为对齐,因此将`diff_threshold`参数修改为了`0.0015`。
```
[2021/11/17 22:41:12] root INFO: acc:
@@ -26,4 +26,4 @@ python check_step5.py
[2021/11/17 22:41:12] root INFO: diff check passed
```
-最终diff为`0.00114`,小于阈值标准,检查通过。
+最终 diff 为`0.00114`,小于阈值标准,检查通过。
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_paddle/train.py b/slm/examples/torch_migration/pipeline/Step5/bert_paddle/train.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_paddle/train.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_paddle/train.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_paddle/train.sh b/slm/examples/torch_migration/pipeline/Step5/bert_paddle/train.sh
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_paddle/train.sh
rename to slm/examples/torch_migration/pipeline/Step5/bert_paddle/train.sh
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_paddle/utils.py b/slm/examples/torch_migration/pipeline/Step5/bert_paddle/utils.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_paddle/utils.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_paddle/utils.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_torch/accuracy.py b/slm/examples/torch_migration/pipeline/Step5/bert_torch/accuracy.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_torch/accuracy.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_torch/accuracy.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_torch/glue.py b/slm/examples/torch_migration/pipeline/Step5/bert_torch/glue.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_torch/glue.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_torch/glue.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_torch/train.py b/slm/examples/torch_migration/pipeline/Step5/bert_torch/train.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_torch/train.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_torch/train.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_torch/train.sh b/slm/examples/torch_migration/pipeline/Step5/bert_torch/train.sh
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_torch/train.sh
rename to slm/examples/torch_migration/pipeline/Step5/bert_torch/train.sh
diff --git a/legacy/examples/torch_migration/pipeline/Step5/bert_torch/utils.py b/slm/examples/torch_migration/pipeline/Step5/bert_torch/utils.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/bert_torch/utils.py
rename to slm/examples/torch_migration/pipeline/Step5/bert_torch/utils.py
diff --git a/legacy/examples/torch_migration/pipeline/Step5/check_step5.py b/slm/examples/torch_migration/pipeline/Step5/check_step5.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/Step5/check_step5.py
rename to slm/examples/torch_migration/pipeline/Step5/check_step5.py
diff --git a/legacy/examples/torch_migration/pipeline/classifier_weights/generate_classifier_weights.py b/slm/examples/torch_migration/pipeline/classifier_weights/generate_classifier_weights.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/classifier_weights/generate_classifier_weights.py
rename to slm/examples/torch_migration/pipeline/classifier_weights/generate_classifier_weights.py
diff --git a/legacy/examples/torch_migration/pipeline/fake_data/gen_fake_data.py b/slm/examples/torch_migration/pipeline/fake_data/gen_fake_data.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/fake_data/gen_fake_data.py
rename to slm/examples/torch_migration/pipeline/fake_data/gen_fake_data.py
diff --git a/legacy/examples/torch_migration/pipeline/models/pd_bert.py b/slm/examples/torch_migration/pipeline/models/pd_bert.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/models/pd_bert.py
rename to slm/examples/torch_migration/pipeline/models/pd_bert.py
diff --git a/legacy/examples/torch_migration/pipeline/models/pt_bert.py b/slm/examples/torch_migration/pipeline/models/pt_bert.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/models/pt_bert.py
rename to slm/examples/torch_migration/pipeline/models/pt_bert.py
diff --git a/legacy/examples/torch_migration/pipeline/reprod_log_demo/check_log_diff.py b/slm/examples/torch_migration/pipeline/reprod_log_demo/check_log_diff.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/reprod_log_demo/check_log_diff.py
rename to slm/examples/torch_migration/pipeline/reprod_log_demo/check_log_diff.py
diff --git a/legacy/examples/torch_migration/pipeline/reprod_log_demo/write_log.py b/slm/examples/torch_migration/pipeline/reprod_log_demo/write_log.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/reprod_log_demo/write_log.py
rename to slm/examples/torch_migration/pipeline/reprod_log_demo/write_log.py
diff --git a/legacy/examples/torch_migration/pipeline/weights/torch2paddle.py b/slm/examples/torch_migration/pipeline/weights/torch2paddle.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/weights/torch2paddle.py
rename to slm/examples/torch_migration/pipeline/weights/torch2paddle.py
diff --git a/legacy/examples/torch_migration/pipeline/weights/torch_bert_weight.py b/slm/examples/torch_migration/pipeline/weights/torch_bert_weight.py
similarity index 100%
rename from legacy/examples/torch_migration/pipeline/weights/torch_bert_weight.py
rename to slm/examples/torch_migration/pipeline/weights/torch_bert_weight.py
diff --git a/legacy/examples/torch_migration/requirements.txt b/slm/examples/torch_migration/requirements.txt
similarity index 100%
rename from legacy/examples/torch_migration/requirements.txt
rename to slm/examples/torch_migration/requirements.txt
diff --git a/legacy/model_zoo/README.md b/slm/model_zoo/README.md
similarity index 100%
rename from legacy/model_zoo/README.md
rename to slm/model_zoo/README.md
diff --git a/legacy/model_zoo/bert/README.md b/slm/model_zoo/bert/README.md
similarity index 63%
rename from legacy/model_zoo/bert/README.md
rename to slm/model_zoo/bert/README.md
index 03022ce3a4be..f25ed3e07bca 100644
--- a/legacy/model_zoo/bert/README.md
+++ b/slm/model_zoo/bert/README.md
@@ -2,15 +2,15 @@
## 模型简介
-[BERT](https://arxiv.org/abs/1810.04805) (Bidirectional Encoder Representations from Transformers)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,使用掩码语言模型(Masked Language Model)和邻接句子预测(Next Sentence Prediction)两个任务在大规模无标注文本语料上进行预训练(pre-train),得到融合了双向内容的通用语义表示模型。以预训练产生的通用语义表示模型为基础,结合任务适配的简单输出层,微调(fine-tune)后即可应用到下游的NLP任务,效果通常也较直接在下游的任务上训练的模型更优。此前BERT即在[GLUE评测任务](https://gluebenchmark.com/tasks)上取得了SOTA的结果。
+[BERT](https://arxiv.org/abs/1810.04805) (Bidirectional Encoder Representations from Transformers)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,使用掩码语言模型(Masked Language Model)和邻接句子预测(Next Sentence Prediction)两个任务在大规模无标注文本语料上进行预训练(pre-train),得到融合了双向内容的通用语义表示模型。以预训练产生的通用语义表示模型为基础,结合任务适配的简单输出层,微调(fine-tune)后即可应用到下游的 NLP 任务,效果通常也较直接在下游的任务上训练的模型更优。此前 BERT 即在[GLUE 评测任务](https://gluebenchmark.com/tasks)上取得了 SOTA 的结果。
-本项目是BERT在 Paddle 2.0上的开源实现,包含了预训练和[GLUE评测任务](https://gluebenchmark.com/tasks)上的微调代码。
+本项目是 BERT 在 Paddle 2.0上的开源实现,包含了预训练和[GLUE 评测任务](https://gluebenchmark.com/tasks)上的微调代码。
## 快速开始
### 环境依赖
-本教程除了需要安装PaddleNLP库,还需以下依赖
+本教程除了需要安装 PaddleNLP 库,还需以下依赖
```text
h5py
@@ -18,9 +18,9 @@ h5py
### 数据准备
-#### Pre-training数据准备
+#### Pre-training 数据准备
-`create_pretraining_data.py` 是创建预训练程序所需数据的脚本。其以文本文件(使用换行符换行和空白符分隔,data目录下提供了部分示例数据)为输入,经由BERT tokenizer进行tokenize后再做生成sentence pair正负样本、掩码token等处理,最后输出hdf5格式的数据文件。使用方式如下:
+`create_pretraining_data.py` 是创建预训练程序所需数据的脚本。其以文本文件(使用换行符换行和空白符分隔,data 目录下提供了部分示例数据)为输入,经由 BERT tokenizer 进行 tokenize 后再做生成 sentence pair 正负样本、掩码 token 等处理,最后输出 hdf5格式的数据文件。使用方式如下:
```shell
python create_pretraining_data.py \
@@ -37,24 +37,24 @@ python create_pretraining_data.py \
其中参数释义如下:
- `input_file` 指定输入文件,可以使用目录,指定目录时将包括目录中的所有`.txt`文件。
- `output_file` 指定输出文件。
-- `bert_model` 指定使用特定BERT模型对应的tokenizer进行tokenize处理。
-- `max_seq_length` 指定最大句子长度,超过该长度将被截断,不足该长度的将会进行padding。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目。
-- `masked_lm_prob` 表示每个token被mask的概率。
+- `bert_model` 指定使用特定 BERT 模型对应的 tokenizer 进行 tokenize 处理。
+- `max_seq_length` 指定最大句子长度,超过该长度将被截断,不足该长度的将会进行 padding。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目。
+- `masked_lm_prob` 表示每个 token 被 mask 的概率。
- `random_seed` 指定随机种子。
-- `dupe_factor` 指定输入数据被重复处理的次数,每次处理将重新产生随机mask。
+- `dupe_factor` 指定输入数据被重复处理的次数,每次处理将重新产生随机 mask。
-使用以上预训练数据生成程序可以用于处理领域垂类数据后进行二次预训练。若需要使用BERT论文中预训练使用的英文Wiki和BookCorpus数据,可以参考[这里](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)进行处理,得到的数据可以直接接入本项目中的预训练程序使用。
+使用以上预训练数据生成程序可以用于处理领域垂类数据后进行二次预训练。若需要使用 BERT 论文中预训练使用的英文 Wiki 和 BookCorpus 数据,可以参考[这里](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)进行处理,得到的数据可以直接接入本项目中的预训练程序使用。
-#### Fine-tunning数据准备
+#### Fine-tunning 数据准备
-##### GLUE评测任务数据
+##### GLUE 评测任务数据
-GLUE评测任务所含数据集已在paddlenlp中以API形式提供,无需预先准备,使用`run_glue.py`执行微调时将会自动下载。
+GLUE 评测任务所含数据集已在 paddlenlp 中以 API 形式提供,无需预先准备,使用`run_glue.py`执行微调时将会自动下载。
-### 执行Pre-training
+### 执行 Pre-training
-GPU训练
+GPU 训练
unset CUDA_VISIBLE_DEVICES
python -m paddle.distributed.launch --gpus "0" run_pretrain.py \
--model_type bert \
@@ -74,24 +74,24 @@ python -m paddle.distributed.launch --gpus "0" run_pretrain.py \
--use_amp False
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目,与创建预训练数据时的设置一致。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目,与创建预训练数据时的设置一致。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `adam_epsilon` 表示AdamW优化器中使用的epsilon值。
-- `warmup_steps` 表示动态学习率热启的step数。
-- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含training的文件将被作为训练数据。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `adam_epsilon` 表示 AdamW 优化器中使用的 epsilon 值。
+- `warmup_steps` 表示动态学习率热启的 step 数。
+- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含 training 的文件将被作为训练数据。
- `output_dir` 表示模型的保存目录。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `max_steps` 表示最大训练步数,达到`max_steps`后就提前结束。注意,我们必须设置 `max_steps`。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `use_amp` 指示是否启用自动混合精度训练。
-#### GPU训练(Trainer版本)
+#### GPU 训练(Trainer 版本)
```shell
unset CUDA_VISIBLE_DEVICES
python -m paddle.distributed.launch --gpus "0" run_pretrain_trainer.py \
@@ -115,7 +115,7 @@ python -m paddle.distributed.launch --gpus "0" run_pretrain_trainer.py \
```
-XPU训练
+XPU 训练
unset FLAGS_selected_xpus
python -m paddle.distributed.launch --xpus "0" run_pretrain.py \
--model_type bert \
@@ -135,24 +135,24 @@ python -m paddle.distributed.launch --xpus "0" run_pretrain.py \
--use_amp False
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目,与创建预训练数据时的设置一致。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目,与创建预训练数据时的设置一致。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `adam_epsilon` 表示AdamW优化器中使用的epsilon值。
-- `warmup_steps` 表示动态学习率热启的step数。
-- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含training的文件将被作为训练数据。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `adam_epsilon` 表示 AdamW 优化器中使用的 epsilon 值。
+- `warmup_steps` 表示动态学习率热启的 step 数。
+- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含 training 的文件将被作为训练数据。
- `output_dir` 表示模型的保存目录。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `max_steps` 表示最大训练步数,达到`max_steps`后就提前结束。注意,我们必须设置 `max_steps`。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `use_amp` 指示是否启用自动混合精度训练。
-#### XPU训练(Trainer版本)
+#### XPU 训练(Trainer 版本)
```shell
unset FLAGS_selected_xpus
python -m paddle.distributed.launch --xpus "0" run_pretrain_trainer.py \
@@ -175,29 +175,29 @@ python -m paddle.distributed.launch --xpus "0" run_pretrain_trainer.py \
--do_train
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目,与创建预训练数据时的设置一致。
-- `per_device_train_batch_size` 表示用于训练的每个 GPU 核心/CPU 的batch大小.(`int`,可选,默认为 8)
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `adam_epsilon` 表示AdamW优化器中使用的epsilon值。
-- `warmup_steps` 表示动态学习率热启的step数。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目,与创建预训练数据时的设置一致。
+- `per_device_train_batch_size` 表示用于训练的每个 GPU 核心/CPU 的 batch 大小.(`int`,可选,默认为 8)
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `adam_epsilon` 表示 AdamW 优化器中使用的 epsilon 值。
+- `warmup_steps` 表示动态学习率热启的 step 数。
- `num_train_epochs` 表示训练轮数。
-- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含training的文件将被作为训练数据。
+- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含 training 的文件将被作为训练数据。
- `output_dir` 表示模型的保存目录。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `max_steps` 表示最大训练步数,达到`max_steps`后就提前结束。注意,我们必须设置 `max_steps`。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `fp16` 是否使用 fp16 混合精度训练而不是 fp32 训练。(`bool`, 可选, 默认为 `False`)
- `do_train` 是否进行训练任务。(`bool`, 可选, 默认为 `False`)
-**NOTICE**: 预训练时data目录存放的是经过 `create_pretraining_data.py` 处理后的数据,因此需要通过该数据处理脚本预先处理,否则预训练将会出现报错。
+**NOTICE**: 预训练时 data 目录存放的是经过 `create_pretraining_data.py` 处理后的数据,因此需要通过该数据处理脚本预先处理,否则预训练将会出现报错。
-### 执行Fine-tunning
+### 执行 Fine-tunning
-以GLUE中的SST-2任务为例,启动Fine-tuning的方式如下:
+以 GLUE 中的 SST-2任务为例,启动 Fine-tuning 的方式如下:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -219,22 +219,22 @@ python -m paddle.distributed.launch --gpus "0" run_glue_trainer.py \
```
其中参数释义如下:
-- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。注:`bert-base-uncased`等对应使用的预训练模型转自[huggingface/transformers](https://github.com/huggingface/transformers),具体可参考当前目录下converter中的内容。
-- `task_name` 表示Fine-tuning的任务。
+- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。注:`bert-base-uncased`等对应使用的预训练模型转自[huggingface/transformers](https://github.com/huggingface/transformers),具体可参考当前目录下 converter 中的内容。
+- `task_name` 表示 Fine-tuning 的任务。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
-- `per_device_train_batch_size` 表示用于训练的每个 GPU 核心/CPU 的batch大小.(`int`,可选,默认为 8)
-- `per_device_eval_batch_size` 表示用于评估的每个 GPU 核心/CPU 的batch大小.(`int`,可选,默认为 8)
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `per_device_train_batch_size` 表示用于训练的每个 GPU 核心/CPU 的 batch 大小.(`int`,可选,默认为 8)
+- `per_device_eval_batch_size` 表示用于评估的每个 GPU 核心/CPU 的 batch 大小.(`int`,可选,默认为 8)
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU, 'npu'表示使用华为昇腾卡。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU, 'npu'表示使用华为昇腾卡。
- `fp16` 是否使用 fp16 混合精度训练而不是 fp32 训练。(`bool`, 可选, 默认为 `False`)
- `do_train` 是否进行训练任务。(`bool`, 可选, 默认为 `False`)
- `do_eval` 是否进行评估任务。同上。(`bool`, 可选, 默认为 `False`)
-基于`bert-base-uncased`在GLUE各评测任务上Fine-tuning后,在验证集上有如下结果:
+基于`bert-base-uncased`在 GLUE 各评测任务上 Fine-tuning 后,在验证集上有如下结果:
| Task | Metric | Result |
|:----:|:--------------------------:|:---------------:|
@@ -250,7 +250,7 @@ python -m paddle.distributed.launch --gpus "0" run_glue_trainer.py \
### 预测
-在Fine-tuning完成后,我们可以使用如下方式导出希望用来预测的模型:
+在 Fine-tuning 完成后,我们可以使用如下方式导出希望用来预测的模型:
```shell
python -u ./export_model.py \
@@ -260,11 +260,11 @@ python -u ./export_model.py \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_path` 表示训练模型的保存路径,与训练时的`output_dir`一致。
-- `output_path` 表示导出预测模型文件的前缀。保存时会添加后缀(`pdiparams`,`pdiparams.info`,`pdmodel`);除此之外,还会在`output_path`包含的目录下保存tokenizer相关内容。
+- `output_path` 表示导出预测模型文件的前缀。保存时会添加后缀(`pdiparams`,`pdiparams.info`,`pdmodel`);除此之外,还会在`output_path`包含的目录下保存 tokenizer 相关内容。
-完成模型导出后,可以开始部署。`deploy/python/seq_cls_infer.py` 文件提供了python部署预测示例。可执行以下命令运行部署示例:
+完成模型导出后,可以开始部署。`deploy/python/seq_cls_infer.py` 文件提供了 python 部署预测示例。可执行以下命令运行部署示例:
```shell
python deploy/python/seq_cls_infer.py --model_dir infer_model/ --device gpu --backend paddle
@@ -285,4 +285,4 @@ Batch id: 4, example id: 0, sentence1: this new jangle of noise , mayhem and stu
## 扩展
-上述的介绍是基于动态图的BERT的预训练任务和微调任务以及预测任务的实践过程,同时在我们也提供了基于PaddlePaddle Fleet API的静态图的BERT相关实践,在组网代码层面保持动静统一,在计算速度以及多机联合训练方面有着更优的性能,具体的细节可以参考 [BERT静态图](./static/)。
+上述的介绍是基于动态图的 BERT 的预训练任务和微调任务以及预测任务的实践过程,同时在我们也提供了基于 PaddlePaddle Fleet API 的静态图的 BERT 相关实践,在组网代码层面保持动静统一,在计算速度以及多机联合训练方面有着更优的性能,具体的细节可以参考 [BERT 静态图](./static/)。
diff --git a/legacy/model_zoo/bert/create_pretraining_data.py b/slm/model_zoo/bert/create_pretraining_data.py
similarity index 100%
rename from legacy/model_zoo/bert/create_pretraining_data.py
rename to slm/model_zoo/bert/create_pretraining_data.py
diff --git a/legacy/model_zoo/bert/data/sample_text.txt b/slm/model_zoo/bert/data/sample_text.txt
similarity index 100%
rename from legacy/model_zoo/bert/data/sample_text.txt
rename to slm/model_zoo/bert/data/sample_text.txt
diff --git a/legacy/model_zoo/bert/deploy/python/README.md b/slm/model_zoo/bert/deploy/python/README.md
similarity index 94%
rename from legacy/model_zoo/bert/deploy/python/README.md
rename to slm/model_zoo/bert/deploy/python/README.md
index e65c589548aa..7e78d164ac14 100644
--- a/legacy/model_zoo/bert/deploy/python/README.md
+++ b/slm/model_zoo/bert/deploy/python/README.md
@@ -32,13 +32,13 @@ Batch id: 4, example id: 0, sentence1: this new jangle of noise , mayhem and stu
| 参数 |参数说明 |
|----------|--------------|
|--model_dir | 指定部署模型的目录, |
-|--batch_size |输入的batch size,默认为 1|
+|--batch_size |输入的 batch size,默认为 1|
|--max_length |最大序列长度,默认为 128|
|--device | 运行的设备,可选范围: ['cpu', 'gpu'],默认为'cpu' |
-|--device_id | 运行设备的id。默认为0。 |
-|--cpu_threads | 当使用cpu推理时,指定推理的cpu线程数,默认为1。|
+|--device_id | 运行设备的 id。默认为0。 |
+|--cpu_threads | 当使用 cpu 推理时,指定推理的 cpu 线程数,默认为1。|
|--backend | 支持的推理后端,可选范围: ['onnx_runtime', 'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt'],默认为'paddle' |
-|--use_fp16 | 是否使用FP16模式进行推理。使用tensorrt和paddle_tensorrt后端时可开启,默认为False |
+|--use_fp16 | 是否使用 FP16模式进行推理。使用 tensorrt 和 paddle_tensorrt 后端时可开启,默认为 False |
## FastDeploy 高阶用法
diff --git a/legacy/model_zoo/bert/deploy/python/seq_cls_infer.py b/slm/model_zoo/bert/deploy/python/seq_cls_infer.py
similarity index 100%
rename from legacy/model_zoo/bert/deploy/python/seq_cls_infer.py
rename to slm/model_zoo/bert/deploy/python/seq_cls_infer.py
diff --git a/legacy/model_zoo/bert/export_model.py b/slm/model_zoo/bert/export_model.py
similarity index 100%
rename from legacy/model_zoo/bert/export_model.py
rename to slm/model_zoo/bert/export_model.py
diff --git a/legacy/model_zoo/bert/run_glue_trainer.py b/slm/model_zoo/bert/run_glue_trainer.py
similarity index 100%
rename from legacy/model_zoo/bert/run_glue_trainer.py
rename to slm/model_zoo/bert/run_glue_trainer.py
diff --git a/legacy/model_zoo/bert/run_pretrain.py b/slm/model_zoo/bert/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/bert/run_pretrain.py
rename to slm/model_zoo/bert/run_pretrain.py
diff --git a/legacy/model_zoo/bert/run_pretrain_trainer.py b/slm/model_zoo/bert/run_pretrain_trainer.py
similarity index 100%
rename from legacy/model_zoo/bert/run_pretrain_trainer.py
rename to slm/model_zoo/bert/run_pretrain_trainer.py
diff --git a/legacy/model_zoo/bert/static/README.md b/slm/model_zoo/bert/static/README.md
similarity index 56%
rename from legacy/model_zoo/bert/static/README.md
rename to slm/model_zoo/bert/static/README.md
index fa3d5f62b28d..dbb757fe99ad 100644
--- a/legacy/model_zoo/bert/static/README.md
+++ b/slm/model_zoo/bert/static/README.md
@@ -1,17 +1,17 @@
# BERT Benchmark with Fleet API
## 模型简介
-[BERT](https://arxiv.org/abs/1810.04805) (Bidirectional Encoder Representations from Transformers)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,使用掩码语言模型(Masked Language Model)和邻接句子预测(Next Sentence Prediction)两个任务在大规模无标注文本语料上进行预训练(pre-train),得到融合了双向内容的通用语义表示模型。以预训练产生的通用语义表示模型为基础,结合任务适配的简单输出层,微调(fine-tune)后即可应用到下游的NLP任务,效果通常也较直接在下游的任务上训练的模型更优。此前BERT即在[GLUE评测任务](https://gluebenchmark.com/tasks)上取得了SOTA的结果。
+[BERT](https://arxiv.org/abs/1810.04805) (Bidirectional Encoder Representations from Transformers)以[Transformer](https://arxiv.org/abs/1706.03762) 编码器为网络基本组件,使用掩码语言模型(Masked Language Model)和邻接句子预测(Next Sentence Prediction)两个任务在大规模无标注文本语料上进行预训练(pre-train),得到融合了双向内容的通用语义表示模型。以预训练产生的通用语义表示模型为基础,结合任务适配的简单输出层,微调(fine-tune)后即可应用到下游的 NLP 任务,效果通常也较直接在下游的任务上训练的模型更优。此前 BERT 即在[GLUE 评测任务](https://gluebenchmark.com/tasks)上取得了 SOTA 的结果。
-本项目是BERT在 Paddle 2.0上的开源实现,包含了预训练和[GLUE评测任务](https://gluebenchmark.com/tasks)上的微调代码。
+本项目是 BERT 在 Paddle 2.0上的开源实现,包含了预训练和[GLUE 评测任务](https://gluebenchmark.com/tasks)上的微调代码。
## 快速开始
### 数据准备
-#### Pre-training数据准备
+#### Pre-training 数据准备
-`create_pretraining_data.py` 是创建预训练程序所需数据的脚本。其以文本文件(使用换行符换行和空白符分隔,data目录下提供了部分示例数据)为输入,经由BERT tokenizer进行tokenize后再做生成sentence pair正负样本、掩码token等处理,最后输出hdf5格式的数据文件。使用方式如下:
+`create_pretraining_data.py` 是创建预训练程序所需数据的脚本。其以文本文件(使用换行符换行和空白符分隔,data 目录下提供了部分示例数据)为输入,经由 BERT tokenizer 进行 tokenize 后再做生成 sentence pair 正负样本、掩码 token 等处理,最后输出 hdf5格式的数据文件。使用方式如下:
```shell
python create_pretraining_data.py \
@@ -28,25 +28,25 @@ python create_pretraining_data.py \
其中参数释义如下:
- `input_file` 指定输入文件,可以使用目录,指定目录时将包括目录中的所有`.txt`文件。
- `output_file` 指定输出文件。
-- `bert_model` 指定使用特定BERT模型对应的tokenizer进行tokenize处理。
-- `max_seq_length` 指定最大句子长度,超过该长度将被截断,不足该长度的将会进行padding。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目。
-- `masked_lm_prob` 表示每个token被mask的概率。
+- `bert_model` 指定使用特定 BERT 模型对应的 tokenizer 进行 tokenize 处理。
+- `max_seq_length` 指定最大句子长度,超过该长度将被截断,不足该长度的将会进行 padding。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目。
+- `masked_lm_prob` 表示每个 token 被 mask 的概率。
- `random_seed` 指定随机种子。
-- `dupe_factor` 指定输入数据被重复处理的次数,每次处理将重新产生随机mask。
+- `dupe_factor` 指定输入数据被重复处理的次数,每次处理将重新产生随机 mask。
-使用以上预训练数据生成程序可以用于处理领域垂类数据后进行二次预训练。若需要使用BERT论文中预训练使用的英文Wiki和BookCorpus数据,可以参考[这里](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)进行处理,得到的数据可以直接接入本项目中的预训练程序使用。
+使用以上预训练数据生成程序可以用于处理领域垂类数据后进行二次预训练。若需要使用 BERT 论文中预训练使用的英文 Wiki 和 BookCorpus 数据,可以参考[这里](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)进行处理,得到的数据可以直接接入本项目中的预训练程序使用。
-#### Fine-tuning数据准备
-Fine-tuning的数据集已经被PaddleNLP框架集成,只需要填写相应的数据集的名称,PaddleNLP会自动下载数据集,具体的使用方法可以参考 `run_glue.py` 脚本。
+#### Fine-tuning 数据准备
+Fine-tuning 的数据集已经被 PaddleNLP 框架集成,只需要填写相应的数据集的名称,PaddleNLP 会自动下载数据集,具体的使用方法可以参考 `run_glue.py` 脚本。
-##### GLUE评测任务数据
+##### GLUE 评测任务数据
-GLUE评测任务所含数据集已在paddlenlp中以API形式提供,无需预先准备,使用`run_glue.py`执行微调时将会自动下载。
+GLUE 评测任务所含数据集已在 paddlenlp 中以 API 形式提供,无需预先准备,使用`run_glue.py`执行微调时将会自动下载。
-### 执行Pre-training
+### 执行 Pre-training
-#### GPU训练
+#### GPU 训练
```shell
unset CUDA_VISIBLE_DEVICES
python -m paddle.distributed.launch --gpus "0" run_pretrain.py \
@@ -67,27 +67,27 @@ python -m paddle.distributed.launch --gpus "0" run_pretrain.py \
--use_amp False
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
-- `max_predictions_per_seq` 表示每个句子中会被mask的token的最大数目,与创建预训练数据时的设置一致。
+- `max_predictions_per_seq` 表示每个句子中会被 mask 的 token 的最大数目,与创建预训练数据时的设置一致。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `adam_epsilon` 表示AdamW优化器中使用的epsilon值。
-- `warmup_steps` 表示动态学习率热启的step数。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `adam_epsilon` 表示 AdamW 优化器中使用的 epsilon 值。
+- `warmup_steps` 表示动态学习率热启的 step 数。
- `num_train_epochs` 表示训练轮数。
-- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含training的文件将被作为训练数据。
+- `input_dir` 表示输入数据的目录,该目录下所有文件名中包含 training 的文件将被作为训练数据。
- `output_dir` 表示模型的保存目录。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `max_steps` 表示最大训练步数。若训练`num_train_epochs`轮包含的训练步数大于该值,则达到`max_steps`后就提前结束。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `use_amp` 指示是否启用自动混合精度训练。
-**NOTICE**: 预训练时data目录存放的是经过 `create_pretraining_data.py` 处理后的数据,因此需要通过该数据处理脚本预先处理,否则预训练将会出现报错。
+**NOTICE**: 预训练时 data 目录存放的是经过 `create_pretraining_data.py` 处理后的数据,因此需要通过该数据处理脚本预先处理,否则预训练将会出现报错。
-### 执行Fine-tunning
+### 执行 Fine-tunning
-以GLUE中的SST-2任务为例,启动Fine-tuning的方式如下:
+以 GLUE 中的 SST-2任务为例,启动 Fine-tuning 的方式如下:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -106,19 +106,19 @@ python -m paddle.distributed.launch --gpus "0" run_glue.py \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
-- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。注:`bert-base-uncased`等对应使用的预训练模型转自[huggingface/transformers](https://github.com/huggingface/transformers),具体可参考当前目录下converter中的内容。
-- `task_name` 表示Fine-tuning的任务。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
+- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。注:`bert-base-uncased`等对应使用的预训练模型转自[huggingface/transformers](https://github.com/huggingface/transformers),具体可参考当前目录下 converter 中的内容。
+- `task_name` 表示 Fine-tuning 的任务。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
-基于`bert-base-uncased`在GLUE各评测任务上Fine-tuning后,在验证集上有如下结果:
+基于`bert-base-uncased`在 GLUE 各评测任务上 Fine-tuning 后,在验证集上有如下结果:
| Task | Metric | Result |
|-------|------------------------------|-------------|
@@ -131,8 +131,8 @@ python -m paddle.distributed.launch --gpus "0" run_glue.py \
### 预测
-在Fine-tuning完成后,我们可以使用如下方式导出希望用来预测的模型:
-然后按照如下的方式进行GLUE中的评测任务进行预测(基于Paddle的[Python预测API](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/python_infer_cn.html)):
+在 Fine-tuning 完成后,我们可以使用如下方式导出希望用来预测的模型:
+然后按照如下的方式进行 GLUE 中的评测任务进行预测(基于 Paddle 的[Python 预测 API](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/05_inference_deployment/inference/python_infer_cn.html)):
```shell
python -u ./predict_glue.py \
@@ -144,8 +144,8 @@ python -u ./predict_glue.py \
```
其中参数释义如下:
-- `task_name` 表示Fine-tuning的任务。
-- `model_type` 指示了模型类型,使用BERT模型时设置为bert即可。
+- `task_name` 表示 Fine-tuning 的任务。
+- `model_type` 指示了模型类型,使用 BERT 模型时设置为 bert 即可。
- `model_path` 表示预测模型文件的前缀,和上一步导出预测模型中的`output_path`一致。
- `batch_size` 表示每个预测批次的样本数目。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
diff --git a/legacy/model_zoo/bert/static/create_pretraining_data.py b/slm/model_zoo/bert/static/create_pretraining_data.py
similarity index 100%
rename from legacy/model_zoo/bert/static/create_pretraining_data.py
rename to slm/model_zoo/bert/static/create_pretraining_data.py
diff --git a/legacy/model_zoo/bert/static/data/sample_text.txt b/slm/model_zoo/bert/static/data/sample_text.txt
similarity index 100%
rename from legacy/model_zoo/bert/static/data/sample_text.txt
rename to slm/model_zoo/bert/static/data/sample_text.txt
diff --git a/legacy/model_zoo/bert/static/dataset.py b/slm/model_zoo/bert/static/dataset.py
similarity index 100%
rename from legacy/model_zoo/bert/static/dataset.py
rename to slm/model_zoo/bert/static/dataset.py
diff --git a/legacy/model_zoo/bert/static/predict_glue.py b/slm/model_zoo/bert/static/predict_glue.py
similarity index 100%
rename from legacy/model_zoo/bert/static/predict_glue.py
rename to slm/model_zoo/bert/static/predict_glue.py
diff --git a/legacy/model_zoo/bert/static/run_glue.py b/slm/model_zoo/bert/static/run_glue.py
similarity index 100%
rename from legacy/model_zoo/bert/static/run_glue.py
rename to slm/model_zoo/bert/static/run_glue.py
diff --git a/legacy/model_zoo/bert/static/run_glue_with_sparaity.py b/slm/model_zoo/bert/static/run_glue_with_sparaity.py
similarity index 100%
rename from legacy/model_zoo/bert/static/run_glue_with_sparaity.py
rename to slm/model_zoo/bert/static/run_glue_with_sparaity.py
diff --git a/legacy/model_zoo/bert/static/run_pretrain.py b/slm/model_zoo/bert/static/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/bert/static/run_pretrain.py
rename to slm/model_zoo/bert/static/run_pretrain.py
diff --git a/legacy/model_zoo/bert/static_ipu/README.md b/slm/model_zoo/bert/static_ipu/README.md
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/README.md
rename to slm/model_zoo/bert/static_ipu/README.md
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/custom_checkpointoutput.cc b/slm/model_zoo/bert/static_ipu/custom_ops/custom_checkpointoutput.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/custom_checkpointoutput.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/custom_checkpointoutput.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/custom_detach.cc b/slm/model_zoo/bert/static_ipu/custom_ops/custom_detach.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/custom_detach.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/custom_detach.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/custom_identity.cc b/slm/model_zoo/bert/static_ipu/custom_ops/custom_identity.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/custom_identity.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/custom_identity.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/custom_nll_loss.cc b/slm/model_zoo/bert/static_ipu/custom_ops/custom_nll_loss.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/custom_nll_loss.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/custom_nll_loss.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/custom_shape_infer.cc b/slm/model_zoo/bert/static_ipu/custom_ops/custom_shape_infer.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/custom_shape_infer.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/custom_shape_infer.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/disable_attn_dropout_bwd_pattern.cc b/slm/model_zoo/bert/static_ipu/custom_ops/disable_attn_dropout_bwd_pattern.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/disable_attn_dropout_bwd_pattern.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/disable_attn_dropout_bwd_pattern.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/tied_gather.cc b/slm/model_zoo/bert/static_ipu/custom_ops/tied_gather.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/tied_gather.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/tied_gather.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/tied_gather_pattern.cc b/slm/model_zoo/bert/static_ipu/custom_ops/tied_gather_pattern.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/tied_gather_pattern.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/tied_gather_pattern.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/utils.cc b/slm/model_zoo/bert/static_ipu/custom_ops/utils.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/utils.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/utils.cc
diff --git a/legacy/model_zoo/bert/static_ipu/custom_ops/workarounds/prevent_const_expr_folding_op.cc b/slm/model_zoo/bert/static_ipu/custom_ops/workarounds/prevent_const_expr_folding_op.cc
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/custom_ops/workarounds/prevent_const_expr_folding_op.cc
rename to slm/model_zoo/bert/static_ipu/custom_ops/workarounds/prevent_const_expr_folding_op.cc
diff --git a/legacy/model_zoo/bert/static_ipu/dataset_ipu.py b/slm/model_zoo/bert/static_ipu/dataset_ipu.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/dataset_ipu.py
rename to slm/model_zoo/bert/static_ipu/dataset_ipu.py
diff --git a/legacy/model_zoo/bert/static_ipu/load_tf_ckpt.py b/slm/model_zoo/bert/static_ipu/load_tf_ckpt.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/load_tf_ckpt.py
rename to slm/model_zoo/bert/static_ipu/load_tf_ckpt.py
diff --git a/legacy/model_zoo/bert/static_ipu/modeling.py b/slm/model_zoo/bert/static_ipu/modeling.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/modeling.py
rename to slm/model_zoo/bert/static_ipu/modeling.py
diff --git a/legacy/model_zoo/bert/static_ipu/requirements.txt b/slm/model_zoo/bert/static_ipu/requirements.txt
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/requirements.txt
rename to slm/model_zoo/bert/static_ipu/requirements.txt
diff --git a/legacy/model_zoo/bert/static_ipu/run_pretrain.py b/slm/model_zoo/bert/static_ipu/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/run_pretrain.py
rename to slm/model_zoo/bert/static_ipu/run_pretrain.py
diff --git a/legacy/model_zoo/bert/static_ipu/run_squad.py b/slm/model_zoo/bert/static_ipu/run_squad.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/run_squad.py
rename to slm/model_zoo/bert/static_ipu/run_squad.py
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain.sh b/slm/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain_phase2.sh b/slm/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain_phase2.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain_phase2.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod16/run_pretrain_phase2.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod16/run_squad.sh b/slm/model_zoo/bert/static_ipu/scripts/pod16/run_squad.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod16/run_squad.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod16/run_squad.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod16/run_squad_infer.sh b/slm/model_zoo/bert/static_ipu/scripts/pod16/run_squad_infer.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod16/run_squad_infer.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod16/run_squad_infer.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain.sh b/slm/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain_phase2.sh b/slm/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain_phase2.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain_phase2.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod4/run_pretrain_phase2.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod4/run_squad.sh b/slm/model_zoo/bert/static_ipu/scripts/pod4/run_squad.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod4/run_squad.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod4/run_squad.sh
diff --git a/legacy/model_zoo/bert/static_ipu/scripts/pod4/run_squad_infer.sh b/slm/model_zoo/bert/static_ipu/scripts/pod4/run_squad_infer.sh
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/scripts/pod4/run_squad_infer.sh
rename to slm/model_zoo/bert/static_ipu/scripts/pod4/run_squad_infer.sh
diff --git a/legacy/model_zoo/bert/static_ipu/utils.py b/slm/model_zoo/bert/static_ipu/utils.py
similarity index 100%
rename from legacy/model_zoo/bert/static_ipu/utils.py
rename to slm/model_zoo/bert/static_ipu/utils.py
diff --git a/legacy/model_zoo/bigbird/README.md b/slm/model_zoo/bigbird/README.md
similarity index 61%
rename from legacy/model_zoo/bigbird/README.md
rename to slm/model_zoo/bigbird/README.md
index 9bc3f26b8346..1dcea475ebb2 100644
--- a/legacy/model_zoo/bigbird/README.md
+++ b/slm/model_zoo/bigbird/README.md
@@ -1,7 +1,7 @@
# Big Bird
## 模型介绍
-[Big Bird](https://arxiv.org/abs/2007.14062)(Transformers for Longer Sequences) 是Google的研究人员提出的针对长序列预训练模型,使用了稀疏注意力机制,将计算复杂度、空间复杂度降到线性复杂度,大大提升了长序列任务的预测能力。
+[Big Bird](https://arxiv.org/abs/2007.14062)(Transformers for Longer Sequences) 是 Google 的研究人员提出的针对长序列预训练模型,使用了稀疏注意力机制,将计算复杂度、空间复杂度降到线性复杂度,大大提升了长序列任务的预测能力。
本项目是 Big Bird 的 PaddlePaddle 实现, 包含模型训练,模型验证等内容。以下是本例的简要目录结构及说明:
@@ -46,25 +46,25 @@ python -m paddle.distributed.launch --gpus "0" --log_dir log run_pretrain.py --
其中参数释义如下:
-- `gpus` paddle.distributed.launch参数,用于指定使用哪张显卡。单卡格式:"0";多卡格式:"0,1,2"。
-- `log_dir` paddle.distributed.launch参数,用于指定训练日志输出的目录,默认值为`log`。(注意,如果需要在同一目录多次启动run_pretrain.py,需要设置不同的log_dir,否则日志会重定向到相同的文件中)。
+- `gpus` paddle.distributed.launch 参数,用于指定使用哪张显卡。单卡格式:"0";多卡格式:"0,1,2"。
+- `log_dir` paddle.distributed.launch 参数,用于指定训练日志输出的目录,默认值为`log`。(注意,如果需要在同一目录多次启动 run_pretrain.py,需要设置不同的 log_dir,否则日志会重定向到相同的文件中)。
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。目前支持的训练模型配置有:"bigbird-base-uncased"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"
- `input_dir` 指定输入文件,可以使用目录,指定目录时将包括目录中的所有文件。
- `output_dir` 指定输出文件。
-- `batch_size` 训练的batch大小
-- `weight_decay` AdamW权重衰减参数
+- `batch_size` 训练的 batch 大小
+- `weight_decay` AdamW 权重衰减参数
- `learning_rate` 训练的学习率
- `max_steps` 最大训练步数
- `save_steps` 保存模型间隔
- `logging_steps` 打印日志的步数
-- `max_encoder_length` MLM任务的最大的token数目
-- `max_pred_length` MLM任务最大的需要预测token的数目
+- `max_encoder_length` MLM 任务的最大的 token 数目
+- `max_pred_length` MLM 任务最大的需要预测 token 的数目
### 验证任务
-#### Imdb分类任务
-通过预训练任务训练完成之后,可以预训练的模型参数,在 Big Bird 的验证任务中通过IMDB数据集来进行最终模型效果的验证,[IMDB数据集](http://ai.stanford.edu/~amaas/data/sentiment/) ,IMDB数据集是关于电影用户评论情感分析的数据集,主要是包含了50000条偏向明显的评论,其中25000条作为训练集,25000作为测试集。label为pos(positive)和neg(negative),是一个序列文本分类任务,具体的执行脚本如下。
+#### Imdb 分类任务
+通过预训练任务训练完成之后,可以预训练的模型参数,在 Big Bird 的验证任务中通过 IMDB 数据集来进行最终模型效果的验证,[IMDB 数据集](http://ai.stanford.edu/~amaas/data/sentiment/) ,IMDB 数据集是关于电影用户评论情感分析的数据集,主要是包含了50000条偏向明显的评论,其中25000条作为训练集,25000作为测试集。label 为 pos(positive)和 neg(negative),是一个序列文本分类任务,具体的执行脚本如下。
```shell
@@ -80,25 +80,25 @@ python run_classifier.py --model_name_or_path bigbird-base-uncased \
其中参数释义如下:
-- `model_name_or_path` 指示了finetune使用的具体预训练模型以及预训练时使用的tokenizer,目前支持的预训练模型有:"bigbird-base-uncased"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型以及预训练时使用的 tokenizer,目前支持的预训练模型有:"bigbird-base-uncased"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
- `output_dir` 指定输出文件。
-- `batch_size` 训练的batch大小。
+- `batch_size` 训练的 batch 大小。
- `learning_rate` 训练的学习率。
- `max_steps` 最大训练步数。
- `save_steps` 保存模型间隔。
- `logging_steps` 打印日志的步数。
-- `max_encoder_length` MLM任务的最大的token数目。
+- `max_encoder_length` MLM 任务的最大的 token 数目。
-基于`bigbird-base-uncased`在IMDB评测任务上Fine-tuning后,在验证集上有如下结果:
+基于`bigbird-base-uncased`在 IMDB 评测任务上 Fine-tuning 后,在验证集上有如下结果:
| Task | Metric | Result |
|:-----:|:----------------------------:|:-----------------:|
| IMDB | Accuracy | 0.9449 |
-#### Glue任务
+#### Glue 任务
-以GLUE中的SST-2任务为例,启动Fine-tuning的方式如下:
+以 GLUE 中的 SST-2任务为例,启动 Fine-tuning 的方式如下:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -117,19 +117,19 @@ python -m paddle.distributed.launch --gpus "0" run_glue.py \
```
其中参数释义如下:
-- `model_type` 指示了模型类型,使用bigbird模型时设置为bigbird即可。
-- `model_name_or_path` 指示了finetune使用的具体预训练模型以及预训练时使用的tokenizer,目前支持的预训练模型有:"bigbird-base-uncased"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
-- `task_name` 表示Fine-tuning的任务。
+- `model_type` 指示了模型类型,使用 bigbird 模型时设置为 bigbird 即可。
+- `model_name_or_path` 指示了 finetune 使用的具体预训练模型以及预训练时使用的 tokenizer,目前支持的预训练模型有:"bigbird-base-uncased"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
+- `task_name` 表示 Fine-tuning 的任务。
- `max_encoder_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU, 'npu'表示使用华为昇腾卡。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU, 'npu'表示使用华为昇腾卡。
-基于`bigbird-base-uncased`在GLUE各评测任务上Fine-tuning后,在验证集上有如下结果:
+基于`bigbird-base-uncased`在 GLUE 各评测任务上 Fine-tuning 后,在验证集上有如下结果:
| Task | Metric | Result |
|:-----:|:----------------------------:|:-----------------:|
@@ -144,7 +144,7 @@ python -m paddle.distributed.launch --gpus "0" run_glue.py \
### 致谢
-* 感谢[Google 研究团队](https://github.com/google-research/bigbird)提供BigBird开源代码的实现以及预训练模型。
+* 感谢[Google 研究团队](https://github.com/google-research/bigbird)提供 BigBird 开源代码的实现以及预训练模型。
### 参考论文
diff --git a/legacy/model_zoo/bigbird/args.py b/slm/model_zoo/bigbird/args.py
similarity index 100%
rename from legacy/model_zoo/bigbird/args.py
rename to slm/model_zoo/bigbird/args.py
diff --git a/legacy/model_zoo/bigbird/data/data.txt b/slm/model_zoo/bigbird/data/data.txt
similarity index 100%
rename from legacy/model_zoo/bigbird/data/data.txt
rename to slm/model_zoo/bigbird/data/data.txt
diff --git a/legacy/model_zoo/bigbird/run_classifier.py b/slm/model_zoo/bigbird/run_classifier.py
similarity index 100%
rename from legacy/model_zoo/bigbird/run_classifier.py
rename to slm/model_zoo/bigbird/run_classifier.py
diff --git a/legacy/model_zoo/bigbird/run_glue.py b/slm/model_zoo/bigbird/run_glue.py
similarity index 100%
rename from legacy/model_zoo/bigbird/run_glue.py
rename to slm/model_zoo/bigbird/run_glue.py
diff --git a/legacy/model_zoo/bigbird/run_pretrain.py b/slm/model_zoo/bigbird/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/bigbird/run_pretrain.py
rename to slm/model_zoo/bigbird/run_pretrain.py
diff --git a/legacy/model_zoo/chinesebert/README.md b/slm/model_zoo/chinesebert/README.md
similarity index 67%
rename from legacy/model_zoo/chinesebert/README.md
rename to slm/model_zoo/chinesebert/README.md
index 7a2c6ccc9422..e60165ca1c03 100644
--- a/legacy/model_zoo/chinesebert/README.md
+++ b/slm/model_zoo/chinesebert/README.md
@@ -3,27 +3,27 @@
[ChineseBERT: Chinese Pretraining Enhanced by Glyph and Pinyin Information](https://arxiv.org/pdf/2106.16038.pdf)
**摘要:**
-最近的汉语预训练模型忽略了汉语特有的两个重要方面:字形和拼音,它们对语言理解具有重要的语法和语义信息。在本研究中,我们提出了汉语预训练,它将汉字的字形和拼音信息纳入语言模型预训练中。字形嵌入是基于汉字的不同字体获得的,能够从视觉特征中捕捉汉字语义,拼音嵌入代表汉字的发音,处理汉语中高度流行的异义现象(同一汉字具有不同的发音和不同的含义)。在大规模的未标记中文语料库上进行预训练后,所提出的ChineseBERT模型在训练步骤较少的基线模型上产生了显著的性能提高。该模型在广泛的中国自然语言处理任务上实现了新的SOTA性能,包括机器阅读理解、自然语言推理、文本分类、句子对匹配和命名实体识别方面的竞争性能。
+最近的汉语预训练模型忽略了汉语特有的两个重要方面:字形和拼音,它们对语言理解具有重要的语法和语义信息。在本研究中,我们提出了汉语预训练,它将汉字的字形和拼音信息纳入语言模型预训练中。字形嵌入是基于汉字的不同字体获得的,能够从视觉特征中捕捉汉字语义,拼音嵌入代表汉字的发音,处理汉语中高度流行的异义现象(同一汉字具有不同的发音和不同的含义)。在大规模的未标记中文语料库上进行预训练后,所提出的 ChineseBERT 模型在训练步骤较少的基线模型上产生了显著的性能提高。该模型在广泛的中国自然语言处理任务上实现了新的 SOTA 性能,包括机器阅读理解、自然语言推理、文本分类、句子对匹配和命名实体识别方面的竞争性能。
-本项目是 ChineseBert 在 Paddle 2.x上的开源实现。
+本项目是 ChineseBert 在 Paddle 2.x 上的开源实现。
## **数据准备**
-涉及到的ChnSentiCorp,crmc2018,XNLI数据
-部分Paddle已提供,其他可参考https://github.com/27182812/ChineseBERT_paddle,
-在data目录下。
+涉及到的 ChnSentiCorp,crmc2018,XNLI 数据
+部分 Paddle 已提供,其他可参考 https://github.com/27182812/ChineseBERT_paddle,
+在 data 目录下。
## **模型预训练**
-模型预训练过程可参考[Electra的README](../electra/README.md)
+模型预训练过程可参考[Electra 的 README](../electra/README.md)
## **Fine-tuning**
-### 运行Fine-tuning
+### 运行 Fine-tuning
-#### **使用Paddle提供的预训练模型运行 Fine-tuning**
+#### **使用 Paddle 提供的预训练模型运行 Fine-tuning**
#### 1、ChnSentiCorp
-以ChnSentiCorp数据集为例
+以 ChnSentiCorp 数据集为例
#### (1)模型微调:
```shell
@@ -48,14 +48,14 @@ python -m paddle.distributed.launch --gpus 0,1 python train_chn.py \
```
其中参数释义如下:
- `data_path` 表示微调数据路径
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
- `num_train_epochs` 表示训练轮数。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `per_device_train_batch_size` 表示每次迭代**每张卡**上的训练样本数目。
- `per_device_eval_batch_size` 表示每次迭代**每张卡**上的验证样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `adam_beta2` 表示优化器中使用的beta2的系数。
-- `weight_decay` 表示优化器中使用的weight_decay的系数。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `adam_beta2` 表示优化器中使用的 beta2的系数。
+- `weight_decay` 表示优化器中使用的 weight_decay 的系数。
- `warmup_ratio` 表示动态学习率热启动的比例。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示验证并保存模型间隔。
@@ -66,7 +66,7 @@ python -m paddle.distributed.launch --gpus 0,1 python train_chn.py \
#### (2) 评估
-在dev和test数据集上acc分别为95.8和96.08,达到论文精度要求。
+在 dev 和 test 数据集上 acc 分别为95.8和96.08,达到论文精度要求。
#### 2、XNLI
@@ -93,14 +93,14 @@ python -m paddle.distributed.launch --gpus 0,1 python train_xnli.py \
```
其中参数释义如下:
- `data_path` 表示微调数据路径
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
- `num_train_epochs` 表示训练轮数。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `per_device_train_batch_size` 表示每次迭代**每张卡**上的训练样本数目。
- `per_device_eval_batch_size` 表示每次迭代**每张卡**上的验证样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `adam_beta2` 表示优化器中使用的beta2的系数。
-- `weight_decay` 表示优化器中使用的weight_decay的系数。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `adam_beta2` 表示优化器中使用的 beta2的系数。
+- `weight_decay` 表示优化器中使用的 weight_decay 的系数。
- `warmup_ratio` 表示动态学习率热启动的比例。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示验证并保存模型间隔。
@@ -111,7 +111,7 @@ python -m paddle.distributed.launch --gpus 0,1 python train_xnli.py \
#### (2)评估
-test数据集 acc最好结果为81.657,达到论文精度要求。
+test 数据集 acc 最好结果为81.657,达到论文精度要求。
#### 3、cmrc2018
@@ -143,27 +143,27 @@ python -m paddle.distributed.launch --gpus 0,1 python train_cmrc2018.py \
```
其中参数释义如下:
- `data_path` 表示微调数据路径。
-- `model_name_or_path` 模型名称或者路径,支持ChineseBERT-base、ChineseBERT-large两种种规格。
+- `model_name_or_path` 模型名称或者路径,支持 ChineseBERT-base、ChineseBERT-large 两种种规格。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `per_device_train_batch_size` 表示训练过程中每次迭代**每张卡**上的样本数目。
- `per_device_eval_batch_size` 表示验证过程中每次迭代**每张卡**上的样本数目。
- `gradient_accumulation_steps` 梯度累加步数。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `max_grad_norm` 梯度裁剪。
-- `adam_beta2` 表示优化器中使用的beta2的系数。
+- `adam_beta2` 表示优化器中使用的 beta2的系数。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示验证并保存模型间隔。
- `warmup_ratio` 表示动态学习率热启动的比例。
-- `weight_decay` 表示优化器中使用的weight_decay的系数。
+- `weight_decay` 表示优化器中使用的 weight_decay 的系数。
- `seed` 指定随机种子。
- `do_train` 表示是否进行训练。
- `do_eval` 表示是否进行验证。
- `dataloader_num_workers` 表示同时工作进程。
-- `fp16` 表示是否使用混合精度fp16。
+- `fp16` 表示是否使用混合精度 fp16。
- `output_dir` 表示模型保存路径。
-训练过程中模型会在dev数据集进行评估,其中最好的结果如下所示:
+训练过程中模型会在 dev 数据集进行评估,其中最好的结果如下所示:
```python
@@ -177,17 +177,17 @@ python -m paddle.distributed.launch --gpus 0,1 python train_cmrc2018.py \
```
-#### (2)运行eval_cmrc.py,生成test数据集预测答案
+#### (2)运行 eval_cmrc.py,生成 test 数据集预测答案
```bash
python eval_cmrc.py --model_name_or_path outputs/step-340 --n_best_size 35 --max_answer_length 65
```
-其中,model_name_or_path为模型路径
+其中,model_name_or_path 为模型路径
-#### (3)提交CLUE
+#### (3)提交 CLUE
-test数据集 EM为78.55,达到论文精度要求
+test 数据集 EM 为78.55,达到论文精度要求
## Reference
diff --git a/legacy/model_zoo/chinesebert/cmrc_eval.sh b/slm/model_zoo/chinesebert/cmrc_eval.sh
similarity index 100%
rename from legacy/model_zoo/chinesebert/cmrc_eval.sh
rename to slm/model_zoo/chinesebert/cmrc_eval.sh
diff --git a/legacy/model_zoo/chinesebert/cmrc_evaluate.py b/slm/model_zoo/chinesebert/cmrc_evaluate.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/cmrc_evaluate.py
rename to slm/model_zoo/chinesebert/cmrc_evaluate.py
diff --git a/legacy/model_zoo/chinesebert/dataset_cmrc2018.py b/slm/model_zoo/chinesebert/dataset_cmrc2018.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/dataset_cmrc2018.py
rename to slm/model_zoo/chinesebert/dataset_cmrc2018.py
diff --git a/legacy/model_zoo/chinesebert/eval_cmrc.py b/slm/model_zoo/chinesebert/eval_cmrc.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/eval_cmrc.py
rename to slm/model_zoo/chinesebert/eval_cmrc.py
diff --git a/legacy/model_zoo/chinesebert/metric_cmrc.py b/slm/model_zoo/chinesebert/metric_cmrc.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/metric_cmrc.py
rename to slm/model_zoo/chinesebert/metric_cmrc.py
diff --git a/legacy/model_zoo/chinesebert/run_chn.sh b/slm/model_zoo/chinesebert/run_chn.sh
similarity index 100%
rename from legacy/model_zoo/chinesebert/run_chn.sh
rename to slm/model_zoo/chinesebert/run_chn.sh
diff --git a/legacy/model_zoo/chinesebert/run_cmrc2018.sh b/slm/model_zoo/chinesebert/run_cmrc2018.sh
similarity index 100%
rename from legacy/model_zoo/chinesebert/run_cmrc2018.sh
rename to slm/model_zoo/chinesebert/run_cmrc2018.sh
diff --git a/legacy/model_zoo/chinesebert/run_xnli.sh b/slm/model_zoo/chinesebert/run_xnli.sh
similarity index 100%
rename from legacy/model_zoo/chinesebert/run_xnli.sh
rename to slm/model_zoo/chinesebert/run_xnli.sh
diff --git a/legacy/model_zoo/chinesebert/train_chn.py b/slm/model_zoo/chinesebert/train_chn.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/train_chn.py
rename to slm/model_zoo/chinesebert/train_chn.py
diff --git a/legacy/model_zoo/chinesebert/train_cmrc2018.py b/slm/model_zoo/chinesebert/train_cmrc2018.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/train_cmrc2018.py
rename to slm/model_zoo/chinesebert/train_cmrc2018.py
diff --git a/legacy/model_zoo/chinesebert/train_xnli.py b/slm/model_zoo/chinesebert/train_xnli.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/train_xnli.py
rename to slm/model_zoo/chinesebert/train_xnli.py
diff --git a/legacy/model_zoo/chinesebert/utils.py b/slm/model_zoo/chinesebert/utils.py
similarity index 100%
rename from legacy/model_zoo/chinesebert/utils.py
rename to slm/model_zoo/chinesebert/utils.py
diff --git a/legacy/model_zoo/convbert/README.md b/slm/model_zoo/convbert/README.md
similarity index 66%
rename from legacy/model_zoo/convbert/README.md
rename to slm/model_zoo/convbert/README.md
index 89494186d585..64f551d38973 100644
--- a/legacy/model_zoo/convbert/README.md
+++ b/slm/model_zoo/convbert/README.md
@@ -3,28 +3,28 @@
[ConvBERT: Improving BERT with Span-based Dynamic Convolution](https://arxiv.org/abs/2008.02496)
**摘要:**
-像BERT及其变体这样的预训练语言模型最近在各种自然语言理解任务中取得了令人印象深刻的表现。然而,BERT严重依赖全局自注意力块,因此需要大量内存占用和计算成本。
+像 BERT 及其变体这样的预训练语言模型最近在各种自然语言理解任务中取得了令人印象深刻的表现。然而,BERT 严重依赖全局自注意力块,因此需要大量内存占用和计算成本。
虽然它的所有注意力头从全局角度查询整个输入序列以生成注意力图,但我们观察到一些头只需要学习局部依赖,这意味着存在计算冗余。
因此,我们提出了一种新颖的基于跨度的动态卷积来代替这些自注意力头,以直接对局部依赖性进行建模。新的卷积头与其余的自注意力头一起形成了一个新的混合注意力块,在全局和局部上下文学习中都更有效。
-我们为 BERT 配备了这种混合注意力设计并构建了一个ConvBERT模型。实验表明,ConvBERT 在各种下游任务中明显优于BERT及其变体,具有更低的训练成本和更少的模型参数。
-值得注意的是,ConvBERT-base 模型达到86.4GLUE分数,比ELECTRA-base高0.7,同时使用不到1/4的训练成本。
+我们为 BERT 配备了这种混合注意力设计并构建了一个 ConvBERT 模型。实验表明,ConvBERT 在各种下游任务中明显优于 BERT 及其变体,具有更低的训练成本和更少的模型参数。
+值得注意的是,ConvBERT-base 模型达到86.4GLUE 分数,比 ELECTRA-base 高0.7,同时使用不到1/4的训练成本。
-本项目是 ConvBert 在 Paddle 2.x上的开源实现。
+本项目是 ConvBert 在 Paddle 2.x 上的开源实现。
## **数据准备**
-### Fine-tuning数据
-Fine-tuning 使用GLUE数据,这部分Paddle已提供,在执行Fine-tuning 命令时会自动下载并加载
+### Fine-tuning 数据
+Fine-tuning 使用 GLUE 数据,这部分 Paddle 已提供,在执行 Fine-tuning 命令时会自动下载并加载
## **模型预训练**
-模型预训练过程可参考[Electra的README](../electra/README.md)
+模型预训练过程可参考[Electra 的 README](../electra/README.md)
## **Fine-tuning**
-### 运行Fine-tuning
+### 运行 Fine-tuning
-#### **使用Paddle提供的预训练模型运行 Fine-tuning**
+#### **使用 Paddle 提供的预训练模型运行 Fine-tuning**
以 GLUE/SST-2 任务为例,启动 Fine-tuning 的方式如下:
```shell
@@ -45,19 +45,19 @@ python -u examples/language_model/convbert/run_glue.py \
--device gpu
```
其中参数释义如下:
-- `model_type` 指示了模型类型,当前支持BERT、ELECTRA、ERNIE、CONVBERT模型。
-- `model_name_or_path` 模型名称或者路径,其中convbert模型当前仅支持convbert-small、convbert-medium-small、convbert-base几种规格。
-- `task_name` 表示 Fine-tuning 的任务,当前支持CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE。
+- `model_type` 指示了模型类型,当前支持 BERT、ELECTRA、ERNIE、CONVBERT 模型。
+- `model_name_or_path` 模型名称或者路径,其中 convbert 模型当前仅支持 convbert-small、convbert-medium-small、convbert-base 几种规格。
+- `task_name` 表示 Fine-tuning 的任务,当前支持 CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU、NPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU、NPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
-Fine-tuning过程将按照 `logging_steps` 和 `save_steps` 的设置打印如下格式的日志:
+Fine-tuning 过程将按照 `logging_steps` 和 `save_steps` 的设置打印如下格式的日志:
```
global step 100/792, epoch: 0, batch: 99, rank_id: 0, loss: 0.333723, lr: 0.0000970547, speed: 3.6162 step/s
@@ -78,7 +78,7 @@ global step 792/792, epoch: 2, batch: 263, rank_id: 0, loss: 0.025735, lr: 0.000
eval loss: 0.226449, acc: 0.9013761467889908, eval done total : 0.5103530883789062 s
```
-使用convbert-small预训练模型进行单卡Fine-tuning ,在验证集上有如下结果(这里各类任务的结果是运行1次的结果):
+使用 convbert-small 预训练模型进行单卡 Fine-tuning ,在验证集上有如下结果(这里各类任务的结果是运行1次的结果):
| Task | Metric | Result |
|-------|------------------------------|--------|
@@ -91,7 +91,7 @@ eval loss: 0.226449, acc: 0.9013761467889908, eval done total : 0.51035308837890
| QNLI | acc. | 87.71 |
| RTE | acc. | 66.06 |
-注:acc.是Accuracy的简称,表中Metric字段名词取自[GLUE论文](https://openreview.net/pdf?id=rJ4km2R5t7)
+注:acc.是 Accuracy 的简称,表中 Metric 字段名词取自[GLUE 论文](https://openreview.net/pdf?id=rJ4km2R5t7)
diff --git a/legacy/model_zoo/convbert/convert.py b/slm/model_zoo/convbert/convert.py
similarity index 100%
rename from legacy/model_zoo/convbert/convert.py
rename to slm/model_zoo/convbert/convert.py
diff --git a/legacy/model_zoo/convbert/run_glue.py b/slm/model_zoo/convbert/run_glue.py
similarity index 100%
rename from legacy/model_zoo/convbert/run_glue.py
rename to slm/model_zoo/convbert/run_glue.py
diff --git a/legacy/model_zoo/convbert/run_pretrain.py b/slm/model_zoo/convbert/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/convbert/run_pretrain.py
rename to slm/model_zoo/convbert/run_pretrain.py
diff --git a/slm/model_zoo/electra/README.md b/slm/model_zoo/electra/README.md
new file mode 100644
index 000000000000..0d3455804e85
--- /dev/null
+++ b/slm/model_zoo/electra/README.md
@@ -0,0 +1,7 @@
+# ELECTRA with PaddleNLP
+
+[ELECTRA](https://openreview.net/pdf?id=r1xMH1BtvB) 在[BERT](https://arxiv.org/abs/1810.04805)的基础上对其预训练过程进行了改进:预训练由两部分模型网络组成,称为 Generator 和 Discriminator,各自包含1个 BERT 模型。Generator 的预训练使用和 BERT 一样的 Masked Language Model(MLM)任务,但 Discriminator 的预训练使用 Replaced Token Detection(RTD)任务(主要改进点)。预训练完成后,使用 Discriminator 作为精调模型,后续的 Fine-tuning 不再使用 Generator。
+
+图片来源:来自[electra 论文](https://openreview.net/pdf?id=r1xMH1BtvB)
+
+详细请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/model_zoo/electra).
diff --git a/legacy/model_zoo/ernie-1.0/README.md b/slm/model_zoo/ernie-1.0/README.md
similarity index 99%
rename from legacy/model_zoo/ernie-1.0/README.md
rename to slm/model_zoo/ernie-1.0/README.md
index b659864b20ab..a0dc191cfa42 100644
--- a/legacy/model_zoo/ernie-1.0/README.md
+++ b/slm/model_zoo/ernie-1.0/README.md
@@ -516,7 +516,7 @@ python3 -u -m paddle.distributed.launch \
- 记录混合精度,loss_scaling 等信息,方便用户 debug。
- 对模型结构,配置参数,paddle 版本信息进行记录,方便复现环境
- **下游任务评估**:CLUE Benchmark 搜索评估参数效果
- - 使用[批量启动-grid-search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/benchmark/clue#%E6%89%B9%E9%87%8F%E5%90%AF%E5%8A%A8-grid-search),可以进行批量搜索任务
+ - 使用[批量启动-grid-search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/benchmark/clue#%E6%89%B9%E9%87%8F%E5%90%AF%E5%8A%A8-grid-search),可以进行批量搜索任务
- 注意,这里使用的是训练中的 checkpoint 进行评估,可以直接试着 评估待评估的参数为,所在的路径地址,即如 `python grid_seach.py output/ernie-base-outdir/model_100000` 之类的 checkpoint 地址。
详细介绍请参见[ERNIE 中文预训练介绍](./pretraining_introduction.md)。
diff --git a/legacy/model_zoo/ernie-1.0/args.py b/slm/model_zoo/ernie-1.0/args.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/args.py
rename to slm/model_zoo/ernie-1.0/args.py
diff --git a/legacy/model_zoo/ernie-1.0/converter/params_static_to_dygraph.py b/slm/model_zoo/ernie-1.0/converter/params_static_to_dygraph.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/converter/params_static_to_dygraph.py
rename to slm/model_zoo/ernie-1.0/converter/params_static_to_dygraph.py
diff --git a/legacy/model_zoo/ernie-1.0/data_tools/Makefile b/slm/model_zoo/ernie-1.0/data_tools/Makefile
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/data_tools/Makefile
rename to slm/model_zoo/ernie-1.0/data_tools/Makefile
diff --git a/legacy/model_zoo/ernie-1.0/data_tools/dataset_utils.py b/slm/model_zoo/ernie-1.0/data_tools/dataset_utils.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/data_tools/dataset_utils.py
rename to slm/model_zoo/ernie-1.0/data_tools/dataset_utils.py
diff --git a/legacy/model_zoo/ernie-1.0/data_tools/ernie_dataset.py b/slm/model_zoo/ernie-1.0/data_tools/ernie_dataset.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/data_tools/ernie_dataset.py
rename to slm/model_zoo/ernie-1.0/data_tools/ernie_dataset.py
diff --git a/legacy/model_zoo/ernie-1.0/data_tools/helpers.cpp b/slm/model_zoo/ernie-1.0/data_tools/helpers.cpp
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/data_tools/helpers.cpp
rename to slm/model_zoo/ernie-1.0/data_tools/helpers.cpp
diff --git a/legacy/model_zoo/ernie-1.0/finetune/README.md b/slm/model_zoo/ernie-1.0/finetune/README.md
similarity index 56%
rename from legacy/model_zoo/ernie-1.0/finetune/README.md
rename to slm/model_zoo/ernie-1.0/finetune/README.md
index 27603219d59b..ac941679183d 100644
--- a/legacy/model_zoo/ernie-1.0/finetune/README.md
+++ b/slm/model_zoo/ernie-1.0/finetune/README.md
@@ -1,5 +1,5 @@
# 预训练下游任务 finetune 示例
-使用训练中产出的checkpoint,或者paddlenlp内置的模型权重,使用本脚本,用户可以快速对当前模型效果进行评估。
+使用训练中产出的 checkpoint,或者 paddlenlp 内置的模型权重,使用本脚本,用户可以快速对当前模型效果进行评估。
## 运行示例
本文档适配了三大主流下游任务,用户可以根据自己的需求,评估自己所需的数据集。
@@ -18,7 +18,7 @@ python run_seq_cls.py \
--output_dir ./tmp/$dataset
```
-2. Token分类
+2. Token 分类
```shell
dataset="peoples_daily_ner"
python run_ner.py \
@@ -45,27 +45,27 @@ python run_qa.py \
### 传入参数
必须参数
-- do_train、do_eval、do_predict分别表示运行训练、评估、测试数据集合。
-- do_export 导出为inference预测模型
-- model_name_or_path 表示模型权重名称,或者训练中保存的checkpoint地址
+- do_train、do_eval、do_predict 分别表示运行训练、评估、测试数据集合。
+- do_export 导出为 inference 预测模型
+- model_name_or_path 表示模型权重名称,或者训练中保存的 checkpoint 地址
- dataset 表示数据集名称
-- output_dir 表示运行中,一些checkpoint等参数的输出目录
+- output_dir 表示运行中,一些 checkpoint 等参数的输出目录
其他可配置参数:
-- per_device_train_batch_size 训练时batch大小
-- per_device_eval_batch_size 评估时batch大小
-- num_train_epochs 训练epoch数目
+- per_device_train_batch_size 训练时 batch 大小
+- per_device_eval_batch_size 评估时 batch 大小
+- num_train_epochs 训练 epoch 数目
- learning_rate 学习率
- max_seq_length 最大序列长度
- weight_decay 训练时优化器对参数衰减系数
- logging_steps 打印日志间隔步数
- eval_steps 评估效果间隔步数
-- max_steps 最大训练步数(可覆盖num_train_epochs)
+- max_steps 最大训练步数(可覆盖 num_train_epochs)
-### yaml文件参数
-本示例也支持用户在yaml文件中配置参数。用户可以自行修改`config.yaml`文件。
+### yaml 文件参数
+本示例也支持用户在 yaml 文件中配置参数。用户可以自行修改`config.yaml`文件。
注意:
-- 这些参数会重写传入的默认参数,以yaml文件参数为准。
-- yaml文件中的batch_size同时等价于per_device_train_batch_size,per_device_eval_batch_size
+- 这些参数会重写传入的默认参数,以 yaml 文件参数为准。
+- yaml 文件中的 batch_size 同时等价于 per_device_train_batch_size,per_device_eval_batch_size
diff --git a/legacy/model_zoo/ernie-1.0/finetune/config.yml b/slm/model_zoo/ernie-1.0/finetune/config.yml
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/config.yml
rename to slm/model_zoo/ernie-1.0/finetune/config.yml
diff --git a/legacy/model_zoo/ernie-1.0/finetune/deploy/README.md b/slm/model_zoo/ernie-1.0/finetune/deploy/README.md
similarity index 95%
rename from legacy/model_zoo/ernie-1.0/finetune/deploy/README.md
rename to slm/model_zoo/ernie-1.0/finetune/deploy/README.md
index cede7f79d2a0..bf75b84958e9 100644
--- a/legacy/model_zoo/ernie-1.0/finetune/deploy/README.md
+++ b/slm/model_zoo/ernie-1.0/finetune/deploy/README.md
@@ -31,13 +31,13 @@ Batch id: 2, example id: 0, sentence: 还稍微重了点,可能是硬盘大的
| 参数 |参数说明 |
|----------|--------------|
|--model_dir | 指定部署模型的目录, |
-|--batch_size |输入的batch size,默认为 1|
+|--batch_size |输入的 batch size,默认为 1|
|--max_length |最大序列长度,默认为 128|
|--device | 运行的设备,可选范围: ['cpu', 'gpu'],默认为'cpu' |
-|--device_id | 运行设备的id。默认为0。 |
-|--cpu_threads | 当使用cpu推理时,指定推理的cpu线程数,默认为1。|
+|--device_id | 运行设备的 id。默认为0。 |
+|--cpu_threads | 当使用 cpu 推理时,指定推理的 cpu 线程数,默认为1。|
|--backend | 支持的推理后端,可选范围: ['onnx_runtime', 'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt'],默认为'paddle' |
-|--use_fp16 | 是否使用FP16模式进行推理。使用tensorrt和paddle_tensorrt后端时可开启,默认为False |
+|--use_fp16 | 是否使用 FP16模式进行推理。使用 tensorrt 和 paddle_tensorrt 后端时可开启,默认为 False |
## FastDeploy 高阶用法
diff --git a/legacy/model_zoo/ernie-1.0/finetune/deploy/seq_cls_infer.py b/slm/model_zoo/ernie-1.0/finetune/deploy/seq_cls_infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/deploy/seq_cls_infer.py
rename to slm/model_zoo/ernie-1.0/finetune/deploy/seq_cls_infer.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/question_answering.py b/slm/model_zoo/ernie-1.0/finetune/question_answering.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/question_answering.py
rename to slm/model_zoo/ernie-1.0/finetune/question_answering.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/run_ner.py b/slm/model_zoo/ernie-1.0/finetune/run_ner.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/run_ner.py
rename to slm/model_zoo/ernie-1.0/finetune/run_ner.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/run_qa.py b/slm/model_zoo/ernie-1.0/finetune/run_qa.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/run_qa.py
rename to slm/model_zoo/ernie-1.0/finetune/run_qa.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/run_seq_cls.py b/slm/model_zoo/ernie-1.0/finetune/run_seq_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/run_seq_cls.py
rename to slm/model_zoo/ernie-1.0/finetune/run_seq_cls.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/sequence_classification.py b/slm/model_zoo/ernie-1.0/finetune/sequence_classification.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/sequence_classification.py
rename to slm/model_zoo/ernie-1.0/finetune/sequence_classification.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/token_classification.py b/slm/model_zoo/ernie-1.0/finetune/token_classification.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/token_classification.py
rename to slm/model_zoo/ernie-1.0/finetune/token_classification.py
diff --git a/legacy/model_zoo/ernie-1.0/finetune/utils.py b/slm/model_zoo/ernie-1.0/finetune/utils.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/finetune/utils.py
rename to slm/model_zoo/ernie-1.0/finetune/utils.py
diff --git a/legacy/model_zoo/ernie-1.0/pretraining_introduction.md b/slm/model_zoo/ernie-1.0/pretraining_introduction.md
similarity index 99%
rename from legacy/model_zoo/ernie-1.0/pretraining_introduction.md
rename to slm/model_zoo/ernie-1.0/pretraining_introduction.md
index 3a8c73665747..713a70cc94f3 100644
--- a/legacy/model_zoo/ernie-1.0/pretraining_introduction.md
+++ b/slm/model_zoo/ernie-1.0/pretraining_introduction.md
@@ -567,7 +567,7 @@ python3 -u -m paddle.distributed.launch \
- **下游任务评估**:CLUE Benchmark 搜索评估参数效果
- - 使用[批量启动-grid-search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/benchmark/clue#%E6%89%B9%E9%87%8F%E5%90%AF%E5%8A%A8-grid-search),可以进行批量搜索任务
+ - 使用[批量启动-grid-search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/benchmark/clue#%E6%89%B9%E9%87%8F%E5%90%AF%E5%8A%A8-grid-search),可以进行批量搜索任务
- 注意,这里使用的是训练中的 checkpoint 进行评估,可以直接试着 评估待评估的参数为,所在的路径地址,即如 `python grid_seach.py output/ernie-base-outdir/model_100000` 之类的 checkpoint 地址。
diff --git a/legacy/model_zoo/ernie-1.0/run_gb512_s1m.sh b/slm/model_zoo/ernie-1.0/run_gb512_s1m.sh
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/run_gb512_s1m.sh
rename to slm/model_zoo/ernie-1.0/run_gb512_s1m.sh
diff --git a/legacy/model_zoo/ernie-1.0/run_gb512_s1m_trainer.sh b/slm/model_zoo/ernie-1.0/run_gb512_s1m_trainer.sh
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/run_gb512_s1m_trainer.sh
rename to slm/model_zoo/ernie-1.0/run_gb512_s1m_trainer.sh
diff --git a/legacy/model_zoo/ernie-1.0/run_npu_single_card.sh b/slm/model_zoo/ernie-1.0/run_npu_single_card.sh
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/run_npu_single_card.sh
rename to slm/model_zoo/ernie-1.0/run_npu_single_card.sh
diff --git a/legacy/model_zoo/ernie-1.0/run_pretrain.py b/slm/model_zoo/ernie-1.0/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/run_pretrain.py
rename to slm/model_zoo/ernie-1.0/run_pretrain.py
diff --git a/legacy/model_zoo/ernie-1.0/run_pretrain_trainer.py b/slm/model_zoo/ernie-1.0/run_pretrain_trainer.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/run_pretrain_trainer.py
rename to slm/model_zoo/ernie-1.0/run_pretrain_trainer.py
diff --git a/legacy/model_zoo/ernie-1.0/vocab/README.md b/slm/model_zoo/ernie-1.0/vocab/README.md
similarity index 71%
rename from legacy/model_zoo/ernie-1.0/vocab/README.md
rename to slm/model_zoo/ernie-1.0/vocab/README.md
index f409dbcdf583..a7275456a1ad 100644
--- a/legacy/model_zoo/ernie-1.0/vocab/README.md
+++ b/slm/model_zoo/ernie-1.0/vocab/README.md
@@ -1,7 +1,7 @@
# ERNIE 中文词表制作
-ERNIE是百度提出的大规模预训练模型,曾在中文场景下取得了SOTA效果。
-PaddleNLP致力于预训练开源工作,本文档提供了ERNIE词表的制作方法。
+ERNIE 是百度提出的大规模预训练模型,曾在中文场景下取得了 SOTA 效果。
+PaddleNLP 致力于预训练开源工作,本文档提供了 ERNIE 词表的制作方法。
预训练全部流程的整体详细介绍文档,请参考[ERNIE 中文预训练介绍](../pretraining_introduction.md)。
@@ -13,8 +13,8 @@ PaddleNLP致力于预训练开源工作,本文档提供了ERNIE词表的制作
- [2.3 英文字符词表](#英文字符词表)
- [2.4 合并词表](#合并词表)
* [3. 词表使用](#vocab_usage)
- - [3.1 转化为jsonl格式数据](#jsonl)
- - [3.2 TokenID转化](#快速TokenID转化)
+ - [3.1 转化为 jsonl 格式数据](#jsonl)
+ - [3.2 TokenID 转化](#快速 TokenID 转化)
* [4. 参考](#ref)
@@ -25,12 +25,12 @@ PaddleNLP致力于预训练开源工作,本文档提供了ERNIE词表的制作
**WuDaoCorpus2.0 Base 语料**
-WuDaoCorpora是悟道爬取的中文大规模语料。整体数量为3TB,目前开源的部分为WuDaoCorpus2.0 bases数据集,大小为200GB。用户请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/tools/preprocess/docs/WuDaoCorpusBase.md)获取原始文本数据。
+WuDaoCorpora 是悟道爬取的中文大规模语料。整体数量为3TB,目前开源的部分为 WuDaoCorpus2.0 bases 数据集,大小为200GB。用户请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/tools/preprocess/docs/WuDaoCorpusBase.md)获取原始文本数据。
**CLUECorpus2020 语料**
-CLUECorpus2020 过对Common Crawl的中文部分进行语料清洗得到。开源部分提供了约200G左右的语料文本,详细介绍见[官网](https://github.com/CLUEbenchmark/CLUECorpus2020#%E6%95%B0%E6%8D%AE%E4%B8%8B%E8%BD%BD),用户参考[这里](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/tools/preprocess/docs/CLUECorpus2020.md)获取原始文本数据。
+CLUECorpus2020 过对 Common Crawl 的中文部分进行语料清洗得到。开源部分提供了约200G 左右的语料文本,详细介绍见[官网](https://github.com/CLUEbenchmark/CLUECorpus2020#%E6%95%B0%E6%8D%AE%E4%B8%8B%E8%BD%BD),用户参考[这里](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/tools/preprocess/docs/CLUECorpus2020.md)获取原始文本数据。
@@ -47,8 +47,8 @@ CLUECorpus2020 过对Common Crawl的中文部分进行语料清洗得到。开
3. 合并词表
第二种,预处理后直接生成,方案
-1. 文本预处理(中文加空格,文本normalize)
-2. 使用sentencepeice制作词表
+1. 文本预处理(中文加空格,文本 normalize)
+2. 使用 sentencepeice 制作词表
第二种方案需要对文本先使用`BasicTokenizer`切分一遍语料。
第一种方案,自定义程度高,但存在一些局限性。本项目采用了第一种方案,详细介绍如下:
@@ -58,8 +58,8 @@ CLUECorpus2020 过对Common Crawl的中文部分进行语料清洗得到。开
- 已有模型对照:
- ERNIE 3.0系列模型的词表,词表大小为 40000 左右。
- 预训练数据存储占用:
- - 文本token id化后,希望使用uint16表示,此时表示的最大字符为65536。
- - 同时考虑到ERNIE虽然是字模型,我们的仍然需要 `##中` 之类的中文字符表示分词信息。假设使用中文全字符20902(0x4E00-0x9FA5)个字符,那么剩余 vocab 大小不能超过 44634。
+ - 文本 token id 化后,希望使用 uint16表示,此时表示的最大字符为65536。
+ - 同时考虑到 ERNIE 虽然是字模型,我们的仍然需要 `##中` 之类的中文字符表示分词信息。假设使用中文全字符20902(0x4E00-0x9FA5)个字符,那么剩余 vocab 大小不能超过 44634。
综上,本项目决定采用 40000 左右的 vocab 容量。
其中:
@@ -83,7 +83,7 @@ wget https://bj.bcebos.com/paddlenlp/models/transformers/data_tools/char_dict.pi
### 2.3 英文字符词表
基于字符的词频统计,使得英文字符也切割为字母,为此我们需要添加英文词表。
英文部分,我们使用了 [WikiText](https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-103-v1.zip) 数据集,来构造词表。
-下载解压数据,使用BPE切词
+下载解压数据,使用 BPE 切词
```
wget https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-103-v1.zip
unzip wikitext-103-v1.zip
@@ -107,17 +107,17 @@ python merge_vocab.py
此阶段需要注意的一些问题是:
1. 对于一些日文、谚文文字字符,需要进行 normalize
-2. 添加special_tokens
+2. 添加 special_tokens
### 2.5 问题遗留
-本项目采用的第一种方式,即拼接产出的词表,对连续非中、英文字符文本,会出现UNK的情况。
-如issue: [#2927](https://github.com/PaddlePaddle/PaddleNLP/issues/2927)、 [#2585](https://github.com/PaddlePaddle/PaddleNLP/issues/2585)。本项目做了两点改进:
+本项目采用的第一种方式,即拼接产出的词表,对连续非中、英文字符文本,会出现 UNK 的情况。
+如 issue: [#2927](https://github.com/PaddlePaddle/PaddleNLP/issues/2927)、 [#2585](https://github.com/PaddlePaddle/PaddleNLP/issues/2585)。本项目做了两点改进:
1. 对 Symbol 字符默认添加空格,变成独立字符
2. 对 日文、谚文 在合并词表阶段默认添加 ## 字符。
虽然有上述两点修复,任然无法避免 [#2927](https://github.com/PaddlePaddle/PaddleNLP/issues/2927) 现象。
-彻底解决的话,建议使用第二种方式制作vocab文件。
+彻底解决的话,建议使用第二种方式制作 vocab 文件。
### 2.6 方案二:预处理后直接生成
此方案没有被采用,这里也简单说明一下具体的方案:
@@ -133,7 +133,7 @@ basic_toknizer = lambda x: " ".join(tokenizer.tokenize(x))
```shell
python gen_vocab.py afer_basic_toknizer_corpus.txt
```
-对处理好的vocab文件手动替换一些` -> [PAD]`之类的special_tokens,即可产出词表。
+对处理好的 vocab 文件手动替换一些` -> [PAD]`之类的 special_tokens,即可产出词表。
@@ -141,9 +141,9 @@ python gen_vocab.py afer_basic_toknizer_corpus.txt
-## 3.1 转化为jsonl格式数据
+## 3.1 转化为 jsonl 格式数据
-本文档以WuDao数据为例,对数据进行分词:
+本文档以 WuDao 数据为例,对数据进行分词:
```shell
python ../preprocess/words_segmentation.py \
@@ -154,7 +154,7 @@ python ../preprocess/words_segmentation.py \
--output_path ./wudao_lac_cut \
```
-文本转化完成后。我们使用 `../data_tools/trans_to_json.py`重新转换为jsonl格式(分词完毕)。
+文本转化完成后。我们使用 `../data_tools/trans_to_json.py`重新转换为 jsonl 格式(分词完毕)。
```shell
python ../preprocess/trans_to_json.py \
--input_path ./wudao_lac_cut \
@@ -162,11 +162,11 @@ python ../preprocess/trans_to_json.py \
--workers 40 \
```
-
+
## 3.2 Token ID 转化
-语料、新建的词表准备妥当后,我们可以开始进行最后的数据ID转化。
+语料、新建的词表准备妥当后,我们可以开始进行最后的数据 ID 转化。
```
python -u ../preprocess/create_pretraining_data.py \
@@ -187,7 +187,7 @@ python -u ../preprocess/create_pretraining_data.py \
- model_name 指定为我们准备的词表路径。也可以更换为其他 ERNIE 系列模型,如: `ernie-3.0-base-zh`
- workers 表示转化的线程数目
-转化后的数据如下,使用这份数据,即可开始ERNIE预训练
+转化后的数据如下,使用这份数据,即可开始 ERNIE 预训练
```
-rw-rw-r-- 1 500 501 129G Jul 4 03:39 wudao_200g_0703_ids.npy
-rw-rw-r-- 1 500 501 6.4G Jul 4 03:39 wudao_200g_0703_idx.npz
@@ -196,7 +196,7 @@ python -u ../preprocess/create_pretraining_data.py \
## 4. 参考
-感谢CLUE,WuDao提供的开源文本语料,参考资料:
+感谢 CLUE,WuDao 提供的开源文本语料,参考资料:
- Xu, L., Zhang, X. and Dong, Q., 2020. CLUECorpus2020: A large-scale Chinese corpus for pre-training language model. arXiv preprint arXiv:2003.01355.
- Yuan, S., Zhao, H., Du, Z., Ding, M., Liu, X., Cen, Y., Zou, X., Yang, Z. and Tang, J., 2021. Wudaocorpora: A super large-scale chinese corpora for pre-training language models. AI Open, 2, pp.65-68.
- https://github.com/CLUEbenchmark/CLUECorpus2020
diff --git a/legacy/model_zoo/ernie-1.0/vocab/gen_char.py b/slm/model_zoo/ernie-1.0/vocab/gen_char.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/vocab/gen_char.py
rename to slm/model_zoo/ernie-1.0/vocab/gen_char.py
diff --git a/legacy/model_zoo/ernie-1.0/vocab/gen_vocab.py b/slm/model_zoo/ernie-1.0/vocab/gen_vocab.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/vocab/gen_vocab.py
rename to slm/model_zoo/ernie-1.0/vocab/gen_vocab.py
diff --git a/legacy/model_zoo/ernie-1.0/vocab/merge_vocab.py b/slm/model_zoo/ernie-1.0/vocab/merge_vocab.py
similarity index 100%
rename from legacy/model_zoo/ernie-1.0/vocab/merge_vocab.py
rename to slm/model_zoo/ernie-1.0/vocab/merge_vocab.py
diff --git a/legacy/model_zoo/ernie-3.0-tiny/README.md b/slm/model_zoo/ernie-3.0-tiny/README.md
similarity index 98%
rename from legacy/model_zoo/ernie-3.0-tiny/README.md
rename to slm/model_zoo/ernie-3.0-tiny/README.md
index 07b7aca47135..d435b870f164 100644
--- a/legacy/model_zoo/ernie-3.0-tiny/README.md
+++ b/slm/model_zoo/ernie-3.0-tiny/README.md
@@ -12,7 +12,7 @@
* [模型评估](#模型评估)
* [端上模型压缩方案🔥](#模型压缩)
* [压缩效果](#压缩效果)
- * [⚡️ FastDeploy 部署](#FastDeploy部署)
+ * [⚡️ FastDeploy 部署](#FastDeploy 部署)
* [性能结论](#压缩结论)
* [参考文献](#参考文献)
@@ -312,7 +312,7 @@ ERNIE 3.0 Tiny v2 多任务学习、在线蒸馏方案效果显著,刷新了
-图中越靠左上方的模型,精度和性能水平越高。可以看到 ERNIE 3.0 Tiny v2 在同等规模的开源模型中,综合实力领先其他同类型轻量级模型。与 UER/RoBERTa-Base 相比,12L768H 的 ERNIE 3.0-Base 平均精度提升了 4.5 个点,比同等规模的BERT-Base-Chinese 提升 3.7 个点;6L768H 的 ERNIE 3.0-Medium 相比 12L768H 的 UER/Chinese-RoBERTa 高 2.4,比 BERT-Base-Chinese 高 1.7,并且节省一倍运算时间;另外值得一提的是,这些小模型能够直接部署在 CPU 上。
+图中越靠左上方的模型,精度和性能水平越高。可以看到 ERNIE 3.0 Tiny v2 在同等规模的开源模型中,综合实力领先其他同类型轻量级模型。与 UER/RoBERTa-Base 相比,12L768H 的 ERNIE 3.0-Base 平均精度提升了 4.5 个点,比同等规模的 BERT-Base-Chinese 提升 3.7 个点;6L768H 的 ERNIE 3.0-Medium 相比 12L768H 的 UER/Chinese-RoBERTa 高 2.4,比 BERT-Base-Chinese 高 1.7,并且节省一倍运算时间;另外值得一提的是,这些小模型能够直接部署在 CPU 上。
使用 PaddleNLP 只需要一行代码就可以下载并获取 ERNIE 3.0 Tiny 预训练模型,之后可以用自己的下游数据下进行微调。
@@ -476,7 +476,7 @@ python run_train.py \
* `model_name_or_path`:必须,进行微调使用的预训练模型。可选择的有 "ernie-3.0-tiny-base-v2-zh"、"ernie-3.0-tiny-medium-v2-zh"、"ernie-3.0-tiny-mini-v2-zh"、"ernie-3.0-tiny-micro-v2-zh"、"ernie-3.0-tiny-nano-v2-zh"、"ernie-3.0-tiny-pico-v2-zh"。
* `output_dir`:必须,模型训练后保存的模型目录。
* `prune_embeddings`:可选,模型的 embeddings 是否需要裁剪。如果设置,会按照 `max_seq_length` 以及 `max_vocab_size` 对预训练模型的 `position embeddings` 和 `word_embeddings` 参数进行裁剪,并将新的 model 和 tokenizer 保存至 `${output_dir}/pretrained_model` 下。后续的模型微调会基于 embeddings 裁剪后的模型开始。该策略主要是为了减少部署时模型的内存占用。如果对模型的内存占用要求不高,也可以不设置。
-* `max_seq_length`:最大序列长度,是指分词后样本的最大token数,本项目中是 16。如果设置了 `prune_embeddings`,那么会对模型的 `position embeddings` 根据 `max_seq_length` 的值进行裁剪。
+* `max_seq_length`:最大序列长度,是指分词后样本的最大 token 数,本项目中是 16。如果设置了 `prune_embeddings`,那么会对模型的 `position embeddings` 根据 `max_seq_length` 的值进行裁剪。
* `max_vocab_size`:词表裁剪后的大小。当设置 `prune_embeddings` 时,会根据词频对预训练模型的词表进行排序,并根据 `max_vocab_size` 大小进行裁剪。
* `train_path`:必须,训练集路径
* `dev_path`:必须,验证集路径
@@ -606,7 +606,7 @@ python run_train.py \
模型经过压缩后,精度基本无损,体积减小了 92.2%,仅有 5.4 MB。到此,算法侧的工作基本完成。
-
+
## ⚡️FastDeplopy 部署
能够将深度学习模型部署到性能较低的端侧本身是比较困难的工作,因此在前面我们对小模型做了大量的优化,在精度不降的情况下将 69 MB 的模型压缩至 5.4 MB,但是如果想更好地满足业务上线要求,还需要有部署工具对性能有更多优化。在这里,PaddlePadde 提供了易用高效的云边端推理部署工具 ⚡️FastDeploy,它的 [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite) 后端基于算子融合和常量折叠进行了深度模型优化,使得模型推理速度可有大幅度提升;在麒麟 985 芯片上单条文本的分词的推理时延低于 0.1 毫秒;
diff --git a/legacy/model_zoo/ernie-3.0-tiny/data/intent_label.txt b/slm/model_zoo/ernie-3.0-tiny/data/intent_label.txt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/data/intent_label.txt
rename to slm/model_zoo/ernie-3.0-tiny/data/intent_label.txt
diff --git a/legacy/model_zoo/ernie-3.0-tiny/data/slot_label.txt b/slm/model_zoo/ernie-3.0-tiny/data/slot_label.txt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/data/slot_label.txt
rename to slm/model_zoo/ernie-3.0-tiny/data/slot_label.txt
diff --git a/slm/model_zoo/ernie-3.0-tiny/deploy/README.md b/slm/model_zoo/ernie-3.0-tiny/deploy/README.md
new file mode 100644
index 000000000000..48669c865339
--- /dev/null
+++ b/slm/model_zoo/ernie-3.0-tiny/deploy/README.md
@@ -0,0 +1,43 @@
+# FastDeploy ERNIE 3.0 Tiny 模型高性能部署
+
+**目录**
+ * [FastDeploy 部署介绍](#FastDeploy 部署介绍)
+ * [代码结构](#代码结构)
+ * [环境要求](#环境要求)
+ * [详细部署文档](#详细部署文档)
+
+
+
+## FastDeploy 部署介绍
+
+**⚡️FastDeploy**是一款**全场景**、**易用灵活**、**极致高效**的 AI 推理部署工具,满足开发者**多硬件、多平台**的产业部署需求。开发者可以基于 FastDeploy 将训练好的预测模型在不同的硬件、不同的操作系统以及不同的推理引擎后端上进行部署。目前 FastDeploy 提供多种编程语言的 SDK,包括 C++、Python 以及 Java SDK。
+
+目前 ERNIE 3.0 Tiny 模型已提供基于 FastDeploy 的云边端的部署示例,在服务端上的 GPU 硬件上,支持`Paddle Inference`、`ONNX Runtime`、`Paddle TensorRT`以及`TensorRT`后端,在 CPU 上支持`Paddle Inference`、`ONNX Runtime`以及`OpenVINO`后端;在移动端上支持`Paddle Lite`后端。多硬件、多推理引擎后端的支持可以满足开发者不同的部署需求。
+
+本部署示例是车载语音场景下的口语理解(Spoken Language Understanding,SLU)任务,详细可看[ERNIE 3.0 Tiny 介绍](../README.md)。
+
+
+
+
+## 代码结构
+
+```text
+
+├── python
+│ ├── infer_demo.py # Python 部署示例代码
+│ └── README.md # Python 部署示例文档
+└── README.md # 文档
+
+```
+
+
+
+## 环境要求
+
+在部署 ERNIE 3.0 Tiny 模型前,需要安装 FastDeploy SDK,可参考[FastDeploy SDK 安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)确认部署环境是否满足 FastDeploy 环境要求,并按照介绍安装相应的 SDK。
+
+
+
+## 详细部署文档
+
+- [Python 部署](python/README.md)
diff --git a/legacy/model_zoo/ernie-3.0-tiny/deploy/python/README.md b/slm/model_zoo/ernie-3.0-tiny/deploy/python/README.md
similarity index 88%
rename from legacy/model_zoo/ernie-3.0-tiny/deploy/python/README.md
rename to slm/model_zoo/ernie-3.0-tiny/deploy/python/README.md
index 58cff6f6be84..73e504499431 100644
--- a/legacy/model_zoo/ernie-3.0-tiny/deploy/python/README.md
+++ b/slm/model_zoo/ernie-3.0-tiny/deploy/python/README.md
@@ -1,6 +1,6 @@
# FastDeploy ERNIE 3.0 Tiny 模型 Python 部署示例
-在部署前,参考 [FastDeploy SDK安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md) 安装 FastDeploy Python SDK。
+在部署前,参考 [FastDeploy SDK 安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md) 安装 FastDeploy Python SDK。
本目录下分别提供 `infer_demo.py` 快速完成在 CPU/GPU 的车载语音场景下的口语理解(Spoken Language Understanding,SLU)任务的 Python 部署示例,并展示端到端预测性能的 Benchmark。
@@ -46,7 +46,7 @@ No. 2 text = 到信阳市汽车配件城
### 量化模型部署
-该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在CPU上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 Tiny 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
+该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在 CPU 上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 Tiny 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
```bash
@@ -90,7 +90,7 @@ No. 2 text = 到信阳市汽车配件城
## FastDeploy 高阶用法
-FastDeploy 在 Python 端上,提供 `fastdeploy.RuntimeOption.use_xxx()` 以及 `fastdeploy.RuntimeOption.use_xxx_backend()` 接口支持开发者选择不同的硬件、不同的推理引擎进行部署。在不同的硬件上部署 ERNIE 3.0 Tiny 模型,需要选择硬件所支持的推理引擎进行部署,下表展示如何在不同的硬件上选择可用的推理引擎部署 ERNIE 3.0 Tiny模型。
+FastDeploy 在 Python 端上,提供 `fastdeploy.RuntimeOption.use_xxx()` 以及 `fastdeploy.RuntimeOption.use_xxx_backend()` 接口支持开发者选择不同的硬件、不同的推理引擎进行部署。在不同的硬件上部署 ERNIE 3.0 Tiny 模型,需要选择硬件所支持的推理引擎进行部署,下表展示如何在不同的硬件上选择可用的推理引擎部署 ERNIE 3.0 Tiny 模型。
符号说明: (1) ✅: 已经支持; (2) ❔: 正在进行中; (3) N/A: 暂不支持;
@@ -102,7 +102,7 @@ FastDeploy 在 Python 端上,提供 `fastdeploy.RuntimeOption.use_xxx()` 以
推理引擎对应的接口 |
是否支持 ERNIE 3.0 Tiny 模型 |
是否支持 Paddle 新格式量化模型 |
- 是否支持FP16模式 |
+ 是否支持 FP16模式 |
CPU |
@@ -191,19 +191,19 @@ FastDeploy 在 Python 端上,提供 `fastdeploy.RuntimeOption.use_xxx()` 以
- GPU型号 |
+ GPU 型号 |
A10 |
- CUDA版本 |
+ CUDA 版本 |
11.6 |
- cuDNN版本 |
+ cuDNN 版本 |
8.4.0 |
- CPU型号 |
+ CPU 型号 |
Intel(R) Xeon(R) Gold 6271C CPU @ 2.60GHz |
@@ -224,9 +224,9 @@ batch size = 32,max length = 16。
切词方式 |
端到端延时(ms) |
- Runtime延时(ms) |
- Tokenizer延时(ms) |
- PostProcess延时(ms) |
+ Runtime 延时(ms) |
+ Tokenizer 延时(ms) |
+ PostProcess 延时(ms) |
Python Tokenizer |
@@ -245,9 +245,9 @@ batch size = 32,max length = 16。
切词方式 |
端到端延时(ms) |
- Runtime延时(ms) |
- Tokenizer延时(ms) |
- PostProcess延时(ms) |
+ Runtime 延时(ms) |
+ Tokenizer 延时(ms) |
+ PostProcess 延时(ms) |
Python Tokenizer |
@@ -260,6 +260,6 @@ batch size = 32,max length = 16。
## 相关文档
-[ERNIE 3.0 Tiny模型详细介绍](../../README.md)
+[ERNIE 3.0 Tiny 模型详细介绍](../../README.md)
-[FastDeploy SDK安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)
+[FastDeploy SDK 安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)
diff --git a/legacy/model_zoo/ernie-3.0-tiny/deploy/python/infer_demo.py b/slm/model_zoo/ernie-3.0-tiny/deploy/python/infer_demo.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/deploy/python/infer_demo.py
rename to slm/model_zoo/ernie-3.0-tiny/deploy/python/infer_demo.py
diff --git a/legacy/model_zoo/ernie-3.0-tiny/model.py b/slm/model_zoo/ernie-3.0-tiny/model.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/model.py
rename to slm/model_zoo/ernie-3.0-tiny/model.py
diff --git a/legacy/model_zoo/ernie-3.0-tiny/run_eval.py b/slm/model_zoo/ernie-3.0-tiny/run_eval.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/run_eval.py
rename to slm/model_zoo/ernie-3.0-tiny/run_eval.py
diff --git a/legacy/model_zoo/ernie-3.0-tiny/run_train.py b/slm/model_zoo/ernie-3.0-tiny/run_train.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/run_train.py
rename to slm/model_zoo/ernie-3.0-tiny/run_train.py
diff --git a/legacy/model_zoo/ernie-3.0-tiny/utils.py b/slm/model_zoo/ernie-3.0-tiny/utils.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0-tiny/utils.py
rename to slm/model_zoo/ernie-3.0-tiny/utils.py
diff --git a/legacy/model_zoo/ernie-3.0/README.md b/slm/model_zoo/ernie-3.0/README.md
similarity index 97%
rename from legacy/model_zoo/ernie-3.0/README.md
rename to slm/model_zoo/ernie-3.0/README.md
index 300282fa8223..f7334127c56d 100644
--- a/legacy/model_zoo/ernie-3.0/README.md
+++ b/slm/model_zoo/ernie-3.0/README.md
@@ -11,17 +11,17 @@
* [模型预测](#模型预测)
* [模型压缩](#模型压缩)
* [环境依赖](#环境依赖)
- * [模型压缩 API 使用](#模型压缩API使用)
+ * [模型压缩 API 使用](#模型压缩 API 使用)
* [压缩效果](#压缩效果)
* [精度测试](#精度测试)
* [性能测试](#性能测试)
- * [CPU 性能](#CPU性能)
- * [GPU 性能](#CPU性能)
+ * [CPU 性能](#CPU 性能)
+ * [GPU 性能](#CPU 性能)
* [部署](#部署)
- * [FastDeploy 部署](#FastDeploy部署)
- * [Python 部署](#Python部署)
+ * [FastDeploy 部署](#FastDeploy 部署)
+ * [Python 部署](#Python 部署)
* [服务化部署](#服务化部署)
- * [Notebook教程](#Notebook教程)
+ * [Notebook 教程](#Notebook 教程)
* [参考文献](#参考文献)
@@ -1411,7 +1411,7 @@ python run_qa.py --model_name_or_path best_models/cmrc2018/ --dataset cmrc2018
pip install paddleslim
```
-
+
### 模型压缩 API 使用
@@ -1493,7 +1493,7 @@ python compress_qa.py --model_name_or_path best_models/cmrc2018/ --dataset cmrc2
7. 精度数据单位:文本分类是 Accuracy,序列标注是 F1-Score,阅读理解是 EM (Exact Match)
-
+
##### CPU 性能
@@ -1510,7 +1510,7 @@ python compress_qa.py --model_name_or_path best_models/cmrc2018/ --dataset cmrc2
三类任务(分类、序列标注、阅读理解)经过相同压缩过程后,加速比达到 2.3 左右。
-
+
##### GPU 性能
@@ -1532,11 +1532,11 @@ python compress_qa.py --model_name_or_path best_models/cmrc2018/ --dataset cmrc2
我们基于 FastDeploy 为 ERNIE 3.0 提供了多种部署方案,可以满足不同场景下的部署需求,请根据实际情况进行选择。
-
+
### FastDeploy 部署
-⚡️[FastDeploy](https://github.com/PaddlePaddle/FastDeploy)是一款全场景、易用灵活、极致高效的AI推理部署工具,为开发者提供多硬件、多推理引擎后端的部署能力。开发者只需调用一行代码即可随意切换硬件、推理引擎后端。
+⚡️[FastDeploy](https://github.com/PaddlePaddle/FastDeploy)是一款全场景、易用灵活、极致高效的 AI 推理部署工具,为开发者提供多硬件、多推理引擎后端的部署能力。开发者只需调用一行代码即可随意切换硬件、推理引擎后端。
@@ -1546,7 +1546,7 @@ python compress_qa.py --model_name_or_path best_models/cmrc2018/ --dataset cmrc2
目前 ERNIE 3.0 模型已提供基于 FastDeploy 的部署示例,支持在多款硬件(CPU、GPU、昆仑芯、华为昇腾以及 Graphcore IPU)以及推理引擎后端进行部署。具体的适配的硬件以及推理引擎请参考:[FastDeploy 部署指南](./deploy/README.md)
-
+
#### Python 部署
@@ -1562,19 +1562,19 @@ Python 部署请参考:[Python 部署指南](./deploy/python/README.md)
-## Notebook教程
+## Notebook 教程
-- [【快速上手ERNIE 3.0】中文情感分析实战](https://aistudio.baidu.com/aistudio/projectdetail/3955163)
+- [【快速上手 ERNIE 3.0】中文情感分析实战](https://aistudio.baidu.com/aistudio/projectdetail/3955163)
-- [【快速上手ERNIE 3.0】法律文本多标签分类实战](https://aistudio.baidu.com/aistudio/projectdetail/3996601)
+- [【快速上手 ERNIE 3.0】法律文本多标签分类实战](https://aistudio.baidu.com/aistudio/projectdetail/3996601)
-- [【快速上手ERNIE 3.0】中文语义匹配实战](https://aistudio.baidu.com/aistudio/projectdetail/3986803)
+- [【快速上手 ERNIE 3.0】中文语义匹配实战](https://aistudio.baidu.com/aistudio/projectdetail/3986803)
-- [【快速上手ERNIE 3.0】MSRA序列标注实战](https://aistudio.baidu.com/aistudio/projectdetail/3989073)
+- [【快速上手 ERNIE 3.0】MSRA 序列标注实战](https://aistudio.baidu.com/aistudio/projectdetail/3989073)
-- [【快速上手ERNIE 3.0】机器阅读理解实战](https://aistudio.baidu.com/aistudio/projectdetail/2017189)
+- [【快速上手 ERNIE 3.0】机器阅读理解实战](https://aistudio.baidu.com/aistudio/projectdetail/2017189)
-- [【快速上手ERNIE 3.0】对话意图识别](https://aistudio.baidu.com/aistudio/projectdetail/2017202?contributionType=1)
+- [【快速上手 ERNIE 3.0】对话意图识别](https://aistudio.baidu.com/aistudio/projectdetail/2017202?contributionType=1)
## 参考文献
diff --git a/legacy/model_zoo/ernie-3.0/compress_qa.py b/slm/model_zoo/ernie-3.0/compress_qa.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/compress_qa.py
rename to slm/model_zoo/ernie-3.0/compress_qa.py
diff --git a/legacy/model_zoo/ernie-3.0/compress_seq_cls.py b/slm/model_zoo/ernie-3.0/compress_seq_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/compress_seq_cls.py
rename to slm/model_zoo/ernie-3.0/compress_seq_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/compress_token_cls.py b/slm/model_zoo/ernie-3.0/compress_token_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/compress_token_cls.py
rename to slm/model_zoo/ernie-3.0/compress_token_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/configs/default.yml b/slm/model_zoo/ernie-3.0/configs/default.yml
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/configs/default.yml
rename to slm/model_zoo/ernie-3.0/configs/default.yml
diff --git a/legacy/model_zoo/ernie-3.0/deploy/README.md b/slm/model_zoo/ernie-3.0/deploy/README.md
similarity index 92%
rename from legacy/model_zoo/ernie-3.0/deploy/README.md
rename to slm/model_zoo/ernie-3.0/deploy/README.md
index 6ebd0956838c..4352b24896fe 100644
--- a/legacy/model_zoo/ernie-3.0/deploy/README.md
+++ b/slm/model_zoo/ernie-3.0/deploy/README.md
@@ -2,7 +2,7 @@
**⚡️FastDeploy** 是一款**全场景**、**易用灵活**、**极致高效**的 AI 推理部署工具,满足开发者**多硬件、多平台**的产业部署需求。开发者可以基于 FastDeploy 将训练好的预测模型在不同的硬件、不同的推理引擎后端上进行部署。目前 FastDeploy 提供多种编程语言的 SDK,包括 C++、Python 以及 Java SDK。
-在部署 ERNIE 3.0 模型前,需要安装 FastDeploy SDK,可参考 [FastDeploy SDK安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)确认部署环境是否满足 FastDeploy 环境要求,并按照介绍安装相应的 SDK。
+在部署 ERNIE 3.0 模型前,需要安装 FastDeploy SDK,可参考 [FastDeploy SDK 安装文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install/download_prebuilt_libraries.md)确认部署环境是否满足 FastDeploy 环境要求,并按照介绍安装相应的 SDK。
目前,ERNIE 3.0 模型支持在如下的硬件以及推理引擎进行部署。
@@ -72,7 +72,7 @@
-## 支持的NLP任务列表
+## 支持的 NLP 任务列表
符号说明: (1) ✅: 已经支持; (2) ❔: 正在进行中; (3) N/A: 暂不支持;
diff --git a/legacy/model_zoo/ernie-3.0/deploy/python/README.md b/slm/model_zoo/ernie-3.0/deploy/python/README.md
similarity index 87%
rename from legacy/model_zoo/ernie-3.0/deploy/python/README.md
rename to slm/model_zoo/ernie-3.0/deploy/python/README.md
index b3c40f924fbd..79728e26f07d 100644
--- a/legacy/model_zoo/ernie-3.0/deploy/python/README.md
+++ b/slm/model_zoo/ernie-3.0/deploy/python/README.md
@@ -32,7 +32,7 @@ Batch id:1, example id:0, sentence1:花呗支持高铁票支付吗, sentence2:
### 量化模型部署
-该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在CPU上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
+该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在 CPU 上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
```bash
@@ -60,17 +60,17 @@ Batch id:1, example id:0, sentence1:花呗支持高铁票支付吗, sentence2:
| 参数 |参数说明 |
|----------|--------------|
|--model_dir | 指定部署模型的目录, |
-|--batch_size |输入的batch size,默认为 1|
+|--batch_size |输入的 batch size,默认为 1|
|--max_length |最大序列长度,默认为 128|
|--device | 运行的设备,可选范围: ['cpu', 'gpu'],默认为'cpu' |
|--backend | 支持的推理后端,可选范围: ['onnx_runtime', 'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt'],默认为'paddle' |
-|--use_fp16 | 是否使用FP16模式进行推理。使用tensorrt和paddle_tensorrt后端时可开启,默认为False |
+|--use_fp16 | 是否使用 FP16模式进行推理。使用 tensorrt 和 paddle_tensorrt 后端时可开启,默认为 False |
## 序列标注任务
### 快速开始
-以下示例展示如何基于 FastDeploy 库完成 ERNIE 3.0 Medium 模型在 CLUE Benchmark 的[ MSRA_NER 数据集](https://github.com/lemonhu/NER-BERT-pytorch/tree/master/data/msra)上进行序列标注任务的Python预测部署,可通过命令行参数`--device`以及`--backend`指定运行在不同的硬件以及推理引擎后端,并使用`--model_dir`参数指定运行的模型,具体参数设置可查看下面[参数说明](#参数说明)。示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md)导出得到的部署模型,其模型目录为`model_zoo/ernie-3.0/best_models/msra_ner/export`(用户可按实际情况设置)。
+以下示例展示如何基于 FastDeploy 库完成 ERNIE 3.0 Medium 模型在 CLUE Benchmark 的[ MSRA_NER 数据集](https://github.com/lemonhu/NER-BERT-pytorch/tree/master/data/msra)上进行序列标注任务的 Python 预测部署,可通过命令行参数`--device`以及`--backend`指定运行在不同的硬件以及推理引擎后端,并使用`--model_dir`参数指定运行的模型,具体参数设置可查看下面[参数说明](#参数说明)。示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md)导出得到的部署模型,其模型目录为`model_zoo/ernie-3.0/best_models/msra_ner/export`(用户可按实际情况设置)。
```bash
@@ -106,7 +106,7 @@ entity: 姚明 label: PER pos: [10, 11]
### 量化模型部署
-该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在CPU上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
+该示例支持部署 Paddle INT8 新格式量化模型,仅需在`--model_dir`参数传入量化模型路径,并且在对应硬件上选择可用的推理引擎后端,即可完成量化模型部署。在 GPU 上部署量化模型时,可选后端为`paddle_tensorrt`、`tensorrt`;在 CPU 上部署量化模型时,可选后端为`paddle`、`onnx_runtime`。下面将展示如何使用该示例完成量化模型部署,示例中的模型是按照 [ERNIE 3.0 训练文档](../../README.md) 压缩量化后导出得到的量化模型。
```bash
@@ -145,11 +145,11 @@ entity: 姚明 label: PER pos: [10, 11]
| 参数 |参数说明 |
|----------|--------------|
|--model_dir | 指定部署模型的目录, |
-|--batch_size |输入的batch size,默认为 1|
+|--batch_size |输入的 batch size,默认为 1|
|--max_length |最大序列长度,默认为 128|
|--device | 运行的设备,可选范围: ['cpu', 'gpu'],默认为'cpu' |
|--backend | 支持的推理后端,可选范围: ['onnx_runtime', 'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt'],默认为'paddle' |
-|--use_fp16 | 是否使用FP16模式进行推理。使用tensorrt和paddle_tensorrt后端时可开启,默认为False |
+|--use_fp16 | 是否使用 FP16模式进行推理。使用 tensorrt 和 paddle_tensorrt 后端时可开启,默认为 False |
|--model_prefix| 模型文件前缀。前缀会分别与'.pdmodel'和'.pdiparams'拼接得到模型文件名和参数文件名。默认为 'model'|
diff --git a/legacy/model_zoo/ernie-3.0/deploy/python/requirements.txt b/slm/model_zoo/ernie-3.0/deploy/python/requirements.txt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/python/requirements.txt
rename to slm/model_zoo/ernie-3.0/deploy/python/requirements.txt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py b/slm/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py
rename to slm/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py b/slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py
rename to slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/README.md b/slm/model_zoo/ernie-3.0/deploy/serving/README.md
similarity index 95%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/README.md
rename to slm/model_zoo/ernie-3.0/deploy/serving/README.md
index a8a9de1ad94e..aeb8be273a95 100644
--- a/legacy/model_zoo/ernie-3.0/deploy/serving/README.md
+++ b/slm/model_zoo/ernie-3.0/deploy/serving/README.md
@@ -179,7 +179,7 @@ pip install tritonclient\[all\]
### 分类任务
-注意执行客户端请求时关闭代理,并根据实际情况修改main函数中的ip地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 main 函数中的 ip 地址(启动服务所在的机器)
```shell
python seq_cls_grpc_client.py
@@ -195,7 +195,7 @@ acc: 0.7224281742354032
### 序列标注任务
-注意执行客户端请求时关闭代理,并根据实际情况修改main函数中的ip地址(启动服务所在的机器)
+注意执行客户端请求时关闭代理,并根据实际情况修改 main 函数中的 ip 地址(启动服务所在的机器)
```shell
@@ -222,4 +222,4 @@ entity: 姚明 label: PER pos: [10, 11]
## 配置修改
-当前分类任务( ernie_seqcls_model/config.pbtxt )默认配置在 CPU上 运行 OpenVINO 引擎; 序列标注任务默认配置在 GPU 上运行 Paddle Inference 引擎。如果要在 CPU/GPU 或其他推理引擎上运行, 需要修改配置,详情请参考[配置文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/serving/docs/zh_CN/model_configuration.md)。
+当前分类任务( ernie_seqcls_model/config.pbtxt )默认配置在 CPU 上 运行 OpenVINO 引擎; 序列标注任务默认配置在 GPU 上运行 Paddle Inference 引擎。如果要在 CPU/GPU 或其他推理引擎上运行, 需要修改配置,详情请参考[配置文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/serving/docs/zh_CN/model_configuration.md)。
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/1/README.md b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/1/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/1/README.md
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/1/README.md
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/1/README.md b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/1/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/1/README.md
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/1/README.md
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_model/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/1/model.py b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/1/model.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/1/model.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/1/model.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_postprocess/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/1/model.py b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/1/model.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/1/model.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/1/model.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_seqcls_tokenizer/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/1/README.md b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/1/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/1/README.md
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/1/README.md
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls/config.pbtxt
diff --git a/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
new file mode 100644
index 000000000000..61c9e74a3231
--- /dev/null
+++ b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/1/README.md
@@ -0,0 +1 @@
+本目录存放 ERNIE 3.0模型
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_model/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/1/model.py b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/1/model.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/1/model.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/1/model.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_postprocess/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/1/model.py b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/1/model.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/1/model.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/1/model.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/config.pbtxt b/slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/config.pbtxt
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/config.pbtxt
rename to slm/model_zoo/ernie-3.0/deploy/serving/models/ernie_tokencls_tokenizer/config.pbtxt
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/seq_cls_grpc_client.py b/slm/model_zoo/ernie-3.0/deploy/serving/seq_cls_grpc_client.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/seq_cls_grpc_client.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/seq_cls_grpc_client.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/serving/token_cls_grpc_client.py b/slm/model_zoo/ernie-3.0/deploy/serving/token_cls_grpc_client.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/serving/token_cls_grpc_client.py
rename to slm/model_zoo/ernie-3.0/deploy/serving/token_cls_grpc_client.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/README.md b/slm/model_zoo/ernie-3.0/deploy/simple_serving/README.md
similarity index 78%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/README.md
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/README.md
index b411bc58b9ea..f4a4be60fecc 100644
--- a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/README.md
+++ b/slm/model_zoo/ernie-3.0/deploy/simple_serving/README.md
@@ -1,14 +1,14 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server启动服务](#Server服务启动)
+- [Server 启动服务](#Server 服务启动)
- [其他参数设置](#其他参数设置)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本
+使用有 SimpleServing 功能的 PaddleNLP 版本
-## Server服务启动
+## Server 服务启动
### 文本分类任务启动
#### 启动文本分类 Server 服务
```bash
@@ -26,7 +26,7 @@ python client_seq_cls.py --dataset afqmc
paddlenlp server server_token_cls:app --host 0.0.0.0 --port 8189
```
-#### 命名实体识别 Client发送服务
+#### 命名实体识别 Client 发送服务
```bash
python client_token_cls.py
```
@@ -43,7 +43,7 @@ python client_qa.py
```
## 其他参数设置
-可以在client端设置 `max_seq_len`, `batch_size` 参数
+可以在 client 端设置 `max_seq_len`, `batch_size` 参数
```python
data = {
'data': {
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_qa.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/client_qa.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_qa.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/client_qa.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_seq_cls.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/client_seq_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_seq_cls.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/client_seq_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_token_cls.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/client_token_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/client_token_cls.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/client_token_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_qa.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/server_qa.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_qa.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/server_qa.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_seq_cls.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/server_seq_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_seq_cls.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/server_seq_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_token_cls.py b/slm/model_zoo/ernie-3.0/deploy/simple_serving/server_token_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/deploy/simple_serving/server_token_cls.py
rename to slm/model_zoo/ernie-3.0/deploy/simple_serving/server_token_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/infer.py b/slm/model_zoo/ernie-3.0/infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/infer.py
rename to slm/model_zoo/ernie-3.0/infer.py
diff --git a/legacy/model_zoo/ernie-3.0/run_qa.py b/slm/model_zoo/ernie-3.0/run_qa.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/run_qa.py
rename to slm/model_zoo/ernie-3.0/run_qa.py
diff --git a/legacy/model_zoo/ernie-3.0/run_seq_cls.py b/slm/model_zoo/ernie-3.0/run_seq_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/run_seq_cls.py
rename to slm/model_zoo/ernie-3.0/run_seq_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/run_token_cls.py b/slm/model_zoo/ernie-3.0/run_token_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/run_token_cls.py
rename to slm/model_zoo/ernie-3.0/run_token_cls.py
diff --git a/legacy/model_zoo/ernie-3.0/utils.py b/slm/model_zoo/ernie-3.0/utils.py
similarity index 100%
rename from legacy/model_zoo/ernie-3.0/utils.py
rename to slm/model_zoo/ernie-3.0/utils.py
diff --git a/legacy/model_zoo/ernie-code/README.md b/slm/model_zoo/ernie-code/README.md
similarity index 64%
rename from legacy/model_zoo/ernie-code/README.md
rename to slm/model_zoo/ernie-code/README.md
index 495fa08303cf..acfd54d4a946 100644
--- a/legacy/model_zoo/ernie-code/README.md
+++ b/slm/model_zoo/ernie-code/README.md
@@ -7,10 +7,10 @@
[ERNIE-Code: Beyond English-Centric Cross-lingual Pretraining for Programming Languages](https://aclanthology.org/2023.findings-acl.676.pdf)
-ERNIE-Code是一个多自然语言、多编程语言的统一代码语言模型(Code LLM),支持116种自然语言和6+种编程语言。采用了两种预训练方法来进行跨语言预训练:
+ERNIE-Code 是一个多自然语言、多编程语言的统一代码语言模型(Code LLM),支持116种自然语言和6+种编程语言。采用了两种预训练方法来进行跨语言预训练:
- Span-Corruption Language Modeling (SCLM) 从单语言的自然语言或编程语言中进行掩码语言学习;
- Pivot-based Translation Language Modeling (PTLM),将多自然语言到多编程语言的映射 规约为,以英语为枢轴(pivot)的多自然语言到英语、和英语到多编程语言的联合学习。
-ERNIE-Code在代码智能的各种下游任务中,包括代码到多自然语言、多自然语言到代码、代码到代码、多自然语言文档翻译等任务,优于以前的多语言代码和文本模型(例如mT5 和 CodeT5),同时在多自然语言的代码摘要和文档翻译等任务上具备较好的的zero-shot prompt能力。
+ERNIE-Code 在代码智能的各种下游任务中,包括代码到多自然语言、多自然语言到代码、代码到代码、多自然语言文档翻译等任务,优于以前的多语言代码和文本模型(例如 mT5 和 CodeT5),同时在多自然语言的代码摘要和文档翻译等任务上具备较好的的 zero-shot prompt 能力。
详细请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/model_zoo/ernie-code).
diff --git a/slm/model_zoo/ernie-doc/README.md b/slm/model_zoo/ernie-doc/README.md
new file mode 100644
index 000000000000..ede3c8e40c30
--- /dev/null
+++ b/slm/model_zoo/ernie-doc/README.md
@@ -0,0 +1,6 @@
+# ERNIE-Doc: A Retrospective Long-Document Modeling Transformer
+
+## 模型简介
+[ERNIE-Doc](https://arxiv.org/abs/2012.15688)是百度 NLP 提出的针对长文本的预训练模型。在循环 Transformer 机制之上,创新性地提出两阶段重复学习以及增强的循环机制,以此提高模型感受野,加强模型对长文本的理解能力。
+
+详细参考这里: https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/model_zoo/ernie-doc
diff --git a/legacy/model_zoo/ernie-gen/README.md b/slm/model_zoo/ernie-gen/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-gen/README.md
rename to slm/model_zoo/ernie-gen/README.md
diff --git a/legacy/model_zoo/ernie-health/README.md b/slm/model_zoo/ernie-health/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-health/README.md
rename to slm/model_zoo/ernie-health/README.md
diff --git a/legacy/model_zoo/ernie-layout/README.md b/slm/model_zoo/ernie-layout/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-layout/README.md
rename to slm/model_zoo/ernie-layout/README.md
diff --git a/legacy/model_zoo/ernie-layout/README_ch.md b/slm/model_zoo/ernie-layout/README_ch.md
similarity index 79%
rename from legacy/model_zoo/ernie-layout/README_ch.md
rename to slm/model_zoo/ernie-layout/README_ch.md
index d755952b20cf..d56079e885c5 100644
--- a/legacy/model_zoo/ernie-layout/README_ch.md
+++ b/slm/model_zoo/ernie-layout/README_ch.md
@@ -9,21 +9,21 @@
- [HuggingFace web demo](#21)
- [应用场景展示](#22)
- [Taskflow](#23)
-- [3. Benchmark模型效果](#3)
+- [3. Benchmark 模型效果](#3)
- [4. 模型微调](#4)
- [4.1 文档信息抽取任务](#41)
- [4.2 文档视觉问答任务](#42)
- [4.3 文档图像分类任务](#43)
- [5. 部署](#5)
- [5.1 静态图导出](#51)
- - [5.2 Python部署](#52)
+ - [5.2 Python 部署](#52)
## 1. 模型介绍
-ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布局等信息进行跨模态联合建模,创新性引入布局知识增强,提出阅读顺序预测、细粒度图文匹配等自监督预训练任务,升级空间解偶注意力机制,在各数据集上效果取得大幅度提升,相关工作[ERNIE-Layout: Layout-Knowledge Enhanced Multi-modal Pre-training for Document Understanding](http://arxiv.org/abs/2210.06155)已被EMNLP 2022 Findings会议收录[1]。考虑到文档智能在多语种上商用广泛,依托PaddleNLP对外开源业界最强的多语言跨模态文档预训练模型ERNIE-Layout。
+ERNIE-Layout 以文心文本大模型 ERNIE 为底座,融合文本、图像、布局等信息进行跨模态联合建模,创新性引入布局知识增强,提出阅读顺序预测、细粒度图文匹配等自监督预训练任务,升级空间解偶注意力机制,在各数据集上效果取得大幅度提升,相关工作[ERNIE-Layout: Layout-Knowledge Enhanced Multi-modal Pre-training for Document Understanding](http://arxiv.org/abs/2210.06155)已被 EMNLP 2022 Findings 会议收录[1]。考虑到文档智能在多语种上商用广泛,依托 PaddleNLP 对外开源业界最强的多语言跨模态文档预训练模型 ERNIE-Layout。

@@ -37,7 +37,7 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
#### HuggingFace web demo
-🧾 通过[Huggingface网页](https://huggingface.co/spaces/PaddlePaddle/ERNIE-Layout)体验DocPrompt功能:
+🧾 通过[Huggingface 网页](https://huggingface.co/spaces/PaddlePaddle/ERNIE-Layout)体验 DocPrompt 功能:

@@ -92,13 +92,13 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
-- Demo图片可在此[下载](https://bj.bcebos.com/paddlenlp/taskflow/document_intelligence/demo.zip)
+- Demo 图片可在此[下载](https://bj.bcebos.com/paddlenlp/taskflow/document_intelligence/demo.zip)
#### Taskflow
-通过``paddlenlp.Taskflow``三行代码调用DocPrompt功能,具备多语言文档抽取问答能力,部分应用场景展示如下:
+通过``paddlenlp.Taskflow``三行代码调用 DocPrompt 功能,具备多语言文档抽取问答能力,部分应用场景展示如下:
- 输入格式
@@ -109,7 +109,7 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
]
```
-默认使用PaddleOCR进行OCR识别,同时支持用户通过``word_boxes``传入自己的OCR结果,格式为``List[str, List[float, float, float, float]]``。
+默认使用 PaddleOCR 进行 OCR 识别,同时支持用户通过``word_boxes``传入自己的 OCR 结果,格式为``List[str, List[float, float, float, float]]``。
```
[
@@ -139,7 +139,7 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
'result': [{'end': 44, 'prob': 0.82, 'start': 38, 'value': '金融学(本科)'}]}]
```
- - http图片链接输入
+ - http 图片链接输入

@@ -162,13 +162,13 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
- 可配置参数说明
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
- * `lang`:选择PaddleOCR的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
- * `topn`: 如果模型识别出多个结果,将返回前n个概率值最高的结果,默认为1。
+ * `lang`:选择 PaddleOCR 的语言,`ch`可在中英混合的图片中使用,`en`在英文图片上的效果更好,默认为`ch`。
+ * `topn`: 如果模型识别出多个结果,将返回前 n 个概率值最高的结果,默认为1。
-## 3. Benchmark模型效果
+## 3. Benchmark 模型效果
- 开源数据集介绍
@@ -177,7 +177,7 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
| FUNSD | 文档信息抽取 | 英文 | - |
| XFUND-ZH | 文档信息抽取 | 中文 | - |
| DocVQA-ZH | 文档视觉问答 | 中文 | [DocVQA-ZH](http://ailab.aiwin.org.cn/competitions/49)已停止榜单提交,因此我们将原始训练集进行重新划分以评估模型效果,划分后训练集包含4,187张图片,验证集包含500张图片,测试集包含500张图片。 |
- | RVL-CDIP (sampled) | 文档图像分类 | 英文 | RVL-CDIP原始数据集共包含400,000张图片,由于数据集较大训练较慢,为验证文档图像分类的模型效果故进行降采样,采样后的训练集包含6,400张图片,验证集包含800张图片,测试集包含800张图片。 |
+ | RVL-CDIP (sampled) | 文档图像分类 | 英文 | RVL-CDIP 原始数据集共包含400,000张图片,由于数据集较大训练较慢,为验证文档图像分类的模型效果故进行降采样,采样后的训练集包含6,400张图片,验证集包含800张图片,测试集包含800张图片。 |
- 评测结果
@@ -190,8 +190,8 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
- 具体评测方式
- - 以上所有任务均基于Grid Search方式进行超参寻优。FUNSD和XFUND-ZH每间隔 100 steps 评估验证集效果,评价指标为F1-Score。
- RVL-CDIP每间隔2000 steps评估验证集效果,评价指标为Accuracy。DocVQA-ZH每间隔10000 steps评估验证集效果,取验证集最优效果作为表格中的汇报指标,评价指标为ANLS(计算方法参考https://arxiv.org/pdf/1907.00490.pdf)。
+ - 以上所有任务均基于 Grid Search 方式进行超参寻优。FUNSD 和 XFUND-ZH 每间隔 100 steps 评估验证集效果,评价指标为 F1-Score。
+ RVL-CDIP 每间隔2000 steps 评估验证集效果,评价指标为 Accuracy。DocVQA-ZH 每间隔10000 steps 评估验证集效果,取验证集最优效果作为表格中的汇报指标,评价指标为 ANLS(计算方法参考 https://arxiv.org/pdf/1907.00490.pdf)。
- 以上每个下游任务的超参范围如下表所示:
@@ -201,13 +201,13 @@ ERNIE-Layout以文心文本大模型ERNIE为底座,融合文本、图像、布
| batch_size | 1, 2, 4 | 8, 16, 24 | 1, 2, 4 | 8, 16, 24 |
| warmup_ratio | - | 0, 0.05, 0.1 | - | 0, 0.05, 0.1 |
- FUNSD和XFUND-ZH使用的lr_scheduler_type策略是constant,因此不对warmup_ratio进行搜索。
+ FUNSD 和 XFUND-ZH 使用的 lr_scheduler_type 策略是 constant,因此不对 warmup_ratio 进行搜索。
- - 文档信息抽取任务FUNSD和XFUND-ZH采用最大步数(max_steps)的微调方式,分别为10000 steps和20000 steps;文档视觉问答DocVQA-ZH的num_train_epochs为6;文档图像分类RVL-CDIP的num_train_epochs为20。
+ - 文档信息抽取任务 FUNSD 和 XFUND-ZH 采用最大步数(max_steps)的微调方式,分别为10000 steps 和20000 steps;文档视觉问答 DocVQA-ZH 的 num_train_epochs 为6;文档图像分类 RVL-CDIP 的 num_train_epochs 为20。
- 最优超参
- 不同预训练模型在下游任务上做Grid Search之后的最优超参(learning_rate、batch_size、warmup_ratio)如下:
+ 不同预训练模型在下游任务上做 Grid Search 之后的最优超参(learning_rate、batch_size、warmup_ratio)如下:
| Model | FUNSD | RVL-CDIP (sampled) | XFUND-ZH | DocVQA-ZH |
| ------------------ | ------------ | ------------ | ------------ | ----------- |
@@ -229,7 +229,7 @@ pip install -r requirements.txt
#### 4.1 文档信息抽取任务
-- FUNSD训练
+- FUNSD 训练
```shell
python -u run_ner.py \
@@ -260,7 +260,7 @@ python -u run_ner.py \
--overwrite_output_dir
```
-- XFUND-ZH训练
+- XFUND-ZH 训练
```shell
python -u run_ner.py \
@@ -296,7 +296,7 @@ python -u run_ner.py \
#### 4.2 文档视觉问答任务
-- DocVQA-ZH训练
+- DocVQA-ZH 训练
```shell
python3 -u run_mrc.py \
@@ -336,7 +336,7 @@ python3 -u run_mrc.py \
#### 4.3 文档图像分类任务
-- RVL-CDIP训练
+- RVL-CDIP 训练
```shell
python3 -u run_cls.py \
@@ -382,19 +382,19 @@ python3 -u run_cls.py \
使用动态图训练结束之后,还可以将动态图参数导出为静态图参数,静态图模型将用于**后续的推理部署工作**。具体代码见[静态图导出脚本](export_model.py),静态图参数保存在`output_path`指定路径中。运行方式:
-- 导出在FUNSD上微调后的模型:
+- 导出在 FUNSD 上微调后的模型:
```shell
python export_model.py --task_type ner --model_path ./ernie-layoutx-base-uncased/models/funsd/ --output_path ./ner_export
```
-- 导出在DocVQA-ZH上微调后的模型:
+- 导出在 DocVQA-ZH 上微调后的模型:
```shell
python export_model.py --task_type mrc --model_path ./ernie-layoutx-base-uncased/models/docvqa_zh/ --output_path ./mrc_export
```
-- 导出在RVL-CDIP(sampled)上微调后的模型:
+- 导出在 RVL-CDIP(sampled)上微调后的模型:
```shell
python export_model.py --task_type cls --model_path ./ernie-layoutx-base-uncased/models/rvl_cdip_sampled/ --output_path ./cls_export
@@ -415,9 +415,9 @@ export/
-#### 5.2 Python部署
+#### 5.2 Python 部署
-导出静态图模型之后可用于部署,项目提供了文档信息抽取、文档视觉问答和文档图像分类三大场景下的使用示例,详见[ERNIE-Layout Python部署指南](./deploy/python/README_ch.md)。
+导出静态图模型之后可用于部署,项目提供了文档信息抽取、文档视觉问答和文档图像分类三大场景下的使用示例,详见[ERNIE-Layout Python 部署指南](./deploy/python/README_ch.md)。
diff --git a/legacy/model_zoo/ernie-layout/data_collator.py b/slm/model_zoo/ernie-layout/data_collator.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/data_collator.py
rename to slm/model_zoo/ernie-layout/data_collator.py
diff --git a/legacy/model_zoo/ernie-layout/deploy/python/README.md b/slm/model_zoo/ernie-layout/deploy/python/README.md
similarity index 100%
rename from legacy/model_zoo/ernie-layout/deploy/python/README.md
rename to slm/model_zoo/ernie-layout/deploy/python/README.md
diff --git a/legacy/model_zoo/ernie-layout/deploy/python/README_ch.md b/slm/model_zoo/ernie-layout/deploy/python/README_ch.md
similarity index 87%
rename from legacy/model_zoo/ernie-layout/deploy/python/README_ch.md
rename to slm/model_zoo/ernie-layout/deploy/python/README_ch.md
index 1eeb0debc1a6..caa305945258 100644
--- a/legacy/model_zoo/ernie-layout/deploy/python/README_ch.md
+++ b/slm/model_zoo/ernie-layout/deploy/python/README_ch.md
@@ -1,8 +1,8 @@
[English](README.md) | 简体中文
-# ERNIE-Layout Python部署指南
+# ERNIE-Layout Python 部署指南
-本文介绍ERNIE-Layout Python部署指南,包括部署环境的准备,文档信息抽取、文档视觉问答和文档图像分类三大场景下的使用示例。
+本文介绍 ERNIE-Layout Python 部署指南,包括部署环境的准备,文档信息抽取、文档视觉问答和文档图像分类三大场景下的使用示例。
- [1. 开始运行](#1-开始运行)
- [2. 文档信息抽取模型推理](#2-文档信息抽取模型推理)
@@ -121,9 +121,9 @@ python infer.py \
## 5. 更多配置
-- `model_path_prefix`: 用于推理的Paddle模型文件路径,需加上文件前缀名称。例如模型文件路径为`./export/inference.pdiparams`,则传入`./export/inference`。
+- `model_path_prefix`: 用于推理的 Paddle 模型文件路径,需加上文件前缀名称。例如模型文件路径为`./export/inference.pdiparams`,则传入`./export/inference`。
- `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
-- `max_seq_length`: 如果OCR的结果超过设定的最大长度则对OCR结果进行自动切分,默认为512。
+- `max_seq_length`: 如果 OCR 的结果超过设定的最大长度则对 OCR 结果进行自动切分,默认为512。
- `task_type`: 选择任务类型,可选有`ner`, `cls`和`mrc`。
- `lang`: 选择任务的语言类型,可选有`en`, `ch`。
- `device`: 选用什么设备进行训练,可选`cpu`或`gpu`。
diff --git a/legacy/model_zoo/ernie-layout/deploy/python/infer.py b/slm/model_zoo/ernie-layout/deploy/python/infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/deploy/python/infer.py
rename to slm/model_zoo/ernie-layout/deploy/python/infer.py
diff --git a/legacy/model_zoo/ernie-layout/deploy/python/predictor.py b/slm/model_zoo/ernie-layout/deploy/python/predictor.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/deploy/python/predictor.py
rename to slm/model_zoo/ernie-layout/deploy/python/predictor.py
diff --git a/legacy/model_zoo/ernie-layout/deploy/python/requirements.txt b/slm/model_zoo/ernie-layout/deploy/python/requirements.txt
similarity index 100%
rename from legacy/model_zoo/ernie-layout/deploy/python/requirements.txt
rename to slm/model_zoo/ernie-layout/deploy/python/requirements.txt
diff --git a/legacy/model_zoo/ernie-layout/export_model.py b/slm/model_zoo/ernie-layout/export_model.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/export_model.py
rename to slm/model_zoo/ernie-layout/export_model.py
diff --git a/legacy/model_zoo/ernie-layout/finetune_args.py b/slm/model_zoo/ernie-layout/finetune_args.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/finetune_args.py
rename to slm/model_zoo/ernie-layout/finetune_args.py
diff --git a/legacy/model_zoo/ernie-layout/layout_trainer.py b/slm/model_zoo/ernie-layout/layout_trainer.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/layout_trainer.py
rename to slm/model_zoo/ernie-layout/layout_trainer.py
diff --git a/legacy/model_zoo/ernie-layout/requirements.txt b/slm/model_zoo/ernie-layout/requirements.txt
similarity index 100%
rename from legacy/model_zoo/ernie-layout/requirements.txt
rename to slm/model_zoo/ernie-layout/requirements.txt
diff --git a/legacy/model_zoo/ernie-layout/run_cls.py b/slm/model_zoo/ernie-layout/run_cls.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/run_cls.py
rename to slm/model_zoo/ernie-layout/run_cls.py
diff --git a/legacy/model_zoo/ernie-layout/run_mrc.py b/slm/model_zoo/ernie-layout/run_mrc.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/run_mrc.py
rename to slm/model_zoo/ernie-layout/run_mrc.py
diff --git a/legacy/model_zoo/ernie-layout/run_ner.py b/slm/model_zoo/ernie-layout/run_ner.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/run_ner.py
rename to slm/model_zoo/ernie-layout/run_ner.py
diff --git a/legacy/model_zoo/ernie-layout/utils.py b/slm/model_zoo/ernie-layout/utils.py
similarity index 100%
rename from legacy/model_zoo/ernie-layout/utils.py
rename to slm/model_zoo/ernie-layout/utils.py
diff --git a/legacy/model_zoo/ernie-m/README.md b/slm/model_zoo/ernie-m/README.md
similarity index 89%
rename from legacy/model_zoo/ernie-m/README.md
rename to slm/model_zoo/ernie-m/README.md
index 5df966108f72..50d9f1b9308d 100644
--- a/legacy/model_zoo/ernie-m/README.md
+++ b/slm/model_zoo/ernie-m/README.md
@@ -6,7 +6,7 @@
原文提出两种方法建模各种语言间的对齐关系:
- **Cross-Attention Masked Language Modeling(CAMLM)**: 该算法在少量双语语料上捕捉语言间的对齐信息。其需要在不利用源句子上下文的情况下,通过目标句子还原被掩盖的词语,使模型初步建模了语言间的对齐关系。
-- **Back-Translation masked language modeling(BTMLM)**: 该方法基于回译机制从单语语料中学习语言间的对齐关系。通过CAMLM 生成伪平行语料,然后让模型学习生成的伪平行句子,使模型可以利用单语语料更好地建模语义对齐关系。
+- **Back-Translation masked language modeling(BTMLM)**: 该方法基于回译机制从单语语料中学习语言间的对齐关系。通过 CAMLM 生成伪平行语料,然后让模型学习生成的伪平行句子,使模型可以利用单语语料更好地建模语义对齐关系。

diff --git a/legacy/model_zoo/ernie-vil2.0/README.md b/slm/model_zoo/ernie-vil2.0/README.md
similarity index 88%
rename from legacy/model_zoo/ernie-vil2.0/README.md
rename to slm/model_zoo/ernie-vil2.0/README.md
index 3717632622cf..5ab6aadef8c0 100644
--- a/legacy/model_zoo/ernie-vil2.0/README.md
+++ b/slm/model_zoo/ernie-vil2.0/README.md
@@ -12,7 +12,7 @@
* [模型评估](#模型评估)
* [模型预测](#模型预测)
* [模型导出预测](#模型导出预测)
- * [Taskflow一键预测](#Taskflow一键预测)
+ * [Taskflow 一键预测](#Taskflow 一键预测)
* [参考文献](#参考文献)
本项目开源了 **ERNIE-ViL 2.0** 预训练模型及微调方案。
@@ -22,7 +22,7 @@
## ERNIE-ViL 2.0 介绍
-近年来,基于大规模数据预训练的跨模态模型取得了令人瞩目的成绩。基于对比学习的双塔预训练框架能够利用大规模的噪声图文数据,在跨模态检索等任务上展现出较大的效果提升,同时具备计算效率高等优势,受到了广泛的关注(如CLIP,ALIGN等)。然而,已有的视觉-语言预训练技术基于单视角的对比学习,无法同时学习多种模态间和模态内的关联性。
+近年来,基于大规模数据预训练的跨模态模型取得了令人瞩目的成绩。基于对比学习的双塔预训练框架能够利用大规模的噪声图文数据,在跨模态检索等任务上展现出较大的效果提升,同时具备计算效率高等优势,受到了广泛的关注(如 CLIP,ALIGN 等)。然而,已有的视觉-语言预训练技术基于单视角的对比学习,无法同时学习多种模态间和模态内的关联性。
ERNIE-ViL 2.0提出了一种基于多视角对比学习的预训练框架,通过构建丰富的视觉/文本视角,能够同时学习模态间和模态内的多种关联性,从而学习到更鲁棒的跨模态对齐,在跨模态检索等任务上取得了业界领先水平。

@@ -67,7 +67,7 @@ Tensor(shape=[1, 2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
## 预训练模型效果
### 跨模态检索效果
-以下为以中、英文模型在Flickr30K、COCO-CN的zero-shot结果,其他详见论文。
+以下为以中、英文模型在 Flickr30K、COCO-CN 的 zero-shot 结果,其他详见论文。
* **ERNIE-ViL 2.0 英文 on Flickr30k**:
| Name | R@1 | R@5 | R@10 |
@@ -129,7 +129,7 @@ Tensor(shape=[1, 2], dtype=float32, place=Place(gpu:0), stop_gradient=True,
本项目使用了 [Flickr30k-CN](https://paddlenlp.bj.bcebos.com/datasets/Flickr30k-CN.tar.gz) 中文场景下的图文数据集。
-为了训练的时候方便随机读取,我们将tsv和图片数据序列化,转换为arrow文件。
+为了训练的时候方便随机读取,我们将 tsv 和图片数据序列化,转换为 arrow 文件。
###
```shell
@@ -199,25 +199,25 @@ python -u -m paddle.distributed.launch --gpus "0,1" \
--lr_scheduler_type cosine \
--recompute
```
-**注意**:如果使用单卡训练,则默认不会开启Cross-batch Negatives策略,如果是多卡训练,则会默认开启Cross-batch Negatives策略,数据量比较大,一般建议多卡进行训练。
+**注意**:如果使用单卡训练,则默认不会开启 Cross-batch Negatives 策略,如果是多卡训练,则会默认开启 Cross-batch Negatives 策略,数据量比较大,一般建议多卡进行训练。
可配置参数说明:
* `do_train` 是否进行微调训练,设置该参数表示进行微调训练。
* `train_data` 必须,训练集路径。
* `val_data` 必须,验证集路径。
* `learning_rate` 训练的学习率。
-* `warmup_steps` warmup的step数。
+* `warmup_steps` warmup 的 step 数。
* `logging_steps` 训练过程中日志打印的间隔 steps 数。
* `per_device_train_batch_size` 训练集训练过程批处理大小,请结合显存情况进行调整,若出现显存不足,请适当调低这一参数;默认为128。
-* `dataloader_num_workers` Dataloader的num_worker的数目。
+* `dataloader_num_workers` Dataloader 的 num_worker 的数目。
* `save_steps` 训练过程中保存模型 checkpoint 的间隔 steps 数,默认50。
-* `num_train_epochs` 训练的epoch数目。
+* `num_train_epochs` 训练的 epoch 数目。
* `weight_decay` 除了所有 bias 和 LayerNorm 权重之外,应用于所有层的权重衰减数值。可选;默认为 0.0。
-* `save_total_limit` 保存checkpoints的数目,默认-1,表示不设限制。
+* `save_total_limit` 保存 checkpoints 的数目,默认-1,表示不设限制。
* `seed` 随机种子,用于固定模型训练的随机因素。
* `label_names`训练集中标签对应的 key 名称。如果不传入,在训练时 Trainer 可能由于无法区分输入数据和标签造成错误。
* `data_root` 数据集的根目录路径。
-* `lr_scheduler_type` 学习率变化的类型,支持linear,cosine,constant等。
+* `lr_scheduler_type` 学习率变化的类型,支持 linear,cosine,constant 等。
* `recompute` 节省缓存的策略,是一种以时间换空间的技术。
@@ -247,9 +247,9 @@ python -u extract_features.py \
* `extract-image-feats` 是否进行文本特征提取。
* `image-data` 图像数据的地址。
* `text-data` 文本数据的地址。
-* `resume` checkpoints的加载地址。
-* `img-batch-size` 图像特征提取的batch size。
-* `text-batch-size` 文本特征提取的batch size。
+* `resume` checkpoints 的加载地址。
+* `img-batch-size` 图像特征提取的 batch size。
+* `text-batch-size` 文本特征提取的 batch size。
* `context-length` 文本序列的最大长度。
### 以文搜图评估
@@ -370,7 +370,7 @@ python export_model.py --model_path=output_pd/checkpoint-600/ \
```
用户在`infer_model`中可以看到导出的文件。
-对于导出的模型,我们提供了Python的infer脚本,调用预测库对简单的例子进行预测。
+对于导出的模型,我们提供了 Python 的 infer 脚本,调用预测库对简单的例子进行预测。
```shell
python deploy/python/infer.py --model_dir ./infer_model/
```
@@ -384,11 +384,11 @@ python deploy/python/infer.py --model_dir ./infer_model/
```
可以看到输出的概率值跟前面的预测结果几乎是一致的
-
+
-## Taskflow一键预测
+## Taskflow 一键预测
-可以使用PaddleNLP提供的Taskflow工具来使用ERNIE Vil2.0,具体使用可以参考文档[模型特征提取](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/model_zoo/taskflow.md#%E6%A8%A1%E5%9E%8B%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96),下面是使用加载微调的模型的示例:
+可以使用 PaddleNLP 提供的 Taskflow 工具来使用 ERNIE Vil2.0,具体使用可以参考文档[模型特征提取](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/docs/model_zoo/taskflow.md#%E6%A8%A1%E5%9E%8B%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96),下面是使用加载微调的模型的示例:
```
vision_language = Taskflow("feature_extraction",model="PaddlePaddle/ernie_vil-2.0-base-zh"", task_path="/path/to/checkpoint-4000")
diff --git a/legacy/model_zoo/ernie-vil2.0/data_util.py b/slm/model_zoo/ernie-vil2.0/data_util.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/data_util.py
rename to slm/model_zoo/ernie-vil2.0/data_util.py
diff --git a/legacy/model_zoo/ernie-vil2.0/deploy/python/infer.py b/slm/model_zoo/ernie-vil2.0/deploy/python/infer.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/deploy/python/infer.py
rename to slm/model_zoo/ernie-vil2.0/deploy/python/infer.py
diff --git a/legacy/model_zoo/ernie-vil2.0/export_model.py b/slm/model_zoo/ernie-vil2.0/export_model.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/export_model.py
rename to slm/model_zoo/ernie-vil2.0/export_model.py
diff --git a/legacy/model_zoo/ernie-vil2.0/extract_features.py b/slm/model_zoo/ernie-vil2.0/extract_features.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/extract_features.py
rename to slm/model_zoo/ernie-vil2.0/extract_features.py
diff --git a/legacy/model_zoo/ernie-vil2.0/predict.py b/slm/model_zoo/ernie-vil2.0/predict.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/predict.py
rename to slm/model_zoo/ernie-vil2.0/predict.py
diff --git a/legacy/model_zoo/ernie-vil2.0/preprocess/create_arrow_dataset.py b/slm/model_zoo/ernie-vil2.0/preprocess/create_arrow_dataset.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/preprocess/create_arrow_dataset.py
rename to slm/model_zoo/ernie-vil2.0/preprocess/create_arrow_dataset.py
diff --git a/legacy/model_zoo/ernie-vil2.0/requirements.txt b/slm/model_zoo/ernie-vil2.0/requirements.txt
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/requirements.txt
rename to slm/model_zoo/ernie-vil2.0/requirements.txt
diff --git a/legacy/model_zoo/ernie-vil2.0/run_finetune.py b/slm/model_zoo/ernie-vil2.0/run_finetune.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/run_finetune.py
rename to slm/model_zoo/ernie-vil2.0/run_finetune.py
diff --git a/legacy/model_zoo/ernie-vil2.0/trainer_util.py b/slm/model_zoo/ernie-vil2.0/trainer_util.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/trainer_util.py
rename to slm/model_zoo/ernie-vil2.0/trainer_util.py
diff --git a/legacy/model_zoo/ernie-vil2.0/utils/evaluation.py b/slm/model_zoo/ernie-vil2.0/utils/evaluation.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/utils/evaluation.py
rename to slm/model_zoo/ernie-vil2.0/utils/evaluation.py
diff --git a/legacy/model_zoo/ernie-vil2.0/utils/evaluation_tr.py b/slm/model_zoo/ernie-vil2.0/utils/evaluation_tr.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/utils/evaluation_tr.py
rename to slm/model_zoo/ernie-vil2.0/utils/evaluation_tr.py
diff --git a/legacy/model_zoo/ernie-vil2.0/utils/make_topk_predictions.py b/slm/model_zoo/ernie-vil2.0/utils/make_topk_predictions.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/utils/make_topk_predictions.py
rename to slm/model_zoo/ernie-vil2.0/utils/make_topk_predictions.py
diff --git a/legacy/model_zoo/ernie-vil2.0/utils/make_topk_predictions_tr.py b/slm/model_zoo/ernie-vil2.0/utils/make_topk_predictions_tr.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/utils/make_topk_predictions_tr.py
rename to slm/model_zoo/ernie-vil2.0/utils/make_topk_predictions_tr.py
diff --git a/legacy/model_zoo/ernie-vil2.0/utils/transform_ir_annotation_to_tr.py b/slm/model_zoo/ernie-vil2.0/utils/transform_ir_annotation_to_tr.py
similarity index 100%
rename from legacy/model_zoo/ernie-vil2.0/utils/transform_ir_annotation_to_tr.py
rename to slm/model_zoo/ernie-vil2.0/utils/transform_ir_annotation_to_tr.py
diff --git a/legacy/model_zoo/gpt-3/.pre-commit-config.yaml b/slm/model_zoo/gpt-3/.pre-commit-config.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/.pre-commit-config.yaml
rename to slm/model_zoo/gpt-3/.pre-commit-config.yaml
diff --git a/legacy/model_zoo/gpt-3/README.md b/slm/model_zoo/gpt-3/README.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/README.md
rename to slm/model_zoo/gpt-3/README.md
diff --git a/legacy/model_zoo/gpt-3/benchmarks/README.md b/slm/model_zoo/gpt-3/benchmarks/README.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/README.md
rename to slm/model_zoo/gpt-3/benchmarks/README.md
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_bs64_fp16_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_1024_flash_bs64_fp16_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/N1C8/gpt_2048_bs64_fp16_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/data_parallel/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_CoLA_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_acc_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_MRPC_f1_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_QNLI_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_RTE_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_SST2_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_pearson_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_STSB_spearman_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/N1C1/CE_gpt_finetune_WNLI_bs32_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/finetune/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp16_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C1/gpt_bs16_fp32_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C4/gpt_bs16_fp16_DP1-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP4-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp16_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs16_fp32_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp16_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_bs64_fp32_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp16_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N1C8/gpt_recompute_bs16_fp32_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP1-MP8-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP2-MP8-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp16_DP4-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP1-MP8-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP2-MP8-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/N4C32/gpt_bs16_fp32_DP4-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/hybrid_parallel/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_False_bs8_fp16_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N1C8/gpt_sp_True_bs8_fp16_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_False_bs16_fp16_DP2-MP8-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/N4C32/gpt_sp_True_bs16_fp16_DP2-MP8-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sequence_parallel/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage2_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp16_DP1-MP1-PP1-Sharding2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N1C2/gpt_stage3_bs16_fp32_DP1-MP1-PP1-Sharding2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N2C16/gpt_stage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N2C16/gpt_stage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N2C16/gpt_stage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/N2C16/gpt_stage2_bs128_fp16_DP1-MP1-PP1-Sharding16.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/dygraph/sharding/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o1_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o2_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage1_bs64_o3_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o1_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o2_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage2_bs64_o3_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o1_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o2_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C1/gpt_auto_stage3_bs64_o3_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o1_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o2_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage1_bs64_o3_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o1_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o2_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage2_bs64_o3_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o1_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o2_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP1-PP8.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP2-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP1-MP8-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP1-PP4.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP2-PP2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP2-MP4-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N1C8/gpt_auto_stage3_bs64_o3_DP8-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage2_bs128_o2_DP16-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/N2C16/gpt_auto_stage3_bs128_o2_DP16-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_amp/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/N1C1/gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/N1C1/gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/N1C1/gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/N1C1/gpt_auto_recompute_bs8_fp32_DP1-MP1-PP1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/auto_parallel/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N1C8/gpt_auto_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N2C16/gpt_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N2C16/gpt_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N2C16/gpt_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N2C16/gpt_auto_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N4C32/gpt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N4C32/gpt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N4C32/gpt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/N4C32/gpt_auto_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O1_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O2_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP1-PP4-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs16_fp16O3_DP2-MP2-PP2-SD2-stage2.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O1_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O2_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP1-PP8-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N1C8/gpt_auto_pir_bs8_fp16O3_DP1-MP2-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N2C16/gpt_auto_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N2C16/gpt_auto_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N2C16/gpt_auto_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N2C16/gpt_auto_pir_bs16_fp32_DP1-MP8-PP2-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N4C32/gpt_auto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N4C32/gpt_auto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N4C32/gpt_auto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/N4C32/gpt_auto_pir_bs4_fp32_DP1-MP8-PP4-SD1-stage1.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/prepare.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/prepare.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/prepare.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/prepare.sh
diff --git a/legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/run_benchmark.sh b/slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/run_benchmark.sh
rename to slm/model_zoo/gpt-3/benchmarks/test_tipc/gpt/static/new_exec_pp_pir/benchmark_common/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/codestyle/clang_format.hook b/slm/model_zoo/gpt-3/codestyle/clang_format.hook
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/clang_format.hook
rename to slm/model_zoo/gpt-3/codestyle/clang_format.hook
diff --git a/legacy/model_zoo/gpt-3/codestyle/copyright.hook b/slm/model_zoo/gpt-3/codestyle/copyright.hook
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/copyright.hook
rename to slm/model_zoo/gpt-3/codestyle/copyright.hook
diff --git a/legacy/model_zoo/gpt-3/codestyle/cpplint_pre_commit.hook b/slm/model_zoo/gpt-3/codestyle/cpplint_pre_commit.hook
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/cpplint_pre_commit.hook
rename to slm/model_zoo/gpt-3/codestyle/cpplint_pre_commit.hook
diff --git a/legacy/model_zoo/gpt-3/codestyle/docstring_checker.py b/slm/model_zoo/gpt-3/codestyle/docstring_checker.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/docstring_checker.py
rename to slm/model_zoo/gpt-3/codestyle/docstring_checker.py
diff --git a/legacy/model_zoo/gpt-3/codestyle/pylint_pre_commit.hook b/slm/model_zoo/gpt-3/codestyle/pylint_pre_commit.hook
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/pylint_pre_commit.hook
rename to slm/model_zoo/gpt-3/codestyle/pylint_pre_commit.hook
diff --git a/legacy/model_zoo/gpt-3/codestyle/test_docstring_checker.py b/slm/model_zoo/gpt-3/codestyle/test_docstring_checker.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/codestyle/test_docstring_checker.py
rename to slm/model_zoo/gpt-3/codestyle/test_docstring_checker.py
diff --git a/legacy/model_zoo/gpt-3/docs/cluster_deployment.md b/slm/model_zoo/gpt-3/docs/cluster_deployment.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/cluster_deployment.md
rename to slm/model_zoo/gpt-3/docs/cluster_deployment.md
diff --git a/legacy/model_zoo/gpt-3/docs/compression.md b/slm/model_zoo/gpt-3/docs/compression.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/compression.md
rename to slm/model_zoo/gpt-3/docs/compression.md
diff --git a/legacy/model_zoo/gpt-3/docs/deployment_faq.md b/slm/model_zoo/gpt-3/docs/deployment_faq.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/deployment_faq.md
rename to slm/model_zoo/gpt-3/docs/deployment_faq.md
diff --git a/legacy/model_zoo/gpt-3/docs/docker_install.md b/slm/model_zoo/gpt-3/docs/docker_install.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/docker_install.md
rename to slm/model_zoo/gpt-3/docs/docker_install.md
diff --git a/legacy/model_zoo/gpt-3/docs/images/fleetx_arc.png b/slm/model_zoo/gpt-3/docs/images/fleetx_arc.png
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/images/fleetx_arc.png
rename to slm/model_zoo/gpt-3/docs/images/fleetx_arc.png
diff --git a/legacy/model_zoo/gpt-3/docs/images/throughput_compare.png b/slm/model_zoo/gpt-3/docs/images/throughput_compare.png
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/images/throughput_compare.png
rename to slm/model_zoo/gpt-3/docs/images/throughput_compare.png
diff --git a/legacy/model_zoo/gpt-3/docs/images/throughput_compare_graph.png b/slm/model_zoo/gpt-3/docs/images/throughput_compare_graph.png
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/images/throughput_compare_graph.png
rename to slm/model_zoo/gpt-3/docs/images/throughput_compare_graph.png
diff --git a/legacy/model_zoo/gpt-3/docs/quick_start.md b/slm/model_zoo/gpt-3/docs/quick_start.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/quick_start.md
rename to slm/model_zoo/gpt-3/docs/quick_start.md
diff --git a/legacy/model_zoo/gpt-3/docs/standard.md b/slm/model_zoo/gpt-3/docs/standard.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/docs/standard.md
rename to slm/model_zoo/gpt-3/docs/standard.md
diff --git a/legacy/model_zoo/gpt-3/external_ops/.gitignore b/slm/model_zoo/gpt-3/external_ops/.gitignore
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/.gitignore
rename to slm/model_zoo/gpt-3/external_ops/.gitignore
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln.h b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln.h
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_kernels.h b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_kernels.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_kernels.h
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_kernels.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_semi_cuda_kernel.cu b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_semi_cuda_kernel.cu
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_semi_cuda_kernel.cu
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_bwd_semi_cuda_kernel.cu
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_cuda_kernel.cu b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_cuda_kernel.cu
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_cuda_kernel.cu
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_cuda_kernel.cu
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_kernels.h b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_kernels.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_kernels.h
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_fwd_kernels.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_kernel_traits.h b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_kernel_traits.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_kernel_traits.h
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_kernel_traits.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_utils.h b/slm/model_zoo/gpt-3/external_ops/fast_ln/ln_utils.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_utils.h
rename to slm/model_zoo/gpt-3/external_ops/fast_ln/ln_utils.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.cu b/slm/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.cu
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.cu
rename to slm/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.cu
diff --git a/legacy/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.h b/slm/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.h
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.h
rename to slm/model_zoo/gpt-3/external_ops/fused_ln/layer_norm_cuda.h
diff --git a/legacy/model_zoo/gpt-3/external_ops/setup.py b/slm/model_zoo/gpt-3/external_ops/setup.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/external_ops/setup.py
rename to slm/model_zoo/gpt-3/external_ops/setup.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/export_gpt_fp16_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/export_gpt_fp16_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/export_gpt_fp16_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/export_gpt_fp16_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_13B_mp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_13B_mp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_13B_mp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_13B_mp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_175B_mp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_175B_mp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_175B_mp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_175B_mp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_mp2.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_mp2.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_mp2.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_mp2.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/generation_gpt_6.7B_mp1.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8_tuning.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8_tuning.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8_tuning.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_dp8_tuning.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_13B_sharding8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_13B_sharding8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_13B_sharding8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_13B_sharding8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_dp2_mp2_pp2_sharding2.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_sharding16.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_sharding16.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_sharding16.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_6.7B_sharding16.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_base.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_base.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_base.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_base.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_debug_mp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/qat_generation_gpt_345M_mp2.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/qat_generation_gpt_345M_mp2.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/qat_generation_gpt_345M_mp2.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/auto/qat_generation_gpt_345M_mp2.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_pruned_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_pruned_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_pruned_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_pruned_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_qat_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_qat_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_qat_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/eval_qat_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/export_qat_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/export_qat_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/export_qat_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/export_qat_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_345M_single_card_glue.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_345M_single_card_glue.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_345M_single_card_glue.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_345M_single_card_glue.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_base.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_base.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_base.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/finetune_gpt_base.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_dp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_dp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_dp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_dp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_mp1.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_mp1.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_mp1.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_mp1.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_6.7B_single_mp1.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_6.7B_single_mp1.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_6.7B_single_mp1.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_gpt_6.7B_single_mp1.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_pruned_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_pruned_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_pruned_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_pruned_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_6.7B_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_6.7B_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_6.7B_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/generation_qat_gpt_6.7B_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_dp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_dp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_dp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_dp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/inference_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_dp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_dp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_dp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_dp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_sep8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_sep8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_sep8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_sep8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_1.3B_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_13B_dp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_175B_mp8_pp16.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_sharding16.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_6.7B_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_base.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_base.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_base.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_base.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_cn_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_cn_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_cn_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/pretrain_gpt_cn_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/prune_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/prune_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/prune_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/prune_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_mp8.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_mp8.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_mp8.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_mp8.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_single_card.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_single_card.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_single_card.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_345M_single_card.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_6.7B_sharding16.yaml b/slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_6.7B_sharding16.yaml
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_6.7B_sharding16.yaml
rename to slm/model_zoo/gpt-3/ppfleetx/configs/nlp/gpt/qat_gpt_6.7B_sharding16.yaml
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/core/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/engine/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/core/engine/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/engine/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/engine/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/engine/auto_engine.py b/slm/model_zoo/gpt-3/ppfleetx/core/engine/auto_engine.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/engine/auto_engine.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/engine/auto_engine.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/engine/basic_engine.py b/slm/model_zoo/gpt-3/ppfleetx/core/engine/basic_engine.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/engine/basic_engine.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/engine/basic_engine.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/engine/eager_engine.py b/slm/model_zoo/gpt-3/ppfleetx/core/engine/eager_engine.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/engine/eager_engine.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/engine/eager_engine.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/engine/inference_engine.py b/slm/model_zoo/gpt-3/ppfleetx/core/engine/inference_engine.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/engine/inference_engine.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/engine/inference_engine.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/module/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/core/module/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/module/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/module/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/core/module/basic_module.py b/slm/model_zoo/gpt-3/ppfleetx/core/module/basic_module.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/core/module/basic_module.py
rename to slm/model_zoo/gpt-3/ppfleetx/core/module/basic_module.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/Makefile b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/Makefile
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/Makefile
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/Makefile
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/compile.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/compile.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/compile.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/compile.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/fast_index_map_helpers.cpp b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/fast_index_map_helpers.cpp
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/fast_index_map_helpers.cpp
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/cpp/fast_index_map_helpers.cpp
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/README.md b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/README.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/README.md
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/README.md
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/preprocess_data.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/preprocess_data.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/preprocess_data.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/preprocess_data.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/raw_trans_to_json.py b/slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/raw_trans_to_json.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/raw_trans_to_json.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/data_tools/gpt/raw_trans_to_json.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/dataset/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/dataset/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/dataset/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/dataset/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/dataset/glue_dataset.py b/slm/model_zoo/gpt-3/ppfleetx/data/dataset/glue_dataset.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/dataset/glue_dataset.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/dataset/glue_dataset.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/dataset/gpt_dataset.py b/slm/model_zoo/gpt-3/ppfleetx/data/dataset/gpt_dataset.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/dataset/gpt_dataset.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/dataset/gpt_dataset.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/sampler/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/sampler/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/sampler/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/sampler/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/sampler/batch_sampler.py b/slm/model_zoo/gpt-3/ppfleetx/data/sampler/batch_sampler.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/sampler/batch_sampler.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/sampler/batch_sampler.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/sampler/collate.py b/slm/model_zoo/gpt-3/ppfleetx/data/sampler/collate.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/sampler/collate.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/sampler/collate.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/gpt_tokenizer.py b/slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/gpt_tokenizer.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/gpt_tokenizer.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/gpt_tokenizer.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/tokenization_utils_base.py b/slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/tokenization_utils_base.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/tokenizers/tokenization_utils_base.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/tokenizers/tokenization_utils_base.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/transforms/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/transforms/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/transforms/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/transforms/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/transforms/preprocess.py b/slm/model_zoo/gpt-3/ppfleetx/data/transforms/preprocess.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/transforms/preprocess.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/transforms/preprocess.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/transforms/utils.py b/slm/model_zoo/gpt-3/ppfleetx/data/transforms/utils.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/transforms/utils.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/transforms/utils.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/utils/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/data/utils/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/utils/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/utils/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/data/utils/batch_collate_fn.py b/slm/model_zoo/gpt-3/ppfleetx/data/utils/batch_collate_fn.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/data/utils/batch_collate_fn.py
rename to slm/model_zoo/gpt-3/ppfleetx/data/utils/batch_collate_fn.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/auto_env.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/auto_env.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/auto_env.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/auto_env.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/comm_groups.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/comm_groups.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/comm_groups.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/comm_groups.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/env.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/env.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/env.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/env.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/io.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/io.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/io.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/io.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/strategy.py b/slm/model_zoo/gpt-3/ppfleetx/distributed/apis/strategy.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/distributed/apis/strategy.py
rename to slm/model_zoo/gpt-3/ppfleetx/distributed/apis/strategy.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/models/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/auto_utils.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/auto_utils.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/auto_utils.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/auto_utils.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_model.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_model.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_model.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_model.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_module.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_module.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_module.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/auto/auto_module.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/processor.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/processor.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/processor.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/processor.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/single_model.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/single_model.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/single_model.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/gpt/dygraph/single_model.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/language_module.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/language_module.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/language_module.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/language_module.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/metrics.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/metrics.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/metrics.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/metrics.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/models/language_model/utils.py b/slm/model_zoo/gpt-3/ppfleetx/models/language_model/utils.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/models/language_model/utils.py
rename to slm/model_zoo/gpt-3/ppfleetx/models/language_model/utils.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/ops/fused_layers.py b/slm/model_zoo/gpt-3/ppfleetx/ops/fused_layers.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/ops/fused_layers.py
rename to slm/model_zoo/gpt-3/ppfleetx/ops/fused_layers.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/ops/setup_cuda.py b/slm/model_zoo/gpt-3/ppfleetx/ops/setup_cuda.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/ops/setup_cuda.py
rename to slm/model_zoo/gpt-3/ppfleetx/ops/setup_cuda.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/ops/test_topp_sampling.py b/slm/model_zoo/gpt-3/ppfleetx/ops/test_topp_sampling.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/ops/test_topp_sampling.py
rename to slm/model_zoo/gpt-3/ppfleetx/ops/test_topp_sampling.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/ops/topp_sampling.cu b/slm/model_zoo/gpt-3/ppfleetx/ops/topp_sampling.cu
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/ops/topp_sampling.cu
rename to slm/model_zoo/gpt-3/ppfleetx/ops/topp_sampling.cu
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/optims/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/optims/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/optims/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/optims/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/optims/grad_clip.py b/slm/model_zoo/gpt-3/ppfleetx/optims/grad_clip.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/optims/grad_clip.py
rename to slm/model_zoo/gpt-3/ppfleetx/optims/grad_clip.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/optims/lr_scheduler.py b/slm/model_zoo/gpt-3/ppfleetx/optims/lr_scheduler.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/optims/lr_scheduler.py
rename to slm/model_zoo/gpt-3/ppfleetx/optims/lr_scheduler.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/optims/optimizer.py b/slm/model_zoo/gpt-3/ppfleetx/optims/optimizer.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/optims/optimizer.py
rename to slm/model_zoo/gpt-3/ppfleetx/optims/optimizer.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/tools/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/tools/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/tools/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/tools/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/tools/multiprocess_tool.py b/slm/model_zoo/gpt-3/ppfleetx/tools/multiprocess_tool.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/tools/multiprocess_tool.py
rename to slm/model_zoo/gpt-3/ppfleetx/tools/multiprocess_tool.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/__init__.py b/slm/model_zoo/gpt-3/ppfleetx/utils/__init__.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/__init__.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/__init__.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/auto_config.py b/slm/model_zoo/gpt-3/ppfleetx/utils/auto_config.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/auto_config.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/auto_config.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/check.py b/slm/model_zoo/gpt-3/ppfleetx/utils/check.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/check.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/check.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/compression_helper.py b/slm/model_zoo/gpt-3/ppfleetx/utils/compression_helper.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/compression_helper.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/compression_helper.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/config.py b/slm/model_zoo/gpt-3/ppfleetx/utils/config.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/config.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/config.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/device.py b/slm/model_zoo/gpt-3/ppfleetx/utils/device.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/device.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/device.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/download.py b/slm/model_zoo/gpt-3/ppfleetx/utils/download.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/download.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/download.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/export.py b/slm/model_zoo/gpt-3/ppfleetx/utils/export.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/export.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/export.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/file.py b/slm/model_zoo/gpt-3/ppfleetx/utils/file.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/file.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/file.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/log.py b/slm/model_zoo/gpt-3/ppfleetx/utils/log.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/log.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/log.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/tensor_fusion_helper.py b/slm/model_zoo/gpt-3/ppfleetx/utils/tensor_fusion_helper.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/tensor_fusion_helper.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/tensor_fusion_helper.py
diff --git a/legacy/model_zoo/gpt-3/ppfleetx/utils/version.py b/slm/model_zoo/gpt-3/ppfleetx/utils/version.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/ppfleetx/utils/version.py
rename to slm/model_zoo/gpt-3/ppfleetx/utils/version.py
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_13B_mp8.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_13B_mp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_13B_mp8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_13B_mp8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_175B_mp8.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_175B_mp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_175B_mp8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_175B_mp8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_mp2.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_mp2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_mp2.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_mp2.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_6.7B_mp1.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_6.7B_mp1.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_6.7B_mp1.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_6.7B_mp1.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_fp16_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_fp16_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_export_gpt_fp16_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_export_gpt_fp16_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8_tuning.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8_tuning.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8_tuning.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_dp8_tuning.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_1.3B_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_13B_sharding8.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_13B_sharding8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_13B_sharding8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_13B_sharding8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_dp2_mp2_pp2_sharding2.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_sharding16.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_sharding16.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_sharding16.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_gpt_6.7B_sharding16.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/auto_qat_export_gpt_345M_mp2.sh b/slm/model_zoo/gpt-3/projects/gpt/auto_qat_export_gpt_345M_mp2.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/auto_qat_export_gpt_345M_mp2.sh
rename to slm/model_zoo/gpt-3/projects/gpt/auto_qat_export_gpt_345M_mp2.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/benchmark.py b/slm/model_zoo/gpt-3/projects/gpt/benchmark.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/benchmark.py
rename to slm/model_zoo/gpt-3/projects/gpt/benchmark.py
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/README.md b/slm/model_zoo/gpt-3/projects/gpt/docs/README.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/README.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/README.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md b/slm/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md
similarity index 99%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md
index 322099b967d3..e051a973ea15 100644
--- a/legacy/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md
+++ b/slm/model_zoo/gpt-3/projects/gpt/docs/auto_parallel.md
@@ -247,7 +247,7 @@ python ./tools/auto.py -c ./ppfleetx/configs/nlp/gpt/auto/pretrain_gpt_1.3B_sing
**启动命令**
```shell
-cd PaddleNLP/legacy/model_zoo/gpt-3 # 如果已在 PaddleNLP/model_zoo/gpt-3 目录下,则忽略
+cd PaddleNLP/slm/model_zoo/gpt-3 # 如果已在 PaddleNLP/model_zoo/gpt-3 目录下,则忽略
log_dir=log_auto
python -m paddle.distributed.launch --log_dir $log_dir --devices "0,1,2,3,4,5,6,7" \
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/hybrid_parallel.md b/slm/model_zoo/gpt-3/projects/gpt/docs/hybrid_parallel.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/hybrid_parallel.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/hybrid_parallel.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/hybrid_profiler.md b/slm/model_zoo/gpt-3/projects/gpt/docs/hybrid_profiler.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/hybrid_profiler.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/hybrid_profiler.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/inference.md b/slm/model_zoo/gpt-3/projects/gpt/docs/inference.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/inference.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/inference.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/quantization_aware_training.md b/slm/model_zoo/gpt-3/projects/gpt/docs/quantization_aware_training.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/quantization_aware_training.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/quantization_aware_training.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/single_card.md b/slm/model_zoo/gpt-3/projects/gpt/docs/single_card.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/single_card.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/single_card.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/single_finetune.md b/slm/model_zoo/gpt-3/projects/gpt/docs/single_finetune.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/single_finetune.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/single_finetune.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/docs/structured_pruning.md b/slm/model_zoo/gpt-3/projects/gpt/docs/structured_pruning.md
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/docs/structured_pruning.md
rename to slm/model_zoo/gpt-3/projects/gpt/docs/structured_pruning.md
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/eval_prune_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/eval_prune_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/eval_prune_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/eval_prune_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/eval_qat_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/eval_qat_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/eval_qat_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/eval_qat_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/evaluate_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/evaluate_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/evaluate_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/evaluate_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/export_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/export_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/export_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/export_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/export_prune_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/export_prune_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/export_prune_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/export_prune_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/export_qat_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/export_qat_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/export_qat_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/export_qat_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/finetune_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/finetune_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/finetune_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/finetune_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/inference.py b/slm/model_zoo/gpt-3/projects/gpt/inference.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/inference.py
rename to slm/model_zoo/gpt-3/projects/gpt/inference.py
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_6.7B_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/inference_gpt_6.7B_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_6.7B_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/inference_gpt_6.7B_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_multigpu.sh b/slm/model_zoo/gpt-3/projects/gpt/inference_gpt_multigpu.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_multigpu.sh
rename to slm/model_zoo/gpt-3/projects/gpt/inference_gpt_multigpu.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/inference_gpt_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/inference_gpt_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/inference_gpt_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_dp8.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_dp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_dp8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_dp8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_sep8.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_sep8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_sep8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_sep8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_1.3B_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_175B_mp8_pp16.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_175B_mp8_pp16.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_175B_mp8_pp16.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_175B_mp8_pp16.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_6.7B_sharding16.sh b/slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_6.7B_sharding16.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/pretrain_gpt_6.7B_sharding16.sh
rename to slm/model_zoo/gpt-3/projects/gpt/pretrain_gpt_6.7B_sharding16.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/prune_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/prune_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/prune_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/prune_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_mp8.sh b/slm/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_mp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_mp8.sh
rename to slm/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_mp8.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_single_card.sh b/slm/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_single_card.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_single_card.sh
rename to slm/model_zoo/gpt-3/projects/gpt/qat_gpt_345M_single_card.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_6.7B_sharding16.sh b/slm/model_zoo/gpt-3/projects/gpt/qat_gpt_6.7B_sharding16.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/qat_gpt_6.7B_sharding16.sh
rename to slm/model_zoo/gpt-3/projects/gpt/qat_gpt_6.7B_sharding16.sh
diff --git a/legacy/model_zoo/gpt-3/projects/gpt/run_benchmark.sh b/slm/model_zoo/gpt-3/projects/gpt/run_benchmark.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/projects/gpt/run_benchmark.sh
rename to slm/model_zoo/gpt-3/projects/gpt/run_benchmark.sh
diff --git a/legacy/model_zoo/gpt-3/requirements.txt b/slm/model_zoo/gpt-3/requirements.txt
similarity index 100%
rename from legacy/model_zoo/gpt-3/requirements.txt
rename to slm/model_zoo/gpt-3/requirements.txt
diff --git a/legacy/model_zoo/gpt-3/run_mp8.sh b/slm/model_zoo/gpt-3/run_mp8.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/run_mp8.sh
rename to slm/model_zoo/gpt-3/run_mp8.sh
diff --git a/legacy/model_zoo/gpt-3/tasks/gpt/generation.py b/slm/model_zoo/gpt-3/tasks/gpt/generation.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tasks/gpt/generation.py
rename to slm/model_zoo/gpt-3/tasks/gpt/generation.py
diff --git a/legacy/model_zoo/gpt-3/tasks/gpt/inference.py b/slm/model_zoo/gpt-3/tasks/gpt/inference.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tasks/gpt/inference.py
rename to slm/model_zoo/gpt-3/tasks/gpt/inference.py
diff --git a/legacy/model_zoo/gpt-3/tasks/gpt/run_generation.sh b/slm/model_zoo/gpt-3/tasks/gpt/run_generation.sh
similarity index 100%
rename from legacy/model_zoo/gpt-3/tasks/gpt/run_generation.sh
rename to slm/model_zoo/gpt-3/tasks/gpt/run_generation.sh
diff --git a/legacy/model_zoo/gpt-3/tasks/gpt/train_pir.py b/slm/model_zoo/gpt-3/tasks/gpt/train_pir.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tasks/gpt/train_pir.py
rename to slm/model_zoo/gpt-3/tasks/gpt/train_pir.py
diff --git a/legacy/model_zoo/gpt-3/tools/auto.py b/slm/model_zoo/gpt-3/tools/auto.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/auto.py
rename to slm/model_zoo/gpt-3/tools/auto.py
diff --git a/legacy/model_zoo/gpt-3/tools/auto_export.py b/slm/model_zoo/gpt-3/tools/auto_export.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/auto_export.py
rename to slm/model_zoo/gpt-3/tools/auto_export.py
diff --git a/legacy/model_zoo/gpt-3/tools/eval.py b/slm/model_zoo/gpt-3/tools/eval.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/eval.py
rename to slm/model_zoo/gpt-3/tools/eval.py
diff --git a/legacy/model_zoo/gpt-3/tools/export.py b/slm/model_zoo/gpt-3/tools/export.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/export.py
rename to slm/model_zoo/gpt-3/tools/export.py
diff --git a/legacy/model_zoo/gpt-3/tools/inference.py b/slm/model_zoo/gpt-3/tools/inference.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/inference.py
rename to slm/model_zoo/gpt-3/tools/inference.py
diff --git a/legacy/model_zoo/gpt-3/tools/train.py b/slm/model_zoo/gpt-3/tools/train.py
similarity index 100%
rename from legacy/model_zoo/gpt-3/tools/train.py
rename to slm/model_zoo/gpt-3/tools/train.py
diff --git a/slm/model_zoo/luke/README.md b/slm/model_zoo/luke/README.md
new file mode 100644
index 000000000000..4a759825b5da
--- /dev/null
+++ b/slm/model_zoo/luke/README.md
@@ -0,0 +1,91 @@
+# LUKE with PaddleNLP
+
+[LUKE: Deep Contextualized Entity Representations with Entity-aware Self-attention](https://arxiv.org/abs/2010.01057)
+
+**模型简介:**
+许多 NLP 任务都涉及实体,例如:关系分类、实体类型、命名实体识别(NER)和问答(QA)。解决此类实体相关任务的关键是学习实体有效表示。传统的实体表示为每个实体分配一个固定的 Embedding 向量,该向量将有关实体的信息存储在知识库(KB)中。它们需要实体链接(entity linking)来表示文本中的实体,而不能表示 KB 中不存在的实体。
+
+相比之下,基于 contextualized word representations(CWRs) transformer 的大型预训练模型,如 BERT 和 RoBERTa,提供了基于语言建模的有效通用词语表征。然而,由于以下两个原因,CWRs 的体系结构不适合表示实体:
+
+- 由于 CWR 不输出实体的跨级(span-level)表示,因此它们通常需要学习如何基于通常较小的下游数据集计算此类表征。
+
+- 许多与实体相关的任务,如关系分类和问答(QA)涉及实体之间关系的推理。尽管 transformer 可以通过使用 self-attention 机制将单词相互关联来捕捉单词之间的复杂关系。在实体之间执行关系推理是困难的,因为许多实体在模型中被分割成多个词。此外,基于单词的 CWRs 预训练任务不适合学习实体的表征,因为在实体中预测一个被 MASK 的单词,例如预测“Rings”, 给予句子“The Lord of the [MASK]”,一个完整的实体就这样被拆分。
+
+LUKE 和现有 CWRs 之间的一个重要区别在于,它不仅将单词视为独立的 token,还将实体视为独立的 token,并使用 transformer 计算所有 token 的中间表征和输出表征。由于实体被视为 token,LUKE 可以直接建模实体之间的关系。
+本项目是 LUKE 在 Paddle 2.x 上的开源实现。
+
+## 快速开始
+
+### 下游任务微调
+
+数据集
+下载 Open Entity 数据集
+[下载地址](https://cloud.tsinghua.edu.cn/f/6ec98dbd931b4da9a7f0/)
+把下载好的文件解压,并把解压后的 Open Entity 目录下的`train.json`、`test.json`和`dev.json`分别为训练集、验证集和测试集
+
+下载 SQuAD1.1数据集,主流机器阅读理解数据集
+[下载地址](https://data.deepai.org/squad1.1.zip)
+
+#### 1、SQuAD1.1
+以 SQuAD1.1数据集为例
+
+运行以下两个命令即可训练并评估 LUKE 在 SQuAD1.1数据集的精度
+
+```shell
+python -m paddle.distributed.launch examples/language_model/luke/run_squad.py
+ --model_type luke \
+ --device gpu \
+ --learning_rate 15e-6 \
+ --num_train_epochs 2 \
+ --batch_size 8 \
+ --do_predict \
+ --do_train \
+ --model_name_or_path luke-large
+```
+其中参数释义如下:
+- `model_type` 指示了模型类型,当前支持`luke`
+- `batch_size` 表示每次迭代**每张卡**上的样本数目。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
+- `num_train_epochs` 表示需要训练的 epoch 数量
+- `do_train` 表示是否开启训练
+- `do_predict` 表示是否开启评估
+- `model_name_or_path` 模型的名称和路径,支持`luke-base` 和 `luke-large`
+
+训练结束后模型会对模型进行评估,其评估在验证集上完成, 训练完成后你将看到如下结果:
+```text
+{"exact_match": 89.75691579943235, "f1": 94.95702001984502}
+```
+
+#### 2、Open Entity
+
+```shell
+python -m paddle.distributed.launch examples/language_model/luke/run_open_entity.py \
+ --model_type luke-large \
+ --data_dir data/ \
+ --output_dir output/ \
+ --device gpu \
+ --learning_rate 1e-5 \
+ --num_train_epochs 3 \
+ --train_batch_size 2
+```
+训练结束后模型会对模型进行评估,其评估在测试集上完成, 训练完成后你将看到如下结果:
+```text
+Results: {
+ "test_f1": 0.7815726767275616,
+ "test_precision": 0.7880405766150561,
+ "test_recall": 0.7752100840336135
+}
+```
+
+
+# Reference
+
+```bibtex
+@inproceedings{yamada2020luke,
+ title={LUKE: Deep Contextualized Entity Representations with Entity-aware Self-attention},
+ author={Ikuya Yamada and Akari Asai and Hiroyuki Shindo and Hideaki Takeda and Yuji Matsumoto},
+ booktitle={EMNLP},
+ year={2020}
+}
+```
diff --git a/legacy/model_zoo/luke/args.py b/slm/model_zoo/luke/args.py
similarity index 100%
rename from legacy/model_zoo/luke/args.py
rename to slm/model_zoo/luke/args.py
diff --git a/legacy/model_zoo/luke/open_entity_processor.py b/slm/model_zoo/luke/open_entity_processor.py
similarity index 100%
rename from legacy/model_zoo/luke/open_entity_processor.py
rename to slm/model_zoo/luke/open_entity_processor.py
diff --git a/legacy/model_zoo/luke/run_open_entity.py b/slm/model_zoo/luke/run_open_entity.py
similarity index 100%
rename from legacy/model_zoo/luke/run_open_entity.py
rename to slm/model_zoo/luke/run_open_entity.py
diff --git a/legacy/model_zoo/luke/run_squad.py b/slm/model_zoo/luke/run_squad.py
similarity index 100%
rename from legacy/model_zoo/luke/run_squad.py
rename to slm/model_zoo/luke/run_squad.py
diff --git a/legacy/model_zoo/megatronbert/README.md b/slm/model_zoo/megatronbert/README.md
similarity index 73%
rename from legacy/model_zoo/megatronbert/README.md
rename to slm/model_zoo/megatronbert/README.md
index e9795358bb40..927ecb742510 100644
--- a/legacy/model_zoo/megatronbert/README.md
+++ b/slm/model_zoo/megatronbert/README.md
@@ -3,10 +3,10 @@
[Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism](https://arxiv.org/pdf/1909.08053.pdf)
**模型简介:**
-近期在语言建模方面的工作表明,训练大型transformers模型提高了自然语言处理应用的技术水平。然而,由于内存限制,非常大的模型可能难以训练。在这项工作中,
-作者提出了训练大型transformers模型的技术,并实现了一种简单、高效的模型运算并行方法,该方法能够训练具有数十亿个参数的transformers模型。
+近期在语言建模方面的工作表明,训练大型 transformers 模型提高了自然语言处理应用的技术水平。然而,由于内存限制,非常大的模型可能难以训练。在这项工作中,
+作者提出了训练大型 transformers 模型的技术,并实现了一种简单、高效的模型运算并行方法,该方法能够训练具有数十亿个参数的 transformers 模型。
-本项目是 MegatronBert 在 Paddle 2.x上的开源实现。
+本项目是 MegatronBert 在 Paddle 2.x 上的开源实现。
## 快速开始
@@ -29,10 +29,10 @@ python -m paddle.distributed.launch run_squad.py \
其中参数释义如下:
- `model_name_or_path` 指示了模型类型,当前支持`megatronbert-cased`和`megatronbert-uncased`模型。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `output_dir` 表示模型保存路径。
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
-- `num_train_epochs` 表示需要训练的epoch数量
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
+- `num_train_epochs` 表示需要训练的 epoch 数量
训练结束后模型会对模型进行评估,其评估在验证集上完成, 训练完成后你将看到如下结果:
```text
@@ -61,7 +61,7 @@ python -m paddle.distributed.launch run_squad.py \
```
其中参数释义如下:
-- `version_2_with_negative` 是否使用SQuAD2.0数据集
+- `version_2_with_negative` 是否使用 SQuAD2.0数据集
训练结束后模型会对模型进行评估,其评估在验证集上完成, 训练完成后你将看到如下结果:
```text
@@ -82,7 +82,7 @@ python -m paddle.distributed.launch run_squad.py \
}
```
-#### 2、mnli数据集
+#### 2、mnli 数据集
```shell
python -m paddle.distributed.launch run_glue.py \
diff --git a/legacy/model_zoo/megatronbert/args.py b/slm/model_zoo/megatronbert/args.py
similarity index 100%
rename from legacy/model_zoo/megatronbert/args.py
rename to slm/model_zoo/megatronbert/args.py
diff --git a/legacy/model_zoo/megatronbert/run_glue.py b/slm/model_zoo/megatronbert/run_glue.py
similarity index 100%
rename from legacy/model_zoo/megatronbert/run_glue.py
rename to slm/model_zoo/megatronbert/run_glue.py
diff --git a/legacy/model_zoo/megatronbert/run_squad.py b/slm/model_zoo/megatronbert/run_squad.py
similarity index 100%
rename from legacy/model_zoo/megatronbert/run_squad.py
rename to slm/model_zoo/megatronbert/run_squad.py
diff --git a/legacy/model_zoo/moe/data_tools b/slm/model_zoo/moe/data_tools
similarity index 100%
rename from legacy/model_zoo/moe/data_tools
rename to slm/model_zoo/moe/data_tools
diff --git a/legacy/model_zoo/moe/dygraph/args.py b/slm/model_zoo/moe/dygraph/args.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/args.py
rename to slm/model_zoo/moe/dygraph/args.py
diff --git a/legacy/model_zoo/moe/dygraph/checkpointing.py b/slm/model_zoo/moe/dygraph/checkpointing.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/checkpointing.py
rename to slm/model_zoo/moe/dygraph/checkpointing.py
diff --git a/legacy/model_zoo/moe/dygraph/dataset.py b/slm/model_zoo/moe/dygraph/dataset.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/dataset.py
rename to slm/model_zoo/moe/dygraph/dataset.py
diff --git a/legacy/model_zoo/moe/dygraph/framework/__init__.py b/slm/model_zoo/moe/dygraph/framework/__init__.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/framework/__init__.py
rename to slm/model_zoo/moe/dygraph/framework/__init__.py
diff --git a/legacy/model_zoo/moe/dygraph/framework/group_sharded.py b/slm/model_zoo/moe/dygraph/framework/group_sharded.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/framework/group_sharded.py
rename to slm/model_zoo/moe/dygraph/framework/group_sharded.py
diff --git a/legacy/model_zoo/moe/dygraph/framework/storage_process.py b/slm/model_zoo/moe/dygraph/framework/storage_process.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/framework/storage_process.py
rename to slm/model_zoo/moe/dygraph/framework/storage_process.py
diff --git a/legacy/model_zoo/moe/dygraph/modeling.py b/slm/model_zoo/moe/dygraph/modeling.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/modeling.py
rename to slm/model_zoo/moe/dygraph/modeling.py
diff --git a/legacy/model_zoo/moe/dygraph/run.sh b/slm/model_zoo/moe/dygraph/run.sh
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/run.sh
rename to slm/model_zoo/moe/dygraph/run.sh
diff --git a/legacy/model_zoo/moe/dygraph/run_moe_pretrain.py b/slm/model_zoo/moe/dygraph/run_moe_pretrain.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/run_moe_pretrain.py
rename to slm/model_zoo/moe/dygraph/run_moe_pretrain.py
diff --git a/legacy/model_zoo/moe/dygraph/sync_files.sh b/slm/model_zoo/moe/dygraph/sync_files.sh
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/sync_files.sh
rename to slm/model_zoo/moe/dygraph/sync_files.sh
diff --git a/legacy/model_zoo/moe/dygraph/utils.py b/slm/model_zoo/moe/dygraph/utils.py
similarity index 100%
rename from legacy/model_zoo/moe/dygraph/utils.py
rename to slm/model_zoo/moe/dygraph/utils.py
diff --git a/legacy/model_zoo/mpnet/README.md b/slm/model_zoo/mpnet/README.md
similarity index 63%
rename from legacy/model_zoo/mpnet/README.md
rename to slm/model_zoo/mpnet/README.md
index f959121c6963..ecf0cc73707c 100644
--- a/legacy/model_zoo/mpnet/README.md
+++ b/slm/model_zoo/mpnet/README.md
@@ -3,16 +3,16 @@
[MPNet: Masked and Permuted Pre-training for Language Understanding - Microsoft Research](https://www.microsoft.com/en-us/research/publication/mpnet-masked-and-permuted-pre-training-for-language-understanding/)
**摘要:**
-BERT采用掩码语言建模(MLM)进行预训练,是最成功的预训练模型之一。由于BERT忽略了预测标记之间的依赖关系,XLNet引入了置换语言建模(PLM)进行预训练来解决这个问题。然而,XLNet没有利用句子的完整位置信息,因此会受到预训练和微调之间的位置差异的影响。在本文中,我们提出了MPNet,这是一种新的预训练方法,它继承了BERT和XLNet的优点并避免了它们的局限性。MPNet通过置换语言建模(相对于BERT中的MLM)利用预测标记之间的依赖性,并以辅助位置信息作为输入,使模型能够看到完整的句子,从而减少位置差异(相对于XLNet中的PLM)。我们在大规模数据集(超过160GB的文本语料库)上预训练了MPNet模型,并对各种下游任务(GLUE、SQuAD 等)进行微调。实验结果表明,在相同的模型设置下,MPNet大大优于MLM和PLM,并且与之前最先进的预训练方法(例如 BERT、XLNet、RoBERTa)相比,在这些任务上取得了更好的结果。原始代码和预训练模型可从 https://github.com/microsoft/MPNet 下载得到。
+BERT 采用掩码语言建模(MLM)进行预训练,是最成功的预训练模型之一。由于 BERT 忽略了预测标记之间的依赖关系,XLNet 引入了置换语言建模(PLM)进行预训练来解决这个问题。然而,XLNet 没有利用句子的完整位置信息,因此会受到预训练和微调之间的位置差异的影响。在本文中,我们提出了 MPNet,这是一种新的预训练方法,它继承了 BERT 和 XLNet 的优点并避免了它们的局限性。MPNet 通过置换语言建模(相对于 BERT 中的 MLM)利用预测标记之间的依赖性,并以辅助位置信息作为输入,使模型能够看到完整的句子,从而减少位置差异(相对于 XLNet 中的 PLM)。我们在大规模数据集(超过160GB 的文本语料库)上预训练了 MPNet 模型,并对各种下游任务(GLUE、SQuAD 等)进行微调。实验结果表明,在相同的模型设置下,MPNet 大大优于 MLM 和 PLM,并且与之前最先进的预训练方法(例如 BERT、XLNet、RoBERTa)相比,在这些任务上取得了更好的结果。原始代码和预训练模型可从 https://github.com/microsoft/MPNet 下载得到。
-本项目是 MPNet 在 Paddle 2.x上的开源实现。
+本项目是 MPNet 在 Paddle 2.x 上的开源实现。
## 快速开始
### 下游任务微调
#### 1、GLUE
-以QQP数据集为例,运行其他glue数据集,请参考`train.sh`文件。(超参数遵循原论文的仓库的[README](https://github.com/microsoft/MPNet/blob/master/MPNet/README.glue.md))
+以 QQP 数据集为例,运行其他 glue 数据集,请参考`train.sh`文件。(超参数遵循原论文的仓库的[README](https://github.com/microsoft/MPNet/blob/master/MPNet/README.glue.md))
##### (1)模型微调:
```shell
@@ -37,22 +37,22 @@ python -m paddle.distributed.launch --gpus "0" run_glue.py \
--device gpu
```
其中参数释义如下:
-- `model_type` 指示了模型类型,当前支持BERT、ELECTRA、ERNIE、CONVBERT、MPNET模型。
-- `model_name_or_path` 模型名称或者路径,其中mpnet模型当前仅支持mpnet-base几种规格。
-- `task_name` 表示 Fine-tuning 的任务,当前支持CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE和WNLI。
+- `model_type` 指示了模型类型,当前支持 BERT、ELECTRA、ERNIE、CONVBERT、MPNET 模型。
+- `model_name_or_path` 模型名称或者路径,其中 mpnet 模型当前仅支持 mpnet-base 几种规格。
+- `task_name` 表示 Fine-tuning 的任务,当前支持 CoLA、SST-2、MRPC、STS-B、QQP、MNLI、QNLI、RTE 和 WNLI。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `per_device_train_batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `lr_scheduler_type` scheduler类型,可选linear和cosine。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `lr_scheduler_type` scheduler 类型,可选 linear 和 cosine。
- `weight_decay` 权重衰减比例。
-- `warmup_steps` warmup步数。
+- `warmup_steps` warmup 步数。
- `max_steps` 表示最大训练步数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
- `do_train` 表示是否需要训练。
- `do_eval` 表示是否需要评测。
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
##### (2)模型预测:
```bash
@@ -60,10 +60,10 @@ cd glue
python run_predict.py --task_name qqp --ckpt_path qqp/best-qqp_ft_model_106000.pdparams
```
-##### (3)压缩template文件夹为zip文件,然后提交到[GLUE排行榜](https://gluebenchmark.com/leaderboard):
+##### (3)压缩 template 文件夹为 zip 文件,然后提交到[GLUE 排行榜](https://gluebenchmark.com/leaderboard):
-###### GLUE开发集结果:
+###### GLUE 开发集结果:
| task | cola | sst-2 | mrpc | sts-b | qqp | mnli | qnli | rte | avg |
|--------------------------------|-------|-------|-------------|------------------|-------------|------|-------|-------|-------|
@@ -71,7 +71,7 @@ python run_predict.py --task_name qqp --ckpt_path qqp/best-qqp_ft_model_106000.
| Paper | **65.0** | **95.5** | **91.8**/空 | 91.1/空 | **91.9**/空 | **88.5**/空 | 93.3 | 85.8 | **87.9** |
| Mine | 64.4 | 95.4 | 90.4/93.1 | **91.6**/91.3 | **91.9**/89.0 | 87.7/88.2 | **93.6** | **86.6** | 87.7 |
-###### GLUE测试集结果对比:
+###### GLUE 测试集结果对比:
| task | cola | sst-2 | mrpc | sts-b | qqp | mnli-m | qnli | rte | avg |
|--------------------------------|-------|-------|-------|-------|-----|-------|-------|-------|----------|
@@ -81,7 +81,7 @@ python run_predict.py --task_name qqp --ckpt_path qqp/best-qqp_ft_model_106000.
#### 2、SQuAD v1.1
-使用Paddle提供的预训练模型运行SQuAD v1.1数据集的Fine-tuning
+使用 Paddle 提供的预训练模型运行 SQuAD v1.1数据集的 Fine-tuning
```bash
unset CUDA_VISIBLE_DEVICES
@@ -143,7 +143,7 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
--version_2_with_negative
```
-* `version_2_with_negative`: 使用squad2.0数据集和评价指标的标志。
+* `version_2_with_negative`: 使用 squad2.0数据集和评价指标的标志。
训练过程中模型会自动对结果进行评估,其中最好的结果如下所示:
@@ -166,8 +166,8 @@ python -m paddle.distributed.launch --gpus "0" run_squad.py \
```
# Tips:
-- 对于SQUAD任务:根据这个[issues](https://github.com/microsoft/MPNet/issues/3)所说,论文中汇报的是`best_exact`和`best_f1`。
-- 对于GLUE任务:根据这个[issues](https://github.com/microsoft/MPNet/issues/7)所说,部分任务采用了热启动初始化的方法。
+- 对于 SQUAD 任务:根据这个[issues](https://github.com/microsoft/MPNet/issues/3)所说,论文中汇报的是`best_exact`和`best_f1`。
+- 对于 GLUE 任务:根据这个[issues](https://github.com/microsoft/MPNet/issues/7)所说,部分任务采用了热启动初始化的方法。
# Reference
diff --git a/legacy/model_zoo/mpnet/convert.py b/slm/model_zoo/mpnet/convert.py
similarity index 100%
rename from legacy/model_zoo/mpnet/convert.py
rename to slm/model_zoo/mpnet/convert.py
diff --git a/legacy/model_zoo/mpnet/glue/predict.sh b/slm/model_zoo/mpnet/glue/predict.sh
similarity index 100%
rename from legacy/model_zoo/mpnet/glue/predict.sh
rename to slm/model_zoo/mpnet/glue/predict.sh
diff --git a/legacy/model_zoo/mpnet/glue/run_glue.py b/slm/model_zoo/mpnet/glue/run_glue.py
similarity index 100%
rename from legacy/model_zoo/mpnet/glue/run_glue.py
rename to slm/model_zoo/mpnet/glue/run_glue.py
diff --git a/legacy/model_zoo/mpnet/glue/run_predict.py b/slm/model_zoo/mpnet/glue/run_predict.py
similarity index 100%
rename from legacy/model_zoo/mpnet/glue/run_predict.py
rename to slm/model_zoo/mpnet/glue/run_predict.py
diff --git a/legacy/model_zoo/mpnet/glue/train.sh b/slm/model_zoo/mpnet/glue/train.sh
similarity index 100%
rename from legacy/model_zoo/mpnet/glue/train.sh
rename to slm/model_zoo/mpnet/glue/train.sh
diff --git a/legacy/model_zoo/mpnet/squad/run_squad.py b/slm/model_zoo/mpnet/squad/run_squad.py
similarity index 100%
rename from legacy/model_zoo/mpnet/squad/run_squad.py
rename to slm/model_zoo/mpnet/squad/run_squad.py
diff --git a/legacy/model_zoo/plato-xl/README.md b/slm/model_zoo/plato-xl/README.md
similarity index 74%
rename from legacy/model_zoo/plato-xl/README.md
rename to slm/model_zoo/plato-xl/README.md
index 452f610ec5b5..df25fba4ce24 100644
--- a/legacy/model_zoo/plato-xl/README.md
+++ b/slm/model_zoo/plato-xl/README.md
@@ -4,7 +4,7 @@
构建高质量的开放领域(Open-Domain)的对话机器人,使得它能用自然语言与人自由地交流,这一直是自然语言处理领域终极目标之一。
-PLATO-XL 是业界首个开源的百亿超大规模开放域对话预训练模型,其使用了参数高效(encoder-decoder共享参数)的 UnifiedTransformer(prefix LM)模型架构,将模型参数量提升到了11B量级,经过了十亿级样本对话数据的预训练,并引入role embedding区分多方对话中的对话角色提升预训练效果,最终模型闲聊测试效果超过了众多代表性的对话模型。可以直接使用 PLATO-XL 构建高质量的开放领域对话机器人。
+PLATO-XL 是业界首个开源的百亿超大规模开放域对话预训练模型,其使用了参数高效(encoder-decoder 共享参数)的 UnifiedTransformer(prefix LM)模型架构,将模型参数量提升到了11B 量级,经过了十亿级样本对话数据的预训练,并引入 role embedding 区分多方对话中的对话角色提升预训练效果,最终模型闲聊测试效果超过了众多代表性的对话模型。可以直接使用 PLATO-XL 构建高质量的开放领域对话机器人。
PaddleNLP 内置了 PLATO-XL 英文预训练模型以供使用。由于 PLATO-XL 模型规模较大,这使得其在预测时生成对话回复的时间较长,并且 11B 的参数量也可能超出部分型号 GPU 显存容量,这是大模型推理与落地存在的普遍和关键问题。PaddleNLP FastGeneration 为 PLATO-XL 提供了 GPU 上的高性能生成加速能力,并且支持模型并行(张量并行)推理允许通过多张小显存容量的 GPU 使用百亿大模型,相比单卡代码中也只增加了`enable_ft_para()`一行,此外模型并行能进一步提升预测速度。
diff --git a/legacy/model_zoo/rembert/README.md b/slm/model_zoo/rembert/README.md
similarity index 79%
rename from legacy/model_zoo/rembert/README.md
rename to slm/model_zoo/rembert/README.md
index 5a3bf3bc2549..41155d164b7c 100644
--- a/legacy/model_zoo/rembert/README.md
+++ b/slm/model_zoo/rembert/README.md
@@ -4,10 +4,10 @@
**模型简介:**
作者发现,分离词嵌入为建模语言模型提供更好的灵活性,使我们能够显著提高多语言模型输入词嵌入中参数分
-配的效率。通过在transformers层中重新分配输入词嵌入参数,在微调过程中,相比于具有相同数量参数量的
+配的效率。通过在 transformers 层中重新分配输入词嵌入参数,在微调过程中,相比于具有相同数量参数量的
自然语言模型在自然语言理解任务上获得了更好的性能。作者还发现,增大输出词嵌入维度可以提升模型的性能,
即使在预训练结束后,输出词嵌入被丢弃,该模型仍能在微调阶段保持不变。作者分析表明,增大输出词嵌入维度
-可以防止模型在预训练数据集上过拟合,并让模型在其他NLP数据集上有更强的泛化能力。利用这些发现,我们能够
+可以防止模型在预训练数据集上过拟合,并让模型在其他 NLP 数据集上有更强的泛化能力。利用这些发现,我们能够
训练性能更强大的模型,而无需在微调阶段增加参数。
## 快速开始
@@ -15,18 +15,18 @@
### 下游任务微调
####数据集
-下载XTREME-XNLI数据集:
+下载 XTREME-XNLI 数据集:
训练集:[下载地址](https://dl.fbaipublicfiles.com/XNLI/XNLI-MT-1.0.zip)
测试集:[下载地址](https://dl.fbaipublicfiles.com/XNLI/XNLI-1.0.zip)
其中训练集为位于`XNLI-MT-1.0/multinli/multinli.train.en.tsv`, 测试集位于`XNLI-1.0/xnli.test.tsv`
-下载XTREME-PAWS-X数据集:
+下载 XTREME-PAWS-X 数据集:
[下载地址](https://storage.googleapis.com/paws/pawsx/x-final.tar.gz)
每个训练集、验证集和测试集分别为`train`、`dev`和`test`开头的`tsv`文件, 将所有语言的数据集解压后,请合并所有语言测试集到一个文件(此任务需要在多语言进行测试)
#### 1、XTREME-XNLI
-XTREME-XNLI数据集为例:
-运行以下两个命令即可训练并评估RemBert在XTREME-XNLI数据集的精度
+XTREME-XNLI 数据集为例:
+运行以下两个命令即可训练并评估 RemBert 在 XTREME-XNLI 数据集的精度
```shell
python -m paddle.distributed.launch examples/language_model/rembert/main.py \
@@ -46,10 +46,10 @@ python -m paddle.distributed.launch examples/language_model/rembert/main.py \
- `model_type` 指示了模型类型,当前支持`rembert`
- `data_dir` 数据集路径。
- `train_batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `output_dir` 表示模型保存路径。
-- `device` 表示使用的设备类型。默认为GPU,可以配置为CPU、GPU、XPU。若希望使用多GPU训练,将其设置为GPU,同时环境变量CUDA_VISIBLE_DEVICES配置要使用的GPU id。
-- `num_train_epochs` 表示需要训练的epoch数量
+- `device` 表示使用的设备类型。默认为 GPU,可以配置为 CPU、GPU、XPU。若希望使用多 GPU 训练,将其设置为 GPU,同时环境变量 CUDA_VISIBLE_DEVICES 配置要使用的 GPU id。
+- `num_train_epochs` 表示需要训练的 epoch 数量
- `do_train` 表示是否开启训练
- `do_eval` 表示是否开启评估
- `task` 表示训练的任务
diff --git a/legacy/model_zoo/rembert/data_processor.py b/slm/model_zoo/rembert/data_processor.py
similarity index 100%
rename from legacy/model_zoo/rembert/data_processor.py
rename to slm/model_zoo/rembert/data_processor.py
diff --git a/legacy/model_zoo/rembert/main.py b/slm/model_zoo/rembert/main.py
similarity index 100%
rename from legacy/model_zoo/rembert/main.py
rename to slm/model_zoo/rembert/main.py
diff --git a/legacy/model_zoo/rembert/trainer.py b/slm/model_zoo/rembert/trainer.py
similarity index 100%
rename from legacy/model_zoo/rembert/trainer.py
rename to slm/model_zoo/rembert/trainer.py
diff --git a/legacy/model_zoo/roberta/README.md b/slm/model_zoo/roberta/README.md
similarity index 58%
rename from legacy/model_zoo/roberta/README.md
rename to slm/model_zoo/roberta/README.md
index 2de917e83213..d514be43465e 100644
--- a/legacy/model_zoo/roberta/README.md
+++ b/slm/model_zoo/roberta/README.md
@@ -1,16 +1,16 @@
-# RoBERTa预训练(Masked Language Modeling)
-本项目是RoBERTa模型在 Paddle 2.0上的开源实现,包含了数据tokenization和预训练代码。本项目旨在用简练清晰的代码完成基本预训练任务(仅Masked Language Modeling)。该代码易于理解,便于修改和定制。
+# RoBERTa 预训练(Masked Language Modeling)
+本项目是 RoBERTa 模型在 Paddle 2.0上的开源实现,包含了数据 tokenization 和预训练代码。本项目旨在用简练清晰的代码完成基本预训练任务(仅 Masked Language Modeling)。该代码易于理解,便于修改和定制。
## 简介
本目录下包含:
-utils.py: 数据采样函数DataCollatorMLM
+utils.py: 数据采样函数 DataCollatorMLM
-create_data.py: tokenize数据(使用HF datasets导入和预处理wikipedia数据)
+create_data.py: tokenize 数据(使用 HF datasets 导入和预处理 wikipedia 数据)
run_pretrain.py: 预训练代码
## 数据准备
-运行create_data.py,默认使用wikipedia corpus数据,自动下载(约34GB)
+运行 create_data.py,默认使用 wikipedia corpus 数据,自动下载(约34GB)
```
python create_data.py \
@@ -24,13 +24,13 @@ python create_data.py \
```
其中参数释义如下:
-- `output_dir` 指示数据tokenize后保存的目录。
-- `dataset_name` 表示数据名称,默认使用wikipedia。
-- `dataset_config_name` 表示数据参数,默认使用wikipedia英文数据。
-- `tokenizer_name` 表示tokenizer名。
+- `output_dir` 指示数据 tokenize 后保存的目录。
+- `dataset_name` 表示数据名称,默认使用 wikipedia。
+- `dataset_config_name` 表示数据参数,默认使用 wikipedia 英文数据。
+- `tokenizer_name` 表示 tokenizer 名。
- `max_seq_length` 表示最大序列长度。
-- `line_by_line` 表示是否将数据group到max_seq_length,True则不进行grouping。
-- `preprocessing_num_workers` 表示worker数量,亦为multi-processing数量。
+- `line_by_line` 表示是否将数据 group 到 max_seq_length,True 则不进行 grouping。
+- `preprocessing_num_workers` 表示 worker 数量,亦为 multi-processing 数量。
## 预训练
@@ -55,21 +55,21 @@ python -m paddle.distributed.launch --gpus "0,1" run_pretrain.py \
其中参数释义如下:
- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录地址。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `weight_decay` 表示AdamW优化器中使用的weight_decay的系数。
-- `warmup_steps` 表示动态学习率热启的step数。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `weight_decay` 表示 AdamW 优化器中使用的 weight_decay 的系数。
+- `warmup_steps` 表示动态学习率热启的 step 数。
- `num_train_epochs` 表示训练轮数。
-- `input_file` 表示输入数据的目录,由create_data.py创建。
+- `input_file` 表示输入数据的目录,由 create_data.py 创建。
- `output_dir` 表示模型的保存目录。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `max_steps` 表示最大训练步数。若训练`num_train_epochs`轮包含的训练步数大于该值,则达到`max_steps`后就提前结束。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU。
- `max_seq_length` 训练数据最大长度。
- `amp` 指示是否启用自动混合精度训练。
注:
-paddle.Dataloader需2.3rc版本才支持HF datasets类,现行版本可以直接在python paddle库中的reader.py中注释掉:
+paddle.Dataloader 需2.3rc 版本才支持 HF datasets 类,现行版本可以直接在 python paddle 库中的 reader.py 中注释掉:
```
assert isinstance(dataset, Dataset)
```
@@ -77,7 +77,7 @@ https://github.com/PaddlePaddle/Paddle/blob/0ee230a7d3177f791d2a5388ab4dffdccc03
## fine-tune
-finetune代码请参考[benchmark_glue](../../examples/benchmark/glue)
+finetune 代码请参考[benchmark_glue](../../examples/benchmark/glue)
运行如下:
@@ -102,7 +102,7 @@ python -u ./run_glue.py \
```
-总训练tokens:512(seq_len) * 32(batch_size) * 780000(iteration),约RoBERTa训练量10%,在GLUE validation set表现:
+总训练 tokens:512(seq_len) * 32(batch_size) * 780000(iteration),约 RoBERTa 训练量10%,在 GLUE validation set 表现:
| Model GLUE Score | CoLA | SST-2 | MRPC | STS-B | QQP | MNLI | QNLI | RTE |
|-------------------|------|-------|------|-------|------|------|------|------|
diff --git a/legacy/model_zoo/roberta/create_data.py b/slm/model_zoo/roberta/create_data.py
similarity index 100%
rename from legacy/model_zoo/roberta/create_data.py
rename to slm/model_zoo/roberta/create_data.py
diff --git a/legacy/model_zoo/roberta/run_pretrain.py b/slm/model_zoo/roberta/run_pretrain.py
similarity index 100%
rename from legacy/model_zoo/roberta/run_pretrain.py
rename to slm/model_zoo/roberta/run_pretrain.py
diff --git a/legacy/model_zoo/roberta/utils.py b/slm/model_zoo/roberta/utils.py
similarity index 100%
rename from legacy/model_zoo/roberta/utils.py
rename to slm/model_zoo/roberta/utils.py
diff --git a/legacy/model_zoo/roformer/README.md b/slm/model_zoo/roformer/README.md
similarity index 60%
rename from legacy/model_zoo/roformer/README.md
rename to slm/model_zoo/roformer/README.md
index e06ee0d6ca94..f1cbe32610be 100644
--- a/legacy/model_zoo/roformer/README.md
+++ b/slm/model_zoo/roformer/README.md
@@ -2,15 +2,15 @@
## 模型简介
-[RoFormer](https://arxiv.org/pdf/2104.09864.pdf) (RoFormer: Enhanced Transformer with Rotary Position Embedding)是一个带有旋转位置嵌入(RoPE)的MLM预训练语言模型。 RoPE是一种相对位置编码方法,具有良好的理论特性。其主要思想是根据绝对位置将上下文嵌入(transformer中的 q,k)乘以旋转矩阵。可以证明上下文嵌入的内积将仅取决于相对位置。
-RoPE 是唯一可用于线性注意力的相对位置嵌入。更多详情请参考[论文](https://arxiv.org/pdf/2104.09864.pdf)或[原博客](https://kexue.fm/archives/8265)。EleutherAI还发布了一篇[博客](https://blog.eleuther.ai/rotary-embeddings/),其中包含有关 RoPE 的直观解释和实验。
+[RoFormer](https://arxiv.org/pdf/2104.09864.pdf) (RoFormer: Enhanced Transformer with Rotary Position Embedding)是一个带有旋转位置嵌入(RoPE)的 MLM 预训练语言模型。 RoPE 是一种相对位置编码方法,具有良好的理论特性。其主要思想是根据绝对位置将上下文嵌入(transformer 中的 q,k)乘以旋转矩阵。可以证明上下文嵌入的内积将仅取决于相对位置。
+RoPE 是唯一可用于线性注意力的相对位置嵌入。更多详情请参考[论文](https://arxiv.org/pdf/2104.09864.pdf)或[原博客](https://kexue.fm/archives/8265)。EleutherAI 还发布了一篇[博客](https://blog.eleuther.ai/rotary-embeddings/),其中包含有关 RoPE 的直观解释和实验。
-本项目是RoFormer在 Paddle 2.x上的开源实现,包含了`THUCNews分类任务`和`Cail2019 Scm任务`的微调代码。
+本项目是 RoFormer 在 Paddle 2.x 上的开源实现,包含了`THUCNews 分类任务`和`Cail2019 Scm 任务`的微调代码。
## 快速开始
-### 预训练MLM测试
+### 预训练 MLM 测试
```bash
python test_mlm.py --model_name roformer-chinese-base --text 今天[MASK]很好,我想去公园玩!
# paddle: 今天[天气||天||阳光||太阳||空气]很好,我想去公园玩!
@@ -22,13 +22,13 @@ RoPE 是唯一可用于线性注意力的相对位置嵌入。更多详情请参
# paddle: 北京是[谁||我||你||他||国]的首都!
```
-### THUCNews分类任务数据
+### THUCNews 分类任务数据
-THUCNews分类任务所含数据集已在paddlenlp中以API形式提供,无需预先准备,使用`run_thucnews.py`执行微调时将会自动下载。
+THUCNews 分类任务所含数据集已在 paddlenlp 中以 API 形式提供,无需预先准备,使用`run_thucnews.py`执行微调时将会自动下载。
-### 执行Fine-tunning
+### 执行 Fine-tunning
-启动thucnews分类任务的Fine-tuning的方式如下:
+启动 thucnews 分类任务的 Fine-tuning 的方式如下:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -46,19 +46,19 @@ python -m paddle.distributed.launch --gpus "0" examples/language_model/roformer/
--use_amp False
```
其中参数释义如下:
-- `model_type` 指示了模型类型,可以选择roformer。
-- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
+- `model_type` 指示了模型类型,可以选择 roformer。
+- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU, 'npu'表示使用华为昇腾卡。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU, 'npu'表示使用华为昇腾卡。
- `use_amp` 指示是否启用自动混合精度训练。
-基于`roformer-chinese-base`在THUCNews分类任务上Fine-tuning后,在验证集上有如下结果:
+基于`roformer-chinese-base`在 THUCNews 分类任务上 Fine-tuning 后,在验证集上有如下结果:
| Task | Metric | Result |
|:-----:|:----------------------------:|:-----------------:|
@@ -66,13 +66,13 @@ python -m paddle.distributed.launch --gpus "0" examples/language_model/roformer/
-### Cail2019_Scm任务数据
+### Cail2019_Scm 任务数据
-Cail2019_Scm分类任务所含数据集已在paddlenlp中以API形式提供,无需预先准备,使用`cail2019_scm.py`执行微调时将会自动下载。
+Cail2019_Scm 分类任务所含数据集已在 paddlenlp 中以 API 形式提供,无需预先准备,使用`cail2019_scm.py`执行微调时将会自动下载。
-### 执行Fine-tunning
+### 执行 Fine-tunning
-启动cail2019_scm任务的Fine-tuning的方式如下:
+启动 cail2019_scm 任务的 Fine-tuning 的方式如下:
```shell
unset CUDA_VISIBLE_DEVICES
@@ -91,8 +91,8 @@ python -m paddle.distributed.launch --gpus "0" examples/language_model/roformer/
```
其中参数释义如下:
-- `model_type` 指示了模型类型,可以选择roformer_cls_pooling和roformer_mean_pooling两种类型。
-- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
+- `model_type` 指示了模型类型,可以选择 roformer_cls_pooling 和 roformer_mean_pooling 两种类型。
+- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `batch_size` 表示每次迭代**每张卡**上的样本数目。
- `learning_rate` 表示学习率大小,本代码并未使用学习率衰减。
@@ -100,10 +100,10 @@ python -m paddle.distributed.launch --gpus "0" examples/language_model/roformer/
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备, 'gpu'表示使用GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用CPU, 'npu'表示使用华为昇腾卡。
+- `device` 表示训练使用的设备, 'gpu'表示使用 GPU, 'xpu'表示使用百度昆仑卡, 'cpu'表示使用 CPU, 'npu'表示使用华为昇腾卡。
- `use_amp` 指示是否启用自动混合精度训练。
-基于`roformer-chinese-base`在Cail2019_Scm任务上Fine-tuning后,有如下结果:
+基于`roformer-chinese-base`在 Cail2019_Scm 任务上 Fine-tuning 后,有如下结果:
| Model | Dev Accuracy | Test Accuracy |
|:-------------:|:-----------------:|:------------------:|
diff --git a/legacy/model_zoo/roformer/convert.py b/slm/model_zoo/roformer/convert.py
similarity index 100%
rename from legacy/model_zoo/roformer/convert.py
rename to slm/model_zoo/roformer/convert.py
diff --git a/legacy/model_zoo/roformer/run_cail2019_scm.py b/slm/model_zoo/roformer/run_cail2019_scm.py
similarity index 100%
rename from legacy/model_zoo/roformer/run_cail2019_scm.py
rename to slm/model_zoo/roformer/run_cail2019_scm.py
diff --git a/legacy/model_zoo/roformer/run_thucnews.py b/slm/model_zoo/roformer/run_thucnews.py
similarity index 100%
rename from legacy/model_zoo/roformer/run_thucnews.py
rename to slm/model_zoo/roformer/run_thucnews.py
diff --git a/legacy/model_zoo/roformer/test_mlm.py b/slm/model_zoo/roformer/test_mlm.py
similarity index 100%
rename from legacy/model_zoo/roformer/test_mlm.py
rename to slm/model_zoo/roformer/test_mlm.py
diff --git a/legacy/model_zoo/rw/README.md b/slm/model_zoo/rw/README.md
similarity index 59%
rename from legacy/model_zoo/rw/README.md
rename to slm/model_zoo/rw/README.md
index 143635377478..7cbb997bd37e 100644
--- a/legacy/model_zoo/rw/README.md
+++ b/slm/model_zoo/rw/README.md
@@ -2,7 +2,7 @@
## 介绍
-Falcon是由[TII](https://www.tii.ae/)构建的Causal decoder-only模型,基于含有 1,500B个tokens的[RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)数据集训练得来。
+Falcon 是由[TII](https://www.tii.ae/)构建的 Causal decoder-only 模型,基于含有 1,500B 个 tokens 的[RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)数据集训练得来。
Falcon 引入了[FlashAttention](https://github.com/HazyResearch/flash-attention)和[Multi-Query Attention]等新特性。更详细的模型介绍见[论文](https://arxiv.org/abs/2306.01116)
## 推理
diff --git a/legacy/model_zoo/rw/predict_generation.py b/slm/model_zoo/rw/predict_generation.py
similarity index 100%
rename from legacy/model_zoo/rw/predict_generation.py
rename to slm/model_zoo/rw/predict_generation.py
diff --git a/legacy/model_zoo/t5/README.md b/slm/model_zoo/t5/README.md
similarity index 77%
rename from legacy/model_zoo/t5/README.md
rename to slm/model_zoo/t5/README.md
index 68cd9f810845..fdb538123e9c 100644
--- a/legacy/model_zoo/t5/README.md
+++ b/slm/model_zoo/t5/README.md
@@ -4,15 +4,15 @@
## 摘要
-迁移学习在自然语言处理(NLP)中已经成为一种强大的技术。迁移学习首先在数据丰富的任务上进行预训练,然后在下游任务上进行调整。迁移学习的有效性引起了不同的方法、方法和实践。在本文中,我们通过引入一个统一的框架,将所有基于文本的语言问题转换为文本到文本的格式,来探索自然语言处理的迁移学习技术。我们的系统研究比较了数十项语言理解任务的训练前目标、架构、未标记数据集、迁移方法和其他因素。通过将我们的探索与规模和我们的新"Colossal Clean Crawled Corpus"数据集相结合,我们在摘要、问答、文本分类等许多基准测试中取得了最先进的结果。为了促进NLP迁移学习的未来工作,我们发布了我们的数据集、预训练模型和代码。
+迁移学习在自然语言处理(NLP)中已经成为一种强大的技术。迁移学习首先在数据丰富的任务上进行预训练,然后在下游任务上进行调整。迁移学习的有效性引起了不同的方法、方法和实践。在本文中,我们通过引入一个统一的框架,将所有基于文本的语言问题转换为文本到文本的格式,来探索自然语言处理的迁移学习技术。我们的系统研究比较了数十项语言理解任务的训练前目标、架构、未标记数据集、迁移方法和其他因素。通过将我们的探索与规模和我们的新"Colossal Clean Crawled Corpus"数据集相结合,我们在摘要、问答、文本分类等许多基准测试中取得了最先进的结果。为了促进 NLP 迁移学习的未来工作,我们发布了我们的数据集、预训练模型和代码。
-本项目是T5在 Paddle 2.x上的开源实现,包含了`模型权重`转换代码和`GLUE任务`的微调代码。
+本项目是 T5在 Paddle 2.x 上的开源实现,包含了`模型权重`转换代码和`GLUE 任务`的微调代码。
## 快速开始
### 预训练
-本项目致力于t5模型的预训练,从数据下载,数据转化,模型训练,流程开源开放,可复现。
+本项目致力于 t5模型的预训练,从数据下载,数据转化,模型训练,流程开源开放,可复现。
接下来将从下面几个方面,详细介绍整个数据制作全流程,从零开始,构建一个预训练模型。
@@ -20,7 +20,7 @@
数据流是预训练的非常重要的,[预处理文档](../../../llm/tools/preprocess/README.md)提供了整体的数据变动的流程示意,用户可以查看数据制作的细节文档。
-在数据ID化步骤中,我们需要配置tokenzer_name,选择t5模型对应的tokenizer;通过下面脚本转化,我们可以得到处理好的预训练数据,token ids:[`t5_openwebtext.bin`](https://paddlenlp.bj.bcebos.com/models/transformers/t5/data/t5_openwebtext.bin), 文章索引信息[`t5_openwebtext.idx`](https://paddlenlp.bj.bcebos.com/models/transformers/t5/data/t5_openwebtext.idx).(这里提供了一个处理好的预训练数据,可点击链接下载)
+在数据 ID 化步骤中,我们需要配置 tokenzer_name,选择 t5模型对应的 tokenizer;通过下面脚本转化,我们可以得到处理好的预训练数据,token ids:[`t5_openwebtext.bin`](https://paddlenlp.bj.bcebos.com/models/transformers/t5/data/t5_openwebtext.bin), 文章索引信息[`t5_openwebtext.idx`](https://paddlenlp.bj.bcebos.com/models/transformers/t5/data/t5_openwebtext.idx).(这里提供了一个处理好的预训练数据,可点击链接下载)
```shell
python -u create_pretraining_data.py \
@@ -40,10 +40,10 @@ python -u create_pretraining_data.py \
**路径配置**
- 主要配置输入输出目录
-- 这里的`tokenizer_name_or_path`请设置为内置的tokenizer,如`t5-small`等。
+- 这里的`tokenizer_name_or_path`请设置为内置的 tokenizer,如`t5-small`等。
- 这里的 `input_dir` 设置输入数据集路径,例如配置`input_dir "./data"`即可。
-**启动训练**:这里启动的是单机8卡任务,整体全局的batch_size 512 (64*8)。如果指定ips参数,进行多机运行,如 `python3 -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" --ips 192.168.1.101,192.168.1.101 `
+**启动训练**:这里启动的是单机8卡任务,整体全局的 batch_size 512 (64*8)。如果指定 ips 参数,进行多机运行,如 `python3 -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" --ips 192.168.1.101,192.168.1.101 `
```shell
python -u -m paddle.distributed.launch \
@@ -82,29 +82,29 @@ python -u -m paddle.distributed.launch \
其中参数释义如下:
-- `model_name_or_path` 要训练的模型或者之前训练的checkpoint。
-- `tokenizer_name_or_path` 模型词表文件所在的文件夹(对于ernie,词表文件名一般命名为vocab.txt),或者PaddleNLP内置tokenizer的名字。
+- `model_name_or_path` 要训练的模型或者之前训练的 checkpoint。
+- `tokenizer_name_or_path` 模型词表文件所在的文件夹(对于 ernie,词表文件名一般命名为 vocab.txt),或者 PaddleNLP 内置 tokenizer 的名字。
- `input_dir` 指定输入文件,可以使用目录,指定目录时将包括目录中的所有文件。
- `output_dir` 指定输出文件。
-- `split` 划分数据集为train、valid、test的比例。整个数据集会按照这个比例划分数据。默认`split=949,50,1`, 使用1/1000的数据为test,当样本数太少时,增大测试的样本数目。
+- `split` 划分数据集为 train、valid、test 的比例。整个数据集会按照这个比例划分数据。默认`split=949,50,1`, 使用1/1000的数据为 test,当样本数太少时,增大测试的样本数目。
- `max_seq_len` 输入文本序列的长度,默认值`512`。
-- `fp16_opt_level` 混合精度策略,支持O1 自动混合精度,O2 pure fp16精度训练。
-- `max_steps` 最大训练步数。训练不支持通过`epoch`控制,第一次制造数据index时候,日志会显示数据会被计算的epoch数,请注意查看。
+- `fp16_opt_level` 混合精度策略,支持 O1 自动混合精度,O2 pure fp16精度训练。
+- `max_steps` 最大训练步数。训练不支持通过`epoch`控制,第一次制造数据 index 时候,日志会显示数据会被计算的 epoch 数,请注意查看。
- `save_steps` 保存模型间隔。默认保存地址格式为`output_dir/model_50000`(5w 步时的权重)。
- `weight_decay` 权重衰减参数。
-- `warmup_rate` 学习率warmup参数。
+- `warmup_rate` 学习率 warmup 参数。
- `max_grad_norm` 梯度裁剪范围。
- `logging_steps` 日志输出间隔。
-- `dataloader_num_workers` DataLoader采样进程,当数据输入为瓶颈时,可尝试提高采样进程数目。
+- `dataloader_num_workers` DataLoader 采样进程,当数据输入为瓶颈时,可尝试提高采样进程数目。
- `eval_steps` 模型评估间隔。
-- `device` 训练设备,默认为GPU。
-- `data_impl` 指定输入文件数据制作类型,默认为mmap,可指定mmap或lazy。mmap格式在读入数据时会建立内存映射,lazy格式在读入数据时直接从文件读取。
+- `device` 训练设备,默认为 GPU。
+- `data_impl` 指定输入文件数据制作类型,默认为 mmap,可指定 mmap 或 lazy。mmap 格式在读入数据时会建立内存映射,lazy 格式在读入数据时直接从文件读取。
-### GLUE任务
+### GLUE 任务
-### 执行Fine-tunning
+### 执行 Fine-tunning
-启动rte分类任务的Fine-tuning的方式如下:
+启动 rte 分类任务的 Fine-tuning 的方式如下:
```shell
python run_glue.py \
@@ -127,22 +127,22 @@ python run_glue.py \
其中参数释义如下:
-- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
-- `task_name` GLUE任务名称,可从选["cola","sst-2","mrpc","sts-b","qqp","mnli", "rte", "qnli"]选择。
+- `model_name_or_path` 指示了某种特定配置的模型,对应有其预训练模型和预训练时使用的 tokenizer。若模型相关内容保存在本地,这里也可以提供相应目录的地址。
+- `task_name` GLUE 任务名称,可从选["cola","sst-2","mrpc","sts-b","qqp","mnli", "rte", "qnli"]选择。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。
- `train_batch_size` 表示训练时的样本数目。
- `eval_batch_size` 表示验证时的样本数目。
-- `learning_rate` 表示基础学习率大小,将于learning rate scheduler产生的值相乘作为当前学习率。
-- `warmup_radio` warmup比率。
+- `learning_rate` 表示基础学习率大小,将于 learning rate scheduler 产生的值相乘作为当前学习率。
+- `warmup_radio` warmup 比率。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔。
- `save_steps` 表示模型保存及评估间隔。
- `seed` 表示随机种子。
-- `scheduler_type` scheduler类型,可选linear和cosine,默认linear。
+- `scheduler_type` scheduler 类型,可选 linear 和 cosine,默认 linear。
- `output_dir` 表示模型保存路径。
-- `device` 表示训练使用的设备,可选cpu、gpu或npu。
+- `device` 表示训练使用的设备,可选 cpu、gpu 或 npu。
-使用trainer进行Fine-tuning:
+使用 trainer 进行 Fine-tuning:
```shell
python -m paddle.distributed.launch --gpus "0,1,2,3" run_glue_trainer.py \
@@ -173,16 +173,16 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_glue_trainer.py \
具体参数含义请参见: https://paddlenlp.readthedocs.io/zh/latest/trainer.html
-###### t5-base模型在GLUE开发集上的结果:
+###### t5-base 模型在 GLUE 开发集上的结果:
| Model | cola | sst-2 | mrpc | sts-b | qqp | mnli | qnli | rte | mean |
| -------------- | ----- | ----- | ----- | ------- | ----- | ----- | ----- | ----- | ------- |
| | mcc | acc | acc | pearson | acc | acc | acc | acc | |
| T5-base-Paddle | 61.74 | 95.18 | 90.44 | 90.09 | 91.60 | 87.18 | 93.56 | 81.95 | 86.4675 |
-###### t5_v1_1-base模型在GLUE开发集上的结果:
+###### t5_v1_1-base 模型在 GLUE 开发集上的结果:
-使用`run_glue_trainer.py`运行,由于`t5_v1_1-base`没有在glue任务上进行训练过,直接生成label的策略需要的训练时间需要更长。
+使用`run_glue_trainer.py`运行,由于`t5_v1_1-base`没有在 glue 任务上进行训练过,直接生成 label 的策略需要的训练时间需要更长。
| Model | cola | sst-2 | mrpc | sts-b | qqp | mnli | qnli | rte |
| ------------------- | ------- | ----- | ----- | ------- | ----- | ----- | ------ | ----- |
@@ -192,13 +192,13 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_glue_trainer.py \
注:
-- 直接生成label的finetune方式难度较大,前期基本学习如何正确生成label标签,后期才学习分类任务。
-- 生成的label标签设计,标签差异大一些,效果会更好一些。
-- `qqp`,`mnli`数据集适当增大训练epoch数,可以取得更好效果。
+- 直接生成 label 的 finetune 方式难度较大,前期基本学习如何正确生成 label 标签,后期才学习分类任务。
+- 生成的 label 标签设计,标签差异大一些,效果会更好一些。
+- `qqp`,`mnli`数据集适当增大训练 epoch 数,可以取得更好效果。
-### CLUE任务
+### CLUE 任务
-使用trainer进行Fine-tuning:
+使用 trainer 进行 Fine-tuning:
```shell
python -m paddle.distributed.launch --gpus "0,1,2,3" run_clue_trainer.py \
@@ -227,7 +227,7 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_clue_trainer.py \
--output_dir outputs/clue/cluewsc2020
```
-###### Langboat/mengzi-t5-base-mt模型在CLUE开发集上的结果:
+###### Langboat/mengzi-t5-base-mt 模型在 CLUE 开发集上的结果:
| Model | afqmc | tnews | iflytek | cmnli | ocnli | cluewsc2020 | csl |
| :------------------------- | :---- | :---- | :------ | :---- | :---- | :---------- | :---- |
@@ -237,7 +237,7 @@ python -m paddle.distributed.launch --gpus "0,1,2,3" run_clue_trainer.py \
-### GLUE Demo测试
+### GLUE Demo 测试
```sh
python glue_demo.py
@@ -258,7 +258,7 @@ label: positive
==================================================
```
-### Zero shot Demo测试 [参考自Langboat/mengzi-zero-shot](https://github.com/Langboat/mengzi-zero-shot)
+### Zero shot Demo 测试 [参考自 Langboat/mengzi-zero-shot](https://github.com/Langboat/mengzi-zero-shot)
```sh
python zero_shot_demo.py
@@ -266,7 +266,7 @@ python zero_shot_demo.py
当前**zero shot**时输入的构造方法如下表所示。
-| **任务类型** | **prompt构造(其中{s}代表句子输**入) |
+| **任务类型** | **prompt 构造(其中{s}代表句子输**入) |
| -------------------- | ------------------------------------------------------------ |
| **实体抽取** | “{s}”找出上述句子中的实体和他们对应的类别 |
| **语义相似度** | “{s1}”和“{s2}”这两句话是在说同一件事吗? |
diff --git a/legacy/model_zoo/t5/convert.py b/slm/model_zoo/t5/convert.py
similarity index 100%
rename from legacy/model_zoo/t5/convert.py
rename to slm/model_zoo/t5/convert.py
diff --git a/legacy/model_zoo/t5/data.py b/slm/model_zoo/t5/data.py
similarity index 100%
rename from legacy/model_zoo/t5/data.py
rename to slm/model_zoo/t5/data.py
diff --git a/legacy/model_zoo/t5/dataset_utils.py b/slm/model_zoo/t5/dataset_utils.py
similarity index 100%
rename from legacy/model_zoo/t5/dataset_utils.py
rename to slm/model_zoo/t5/dataset_utils.py
diff --git a/legacy/model_zoo/t5/glue_demo.py b/slm/model_zoo/t5/glue_demo.py
similarity index 100%
rename from legacy/model_zoo/t5/glue_demo.py
rename to slm/model_zoo/t5/glue_demo.py
diff --git a/legacy/model_zoo/t5/run_clue_trainer.py b/slm/model_zoo/t5/run_clue_trainer.py
similarity index 100%
rename from legacy/model_zoo/t5/run_clue_trainer.py
rename to slm/model_zoo/t5/run_clue_trainer.py
diff --git a/legacy/model_zoo/t5/run_glue.py b/slm/model_zoo/t5/run_glue.py
similarity index 100%
rename from legacy/model_zoo/t5/run_glue.py
rename to slm/model_zoo/t5/run_glue.py
diff --git a/legacy/model_zoo/t5/run_glue_trainer.py b/slm/model_zoo/t5/run_glue_trainer.py
similarity index 100%
rename from legacy/model_zoo/t5/run_glue_trainer.py
rename to slm/model_zoo/t5/run_glue_trainer.py
diff --git a/legacy/model_zoo/t5/t5_dataset.py b/slm/model_zoo/t5/t5_dataset.py
similarity index 100%
rename from legacy/model_zoo/t5/t5_dataset.py
rename to slm/model_zoo/t5/t5_dataset.py
diff --git a/legacy/model_zoo/t5/t5_run_pretrain_trainer.py b/slm/model_zoo/t5/t5_run_pretrain_trainer.py
similarity index 100%
rename from legacy/model_zoo/t5/t5_run_pretrain_trainer.py
rename to slm/model_zoo/t5/t5_run_pretrain_trainer.py
diff --git a/legacy/model_zoo/t5/tests/t5_mp.py b/slm/model_zoo/t5/tests/t5_mp.py
similarity index 100%
rename from legacy/model_zoo/t5/tests/t5_mp.py
rename to slm/model_zoo/t5/tests/t5_mp.py
diff --git a/legacy/model_zoo/t5/tests/test_parallel_dygraph_dataparallel.py b/slm/model_zoo/t5/tests/test_parallel_dygraph_dataparallel.py
similarity index 100%
rename from legacy/model_zoo/t5/tests/test_parallel_dygraph_dataparallel.py
rename to slm/model_zoo/t5/tests/test_parallel_dygraph_dataparallel.py
diff --git a/legacy/model_zoo/t5/tests/test_t5_mp.py b/slm/model_zoo/t5/tests/test_t5_mp.py
similarity index 100%
rename from legacy/model_zoo/t5/tests/test_t5_mp.py
rename to slm/model_zoo/t5/tests/test_t5_mp.py
diff --git a/legacy/model_zoo/t5/utils.py b/slm/model_zoo/t5/utils.py
similarity index 100%
rename from legacy/model_zoo/t5/utils.py
rename to slm/model_zoo/t5/utils.py
diff --git a/legacy/model_zoo/t5/zero_shot_demo.py b/slm/model_zoo/t5/zero_shot_demo.py
similarity index 100%
rename from legacy/model_zoo/t5/zero_shot_demo.py
rename to slm/model_zoo/t5/zero_shot_demo.py
diff --git a/legacy/model_zoo/tinybert/README.md b/slm/model_zoo/tinybert/README.md
similarity index 56%
rename from legacy/model_zoo/tinybert/README.md
rename to slm/model_zoo/tinybert/README.md
index 648baa02f7bb..8bb906ddbf27 100644
--- a/legacy/model_zoo/tinybert/README.md
+++ b/slm/model_zoo/tinybert/README.md
@@ -8,35 +8,35 @@
```
## 简介
本目录下的实验主要参考论文[《TinyBERT: Distilling BERT for Natural Language Understanding》](https://arxiv.org/abs/1909.10351)实现。
-TinyBERT中蒸馏的整体过程:首先进行通用蒸馏,然后用数据增强后的数据,在特定任务上进行蒸馏,本文主要进行了第二阶段的蒸馏,模型是利用第一阶段得到的通用小模型`tinybert-6l-768d-v2`进行初始化。
+TinyBERT 中蒸馏的整体过程:首先进行通用蒸馏,然后用数据增强后的数据,在特定任务上进行蒸馏,本文主要进行了第二阶段的蒸馏,模型是利用第一阶段得到的通用小模型`tinybert-6l-768d-v2`进行初始化。

-TinyBERT蒸馏流程图
+TinyBERT 蒸馏流程图
-在模型蒸馏中,较大的模型(在本例中是BERT base)通常被称为教师模型,较小的模型(在本例中是层数为6的BERT,下文都称TinyBERT6)通常被称为学生模型。
-知识的蒸馏通常是通过让学生模型学习相关的蒸馏相损失函数实现,在本实验中,蒸馏的学习目标由两个部分组成,分别是中间层的蒸馏损失和预测层的蒸馏损失。其中,中间层的蒸馏包括对Embedding层的蒸馏、对每个Transformer layer输出的蒸馏、以及对每个Transformer中attention矩阵(softmax之前的结果)的蒸馏,三者均采用的是均方误差损失函数。而预测层蒸馏的学习目标则是学生模型输出的logits和教师模型输出的logits的交叉熵损失。
+在模型蒸馏中,较大的模型(在本例中是 BERT base)通常被称为教师模型,较小的模型(在本例中是层数为6的 BERT,下文都称 TinyBERT6)通常被称为学生模型。
+知识的蒸馏通常是通过让学生模型学习相关的蒸馏相损失函数实现,在本实验中,蒸馏的学习目标由两个部分组成,分别是中间层的蒸馏损失和预测层的蒸馏损失。其中,中间层的蒸馏包括对 Embedding 层的蒸馏、对每个 Transformer layer 输出的蒸馏、以及对每个 Transformer 中 attention 矩阵(softmax 之前的结果)的蒸馏,三者均采用的是均方误差损失函数。而预测层蒸馏的学习目标则是学生模型输出的 logits 和教师模型输出的 logits 的交叉熵损失。
-由于教师模型是12层,学生模型的层数少于教师模型的层数,因此需要选择一种layer mapping的方式。论文中采用了一种固定的映射方式,当学生模型的层数为教师模型的1/2时,学生第i层的attention矩阵,需要学习教师的第2i+1层的attention矩阵,Transformer layer输出同理。
+由于教师模型是12层,学生模型的层数少于教师模型的层数,因此需要选择一种 layer mapping 的方式。论文中采用了一种固定的映射方式,当学生模型的层数为教师模型的1/2时,学生第 i 层的 attention 矩阵,需要学习教师的第2i+1层的 attention 矩阵,Transformer layer 输出同理。
-实验分为两个大的训练过程:先对BERT-base进行微调,得到教师模型,再进行蒸馏的训练。其中,蒸馏过程也分为两个步骤:先对中间层进行蒸馏多个epochs(论文中针对具体任务可能是10、20或者30个),再对预测层蒸馏3个epochs。
+实验分为两个大的训练过程:先对 BERT-base 进行微调,得到教师模型,再进行蒸馏的训练。其中,蒸馏过程也分为两个步骤:先对中间层进行蒸馏多个 epochs(论文中针对具体任务可能是10、20或者30个),再对预测层蒸馏3个 epochs。
-需要注意的是,在使用不同教师模型时,`tinybert-6l-768d-v2`、`tinybert-4l-312d-v2`这两个v2版本的预训练模型中开放的从学生embedding输出、transformer中间层输出到教师相应输出的转换矩阵是每层独立的,而其他的`tinybert-6l-768d`、`tinybert-4l-312d`、`tinybert-6l-768d-zh`、`tinybert-4l-312-zh`则是多层之间的参数共用一个转换矩阵的。
+需要注意的是,在使用不同教师模型时,`tinybert-6l-768d-v2`、`tinybert-4l-312d-v2`这两个 v2版本的预训练模型中开放的从学生 embedding 输出、transformer 中间层输出到教师相应输出的转换矩阵是每层独立的,而其他的`tinybert-6l-768d`、`tinybert-4l-312d`、`tinybert-6l-768d-zh`、`tinybert-4l-312-zh`则是多层之间的参数共用一个转换矩阵的。
## 数据、预训练模型介绍及获取
-本实验使用GLUE中数据集中的训练集作为训练语料,用数据集中的验证集评估模型的效果。
+本实验使用 GLUE 中数据集中的训练集作为训练语料,用数据集中的验证集评估模型的效果。
-运行本目录下的实验,数据集会被自动下载到`paddlenlp.utils.env.DATA_HOME` 路径下,例如在linux系统下,对于GLUE中的QQP数据集,默认存储路径是`~/.paddlenlp/datasets/Glue/QQP`。
+运行本目录下的实验,数据集会被自动下载到`paddlenlp.utils.env.DATA_HOME` 路径下,例如在 linux 系统下,对于 GLUE 中的 QQP 数据集,默认存储路径是`~/.paddlenlp/datasets/Glue/QQP`。
-对于BERT的fine-tuning任务,本实验中使用了预训练模型`bert-base-uncased`。同样,这几个模型在训练时会被自动下载到`paddlenlp.utils.env.MODEL_HOME`路径下。例如,对于`bert-base-uncased`模型,在linux系统下,会被下载到`~/.paddlenlp/models/bert-base-uncased`下。
+对于 BERT 的 fine-tuning 任务,本实验中使用了预训练模型`bert-base-uncased`。同样,这几个模型在训练时会被自动下载到`paddlenlp.utils.env.MODEL_HOME`路径下。例如,对于`bert-base-uncased`模型,在 linux 系统下,会被下载到`~/.paddlenlp/models/bert-base-uncased`下。
## 蒸馏实验过程
-### 对BERT Fine-tuning得到教师模型
-以GLUE的SST-2任务为例,调用BERT fine-tune的训练脚本,配置如下的参数,训练SST-2任务:
+### 对 BERT Fine-tuning 得到教师模型
+以 GLUE 的 SST-2任务为例,调用 BERT fine-tune 的训练脚本,配置如下的参数,训练 SST-2任务:
```shell
cd ../../examples/benchmark/glue/
@@ -61,7 +61,7 @@ python -u ./run_glue.py \
训练完成之后,可将训练效果最好的模型保存在本项目下的 `$TEACHER_DIR` 下。模型目录下有`model_config.json`, `model_state.pdparams`, `tokenizer_config.json`及`vocab.txt`这几个文件。
-### 对TinyBERT在特定任务下蒸馏
+### 对 TinyBERT 在特定任务下蒸馏
先蒸馏中间层:
@@ -94,14 +94,14 @@ python task_distill.py \
其中参数释义如下:
-- `model_type` 学生模型类型,默认且目前仅支持tinybert。
+- `model_type` 学生模型类型,默认且目前仅支持 tinybert。
- `student_model_name_or_path` 中间层蒸馏后,学生模型存放的目录
- `max_seq_length` 表示最大句子长度,超过该长度将被截断。默认:128
-- `T` softmax的温度,用于对softmax做平滑,在训练中起到放大负标签效果的作用。默认:1
-- `teacher_model_type` 教师模型的类型,默认且目前仅支持bert
-- `teacher_path` 教师Fine-tuned模型的目录
+- `T` softmax 的温度,用于对 softmax 做平滑,在训练中起到放大负标签效果的作用。默认:1
+- `teacher_model_type` 教师模型的类型,默认且目前仅支持 bert
+- `teacher_path` 教师 Fine-tuned 模型的目录
- `output_dir` 学生模型存放的目录
-- `device` 表示运行该程序的设备,默认是gpu
+- `device` 表示运行该程序的设备,默认是 gpu
然后对预测层进行蒸馏:
@@ -142,7 +142,7 @@ python task_distill.py \
## 蒸馏实验结果
-本文档的实验基于TinyBERT的6层、hidden_size为768的通用蒸馏得到的模型,用未使用数据增强的原始数据集训练,并基于验证集进行评价。得到以下实验结果:
+本文档的实验基于 TinyBERT 的6层、hidden_size 为768的通用蒸馏得到的模型,用未使用数据增强的原始数据集训练,并基于验证集进行评价。得到以下实验结果:
| | SST-2 | QQP(acc/f1) | MRPC(acc/f1) | CoLA | RTE | MNLI-m | MNLI-mm | QNLI |
@@ -154,17 +154,17 @@ python task_distill.py \
## 数据增强扩充训练集(推荐)
-TinyBERT使用的数据增强需要用到BERT预训练模型和Glove Embeddings做词替换。
+TinyBERT 使用的数据增强需要用到 BERT 预训练模型和 Glove Embeddings 做词替换。
-即对于样本中的词,有一定的概率会被近义词替换。对于single-piece的词,会利用BERT的预训练模型,把选中的词替换成mask token,然后返回模型预测的top k个概率最大的词,最后随机选择其中一个词做替换;对于非single-piece的词,则使用Glove Embedding,找到top k个最近似的词,随机选择一个做替换。
+即对于样本中的词,有一定的概率会被近义词替换。对于 single-piece 的词,会利用 BERT 的预训练模型,把选中的词替换成 mask token,然后返回模型预测的 top k 个概率最大的词,最后随机选择其中一个词做替换;对于非 single-piece 的词,则使用 Glove Embedding,找到 top k 个最近似的词,随机选择一个做替换。
-先下载glove embeddings
+先下载 glove embeddings
```
wget http://nlp.stanford.edu/data/glove.6B.zip
```
-然后运行下面的命令对GLUE数据集进行扩展
+然后运行下面的命令对 GLUE 数据集进行扩展
```
export TASK_NAME=SST-2
export GLOVE_EMB="glove/glove.6B.300d.txt"
@@ -175,10 +175,10 @@ python data_augmentation.py --pretrained_bert_model bert-base-uncased \
```
-运行结束后,在glue_dir/$TASK_NAME目录下,会生成`train_aug.tsv`的数据增强后的训练集文件。
-利用`task_distill.py`时,带上--use_aug这个参数,程序会读取`train_aug.tsv`作训练集进行训练。
+运行结束后,在 glue_dir/$TASK_NAME 目录下,会生成`train_aug.tsv`的数据增强后的训练集文件。
+利用`task_distill.py`时,带上--use_aug 这个参数,程序会读取`train_aug.tsv`作训练集进行训练。
-经过实验,利用数据增强后的数据集,在RTE数据集上,Acc由0.7148提升至0.7184。
+经过实验,利用数据增强后的数据集,在 RTE 数据集上,Acc 由0.7148提升至0.7184。
## 参考文献
diff --git a/legacy/model_zoo/tinybert/data_augmentation.py b/slm/model_zoo/tinybert/data_augmentation.py
similarity index 100%
rename from legacy/model_zoo/tinybert/data_augmentation.py
rename to slm/model_zoo/tinybert/data_augmentation.py
diff --git a/legacy/model_zoo/tinybert/general_distill.py b/slm/model_zoo/tinybert/general_distill.py
similarity index 100%
rename from legacy/model_zoo/tinybert/general_distill.py
rename to slm/model_zoo/tinybert/general_distill.py
diff --git a/legacy/model_zoo/tinybert/imgs/tinybert.png b/slm/model_zoo/tinybert/imgs/tinybert.png
similarity index 100%
rename from legacy/model_zoo/tinybert/imgs/tinybert.png
rename to slm/model_zoo/tinybert/imgs/tinybert.png
diff --git a/legacy/model_zoo/tinybert/task_distill.py b/slm/model_zoo/tinybert/task_distill.py
similarity index 100%
rename from legacy/model_zoo/tinybert/task_distill.py
rename to slm/model_zoo/tinybert/task_distill.py
diff --git a/legacy/model_zoo/transformer-xl/README.md b/slm/model_zoo/transformer-xl/README.md
similarity index 100%
rename from legacy/model_zoo/transformer-xl/README.md
rename to slm/model_zoo/transformer-xl/README.md
diff --git a/legacy/model_zoo/uie/README.md b/slm/model_zoo/uie/README.md
similarity index 86%
rename from legacy/model_zoo/uie/README.md
rename to slm/model_zoo/uie/README.md
index d36f01550877..3ea4eea9da2c 100644
--- a/legacy/model_zoo/uie/README.md
+++ b/slm/model_zoo/uie/README.md
@@ -22,13 +22,13 @@
- [4.6 模型快速服务化部署](#模型快速服务化部署)
- [4.7 实验指标](#实验指标)
- [4.8 模型部署](#模型部署)
-- [5. CCKS比赛](#CCKS比赛)
+- [5. CCKS 比赛](#CCKS 比赛)
## 1. 模型简介
-[UIE(Universal Information Extraction)](https://arxiv.org/pdf/2203.12277.pdf):Yaojie Lu等人在ACL-2022中提出了通用信息抽取统一框架UIE。该框架实现了实体抽取、关系抽取、事件抽取、情感分析等任务的统一建模,并使得不同任务间具备良好的迁移和泛化能力。为了方便大家使用UIE的强大能力,PaddleNLP借鉴该论文的方法,基于ERNIE 3.0知识增强预训练模型,训练并开源了首个中文通用信息抽取模型UIE。该模型可以支持不限定行业领域和抽取目标的关键信息抽取,实现零样本快速冷启动,并具备优秀的小样本微调能力,快速适配特定的抽取目标。
+[UIE(Universal Information Extraction)](https://arxiv.org/pdf/2203.12277.pdf):Yaojie Lu 等人在 ACL-2022中提出了通用信息抽取统一框架 UIE。该框架实现了实体抽取、关系抽取、事件抽取、情感分析等任务的统一建模,并使得不同任务间具备良好的迁移和泛化能力。为了方便大家使用 UIE 的强大能力,PaddleNLP 借鉴该论文的方法,基于 ERNIE 3.0知识增强预训练模型,训练并开源了首个中文通用信息抽取模型 UIE。该模型可以支持不限定行业领域和抽取目标的关键信息抽取,实现零样本快速冷启动,并具备优秀的小样本微调能力,快速适配特定的抽取目标。

@@ -36,9 +36,9 @@
#### News 📢: UIE-X 🧾
-**全新升级UIE-X,除已有纯文本抽取的全部功能外,新增文档抽取能力**,欢迎体验 👉 [信息抽取应用](../../applications/information_extraction)
+**全新升级 UIE-X,除已有纯文本抽取的全部功能外,新增文档抽取能力**,欢迎体验 👉 [信息抽取应用](../../applications/information_extraction)
-#### UIE的优势
+#### UIE 的优势
- **使用简单**:用户可以使用自然语言自定义抽取目标,无需训练即可统一抽取输入文本中的对应信息。**实现开箱即用,并满足各类信息抽取需求**。
@@ -50,7 +50,7 @@
## 2. 应用示例
-UIE不限定行业领域和抽取目标,以下是一些零样本行业示例:
+UIE 不限定行业领域和抽取目标,以下是一些零样本行业示例:
- 医疗场景-专病结构化
@@ -82,9 +82,9 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 3.1 实体抽取
- 命名实体识别(Named Entity Recognition,简称NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
+ 命名实体识别(Named Entity Recognition,简称 NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,抽取的类别没有限制,用户可以自己定义。
- - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema构造如下:
+ - 例如抽取的目标实体类型是"时间"、"选手"和"赛事名称", schema 构造如下:
```text
['时间', '选手', '赛事名称']
@@ -113,7 +113,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
'text': '谷爱凌'}]}]
```
- - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema构造如下:
+ - 例如抽取的目标实体类型是"肿瘤的大小"、"肿瘤的个数"、"肝癌级别"和"脉管内癌栓分级", schema 构造如下:
```text
['肿瘤的大小', '肿瘤的个数', '肝癌级别', '脉管内癌栓分级']
@@ -145,7 +145,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
'text': 'M0级'}]}]
```
- - 例如抽取的目标实体类型是"person"和"organization",schema构造如下:
+ - 例如抽取的目标实体类型是"person"和"organization",schema 构造如下:
```text
['person', 'organization']
@@ -173,9 +173,9 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 3.2 关系抽取
- 关系抽取(Relation Extraction,简称RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
+ 关系抽取(Relation Extraction,简称 RE),是指从文本中识别实体并抽取实体之间的语义关系,进而获取三元组信息,即<主体,谓语,客体>。
- - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema构造如下:
+ - 例如以"竞赛名称"作为抽取主体,抽取关系类型为"主办方"、"承办方"和"已举办次数", schema 构造如下:
```text
{
@@ -223,7 +223,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
'text': '2022语言与智能技术竞赛'}]}]
```
- - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema构造如下:
+ - 例如以"person"作为抽取主体,抽取关系类型为"Company"和"Position", schema 构造如下:
```text
{
@@ -258,9 +258,9 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 3.3 事件抽取
- 事件抽取 (Event Extraction, 简称EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
+ 事件抽取 (Event Extraction, 简称 EE),是指从自然语言文本中抽取预定义的事件触发词(Trigger)和事件论元(Argument),组合为相应的事件结构化信息。
- - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema构造如下:
+ - 例如抽取的目标是"地震"事件的"地震强度"、"时间"、"震中位置"和"震源深度"这些信息,schema 构造如下:
```text
{
@@ -273,7 +273,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
}
```
- 触发词的格式统一为`触发词`或``XX触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
+ 触发词的格式统一为`触发词`或``XX 触发词`,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。
调用示例:
@@ -292,7 +292,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
评论观点抽取,是指抽取文本中包含的评价维度、观点词。
- - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema构造如下:
+ - 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向,schema 构造如下:
```text
{
@@ -331,7 +331,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
'text': '店面'}]}]
```
- - 英文模型schema构造如下:
+ - 英文模型 schema 构造如下:
```text
{
@@ -364,7 +364,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 3.5 情感分类
- - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema构造如下:
+ - 句子级情感倾向分类,即判断句子的情感倾向是“正向”还是“负向”,schema 构造如下:
```text
'情感倾向[正向,负向]'
@@ -379,7 +379,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
[{'情感倾向[正向,负向]': [{'text': '正向', 'probability': 0.9988661643929895}]}]
```
- 英文模型schema构造如下:
+ 英文模型 schema 构造如下:
```text
'情感倾向[正向,负向]'
@@ -398,7 +398,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 3.6 跨任务抽取
- - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema可按照如下方式进行构造:
+ - 例如在法律场景同时对文本进行实体抽取和关系抽取,schema 可按照如下方式进行构造:
```text
[
@@ -523,16 +523,16 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
```
* `schema`:定义任务抽取目标,可参考开箱即用中不同任务的调用示例进行配置。
-* `schema_lang`:设置schema的语言,默认为`zh`, 可选有`zh`和`en`。因为中英schema的构造有所不同,因此需要指定schema的语言。该参数只对`uie-m-base`和`uie-m-large`模型有效。
+* `schema_lang`:设置 schema 的语言,默认为`zh`, 可选有`zh`和`en`。因为中英 schema 的构造有所不同,因此需要指定 schema 的语言。该参数只对`uie-m-base`和`uie-m-large`模型有效。
* `batch_size`:批处理大小,请结合机器情况进行调整,默认为1。
* `model`:选择任务使用的模型,默认为`uie-base`,可选有`uie-base`, `uie-medium`, `uie-mini`, `uie-micro`, `uie-nano`和`uie-medical-base`, `uie-base-en`。
-* `position_prob`:模型对于span的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span的最终概率输出为起始位置概率和终止位置概率的乘积。
-* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持GPU和NPU硬件环境。如果选择`fp16`,在GPU硬件环境下,请先确保机器正确安装NVIDIA相关驱动和基础软件,**确保CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保GPU设备的CUDA计算能力(CUDA Compute Capability)大于7.0,典型的设备包括V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于CUDA Compute Capability和精度支持情况请参考NVIDIA文档:[GPU硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
+* `position_prob`:模型对于 span 的起始位置/终止位置的结果概率在0~1之间,返回结果去掉小于这个阈值的结果,默认为0.5,span 的最终概率输出为起始位置概率和终止位置概率的乘积。
+* `precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,支持 GPU 和 NPU 硬件环境。如果选择`fp16`,在 GPU 硬件环境下,请先确保机器正确安装 NVIDIA 相关驱动和基础软件,**确保 CUDA>=11.2,cuDNN>=8.1.1**,初次使用需按照提示安装相关依赖。其次,需要确保 GPU 设备的 CUDA 计算能力(CUDA Compute Capability)大于7.0,典型的设备包括 V100、T4、A10、A100、GTX 20系列和30系列显卡等。更多关于 CUDA Compute Capability 和精度支持情况请参考 NVIDIA 文档:[GPU 硬件与支持精度对照表](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-840-ea/support-matrix/index.html#hardware-precision-matrix)。
## 4. 训练定制
-对于简单的抽取目标可以直接使用```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用轻定制功能(标注少量数据进行模型微调)以进一步提升效果。下面通过`报销工单信息抽取`的例子展示如何通过5条训练数据进行UIE模型微调。
+对于简单的抽取目标可以直接使用 ```paddlenlp.Taskflow```实现零样本(zero-shot)抽取,对于细分场景我们推荐使用轻定制功能(标注少量数据进行模型微调)以进一步提升效果。下面通过`报销工单信息抽取`的例子展示如何通过5条训练数据进行 UIE 模型微调。
@@ -553,7 +553,7 @@ UIE不限定行业领域和抽取目标,以下是一些零样本行业示例
#### 4.2 数据标注
-我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano) 进行数据标注,本示例也打通了从标注到训练的通道,即doccano导出数据后可通过[doccano.py](./doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano数据标注指南](doccano.md)。
+我们推荐使用数据标注平台[doccano](https://github.com/doccano/doccano) 进行数据标注,本示例也打通了从标注到训练的通道,即 doccano 导出数据后可通过[doccano.py](./doccano.py)脚本轻松将数据转换为输入模型时需要的形式,实现无缝衔接。标注方法的详细介绍请参考[doccano 数据标注指南](doccano.md)。
原始数据示例:
@@ -569,15 +569,15 @@ schema = ['出发地', '目的地', '费用', '时间']
标注步骤如下:
-- 在doccano平台上,创建一个类型为``序列标注``的标注项目。
+- 在 doccano 平台上,创建一个类型为``序列标注``的标注项目。
- 定义实体标签类别,上例中需要定义的实体标签有``出发地``、``目的地``、``费用``和``时间``。
-- 使用以上定义的标签开始标注数据,下面展示了一个doccano标注示例:
+- 使用以上定义的标签开始标注数据,下面展示了一个 doccano 标注示例:
-- 标注完成后,在doccano平台上导出文件,并将其重命名为``doccano_ext.json``后,放入``./data``目录下。
+- 标注完成后,在 doccano 平台上导出文件,并将其重命名为``doccano_ext.json``后,放入``./data``目录下。
- 这里我们提供预先标注好的文件[doccano_ext.json](https://bj.bcebos.com/paddlenlp/datasets/uie/doccano_ext.json),可直接下载并放入`./data`目录。执行以下脚本进行数据转换,执行后会在`./data`目录下生成训练/验证/测试集文件。
@@ -593,25 +593,25 @@ python doccano.py \
可配置参数说明:
-- ``doccano_file``: 从doccano导出的数据标注文件。
+- ``doccano_file``: 从 doccano 导出的数据标注文件。
- ``save_dir``: 训练数据的保存目录,默认存储在``data``目录下。
- ``negative_ratio``: 最大负例比例,该参数只对抽取类型任务有效,适当构造负例可提升模型效果。负例数量和实际的标签数量有关,最大负例数量 = negative_ratio * 正例数量。该参数只对训练集有效,默认为5。为了保证评估指标的准确性,验证集和测试集默认构造全负例。
- ``splits``: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.1, 0.1]表示按照``8:1:1``的比例将数据划分为训练集、验证集和测试集。
- ``task_type``: 选择任务类型,可选有抽取和分类两种类型的任务。
- ``options``: 指定分类任务的类别标签,该参数只对分类类型任务有效。默认为["正向", "负向"]。
-- ``prompt_prefix``: 声明分类任务的prompt前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
-- ``is_shuffle``: 是否对数据集进行随机打散,默认为True。
+- ``prompt_prefix``: 声明分类任务的 prompt 前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
+- ``is_shuffle``: 是否对数据集进行随机打散,默认为 True。
- ``seed``: 随机种子,默认为1000.
- ``separator``: 实体类别/评价维度与分类标签的分隔符,该参数只对实体/评价维度级分类任务有效。默认为"##"。
-- ``schema_lang``: 选择schema的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
+- ``schema_lang``: 选择 schema 的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
备注:
- 默认情况下 [doccano.py](./doccano.py) 脚本会按照比例将数据划分为 train/dev/test 数据集
- 每次执行 [doccano.py](./doccano.py) 脚本,将会覆盖已有的同名数据文件
- 在模型训练阶段我们推荐构造一些负例以提升模型效果,在数据转换阶段我们内置了这一功能。可通过`negative_ratio`控制自动构造的负样本比例;负样本数量 = negative_ratio * 正样本数量。
-- 对于从doccano导出的文件,默认文件中的每条数据都是经过人工正确标注的。
+- 对于从 doccano 导出的文件,默认文件中的每条数据都是经过人工正确标注的。
-更多**不同类型任务(关系抽取、事件抽取、评价观点抽取等)的标注规则及参数说明**,请参考[doccano数据标注指南](doccano.md)。
+更多**不同类型任务(关系抽取、事件抽取、评价观点抽取等)的标注规则及参数说明**,请参考[doccano 数据标注指南](doccano.md)。
此外,也可以通过数据标注平台 [Label Studio](https://labelstud.io/) 进行数据标注。本示例提供了 [labelstudio2doccano.py](./labelstudio2doccano.py) 脚本,将 label studio 导出的 JSON 数据文件格式转换成 doccano 导出的数据文件格式,后续的数据转换与模型微调等操作不变。
@@ -666,7 +666,7 @@ python finetune.py \
```
-如果在GPU环境中使用,可以指定gpus参数进行多卡训练:
+如果在 GPU 环境中使用,可以指定 gpus 参数进行多卡训练:
```shell
export finetuned_model=./checkpoint/model_best
@@ -784,9 +784,9 @@ python evaluate.py \
- `test_path`: 进行评估的测试集文件。
- `batch_size`: 批处理大小,请结合机器情况进行调整,默认为16。
- `max_seq_len`: 文本最大切分长度,输入超过最大长度时会对输入文本进行自动切分,默认为512。
-- `debug`: 是否开启debug模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
+- `debug`: 是否开启 debug 模式对每个正例类别分别进行评估,该模式仅用于模型调试,默认关闭。
- `multilingual`: 是否是跨语言模型,默认关闭。
-- `schema_lang`: 选择schema的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
+- `schema_lang`: 选择 schema 的语言,可选有`ch`和`en`。默认为`ch`,英文数据集请选择`en`。
@@ -823,7 +823,7 @@ python evaluate.py \
#### 4.6 模型快速服务化部署
-在UIE的服务化能力中我们提供基于PaddleNLP SimpleServing 来搭建服务化能力,通过几行代码即可搭建服务化部署能力
+在 UIE 的服务化能力中我们提供基于 PaddleNLP SimpleServing 来搭建服务化能力,通过几行代码即可搭建服务化部署能力
```python
@@ -865,7 +865,7 @@ paddlenlp server server:app --host 0.0.0.0 --port 8989
uie-m-base (12L768H) | 38.46 | 74.31 | 63.37 | 87.32 | 76.27 | 80.13
-0-shot表示无训练数据直接通过```paddlenlp.Taskflow```进行预测,5-shot表示每个类别包含5条标注数据进行模型微调。**实验表明UIE在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
+0-shot 表示无训练数据直接通过 ```paddlenlp.Taskflow```进行预测,5-shot 表示每个类别包含5条标注数据进行模型微调。**实验表明 UIE 在垂类场景可以通过少量数据(few-shot)进一步提升效果**。
@@ -881,7 +881,7 @@ paddlenlp server server:app --host 0.0.0.0 --port 8989
- 模型部署
-以下示例展示如何基于 FastDeploy 库完成 UIE 模型完成通用信息抽取任务的 Python 预测部署。先参考 [UIE 模型部署](./deploy/python/README.md)安装FastDeploy Python 依赖包。 可通过命令行参数`--device`以及`--backend`指定运行在不同的硬件以及推理引擎后端,并使用`--model_dir`参数指定运行的模型。模型目录为 `model_zoo/uie/checkpoint/model_best`(用户可按实际情况设置)。
+以下示例展示如何基于 FastDeploy 库完成 UIE 模型完成通用信息抽取任务的 Python 预测部署。先参考 [UIE 模型部署](./deploy/python/README.md)安装 FastDeploy Python 依赖包。 可通过命令行参数`--device`以及`--backend`指定运行在不同的硬件以及推理引擎后端,并使用`--model_dir`参数指定运行的模型。模型目录为 `model_zoo/uie/checkpoint/model_best`(用户可按实际情况设置)。
```bash
# UIE 模型 CPU 推理
@@ -938,9 +938,9 @@ python deploy/python/infer.py --model_dir ./checkpoint/model_best --device gpu -
更多细节请参考[UIE Python 部署方法](./deploy/python/README.md)
-
+
-## 5.CCKS比赛
+## 5.CCKS 比赛
为了进一步探索通用信息抽取的边界,我们举办了**CCKS 2022 千言通用信息抽取竞赛评测**(2022/03/30 - 2022/07/31)。
diff --git a/legacy/model_zoo/uie/deploy/python/README.md b/slm/model_zoo/uie/deploy/python/README.md
similarity index 95%
rename from legacy/model_zoo/uie/deploy/python/README.md
rename to slm/model_zoo/uie/deploy/python/README.md
index 8473c2adf704..29ddd8e5c6ca 100644
--- a/legacy/model_zoo/uie/deploy/python/README.md
+++ b/slm/model_zoo/uie/deploy/python/README.md
@@ -62,14 +62,14 @@ python infer.py --model_dir ../../checkpoint/model_best --device gpu
| 参数 |参数说明 |
|----------|--------------|
|--model_dir | 指定部署模型的目录, |
-|--batch_size |输入的batch size,默认为 1|
+|--batch_size |输入的 batch size,默认为 1|
|--max_length |最大序列长度,默认为 128|
|--num_omask_tokens | 最大标签数量,默认为64|
|--device | 运行的设备,可选范围: ['cpu', 'gpu'],默认为'cpu' |
-|--device_id | 运行设备的id。默认为0。 |
-|--cpu_threads | 当使用cpu推理时,指定推理的cpu线程数,默认为1。|
+|--device_id | 运行设备的 id。默认为0。 |
+|--cpu_threads | 当使用 cpu 推理时,指定推理的 cpu 线程数,默认为1。|
|--backend | 支持的推理后端,可选范围: ['onnx_runtime', 'paddle', 'openvino', 'tensorrt', 'paddle_tensorrt'],默认为'paddle' |
-|--use_fp16 | 是否使用FP16模式进行推理。使用tensorrt和paddle_tensorrt后端时可开启,默认为False |
+|--use_fp16 | 是否使用 FP16模式进行推理。使用 tensorrt 和 paddle_tensorrt 后端时可开启,默认为 False |
## FastDeploy 高阶用法
diff --git a/legacy/model_zoo/uie/deploy/python/infer.py b/slm/model_zoo/uie/deploy/python/infer.py
similarity index 100%
rename from legacy/model_zoo/uie/deploy/python/infer.py
rename to slm/model_zoo/uie/deploy/python/infer.py
diff --git a/legacy/model_zoo/uie/deploy/serving/simple_serving/README.md b/slm/model_zoo/uie/deploy/serving/simple_serving/README.md
similarity index 74%
rename from legacy/model_zoo/uie/deploy/serving/simple_serving/README.md
rename to slm/model_zoo/uie/deploy/serving/simple_serving/README.md
index def3a1ec8038..07151fe3534f 100644
--- a/legacy/model_zoo/uie/deploy/serving/simple_serving/README.md
+++ b/slm/model_zoo/uie/deploy/serving/simple_serving/README.md
@@ -1,26 +1,26 @@
-# 基于PaddleNLP SimpleServing 的服务化部署
+# 基于 PaddleNLP SimpleServing 的服务化部署
## 目录
- [环境准备](#环境准备)
-- [Server服务启动](#Server服务启动)
-- [Client请求启动](#Client请求启动)
+- [Server 服务启动](#Server 服务启动)
+- [Client 请求启动](#Client 请求启动)
- [服务化自定义参数](#服务化自定义参数)
## 环境准备
-使用有SimpleServing功能的PaddleNLP版本(或者最新的develop版本)
+使用有 SimpleServing 功能的 PaddleNLP 版本(或者最新的 develop 版本)
```shell
pip install paddlenlp >= 2.4.4
```
-## Server服务启动
+## Server 服务启动
```bash
paddlenlp server server:app --workers 1 --host 0.0.0.0 --port 8189
```
-## Client请求启动
+## Client 请求启动
```bash
python client.py
@@ -29,7 +29,7 @@ python client.py
## 服务化自定义参数
### Server 自定义参数
-#### schema替换
+#### schema 替换
```python
# Default schema
schema = ['出发地', '目的地', '费用', '时间']
@@ -42,7 +42,7 @@ uie = Taskflow('information_extraction', task_path='../../../checkpoint/model_be
```
#### 多卡服务化预测
-PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个Taskflow的task即可,下面是示例代码
+PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个 Taskflow 的 task 即可,下面是示例代码
```
uie1 = Taskflow('information_extraction', task_path='../../../checkpoint/model_best/', schema=schema, device_id=0)
uie2 = Taskflow('information_extraction', task_path='../../../checkpoint/model_best/', schema=schema, device_id=1)
diff --git a/legacy/model_zoo/uie/deploy/serving/simple_serving/client.py b/slm/model_zoo/uie/deploy/serving/simple_serving/client.py
similarity index 100%
rename from legacy/model_zoo/uie/deploy/serving/simple_serving/client.py
rename to slm/model_zoo/uie/deploy/serving/simple_serving/client.py
diff --git a/legacy/model_zoo/uie/deploy/serving/simple_serving/server.py b/slm/model_zoo/uie/deploy/serving/simple_serving/server.py
similarity index 100%
rename from legacy/model_zoo/uie/deploy/serving/simple_serving/server.py
rename to slm/model_zoo/uie/deploy/serving/simple_serving/server.py
diff --git a/legacy/model_zoo/uie/doccano.md b/slm/model_zoo/uie/doccano.md
similarity index 69%
rename from legacy/model_zoo/uie/doccano.md
rename to slm/model_zoo/uie/doccano.md
index 5faf6a539aa3..7f666fccd5eb 100644
--- a/legacy/model_zoo/uie/doccano.md
+++ b/slm/model_zoo/uie/doccano.md
@@ -14,7 +14,7 @@
## 1. 安装
-参考[doccano官方文档](https://github.com/doccano/doccano) 完成doccano的安装与初始配置。
+参考[doccano 官方文档](https://github.com/doccano/doccano) 完成 doccano 的安装与初始配置。
**以下标注示例用到的环境配置:**
@@ -24,7 +24,7 @@
## 2. 项目创建
-UIE支持抽取与分类两种类型的任务,根据实际需要创建一个新的项目:
+UIE 支持抽取与分类两种类型的任务,根据实际需要创建一个新的项目:
#### 2.1 抽取式任务项目创建
@@ -46,20 +46,20 @@ UIE支持抽取与分类两种类型的任务,根据实际需要创建一个
## 3. 数据上传
-上传的文件为txt格式,每一行为一条待标注文本,示例:
+上传的文件为 txt 格式,每一行为一条待标注文本,示例:
```text
2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌
第十四届全运会在西安举办
```
-上传数据类型**选择TextLine**:
+上传数据类型**选择 TextLine**:
-**NOTE**:doccano支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式,UIE定制训练中**统一使用TextLine**这一文件格式,即上传的文件需要为txt格式,且在数据标注时,该文件的每一行待标注文本显示为一页内容。
+**NOTE**:doccano 支持`TextFile`、`TextLine`、`JSONL`和`CoNLL`四种数据上传格式,UIE 定制训练中**统一使用 TextLine**这一文件格式,即上传的文件需要为 txt 格式,且在数据标注时,该文件的每一行待标注文本显示为一页内容。
@@ -67,15 +67,15 @@ UIE支持抽取与分类两种类型的任务,根据实际需要创建一个
#### 4.1 构建抽取式任务标签
-抽取式任务包含**Span**与**Relation**两种标签类型,Span指**原文本中的目标信息片段**,如实体识别中某个类型的实体,事件抽取中的触发词和论元;Relation指**原文本中Span之间的关系**,如关系抽取中两个实体(Subject&Object)之间的关系,事件抽取中论元和触发词之间的关系。
+抽取式任务包含**Span**与**Relation**两种标签类型,Span 指**原文本中的目标信息片段**,如实体识别中某个类型的实体,事件抽取中的触发词和论元;Relation 指**原文本中 Span 之间的关系**,如关系抽取中两个实体(Subject&Object)之间的关系,事件抽取中论元和触发词之间的关系。
-Span类型标签构建示例:
+Span 类型标签构建示例:
-Relation类型标签构建示例:
+Relation 类型标签构建示例:

@@ -95,7 +95,7 @@ Relation类型标签构建示例:
#### 5.1 命名实体识别
-命名实体识别(Named Entity Recognition,简称NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,**抽取的类别没有限制,用户可以自己定义**。
+命名实体识别(Named Entity Recognition,简称 NER),是指识别文本中具有特定意义的实体。在开放域信息抽取中,**抽取的类别没有限制,用户可以自己定义**。
标注示例:
@@ -103,7 +103,7 @@ Relation类型标签构建示例:
-示例中定义了`时间`、`选手`、`赛事名称`和`得分`四种Span类型标签。
+示例中定义了`时间`、`选手`、`赛事名称`和`得分`四种 Span 类型标签。
```text
schema = [
@@ -116,7 +116,7 @@ schema = [
#### 5.2 关系抽取
-关系抽取(Relation Extraction,简称RE),是指从文本中识别实体并抽取实体之间的语义关系,即抽取三元组(实体一,关系类型,实体二)。
+关系抽取(Relation Extraction,简称 RE),是指从文本中识别实体并抽取实体之间的语义关系,即抽取三元组(实体一,关系类型,实体二)。
标注示例:
@@ -124,9 +124,9 @@ schema = [
-示例中定义了`作品名`、`人物名`和`时间`三种Span类型标签,以及`歌手`、`发行时间`和`所属专辑`三种Relation标签。Relation标签**由Subject对应实体指向Object对应实体**。
+示例中定义了`作品名`、`人物名`和`时间`三种 Span 类型标签,以及`歌手`、`发行时间`和`所属专辑`三种 Relation 标签。Relation 标签**由 Subject 对应实体指向 Object 对应实体**。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -140,7 +140,7 @@ schema = {
#### 5.3 事件抽取
-事件抽取 (Event Extraction, 简称EE),是指从自然语言文本中抽取事件并识别事件类型和事件论元的技术。UIE所包含的事件抽取任务,是指根据已知事件类型,抽取该事件所包含的事件论元。
+事件抽取 (Event Extraction, 简称 EE),是指从自然语言文本中抽取事件并识别事件类型和事件论元的技术。UIE 所包含的事件抽取任务,是指根据已知事件类型,抽取该事件所包含的事件论元。
标注示例:
@@ -148,9 +148,9 @@ schema = {
-示例中定义了`地震触发词`(触发词)、`等级`(事件论元)和`时间`(事件论元)三种Span标签,以及`时间`和`震级`两种Relation标签。触发词标签**统一格式为`XX触发词`**,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。Relation标签**由触发词指向对应的事件论元**。
+示例中定义了`地震触发词`(触发词)、`等级`(事件论元)和`时间`(事件论元)三种 Span 标签,以及`时间`和`震级`两种 Relation 标签。触发词标签**统一格式为`XX 触发词`**,`XX`表示具体事件类型,上例中的事件类型是`地震`,则对应触发词为`地震触发词`。Relation 标签**由触发词指向对应的事件论元**。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -171,9 +171,9 @@ schema = {
-示例中定义了`评价维度`和`观点词`两种Span标签,以及`观点词`一种Relation标签。Relation标签**由评价维度指向观点词**。
+示例中定义了`评价维度`和`观点词`两种 Span 标签,以及`观点词`一种 Relation 标签。Relation 标签**由评价维度指向观点词**。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -191,7 +191,7 @@ schema = {
示例中定义了`正向`和`负向`两种类别标签对文本的情感倾向进行分类。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = '情感倾向[正向,负向]'
@@ -205,9 +205,9 @@ schema = '情感倾向[正向,负向]'
标注示例:
-示例中定义了`评价维度##正向`,`评价维度##负向`和`观点词`三种Span标签以及`观点词`一种Relation标签。其中,`##`是实体类别/评价维度与分类标签的分隔符(可通过doccano.py中的separator参数自定义)。
+示例中定义了`评价维度##正向`,`评价维度##负向`和`观点词`三种 Span 标签以及`观点词`一种 Relation 标签。其中,`##`是实体类别/评价维度与分类标签的分隔符(可通过 doccano.py 中的 separator 参数自定义)。
-该标注示例对应的schema为:
+该标注示例对应的 schema 为:
```text
schema = {
@@ -280,18 +280,18 @@ schema = {
```
标注数据保存在同一个文本文件中,每条样例占一行且存储为``json``格式,其包含以下字段
-- ``id``: 样本在数据集中的唯一标识ID。
+- ``id``: 样本在数据集中的唯一标识 ID。
- ``text``: 原始文本数据。
-- ``entities``: 数据中包含的Span标签,每个Span标签包含四个字段:
- - ``id``: Span在数据集中的唯一标识ID。
- - ``start_offset``: Span的起始token在文本中的下标。
- - ``end_offset``: Span的结束token在文本中下标的下一个位置。
- - ``label``: Span类型。
-- ``relations``: 数据中包含的Relation标签,每个Relation标签包含四个字段:
- - ``id``: (Span1, Relation, Span2)三元组在数据集中的唯一标识ID,不同样本中的相同三元组对应同一个ID。
- - ``from_id``: Span1对应的标识ID。
- - ``to_id``: Span2对应的标识ID。
- - ``type``: Relation类型。
+- ``entities``: 数据中包含的 Span 标签,每个 Span 标签包含四个字段:
+ - ``id``: Span 在数据集中的唯一标识 ID。
+ - ``start_offset``: Span 的起始 token 在文本中的下标。
+ - ``end_offset``: Span 的结束 token 在文本中下标的下一个位置。
+ - ``label``: Span 类型。
+- ``relations``: 数据中包含的 Relation 标签,每个 Relation 标签包含四个字段:
+ - ``id``: (Span1, Relation, Span2)三元组在数据集中的唯一标识 ID,不同样本中的相同三元组对应同一个 ID。
+ - ``from_id``: Span1对应的标识 ID。
+ - ``to_id``: Span2对应的标识 ID。
+ - ``type``: Relation 类型。
#### 6.2 导出句子级分类任务数据
@@ -308,7 +308,7 @@ schema = {
```
标注数据保存在同一个文本文件中,每条样例占一行且存储为``json``格式,其包含以下字段
-- ``id``: 样本在数据集中的唯一标识ID。
+- ``id``: 样本在数据集中的唯一标识 ID。
- ``data``: 原始文本数据。
- ``label``: 文本对应类别标签。
@@ -316,7 +316,7 @@ schema = {
## 7.数据转换
-该章节详细说明如何通过`doccano.py`脚本对doccano平台导出的标注数据进行转换,一键生成训练/验证/测试集。
+该章节详细说明如何通过`doccano.py`脚本对 doccano 平台导出的标注数据进行转换,一键生成训练/验证/测试集。
#### 7.1 抽取式任务数据转换
@@ -334,7 +334,7 @@ python doccano.py \
#### 7.2 句子级分类任务数据转换
- 当标注完成后,在 doccano 平台上导出 `JSON` 形式的文件,并将其重命名为 `doccano_cls.json` 后,放入 `./data` 目录下。
-- 在数据转换阶段,我们会自动构造用于模型训练的prompt信息。例如句子级情感分类中,prompt为``情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
+- 在数据转换阶段,我们会自动构造用于模型训练的 prompt 信息。例如句子级情感分类中,prompt 为``情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
- 通过 [doccano.py](./doccano.py) 脚本进行数据形式转换,然后便可以开始进行相应模型训练。
```shell
@@ -350,7 +350,7 @@ python doccano.py \
#### 7.3 实体/评价维度级分类任务数据转换
- 当标注完成后,在 doccano 平台上导出 `JSONL(relation)` 形式的文件,并将其重命名为 `doccano_ext.json` 后,放入 `./data` 目录下。
-- 在数据转换阶段,我们会自动构造用于模型训练的prompt信息。例如评价维度级情感分类中,prompt为``XXX的情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
+- 在数据转换阶段,我们会自动构造用于模型训练的 prompt 信息。例如评价维度级情感分类中,prompt 为``XXX 的情感倾向[正向,负向]``,可以通过`prompt_prefix`和`options`参数进行声明。
- 通过 [doccano.py](./doccano.py) 脚本进行数据形式转换,然后便可以开始进行相应模型训练。
```shell
@@ -366,14 +366,14 @@ python doccano.py \
可配置参数说明:
-- ``doccano_file``: 从doccano导出的数据标注文件。
+- ``doccano_file``: 从 doccano 导出的数据标注文件。
- ``save_dir``: 训练数据的保存目录,默认存储在``data``目录下。
- ``negative_ratio``: 最大负例比例,该参数只对抽取类型任务有效,适当构造负例可提升模型效果。负例数量和实际的标签数量有关,最大负例数量 = negative_ratio * 正例数量。该参数只对训练集有效,默认为5。为了保证评估指标的准确性,验证集和测试集默认构造全负例。
- ``splits``: 划分数据集时训练集、验证集所占的比例。默认为[0.8, 0.1, 0.1]表示按照``8:1:1``的比例将数据划分为训练集、验证集和测试集。
- ``task_type``: 选择任务类型,可选有抽取和分类两种类型的任务。
- ``options``: 指定分类任务的类别标签,该参数只对分类类型任务有效。默认为["正向", "负向"]。
-- ``prompt_prefix``: 声明分类任务的prompt前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
-- ``is_shuffle``: 是否对数据集进行随机打散,默认为True。
+- ``prompt_prefix``: 声明分类任务的 prompt 前缀信息,该参数只对分类类型任务有效。默认为"情感倾向"。
+- ``is_shuffle``: 是否对数据集进行随机打散,默认为 True。
- ``seed``: 随机种子,默认为1000.
- ``separator``: 实体类别/评价维度与分类标签的分隔符,该参数只对实体/评价维度级分类任务有效。默认为"##"。
@@ -381,7 +381,7 @@ python doccano.py \
- 默认情况下 [doccano.py](./doccano.py) 脚本会按照比例将数据划分为 train/dev/test 数据集
- 每次执行 [doccano.py](./doccano.py) 脚本,将会覆盖已有的同名数据文件
- 在模型训练阶段我们推荐构造一些负例以提升模型效果,在数据转换阶段我们内置了这一功能。可通过`negative_ratio`控制自动构造的负样本比例;负样本数量 = negative_ratio * 正样本数量。
-- 对于从doccano导出的文件,默认文件中的每条数据都是经过人工正确标注的。
+- 对于从 doccano 导出的文件,默认文件中的每条数据都是经过人工正确标注的。
## References
- **[doccano](https://github.com/doccano/doccano)**
diff --git a/legacy/model_zoo/uie/doccano.py b/slm/model_zoo/uie/doccano.py
similarity index 100%
rename from legacy/model_zoo/uie/doccano.py
rename to slm/model_zoo/uie/doccano.py
diff --git a/legacy/model_zoo/uie/evaluate.py b/slm/model_zoo/uie/evaluate.py
similarity index 100%
rename from legacy/model_zoo/uie/evaluate.py
rename to slm/model_zoo/uie/evaluate.py
diff --git a/legacy/model_zoo/uie/finetune.py b/slm/model_zoo/uie/finetune.py
similarity index 100%
rename from legacy/model_zoo/uie/finetune.py
rename to slm/model_zoo/uie/finetune.py
diff --git a/legacy/model_zoo/uie/labelstudio2doccano.py b/slm/model_zoo/uie/labelstudio2doccano.py
similarity index 100%
rename from legacy/model_zoo/uie/labelstudio2doccano.py
rename to slm/model_zoo/uie/labelstudio2doccano.py
diff --git a/legacy/model_zoo/uie/utils.py b/slm/model_zoo/uie/utils.py
similarity index 100%
rename from legacy/model_zoo/uie/utils.py
rename to slm/model_zoo/uie/utils.py
diff --git a/legacy/model_zoo/xlm/README.md b/slm/model_zoo/xlm/README.md
similarity index 69%
rename from legacy/model_zoo/xlm/README.md
rename to slm/model_zoo/xlm/README.md
index 31a707f9f3eb..dfcb640416cf 100644
--- a/legacy/model_zoo/xlm/README.md
+++ b/slm/model_zoo/xlm/README.md
@@ -10,24 +10,24 @@
## 模型简介
-[XLM—Enhancing BERT for Cross-lingual Language Model](https://arxiv.org/abs/1901.07291) 是facebook团队提出的一个跨语言模型。
+[XLM—Enhancing BERT for Cross-lingual Language Model](https://arxiv.org/abs/1901.07291) 是 facebook 团队提出的一个跨语言模型。
-在这项工作中,他们将这种方法扩展到多种语言,并展示了跨语言预训练的有效性。论文提出了两种学习跨语言语言模型 (XLM) 的方法:一种是**仅依赖单语数据的无监督方法**,另一种是**利用具有新的跨语言语言模型目标的并行数据的监督方法**。该方法在跨语言分类、无监督和有监督机器翻译方面获得了最先进的结果。在 XNLI 上,该方法以4.9% 的绝对精度提升了最新技术水平。在无监督机器翻译上,该方法在 WMT'16 German-English 上获得 34.3 BLEU,将之前的最新技术提高了9BLEU 以上。在有监督的机器翻译上,该方法在WMT'16罗马尼亚语-英语上获得了 38.5 BLEU 的最新技术水平,比之前的最佳方法高出 4 BLEU 以上。
+在这项工作中,他们将这种方法扩展到多种语言,并展示了跨语言预训练的有效性。论文提出了两种学习跨语言语言模型 (XLM) 的方法:一种是**仅依赖单语数据的无监督方法**,另一种是**利用具有新的跨语言语言模型目标的并行数据的监督方法**。该方法在跨语言分类、无监督和有监督机器翻译方面获得了最先进的结果。在 XNLI 上,该方法以4.9% 的绝对精度提升了最新技术水平。在无监督机器翻译上,该方法在 WMT'16 German-English 上获得 34.3 BLEU,将之前的最新技术提高了9BLEU 以上。在有监督的机器翻译上,该方法在 WMT'16罗马尼亚语-英语上获得了 38.5 BLEU 的最新技术水平,比之前的最佳方法高出 4 BLEU 以上。
-XLM论文中一共提出了三种预训练任务:**CLM**、**MLM**和**TLM**。
-- **CLM:Causal Language Model**,无监督单语单向LM训练任务,就是用`Transformer`进行LM的单向训练。
-- **MLM:Masked Language Model**,无监督单语双向LM训练任务,与`BERT`一样。
-- **TLM:Translation Language Model**,有监督翻译LM训练,拼接平行双语语料,然后执行MLM,以期这样能学到翻译的对齐信息。
+XLM 论文中一共提出了三种预训练任务:**CLM**、**MLM**和**TLM**。
+- **CLM:Causal Language Model**,无监督单语单向 LM 训练任务,就是用`Transformer`进行 LM 的单向训练。
+- **MLM:Masked Language Model**,无监督单语双向 LM 训练任务,与`BERT`一样。
+- **TLM:Translation Language Model**,有监督翻译 LM 训练,拼接平行双语语料,然后执行 MLM,以期这样能学到翻译的对齐信息。

## 模型实现的注意点
-本仓库的模型在复现过程中主要参考了huggingface的实现,故在实现过程中与facebook团队的官方实现相比存在一定的不同。
+本仓库的模型在复现过程中主要参考了 huggingface 的实现,故在实现过程中与 facebook 团队的官方实现相比存在一定的不同。
- 对于`token_pair`任务,`huggingface`的`tokenizer`会额外添加` A B `的标记,而`facebook`的`tokenizer`会添加` A B `的标记,本仓库的实现遵循了`huggingface`的实现,主要区别在于第一个特殊标记使用了``而不是``。
-- facebook的XLM模型由于并未使用`token_type_id`参数,因此我们在实际使用`tokenizer`的时候需要人工传入`return_token_type_ids=False`,如:`tokenizer(text, return_token_type_ids=False)`,这样就不会返回`token_type_id`了。
-- 考虑到现有已开源预训练权重的XLM模型,在`XLMPredLayer`处并未使用到`adaptive_softmax`,因此本仓库仅实现了带有`cross_entropy`的`XLMPredLayer`。
+- facebook 的 XLM 模型由于并未使用`token_type_id`参数,因此我们在实际使用`tokenizer`的时候需要人工传入`return_token_type_ids=False`,如:`tokenizer(text, return_token_type_ids=False)`,这样就不会返回`token_type_id`了。
+- 考虑到现有已开源预训练权重的 XLM 模型,在`XLMPredLayer`处并未使用到`adaptive_softmax`,因此本仓库仅实现了带有`cross_entropy`的`XLMPredLayer`。
-本文件夹内包含了`XLM模型`在`xnli任务`上的训练和验证内容。以下是本例的简要目录结构及说明:
+本文件夹内包含了`XLM 模型`在`xnli 任务`上的训练和验证内容。以下是本例的简要目录结构及说明:
```text
.
@@ -38,7 +38,7 @@ XLM论文中一共提出了三种预训练任务:**CLM**、**MLM**和**TLM**
## 快速开始
-### xlm tokenizer依赖安装
+### xlm tokenizer 依赖安装
```shell
# sacremoses
@@ -57,15 +57,15 @@ pip install jieba
```
### 通用参数释义
-- `model_name_or_path` 指示了 Fine-tuning 使用的具体预训练模型以及预训练时使用的tokenizer,目前支持的预训练模型有:"xlm-mlm-tlm-xnli15-1024"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
+- `model_name_or_path` 指示了 Fine-tuning 使用的具体预训练模型以及预训练时使用的 tokenizer,目前支持的预训练模型有:"xlm-mlm-tlm-xnli15-1024"。若模型相关内容保存在本地,这里也可以提供相应目录地址,例如:"./checkpoint/model_xx/"。
- `output_dir` 表示模型保存路径。
- `max_seq_length` 表示最大句子长度,超过该长度将被截断,不足该长度的将会进行 padding。
-- `learning_rate` 表示基础学习率大小,本代码并未使用学习率warmup和衰减。
+- `learning_rate` 表示基础学习率大小,本代码并未使用学习率 warmup 和衰减。
- `num_train_epochs` 表示训练轮数。
- `logging_steps` 表示日志打印间隔步数。
- `save_steps` 表示模型保存及评估间隔步数。
- `batch_size` 表示每次迭代**每张**卡上的样本数目。
-- `adam_epsilon` 表示Adam优化器的epsilon。
+- `adam_epsilon` 表示 Adam 优化器的 epsilon。
- `max_steps` 表示最大训练步数。若训练`num_train_epochs`轮包含的训练步数大于该值,则达到`max_steps`后就提前结束。
- `seed` 表示随机数种子。
- `device` 表示训练使用的设备, `'gpu'`表示使用 GPU, `'xpu'`表示使用百度昆仑卡, `'cpu'`表示使用 CPU。
@@ -105,7 +105,7 @@ python -m paddle.distributed.launch --gpus 0,1 --log_dir outputs xnli_train.py \
--output_dir outputs
```
-在XNLI数据集上微调 cross-lingual-transfer 类型的自然语言推断任务后,在测试集上有如下结果
+在 XNLI 数据集上微调 cross-lingual-transfer 类型的自然语言推断任务后,在测试集上有如下结果
| Model | en | fr | es | de | el | bg | ru | tr | ar | vi | th | zh | hi | sw | ur | Avg |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| XLM | 84.6 | 79.2 | 79.8 | 76.9 | 76.6 | 77.6 | 76.2 | 71.7 | 73.8 | 74.5 | 71.1 | 74.8 | 68.8 | 69.2 | 65.8 | 74.7 |
diff --git a/legacy/model_zoo/xlm/framework.jpg b/slm/model_zoo/xlm/framework.jpg
similarity index 100%
rename from legacy/model_zoo/xlm/framework.jpg
rename to slm/model_zoo/xlm/framework.jpg
diff --git a/legacy/model_zoo/xlm/xnli_eval.py b/slm/model_zoo/xlm/xnli_eval.py
similarity index 100%
rename from legacy/model_zoo/xlm/xnli_eval.py
rename to slm/model_zoo/xlm/xnli_eval.py
diff --git a/legacy/model_zoo/xlm/xnli_train.py b/slm/model_zoo/xlm/xnli_train.py
similarity index 100%
rename from legacy/model_zoo/xlm/xnli_train.py
rename to slm/model_zoo/xlm/xnli_train.py
diff --git a/slm/model_zoo/xlnet/README.md b/slm/model_zoo/xlnet/README.md
new file mode 100644
index 000000000000..91173376e497
--- /dev/null
+++ b/slm/model_zoo/xlnet/README.md
@@ -0,0 +1,7 @@
+# XLNet
+
+## 模型简介
+
+[XLNet: Generalized Autoregressive Pretraining for Language Understanding](https://arxiv.org/abs/1906.08237) 是一款无监督的自回归预训练语言模型。 有别于传统的单向自回归模型,XLNet 通过最大化输入序列所有排列的期望来进行语言建模,这使得它可以同时关注到上下文的信息。 另外,XLNet 在预训练阶段集成了 [Transformer-XL](https://arxiv.org/abs/1901.02860) 模型,Transformer-XL 中的片段循环机制(Segment Recurrent Mechanism)和 相对位置编码(Relative Positional Encoding)机制能够支持 XLNet 接受更长的输入序列,这使得 XLNet 在长文本序列的语言任务上有着优秀的表现。
+
+详细请参考[这里](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/examples/language_model/xlnet).
diff --git a/legacy/pipelines/.readthedocs.yaml b/slm/pipelines/.readthedocs.yaml
similarity index 100%
rename from legacy/pipelines/.readthedocs.yaml
rename to slm/pipelines/.readthedocs.yaml
diff --git a/legacy/pipelines/API.md b/slm/pipelines/API.md
similarity index 95%
rename from legacy/pipelines/API.md
rename to slm/pipelines/API.md
index bb5f19e04f24..c059da986ceb 100644
--- a/legacy/pipelines/API.md
+++ b/slm/pipelines/API.md
@@ -1,6 +1,6 @@
-# API的预置模型介绍
+# API 的预置模型介绍
-以下是`Pipelines`的主要API的模型介绍,有其他定制化的需求的用户可提issue。
+以下是`Pipelines`的主要 API 的模型介绍,有其他定制化的需求的用户可提 issue。
## DensePassageRetriever
diff --git a/legacy/pipelines/FAQ.md b/slm/pipelines/FAQ.md
similarity index 69%
rename from legacy/pipelines/FAQ.md
rename to slm/pipelines/FAQ.md
index d4ff5c147535..803480af64ff 100644
--- a/legacy/pipelines/FAQ.md
+++ b/slm/pipelines/FAQ.md
@@ -1,8 +1,8 @@
## FAQ
-#### pip安装htbuilder包报错,`UnicodeDecodeError: 'gbk' codec can't decode byte....`
+#### pip 安装 htbuilder 包报错,`UnicodeDecodeError: 'gbk' codec can't decode byte....`
-windows的默认字符gbk导致的,可以使用源码进行安装,源码已经进行了修复。
+windows 的默认字符 gbk 导致的,可以使用源码进行安装,源码已经进行了修复。
```
git clone https://github.com/tvst/htbuilder.git
@@ -17,9 +17,9 @@ python setup install
export LANG=zh_CN.UTF-8
```
-#### Linux上安装elasticsearch出现错误 `java.lang.RuntimeException: can not run elasticsearch as root`
+#### Linux 上安装 elasticsearch 出现错误 `java.lang.RuntimeException: can not run elasticsearch as root`
-elasticsearch 需要在非root环境下运行,可以做如下的操作:
+elasticsearch 需要在非 root 环境下运行,可以做如下的操作:
```
adduser est
@@ -29,16 +29,16 @@ su est
./bin/elasticsearch
```
-#### Mac OS上安装elasticsearch出现错误 `flood stage disk watermark [95%] exceeded on.... all indices on this node will be marked read-only`
+#### Mac OS 上安装 elasticsearch 出现错误 `flood stage disk watermark [95%] exceeded on.... all indices on this node will be marked read-only`
-elasticsearch默认达到95%就全都设置只读,可以腾出一部分空间出来再启动,或者修改 `config/elasticsearch.pyml`。
+elasticsearch 默认达到95%就全都设置只读,可以腾出一部分空间出来再启动,或者修改 `config/elasticsearch.pyml`。
```
cluster.routing.allocation.disk.threshold_enabled: false
```
-#### nltk_data加载失败的错误 `[nltk_data] Error loading punkt: [Errno 60] Operation timed out`
+#### nltk_data 加载失败的错误 `[nltk_data] Error loading punkt: [Errno 60] Operation timed out`
-在命令行里面输入python,然后输入下面的命令进行下载:
+在命令行里面输入 python,然后输入下面的命令进行下载:
```
import nltk
@@ -53,9 +53,9 @@ lsof -i:8891
kill -9 PID # PID为8891端口的进程
```
-#### faiss 安装上了但还是显示找不到faiss怎么办?
+#### faiss 安装上了但还是显示找不到 faiss 怎么办?
-推荐您使用anaconda进行单独安装,安装教程请参考[faiss](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md)
+推荐您使用 anaconda 进行单独安装,安装教程请参考[faiss](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md)
```
# CPU-only version
@@ -65,7 +65,7 @@ conda install -c pytorch faiss-cpu
conda install -c pytorch faiss-gpu
```
-#### 如何更换pipelines中预置的模型?
+#### 如何更换 pipelines 中预置的模型?
更换系统预置的模型以后,由于模型不一样了,需要重新构建索引,并修改相关的配置文件。以语义索引为例,需要修改2个地方,第一个地方是`utils/offline_ann.py`,另一个是`rest_api/pipeline/semantic_search.yaml`,并重新运行:
@@ -115,7 +115,7 @@ export PIPELINE_YAML_PATH=rest_api/pipeline/semantic_search.yaml
python rest_api/application.py 8891
```
-#### 运行faiss examples出现了错误:`sqlalchemy.exec.OperationalError: (sqlite3.OperationalError) too many SQL variables`
+#### 运行 faiss examples 出现了错误:`sqlalchemy.exec.OperationalError: (sqlite3.OperationalError) too many SQL variables`
python 3.7版本引起的错误,修改如下代码:
@@ -130,7 +130,7 @@ document_store.update_embeddings(retriever, batch_size=256)
#### 安装后出现错误:`cannot import name '_registerMatType' from 'cv2'`
-opencv版本不匹配的原因,可以对其进行升级到最新版本,保证opencv系列的版本一致。
+opencv 版本不匹配的原因,可以对其进行升级到最新版本,保证 opencv 系列的版本一致。
```
pip install opencv-contrib-python --upgrade
@@ -140,14 +140,14 @@ pip install opencv-python --upgrade
#### 安装运行出现 `RuntimeError: Can't load weights for 'rocketqa-zh-nano-query-encoder'`
-rocketqa模型2.3.7之后才添加,paddlenlp版本需要升级:
+rocketqa 模型2.3.7之后才添加,paddlenlp 版本需要升级:
```
pip install paddlenlp --upgrade
```
#### 安装出现问题 `The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored.`
-设置pip源为清华源,然后重新安装,可运行如下命令进行设置:
+设置 pip 源为清华源,然后重新安装,可运行如下命令进行设置:
```
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
@@ -155,12 +155,12 @@ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#### Elastic search 日志显示错误 `exception during geoip databases update`
-需要编辑config/elasticsearch.yml,在末尾添加:
+需要编辑 config/elasticsearch.yml,在末尾添加:
```
ingest.geoip.downloader.enabled: false
```
-如果是Docker启动,请添加如下的配置,然后运行:
+如果是 Docker 启动,请添加如下的配置,然后运行:
```
docker run \
@@ -177,9 +177,9 @@ docker run \
docker.elastic.co/elasticsearch/elasticsearch:8.3.3
```
-#### Windows出现运行前端报错`requests.exceptions.MissingSchema: Invalid URL 'None/query': No scheme supplied. Perhaps you meant http://None/query?`
+#### Windows 出现运行前端报错`requests.exceptions.MissingSchema: Invalid URL 'None/query': No scheme supplied. Perhaps you meant http://None/query?`
-环境变量没有生效,请检查一下环境变量,确保PIPELINE_YAML_PATH和API_ENDPOINT生效:
+环境变量没有生效,请检查一下环境变量,确保 PIPELINE_YAML_PATH 和 API_ENDPOINT 生效:
```
$env:PIPELINE_YAML_PATH='rest_api/pipeline/semantic_search.yaml'
@@ -187,9 +187,9 @@ $env:PIPELINE_YAML_PATH='rest_api/pipeline/semantic_search.yaml'
$env:API_ENDPOINT='http://127.0.0.1:8891'
```
-#### Windows的GPU运行出现错误:`IndexError: index 4616429690595525704 is out of bounds for axis 0 with size 1`
+#### Windows 的 GPU 运行出现错误:`IndexError: index 4616429690595525704 is out of bounds for axis 0 with size 1`
-paddle.nozero算子出现异常,请退回到PaddlePaddle 2.2.2版本,比如您使用的是cuda 11.2,可以使用如下的命令:
+paddle.nozero 算子出现异常,请退回到 PaddlePaddle 2.2.2版本,比如您使用的是 cuda 11.2,可以使用如下的命令:
```
python -m pip install paddlepaddle-gpu==2.2.2.post112 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html
@@ -197,34 +197,34 @@ python -m pip install paddlepaddle-gpu==2.2.2.post112 -f https://www.paddlepaddl
#### 运行应用的时候出现错误 `assert d == self.d`
-这是运行多个应用引起的,请在运行其他应用之前,删除现有的db文件:
+这是运行多个应用引起的,请在运行其他应用之前,删除现有的 db 文件:
```
rm -rf faiss_document_store.db
```
-#### Windows运行应用的时候出现了下面的错误:`RuntimeError: (NotFound) Cannot open file C:\Users\my_name/.paddleocr/whl\det\ch\ch_PP-OCRv3_det_infer/inference.pdmodel, please confirm whether the file is normal.`
+#### Windows 运行应用的时候出现了下面的错误:`RuntimeError: (NotFound) Cannot open file C:\Users\my_name/.paddleocr/whl\det\ch\ch_PP-OCRv3_det_infer/inference.pdmodel, please confirm whether the file is normal.`
-这是Windows系统用户命名为中文的原因,详细解决方法参考issue. [https://github.com/PaddlePaddle/PaddleNLP/issues/3242](https://github.com/PaddlePaddle/PaddleNLP/issues/3242)
+这是 Windows 系统用户命名为中文的原因,详细解决方法参考 issue. [https://github.com/PaddlePaddle/PaddleNLP/issues/3242](https://github.com/PaddlePaddle/PaddleNLP/issues/3242)
-#### 怎样从GPU切换到CPU上运行?
+#### 怎样从 GPU 切换到 CPU 上运行?
请在对应的所有`sh`文件里面加入下面的环境变量
```
export CUDA_VISIBLE_DEVICES=""
```
-#### 运行streamlit前端程序出现错误:`AttributeError: module 'click' has no attribute 'get_os_args'`
+#### 运行 streamlit 前端程序出现错误:`AttributeError: module 'click' has no attribute 'get_os_args'`
-click版本过高导致:
+click 版本过高导致:
```
pip install click==8.0
```
-#### 怎么样新增最新的pytorch的检索模型
+#### 怎么样新增最新的 pytorch 的检索模型
-PaddleNLP-Pipelines 提供了可自动将 PyTorch 相关的权重转化为 Paddle 权重的接口,以BAAI/bge-large-zh-v1.5为例,代码如下:
+PaddleNLP-Pipelines 提供了可自动将 PyTorch 相关的权重转化为 Paddle 权重的接口,以 BAAI/bge-large-zh-v1.5为例,代码如下:
```python
from paddlenlp.transformers import AutoModel, AutoTokenizer
@@ -265,4 +265,4 @@ retriever = DensePassageRetriever(
)
```
-**注意** bge-m3的底座模型是XLMRobertaModel,paddlenlp没有实现,不推荐使用。
+**注意** bge-m3的底座模型是 XLMRobertaModel,paddlenlp 没有实现,不推荐使用。
diff --git a/legacy/pipelines/Makefile b/slm/pipelines/Makefile
similarity index 100%
rename from legacy/pipelines/Makefile
rename to slm/pipelines/Makefile
diff --git a/legacy/pipelines/README.md b/slm/pipelines/README.md
similarity index 75%
rename from legacy/pipelines/README.md
rename to slm/pipelines/README.md
index fa8e18ad5386..156ba9482566 100644
--- a/legacy/pipelines/README.md
+++ b/slm/pipelines/README.md
@@ -1,19 +1,19 @@
-## PaddleNLP Pipelines:NLP流水线系统
+## PaddleNLP Pipelines:NLP 流水线系统
-PaddleNLP Pipelines 是一个端到端NLP流水线系统框架,面向 NLP **全场景**,帮助用户**低门槛**构建强大**产品级系统**。
+PaddleNLP Pipelines 是一个端到端 NLP 流水线系统框架,面向 NLP **全场景**,帮助用户**低门槛**构建强大**产品级系统**。
-更多效果展示Demo请参考 [效果展示](#效果展示)
+更多效果展示 Demo 请参考 [效果展示](#效果展示)
-## NLP流水线系统特色
+## NLP 流水线系统特色
* **全场景支持**:依托灵活的插拔式组件产线化设计,支持各类 NLP 场景任务,包括:信息抽取、情感倾向分析、阅读理解、检索系统、问答系统、文本分类、文本生成等。
* **低门槛开发**:依托丰富的预置组件,像搭积木一样快速构建产品级系统,预置组件覆盖文档解析、数据处理、模型组网、预测部署、Web 服务、UI 界面等全流程系统功能。
-* **高精度预测**:基于前沿的预训练模型、成熟的系统方案,可构建效果领先的产品级系统,如[NLP流水线系统](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#NLP流水线系统)中预置的语义检索系统、阅读理解式智能问答系统等。
+* **高精度预测**:基于前沿的预训练模型、成熟的系统方案,可构建效果领先的产品级系统,如[NLP 流水线系统](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#NLP 流水线系统)中预置的语义检索系统、阅读理解式智能问答系统等。
* **灵活可定制**:除深度兼容 PaddleNLP 模型组件外,还可嵌入飞桨生态下任意模型、[AI 开放平台算子](https://ai.baidu.com/)、其它开源项目如 Elasticsearch 等作为基础组件,快速扩展,从而实现任意复杂系统的灵活定制开发。
@@ -23,15 +23,15 @@ PaddleNLP Pipelines 是一个端到端NLP流水线系统框架,面向 NLP **
-更多的Benchmarks的信息请参考文档[Benchmarks](./benchmarks/README.md)
+更多的 Benchmarks 的信息请参考文档[Benchmarks](./benchmarks/README.md)
-## NLP流水线系统
+## NLP 流水线系统
-PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经过充分打磨的产品级系统,并会不断开放其它场景的产品级系统,用户可以基于NLP流水线系统提供的系统能力快速开发出适配业务数据的产品。
+PaddleNLP Pipelines NLP 流水线系统针对 NLP 部分高频场景开源了经过充分打磨的产品级系统,并会不断开放其它场景的产品级系统,用户可以基于 NLP 流水线系统提供的系统能力快速开发出适配业务数据的产品。
-* 快速搭建产品级[**语义检索**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/semantic-search)系统:使用自然语言文本通过语义进行智能文档查询,而不是关键字匹配
-* 快速搭建产品级[**智能问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/question-answering)系统:用自然语言提问,即可获得精准答案片段
-* 快速搭建产品级 [**FAQ 问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/FAQ)系统:用自然语言提问,匹配相关的高频问题,并返回匹配到的高频问题的答案
+* 快速搭建产品级[**语义检索**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/semantic-search)系统:使用自然语言文本通过语义进行智能文档查询,而不是关键字匹配
+* 快速搭建产品级[**智能问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/question-answering)系统:用自然语言提问,即可获得精准答案片段
+* 快速搭建产品级 [**FAQ 问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/FAQ)系统:用自然语言提问,匹配相关的高频问题,并返回匹配到的高频问题的答案
### 效果展示
@@ -47,7 +47,7 @@ PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经
-+ FAQ智能问答
++ FAQ 智能问答

@@ -55,14 +55,14 @@ PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经
| | |
|-|-|
-| :floppy_disk: [快速安装](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#floppy_disk-安装) |安装 PaddleNLP Pipelines|
-| :beginner: [快速体验](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#beginner-快速体验) |基于 Pipelines 快速搭建语义检索/智能问答等产品系统|
-| :man_office_worker: [用户案例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#man_office_worker-用户案例) |各行业用户基于PaddleNLP Pipelinse 构建的产品案例|
-| :mortar_board: [Tutorials](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#mortar_board-tutorials) |像搭积木一样一步步构建 NLP 流水线系统教程|
-| :bar_chart: [Benchmarks](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/benchmarks) |针对各场景模型的性能、精度评测指标|
+| :floppy_disk: [快速安装](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#floppy_disk-安装) |安装 PaddleNLP Pipelines|
+| :beginner: [快速体验](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#beginner-快速体验) |基于 Pipelines 快速搭建语义检索/智能问答等产品系统|
+| :man_office_worker: [用户案例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#man_office_worker-用户案例) |各行业用户基于 PaddleNLP Pipelinse 构建的产品案例|
+| :mortar_board: [Tutorials](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#mortar_board-tutorials) |像搭积木一样一步步构建 NLP 流水线系统教程|
+| :bar_chart: [Benchmarks](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/benchmarks) |针对各场景模型的性能、精度评测指标|
| :telescope: [Roadmap](https://github.com/PaddlePaddle/PaddleNLP) | PaddleNLP Pipelines 产品路线图|
| :newspaper: [技术博客](https://github.com/PaddlePaddle/PaddleNLP) | 阅读 PaddleNLP Pipelines 系列技术文章|
-| :vulcan_salute: [社区交流](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#vulcan_salute-社区交流) | [官方微信群](https://github.com/PaddlePaddle/PaddleNLP#社区交流), [GitHub Discussions](https://github.com/PaddlePaddle/PaddleNLP/discussions) |
+| :vulcan_salute: [社区交流](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#vulcan_salute-社区交流) | [官方微信群](https://github.com/PaddlePaddle/PaddleNLP#社区交流), [GitHub Discussions](https://github.com/PaddlePaddle/PaddleNLP/discussions) |
## :floppy_disk: 安装
Note: 因为 pipelines 依赖较多, 安装耗时大概 10 分钟左右,安装过程中请请耐心等待。
@@ -145,12 +145,12 @@ docker run \
#### 部署 CPU 服务
-对于Linux使用Docker的用户,使用下面的命令:
+对于 Linux 使用 Docker 的用户,使用下面的命令:
```
docker pull registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0
docker run -d --name paddlenlp_pipelines --net host -ti registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0
```
-对于Windows&Macos上使用Docker的用户,用下面的命令:
+对于 Windows&Macos 上使用 Docker 的用户,用下面的命令:
```
docker pull registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0.windows.darwin
@@ -167,7 +167,7 @@ nvidia-docker run -d --name paddlenlp_pipelines_gpu --net host -ti registry.baid
GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1分钟左右,通过浏览器访问 [http://127.0.0.1:8502](http://127.0.0.1:8502) 快速体验产品级语义检索服务。
-对于国内用户,因为网络问题下载docker比较慢时,可使用百度提供的镜像:
+对于国内用户,因为网络问题下载 docker 比较慢时,可使用百度提供的镜像:
| 环境 | 镜像 Tag | 运行平台 |
@@ -177,7 +177,7 @@ GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1
| CUDA10.2 + cuDNN 7 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |
-如果您的机器不在中国大陆地区,我们推荐您使用DockerHub的镜像:
+如果您的机器不在中国大陆地区,我们推荐您使用 DockerHub 的镜像:
| 环境 | 镜像 Tag | 运行平台 |
| :--------------------------: | :-------------------------------: | :-------------: |
@@ -186,11 +186,11 @@ GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1
| CUDA10.2 + cuDNN 7 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |
-对于智能问答应用,请参考Docker文档[docker文档](./docker/README.md),只需做少量的修改,就可以完成智能问答应用的部署。
+对于智能问答应用,请参考 Docker 文档[docker 文档](./docker/README.md),只需做少量的修改,就可以完成智能问答应用的部署。
#### REST API
-Pipelines可以服务化,通过HTTP接口的形式供其他程序进行调用,Pipelines提供了Swagger API方便用户查询接口文档,从而把Pipelines的能力接入到自己的应用系统中,只需要在启动REST API后通过浏览器访问 [http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+Pipelines 可以服务化,通过 HTTP 接口的形式供其他程序进行调用,Pipelines 提供了 Swagger API 方便用户查询接口文档,从而把 Pipelines 的能力接入到自己的应用系统中,只需要在启动 REST API 后通过浏览器访问 [http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)

@@ -212,10 +212,10 @@ Pipelines可以服务化,通过HTTP接口的形式供其他程序进行调用
市面现已有的工程规范查询系统解决方案一直延续着传统关键字词匹配的查询方式,依赖用户对查询结果进行自行排序、筛选、鉴别,有时甚至还要再次由工程设计人员耗费一定时间精力人工查阅工程规范文件后,才能最终确认是否为想要查询的规范条款。传统规范查询系统至少需要进行 3~5 次查询才能找到用户想要的规范条款,而寻规系统是基于强大预训练模型构建起来的语义检索系统,针对 80% 的规范查询需求仅 **1 次查询** 就能精确命中查询意图,并返回真正符合工程设计人员查询意图的结果!
## :mortar_board: Tutorials
-- Tutorial 1 - Pipelines [Windows视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
-- Tutorial 2 - 语义检索 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442670) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/semantic-search/semantic_search_example.py)
-- Tutorial 3 - 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442857) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/question-answering/dense_qa_example.py)
-- Tutorial 4 - FAQ智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4465498) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/FAQ/dense_faq_example.py)
+- Tutorial 1 - Pipelines [Windows 视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
+- Tutorial 2 - 语义检索 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442670) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/semantic-search/semantic_search_example.py)
+- Tutorial 3 - 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442857) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/question-answering/dense_qa_example.py)
+- Tutorial 4 - FAQ 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4465498) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/FAQ/dense_faq_example.py)
- Tutorial 5 - Pipelines 快速上手二次开发教程: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/5011119)
## :vulcan_salute: 社区交流
微信扫描二维码并填写问卷之后,加入交流群与来自各行各业的小伙伴交流学习吧~
diff --git a/legacy/pipelines/VERSION b/slm/pipelines/VERSION
similarity index 100%
rename from legacy/pipelines/VERSION
rename to slm/pipelines/VERSION
diff --git a/legacy/pipelines/VERSION.txt b/slm/pipelines/VERSION.txt
similarity index 100%
rename from legacy/pipelines/VERSION.txt
rename to slm/pipelines/VERSION.txt
diff --git a/legacy/pipelines/benchmarks/README.md b/slm/pipelines/benchmarks/README.md
similarity index 80%
rename from legacy/pipelines/benchmarks/README.md
rename to slm/pipelines/benchmarks/README.md
index acbd8d2221f4..cfe00c345963 100644
--- a/legacy/pipelines/benchmarks/README.md
+++ b/slm/pipelines/benchmarks/README.md
@@ -1,13 +1,13 @@
-# ERNIE 3.0 的RocketQA模型
+# ERNIE 3.0 的 RocketQA 模型
## 模型介绍
-本次开源的模型ERNIE 3.0系列的模型的基础上,使用RocketQA的训练策略训练的`DualEncoder`和`CrossEncoder`模型,相比于原始的RocektQA模型,在中文上的效果达到最佳。
+本次开源的模型 ERNIE 3.0系列的模型的基础上,使用 RocketQA 的训练策略训练的`DualEncoder`和`CrossEncoder`模型,相比于原始的 RocektQA 模型,在中文上的效果达到最佳。
## 模型效果
-### DualEncoder模型效果
+### DualEncoder 模型效果
| 模型 | 模型规模 | MRR@10 | Recall@1 | Recall@50 |
|:----------------------------------------------------------------:|:--------------------:|:----------:|:----------:|:----------:|
@@ -19,7 +19,7 @@
| rocketqa-zh-nano-query-encoder&rocketqa-zh-nano-para-encoder | 4-layer, 312-hidden | 38.07% | 27.35% | 80.35% |
-### CrossEncoder模型效果
+### CrossEncoder 模型效果
| 模型 | 模型规模 | MRR@10 | Recall@1 | Recall@50 |
|:-----------------------------:|:--------------------:|:----------:|:----------:|:----------:|
@@ -33,7 +33,7 @@
## 模型性能
-RocketQA系列的模型在GPU上能够达到ms级别的速度,一个query大概20ms左右,最快能够达到10ms,另外,为了验证在CPU上的速度,我们使用RocketQA系列的模型在CPU上测试了构建索引的时间,数据集是1398条,在cpu上的测试时间,以下cpu上的查询时间指的是在后台query发一次请求经过模型处理后得到结果的时间,包含召回和排序两部分,召回的文本数为30条。
+RocketQA 系列的模型在 GPU 上能够达到 ms 级别的速度,一个 query 大概20ms 左右,最快能够达到10ms,另外,为了验证在 CPU 上的速度,我们使用 RocketQA 系列的模型在 CPU 上测试了构建索引的时间,数据集是1398条,在 cpu 上的测试时间,以下 cpu 上的查询时间指的是在后台 query 发一次请求经过模型处理后得到结果的时间,包含召回和排序两部分,召回的文本数为30条。
| 模型 | 模型规模 | 构建索引时间 | 查询一条文本时间 |
|:------------------:|:--------------------:|:------------:|:----------------:|
diff --git a/legacy/pipelines/benchmarks/requirements.txt b/slm/pipelines/benchmarks/requirements.txt
similarity index 100%
rename from legacy/pipelines/benchmarks/requirements.txt
rename to slm/pipelines/benchmarks/requirements.txt
diff --git a/legacy/pipelines/benchmarks/retrieval_benchmarks.py b/slm/pipelines/benchmarks/retrieval_benchmarks.py
similarity index 100%
rename from legacy/pipelines/benchmarks/retrieval_benchmarks.py
rename to slm/pipelines/benchmarks/retrieval_benchmarks.py
diff --git a/legacy/pipelines/docker/Dockerfile b/slm/pipelines/docker/Dockerfile
similarity index 100%
rename from legacy/pipelines/docker/Dockerfile
rename to slm/pipelines/docker/Dockerfile
diff --git a/legacy/pipelines/docker/Dockerfile-GPU b/slm/pipelines/docker/Dockerfile-GPU
similarity index 100%
rename from legacy/pipelines/docker/Dockerfile-GPU
rename to slm/pipelines/docker/Dockerfile-GPU
diff --git a/legacy/pipelines/docker/README.md b/slm/pipelines/docker/README.md
similarity index 58%
rename from legacy/pipelines/docker/README.md
rename to slm/pipelines/docker/README.md
index eca399f45cf0..60296d131aaa 100644
--- a/legacy/pipelines/docker/README.md
+++ b/slm/pipelines/docker/README.md
@@ -1,10 +1,10 @@
-# Docker 启动 pipelines服务
+# Docker 启动 pipelines 服务
## 1. Docker 一键启动
-### 1.1 Docker本地构建镜像启动
+### 1.1 Docker 本地构建镜像启动
-为了满足用户多种多样的需求,我们提供了Dockerfile来构建一个镜像(以语义索引为例),其中`Docker`的安装请参考[官方文档](https://docs.docker.com/desktop/),安装完以后,修改服务端运行脚本`run_server.sh`,客户端界面脚本`run_client.sh`,然后执行下面的命令:
+为了满足用户多种多样的需求,我们提供了 Dockerfile 来构建一个镜像(以语义索引为例),其中`Docker`的安装请参考[官方文档](https://docs.docker.com/desktop/),安装完以后,修改服务端运行脚本`run_server.sh`,客户端界面脚本`run_client.sh`,然后执行下面的命令:
```
cd docker
@@ -34,7 +34,7 @@ docker run -d --name paddlenlp_pipelines --net host -it pipeline_cpu_server
nvidia-docker run -d --name paddlenlp_pipelines --net host -it pipeline_server
```
-cpu版本大概等待3分钟左右,gpu版本大概1分钟左右,到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验语义检索系统服务了。
+cpu 版本大概等待3分钟左右,gpu 版本大概1分钟左右,到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验语义检索系统服务了。
## 2. Docker-Compose 一键启动
@@ -58,15 +58,15 @@ docker-compose -f docker-compose-gpu.yml stop
# 查看容器运行的日志 gpu
docker logs pip02
```
-构建过程一般会持续3分钟左右,然后cpu版本启动等待1分钟左右,然后您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验语义检索系统服务了。
+构建过程一般会持续3分钟左右,然后 cpu 版本启动等待1分钟左右,然后您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验语义检索系统服务了。
-## 3. Docker编译一个定制化CUDA版本的Pipelines的镜像
+## 3. Docker 编译一个定制化 CUDA 版本的 Pipelines 的镜像
-Docker编译一个定制化CUDA版本的Pipelines的镜像流程分2步,第一步是利用Paddle镜像构建Pipelines基础镜像,第二步是构建一键启动镜像。第一步构建的镜像是一个可用的状态,但是启动后,需要进入容器,手工启动服务,第二步是需要把运行命令打包到镜像中,使得Docker启动的时候能够自动启动Pipelines的服务。
+Docker 编译一个定制化 CUDA 版本的 Pipelines 的镜像流程分2步,第一步是利用 Paddle 镜像构建 Pipelines 基础镜像,第二步是构建一键启动镜像。第一步构建的镜像是一个可用的状态,但是启动后,需要进入容器,手工启动服务,第二步是需要把运行命令打包到镜像中,使得 Docker 启动的时候能够自动启动 Pipelines 的服务。
### 3.1 基础镜像
-以CUDA 11.2环境为例,编译一个Pipelines基础镜像流程如下:
+以 CUDA 11.2环境为例,编译一个 Pipelines 基础镜像流程如下:
```
nvidia-docker run --name pipelines --net host --shm-size 4g -it registry.baidubce.com/paddlepaddle/paddle:2.3.2-gpu-cuda11.2-cudnn8 /bin/bash
@@ -79,11 +79,11 @@ apt-get install lsof
```
镜像构建完成可以使用`Ctrl+P+Q`组合键跳出容器。
-在第一步构建镜像的过程中,如果是CUDA的其他版本,则需要在[Paddle官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/docker/linux-docker.html)上查找是否有对应的CUDA版本的Paddle镜像,如果没有,则需要自己手工构建一个该CUDA版本的Docker,然后安装对应CUDA版本的PaddlePaddle,然后继续执行上面的流程。
+在第一步构建镜像的过程中,如果是 CUDA 的其他版本,则需要在[Paddle 官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/docker/linux-docker.html)上查找是否有对应的 CUDA 版本的 Paddle 镜像,如果没有,则需要自己手工构建一个该 CUDA 版本的 Docker,然后安装对应 CUDA 版本的 PaddlePaddle,然后继续执行上面的流程。
### 3.2 一键启动镜像
-到了上一步就构建了一个可用的Pipelines镜像了,但是这个镜像还没有一键启动功能,即需要进入容器手动启动后台和前端。这里进一步打包镜像,把启动运行的命令也打包到镜像中,执行过程如下:
+到了上一步就构建了一个可用的 Pipelines 镜像了,但是这个镜像还没有一键启动功能,即需要进入容器手动启动后台和前端。这里进一步打包镜像,把启动运行的命令也打包到镜像中,执行过程如下:
```
docker commit pipelines pipelines:1.0-gpu-cuda11.2-cudnn8
@@ -106,11 +106,11 @@ ENTRYPOINT /root/start.sh && tail -f /dev/null
docker build --tag=paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 . -f Dockerfile-GPU
```
-这样就构建了一键启动的Docker镜像。
+这样就构建了一键启动的 Docker 镜像。
### 3.3 启动镜像
-一键启动的Docker构建完成以后就可以使用下面的命令启动:
+一键启动的 Docker 构建完成以后就可以使用下面的命令启动:
```
nvidia-docker run -d --name paddlenlp_pipelines_gpu --net host -ti paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8
diff --git a/legacy/pipelines/docker/create_index.sh b/slm/pipelines/docker/create_index.sh
similarity index 100%
rename from legacy/pipelines/docker/create_index.sh
rename to slm/pipelines/docker/create_index.sh
diff --git a/legacy/pipelines/docker/dense_qa.yaml b/slm/pipelines/docker/dense_qa.yaml
similarity index 100%
rename from legacy/pipelines/docker/dense_qa.yaml
rename to slm/pipelines/docker/dense_qa.yaml
diff --git a/legacy/pipelines/docker/docker-compose-gpu.yml b/slm/pipelines/docker/docker-compose-gpu.yml
similarity index 100%
rename from legacy/pipelines/docker/docker-compose-gpu.yml
rename to slm/pipelines/docker/docker-compose-gpu.yml
diff --git a/legacy/pipelines/docker/docker-compose.yml b/slm/pipelines/docker/docker-compose.yml
similarity index 100%
rename from legacy/pipelines/docker/docker-compose.yml
rename to slm/pipelines/docker/docker-compose.yml
diff --git a/legacy/pipelines/docker/run_client.sh b/slm/pipelines/docker/run_client.sh
similarity index 100%
rename from legacy/pipelines/docker/run_client.sh
rename to slm/pipelines/docker/run_client.sh
diff --git a/legacy/pipelines/docker/run_server.sh b/slm/pipelines/docker/run_server.sh
similarity index 100%
rename from legacy/pipelines/docker/run_server.sh
rename to slm/pipelines/docker/run_server.sh
diff --git a/legacy/pipelines/docker/semantic_search.yaml b/slm/pipelines/docker/semantic_search.yaml
similarity index 100%
rename from legacy/pipelines/docker/semantic_search.yaml
rename to slm/pipelines/docker/semantic_search.yaml
diff --git a/legacy/pipelines/docker/start.sh b/slm/pipelines/docker/start.sh
similarity index 100%
rename from legacy/pipelines/docker/start.sh
rename to slm/pipelines/docker/start.sh
diff --git a/legacy/pipelines/docker/start_compose.sh b/slm/pipelines/docker/start_compose.sh
similarity index 100%
rename from legacy/pipelines/docker/start_compose.sh
rename to slm/pipelines/docker/start_compose.sh
diff --git a/legacy/pipelines/docs/index.md b/slm/pipelines/docs/index.md
similarity index 74%
rename from legacy/pipelines/docs/index.md
rename to slm/pipelines/docs/index.md
index 141c2fa4e0c6..64d20ce2f0b5 100644
--- a/legacy/pipelines/docs/index.md
+++ b/slm/pipelines/docs/index.md
@@ -1,20 +1,20 @@
-## PaddleNLP Pipelines:NLP流水线系统
+## PaddleNLP Pipelines:NLP 流水线系统
-PaddleNLP Pipelines 是一个端到端NLP流水线系统框架,面向 NLP **全场景**,帮助用户**低门槛**构建强大**产品级系统**。
+PaddleNLP Pipelines 是一个端到端 NLP 流水线系统框架,面向 NLP **全场景**,帮助用户**低门槛**构建强大**产品级系统**。
-更多效果展示Demo请参考 [效果展示](#效果展示)
+更多效果展示 Demo 请参考 [效果展示](#效果展示)
-## NLP流水线系统特色
+## NLP 流水线系统特色
* **全场景支持**:依托灵活的插拔式组件产线化设计,支持各类 NLP 场景任务,包括:信息抽取、情感倾向分析、阅读理解、检索系统、问答系统、文本分类、文本生成等。
* **低门槛开发**:依托丰富的预置组件,像搭积木一样快速构建产品级系统,预置组件覆盖文档解析、数据处理、模型组网、预测部署、Web 服务、UI 界面等全流程系统功能。
-* **高精度预测**:基于前沿的预训练模型、成熟的系统方案,可构建效果领先的产品级系统,如[NLP流水线系统](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#NLP流水线系统)中预置的语义检索系统、阅读理解式智能问答系统等。
+* **高精度预测**:基于前沿的预训练模型、成熟的系统方案,可构建效果领先的产品级系统,如[NLP 流水线系统](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#NLP 流水线系统)中预置的语义检索系统、阅读理解式智能问答系统等。
* **灵活可定制**:除深度兼容 PaddleNLP 模型组件外,还可嵌入飞桨生态下任意模型、[AI 开放平台算子](https://ai.baidu.com/)、其它开源项目如 Elasticsearch 等作为基础组件,快速扩展,从而实现任意复杂系统的灵活定制开发。
@@ -24,15 +24,15 @@ PaddleNLP Pipelines 是一个端到端NLP流水线系统框架,面向 NLP **
-更多的Benchmarks的信息请参考文档[Benchmarks](../benchmarks/README.md)
+更多的 Benchmarks 的信息请参考文档[Benchmarks](../benchmarks/README.md)
-## NLP流水线系统
+## NLP 流水线系统
-PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经过充分打磨的产品级系统,并会不断开放其它场景的产品级系统,用户可以基于NLP流水线系统提供的系统能力快速开发出适配业务数据的产品。
+PaddleNLP Pipelines NLP 流水线系统针对 NLP 部分高频场景开源了经过充分打磨的产品级系统,并会不断开放其它场景的产品级系统,用户可以基于 NLP 流水线系统提供的系统能力快速开发出适配业务数据的产品。
-* 快速搭建产品级[**语义检索**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/semantic-search)系统:使用自然语言文本通过语义进行智能文档查询,而不是关键字匹配
-* 快速搭建产品级[**智能问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/question-answering)系统:用自然语言提问,即可获得精准答案片段
-* 快速搭建产品级 [**FAQ 问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/examples/FAQ)系统:用自然语言提问,匹配相关的高频问题,并返回匹配到的高频问题的答案
+* 快速搭建产品级[**语义检索**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/semantic-search)系统:使用自然语言文本通过语义进行智能文档查询,而不是关键字匹配
+* 快速搭建产品级[**智能问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/question-answering)系统:用自然语言提问,即可获得精准答案片段
+* 快速搭建产品级 [**FAQ 问答**](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/examples/FAQ)系统:用自然语言提问,匹配相关的高频问题,并返回匹配到的高频问题的答案
### 效果展示
@@ -48,7 +48,7 @@ PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经
-+ FAQ智能问答
++ FAQ 智能问答

@@ -56,14 +56,14 @@ PaddleNLP Pipelines NLP流水线系统针对 NLP 部分高频场景开源了经
| | |
|------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
-| :floppy_disk: [快速安装](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#floppy_disk-安装) | 安装 PaddleNLP Pipelines |
-| :beginner: [快速体验](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#beginner-快速体验) | 基于 Pipelines 快速搭建语义检索/智能问答等产品系统 |
-| :man_office_worker: [用户案例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#man_office_worker-用户案例) | 各行业用户基于PaddleNLP Pipelinse 构建的产品案例 |
-| :mortar_board: [Tutorials](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#mortar_board-tutorials) | 像搭积木一样一步步构建 NLP 流水线系统教程 |
-| :bar_chart: [Benchmarks](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines/benchmarks) | 针对各场景模型的性能、精度评测指标 |
+| :floppy_disk: [快速安装](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#floppy_disk-安装) | 安装 PaddleNLP Pipelines |
+| :beginner: [快速体验](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#beginner-快速体验) | 基于 Pipelines 快速搭建语义检索/智能问答等产品系统 |
+| :man_office_worker: [用户案例](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#man_office_worker-用户案例) | 各行业用户基于 PaddleNLP Pipelinse 构建的产品案例 |
+| :mortar_board: [Tutorials](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#mortar_board-tutorials) | 像搭积木一样一步步构建 NLP 流水线系统教程 |
+| :bar_chart: [Benchmarks](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines/benchmarks) | 针对各场景模型的性能、精度评测指标 |
| :telescope: [Roadmap](https://github.com/PaddlePaddle/PaddleNLP) | PaddleNLP Pipelines 产品路线图 |
| :newspaper: [技术博客](https://github.com/PaddlePaddle/PaddleNLP) | 阅读 PaddleNLP Pipelines 系列技术文章 |
-| :vulcan_salute: [社区交流](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines#vulcan_salute-社区交流) | [官方微信群](https://github.com/PaddlePaddle/PaddleNLP#社区交流), [GitHub Discussions](https://github.com/PaddlePaddle/PaddleNLP/discussions) |
+| :vulcan_salute: [社区交流](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines#vulcan_salute-社区交流) | [官方微信群](https://github.com/PaddlePaddle/PaddleNLP#社区交流), [GitHub Discussions](https://github.com/PaddlePaddle/PaddleNLP/discussions) |
## :floppy_disk: 安装
Note: 因为 pipelines 依赖较多, 安装耗时大概 10 分钟左右,安装过程中请请耐心等待。
@@ -145,12 +145,12 @@ docker run \
#### 部署 CPU 服务
-对于Linux使用Docker的用户,使用下面的命令:
+对于 Linux 使用 Docker 的用户,使用下面的命令:
```
docker pull registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0
docker run -d --name paddlenlp_pipelines --net host -ti registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0
```
-对于Windows&Macos上使用Docker的用户,用下面的命令:
+对于 Windows&Macos 上使用 Docker 的用户,用下面的命令:
```
docker pull registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0.windows.darwin
@@ -167,7 +167,7 @@ nvidia-docker run -d --name paddlenlp_pipelines_gpu --net host -ti registry.baid
GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1分钟左右,通过浏览器访问 [http://127.0.0.1:8502](http://127.0.0.1:8502) 快速体验产品级语义检索服务。
-对于国内用户,因为网络问题下载docker比较慢时,可使用百度提供的镜像:
+对于国内用户,因为网络问题下载 docker 比较慢时,可使用百度提供的镜像:
| 环境 | 镜像 Tag | 运行平台 |
@@ -177,7 +177,7 @@ GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1
| CUDA10.2 + cuDNN 7 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |
-如果您的机器不在中国大陆地区,我们推荐您使用DockerHub的镜像:
+如果您的机器不在中国大陆地区,我们推荐您使用 DockerHub 的镜像:
| 环境 | 镜像 Tag | 运行平台 |
|:------------------:|:------------------------------------------------:|:-------------:|
@@ -186,11 +186,11 @@ GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1
| CUDA10.2 + cuDNN 7 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |
-对于智能问答应用,请参考Docker文档[docker文档](../docker/README.md),只需做少量的修改,就可以完成智能问答应用的部署。
+对于智能问答应用,请参考 Docker 文档[docker 文档](../docker/README.md),只需做少量的修改,就可以完成智能问答应用的部署。
#### REST API
-Pipelines可以服务化,通过HTTP接口的形式供其他程序进行调用,Pipelines提供了Swagger API方便用户查询接口文档,从而把Pipelines的能力接入到自己的应用系统中,只需要在启动REST API后通过浏览器访问 [http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+Pipelines 可以服务化,通过 HTTP 接口的形式供其他程序进行调用,Pipelines 提供了 Swagger API 方便用户查询接口文档,从而把 Pipelines 的能力接入到自己的应用系统中,只需要在启动 REST API 后通过浏览器访问 [http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)

@@ -212,10 +212,10 @@ Pipelines可以服务化,通过HTTP接口的形式供其他程序进行调用
市面现已有的工程规范查询系统解决方案一直延续着传统关键字词匹配的查询方式,依赖用户对查询结果进行自行排序、筛选、鉴别,有时甚至还要再次由工程设计人员耗费一定时间精力人工查阅工程规范文件后,才能最终确认是否为想要查询的规范条款。传统规范查询系统至少需要进行 3~5 次查询才能找到用户想要的规范条款,而寻规系统是基于强大预训练模型构建起来的语义检索系统,针对 80% 的规范查询需求仅 **1 次查询** 就能精确命中查询意图,并返回真正符合工程设计人员查询意图的结果!
## :mortar_board: Tutorials
-- Tutorial 1 - Pipelines [Windows视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
-- Tutorial 2 - 语义检索 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442670) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/semantic-search/semantic_search_example.py)
-- Tutorial 3 - 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442857) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/question-answering/dense_qa_example.py)
-- Tutorial 4 - FAQ智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4465498) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/legacy/pipelines/examples/FAQ/dense_faq_example.py)
+- Tutorial 1 - Pipelines [Windows 视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
+- Tutorial 2 - 语义检索 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442670) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/semantic-search/semantic_search_example.py)
+- Tutorial 3 - 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4442857) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/question-answering/dense_qa_example.py)
+- Tutorial 4 - FAQ 智能问答 Pipeline: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/4465498) | [Python](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/slm/pipelines/examples/FAQ/dense_faq_example.py)
- Tutorial 5 - Pipelines 快速上手二次开发教程: [AIStudio notebook](https://aistudio.baidu.com/aistudio/projectdetail/5011119)
## :vulcan_salute: 社区交流
微信扫描二维码并填写问卷之后,加入交流群与来自各行各业的小伙伴交流学习吧~
diff --git a/legacy/pipelines/docs/package/agents/agents.md b/slm/pipelines/docs/package/agents/agents.md
similarity index 100%
rename from legacy/pipelines/docs/package/agents/agents.md
rename to slm/pipelines/docs/package/agents/agents.md
diff --git a/legacy/pipelines/docs/package/agents/memory.md b/slm/pipelines/docs/package/agents/memory.md
similarity index 100%
rename from legacy/pipelines/docs/package/agents/memory.md
rename to slm/pipelines/docs/package/agents/memory.md
diff --git a/legacy/pipelines/docs/package/docstore/elasticsearch.md b/slm/pipelines/docs/package/docstore/elasticsearch.md
similarity index 100%
rename from legacy/pipelines/docs/package/docstore/elasticsearch.md
rename to slm/pipelines/docs/package/docstore/elasticsearch.md
diff --git a/legacy/pipelines/docs/package/docstore/faiss.md b/slm/pipelines/docs/package/docstore/faiss.md
similarity index 100%
rename from legacy/pipelines/docs/package/docstore/faiss.md
rename to slm/pipelines/docs/package/docstore/faiss.md
diff --git a/legacy/pipelines/docs/package/docstore/milvus2.md b/slm/pipelines/docs/package/docstore/milvus2.md
similarity index 100%
rename from legacy/pipelines/docs/package/docstore/milvus2.md
rename to slm/pipelines/docs/package/docstore/milvus2.md
diff --git a/legacy/pipelines/docs/package/nodes/answer_extractor.md b/slm/pipelines/docs/package/nodes/answer_extractor.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/answer_extractor.md
rename to slm/pipelines/docs/package/nodes/answer_extractor.md
diff --git a/legacy/pipelines/docs/package/nodes/document_intelligence.md b/slm/pipelines/docs/package/nodes/document_intelligence.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/document_intelligence.md
rename to slm/pipelines/docs/package/nodes/document_intelligence.md
diff --git a/legacy/pipelines/docs/package/nodes/file_converter.md b/slm/pipelines/docs/package/nodes/file_converter.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/file_converter.md
rename to slm/pipelines/docs/package/nodes/file_converter.md
diff --git a/legacy/pipelines/docs/package/nodes/llm.md b/slm/pipelines/docs/package/nodes/llm.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/llm.md
rename to slm/pipelines/docs/package/nodes/llm.md
diff --git a/legacy/pipelines/docs/package/nodes/other.md b/slm/pipelines/docs/package/nodes/other.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/other.md
rename to slm/pipelines/docs/package/nodes/other.md
diff --git a/legacy/pipelines/docs/package/nodes/preprocessor.md b/slm/pipelines/docs/package/nodes/preprocessor.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/preprocessor.md
rename to slm/pipelines/docs/package/nodes/preprocessor.md
diff --git a/legacy/pipelines/docs/package/nodes/question_generator.md b/slm/pipelines/docs/package/nodes/question_generator.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/question_generator.md
rename to slm/pipelines/docs/package/nodes/question_generator.md
diff --git a/legacy/pipelines/docs/package/nodes/ranker.md b/slm/pipelines/docs/package/nodes/ranker.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/ranker.md
rename to slm/pipelines/docs/package/nodes/ranker.md
diff --git a/legacy/pipelines/docs/package/nodes/reader.md b/slm/pipelines/docs/package/nodes/reader.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/reader.md
rename to slm/pipelines/docs/package/nodes/reader.md
diff --git a/legacy/pipelines/docs/package/nodes/retriever.md b/slm/pipelines/docs/package/nodes/retriever.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/retriever.md
rename to slm/pipelines/docs/package/nodes/retriever.md
diff --git a/legacy/pipelines/docs/package/nodes/search_engine.md b/slm/pipelines/docs/package/nodes/search_engine.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/search_engine.md
rename to slm/pipelines/docs/package/nodes/search_engine.md
diff --git a/legacy/pipelines/docs/package/nodes/sentiment_analysis.md b/slm/pipelines/docs/package/nodes/sentiment_analysis.md
similarity index 100%
rename from legacy/pipelines/docs/package/nodes/sentiment_analysis.md
rename to slm/pipelines/docs/package/nodes/sentiment_analysis.md
diff --git a/legacy/pipelines/docs/package/pipelines/standard_pipelines.md b/slm/pipelines/docs/package/pipelines/standard_pipelines.md
similarity index 100%
rename from legacy/pipelines/docs/package/pipelines/standard_pipelines.md
rename to slm/pipelines/docs/package/pipelines/standard_pipelines.md
diff --git a/legacy/pipelines/docs/package/rest_api/application.md b/slm/pipelines/docs/package/rest_api/application.md
similarity index 100%
rename from legacy/pipelines/docs/package/rest_api/application.md
rename to slm/pipelines/docs/package/rest_api/application.md
diff --git a/legacy/pipelines/docs/package/rest_api/controller.md b/slm/pipelines/docs/package/rest_api/controller.md
similarity index 100%
rename from legacy/pipelines/docs/package/rest_api/controller.md
rename to slm/pipelines/docs/package/rest_api/controller.md
diff --git a/legacy/pipelines/docs/requirements.txt b/slm/pipelines/docs/requirements.txt
similarity index 100%
rename from legacy/pipelines/docs/requirements.txt
rename to slm/pipelines/docs/requirements.txt
diff --git a/legacy/pipelines/examples/FAQ/Install_windows.md b/slm/pipelines/examples/FAQ/Install_windows.md
similarity index 60%
rename from legacy/pipelines/examples/FAQ/Install_windows.md
rename to slm/pipelines/examples/FAQ/Install_windows.md
index 43ff97dda2f8..006cd07f5b15 100644
--- a/legacy/pipelines/examples/FAQ/Install_windows.md
+++ b/slm/pipelines/examples/FAQ/Install_windows.md
@@ -1,12 +1,12 @@
-# WINDOWS环境下搭建端到端FAQ智能问答系统
-以下的流程都是使用的Anaconda的环境进行的搭建,Anaconda安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
+# WINDOWS 环境下搭建端到端 FAQ 智能问答系统
+以下的流程都是使用的 Anaconda 的环境进行的搭建,Anaconda 安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
-## 1. 快速开始: 快速搭建FAQ智能问答系统
+## 1. 快速开始: 快速搭建 FAQ 智能问答系统
### 1.1 运行环境和安装说明
a. 依赖安装:
-我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险FAQ智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
+我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险 FAQ 智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
```bash
git clone https://github.com/tvst/htbuilder.git
cd htbuilder/
@@ -27,9 +27,9 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 1.2 数据说明
-我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险FAQ智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
+我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险 FAQ 智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
-### 1.3 一键体验FAQ智能问答系统
+### 1.3 一键体验 FAQ 智能问答系统
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
@@ -38,22 +38,22 @@ python examples/FAQ/dense_faq_example.py --device gpu
python examples/FAQ/dense_faq_example.py --device cpu
```
-### 1.4 构建 Web 可视化FAQ系统
+### 1.4 构建 Web 可视化 FAQ 系统
-整个 Web 可视化FAQ智能问答系统主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,接下来我们依次搭建这 3 个服务并最终形成可视化的FAQ智能问答系统。
+整个 Web 可视化 FAQ 智能问答系统主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,接下来我们依次搭建这 3 个服务并最终形成可视化的 FAQ 智能问答系统。
#### 1.4.1 启动 ANN 服务
1. 参考官方文档下载安装 [elasticsearch-8.3.2](https://www.elastic.co/cn/downloads/elasticsearch) 并解压。
2. 启动 ES 服务
-把`xpack.security.enabled` 设置成false,如下:
+把`xpack.security.enabled` 设置成 false,如下:
```
xpack.security.enabled: false
```
-然后直接双击bin目录下的elasticsearch.bat即可启动。
+然后直接双击 bin 目录下的 elasticsearch.bat 即可启动。
-3. elasticsearch可视化工具Kibana(可选)
-为了更好的对数据进行管理,可以使用Kibana可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
+3. elasticsearch 可视化工具 Kibana(可选)
+为了更好的对数据进行管理,可以使用 Kibana 可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
#### 1.4.2 文档数据写入 ANN 索引库
```
@@ -62,17 +62,17 @@ python utils/offline_ann.py --index_name insurance --doc_dir data/insurance --sp
```
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
-运行结束后,可使用Kibana查看数据
+运行结束后,可使用 Kibana 查看数据
#### 1.4.3 启动 RestAPI 模型服务
-**注意** dense_faq.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** dense_faq.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定FAQ智能问答系统的Yaml配置文件
@@ -89,11 +89,11 @@ $env:API_ENDPOINT='http://127.0.0.1:8891'
python -m streamlit run ui/webapp_faq.py --server.port 8502
```
-到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验FAQ智能问答系统服务了。
+到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验 FAQ 智能问答系统服务了。
#### 1.4.5 数据更新
-数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -105,4 +105,4 @@ python -m streamlit run ui/webapp_faq.py --server.port 8502
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
diff --git a/legacy/pipelines/examples/FAQ/README.md b/slm/pipelines/examples/FAQ/README.md
similarity index 66%
rename from legacy/pipelines/examples/FAQ/README.md
rename to slm/pipelines/examples/FAQ/README.md
index 703052e46e51..2796404d6311 100644
--- a/legacy/pipelines/examples/FAQ/README.md
+++ b/slm/pipelines/examples/FAQ/README.md
@@ -1,4 +1,4 @@
-# 端到端FAQ智能问答系统
+# 端到端 FAQ 智能问答系统
## 1. 场景概述
@@ -6,7 +6,7 @@
## 2. 产品功能介绍
-本项目提供了低成本搭建端到端FAQ智能问答的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的检索系统模型(召回模型、排序模型)快速搭建一个针对自己业务数据的问答系统,并可以提供 Web 化产品服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,模型训练可以参考[FAQ Finance](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa/faq_finance),模型的接入流程参考Pipelines语义检索中Neural Search模型接入流程即可。
+本项目提供了低成本搭建端到端 FAQ 智能问答的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的检索系统模型(召回模型、排序模型)快速搭建一个针对自己业务数据的问答系统,并可以提供 Web 化产品服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,模型训练可以参考[FAQ Finance](https://github.com/PaddlePaddle/PaddleNLP/tree/release/2.8/applications/question_answering/supervised_qa/faq_finance),模型的接入流程参考 Pipelines 语义检索中 Neural Search 模型接入流程即可。

@@ -15,15 +15,15 @@
### 2.1 系统特色
+ 端到端
- + 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端FAQ智能问答系统能力
+ + 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端 FAQ 智能问答系统能力
+ 多源数据支持: 支持对 Txt、Word、PDF、Image 多源数据进行解析、识别并写入 ANN 数据库
+ 效果好
- + 依托百度领先的NLP技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ + 依托百度领先的 NLP 技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ 预置领先的深度学习模型
-## 3. 快速开始: 快速搭建FAQ智能问答系统
+## 3. 快速开始: 快速搭建 FAQ 智能问答系统
-以下是针对mac和linux的安装流程
+以下是针对 mac 和 linux 的安装流程
### 3.1 运行环境和安装说明
@@ -43,7 +43,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -62,13 +62,13 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 3.2 数据说明
-FAQ智能问答数据库的数据来自于[8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb),共包含 8000 多个问答对,并过滤选取了其中3788条问答对来搭建FAQ智能问答系统。
+FAQ 智能问答数据库的数据来自于[8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb),共包含 8000 多个问答对,并过滤选取了其中3788条问答对来搭建 FAQ 智能问答系统。
-### 3.3 一键体验FAQ智能问答系统
+### 3.3 一键体验 FAQ 智能问答系统
#### 3.3.1 快速一键启动
-我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险FAQ智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
+我们预置了基于[ 8000 多条保险行业问答数据](https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/baoxianzhidao/intro.ipynb)搭建保险 FAQ 智能问答的代码示例,您可以通过如下命令快速体验智能问答的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -78,11 +78,11 @@ python examples/FAQ/dense_faq_example.py --device gpu
unset CUDA_VISIBLE_DEVICES
python examples/FAQ/dense_faq_example.py --device cpu
```
-`dense_faq_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API介绍](../../API.md)
+`dense_faq_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API 介绍](../../API.md)
-### 3.4 构建 Web 可视化FAQ智能问答
+### 3.4 构建 Web 可视化 FAQ 智能问答
-整个 Web 可视化FAQ智能问答主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,接下来我们依次搭建这 3 个服务并最终形成可视化的FAQ智能问答。
+整个 Web 可视化 FAQ 智能问答主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,接下来我们依次搭建这 3 个服务并最终形成可视化的 FAQ 智能问答。
#### 3.4.1 启动 ANN 服务
1. 参考官方文档下载安装 [elasticsearch-8.3.2](https://www.elastic.co/cn/downloads/elasticsearch) 并解压。
@@ -99,7 +99,7 @@ xpack.security.enabled: false
```bash
curl http://localhost:9200/_aliases?pretty=true
```
-如果elasticsearch里面没有数据,结果会输出为空:
+如果 elasticsearch 里面没有数据,结果会输出为空:
```
{ }
@@ -121,11 +121,11 @@ python utils/offline_ann.py --index_name insurance \
```
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `split_answers`: 是否切分每一行的数据为query和answer两部分
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `split_answers`: 是否切分每一行的数据为 query 和 answer 两部分
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
```
# 打印几条数据
@@ -139,7 +139,7 @@ curl http://localhost:9200/insurance/_search
#### 3.4.3 启动 RestAPI 模型服务
-**注意** dense_faq.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** dense_faq.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定FAQ智能问答系统的Yaml配置文件
@@ -152,14 +152,14 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
```bash
sh examples/FAQ/run_faq_server.sh
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "企业如何办理养老保险?","params": {"Retriever": {"top_k": 5}, "Ranker":{"top_k": 5}}}'
```
如果成功运行,则会返回结果。
-更多API接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+更多 API 接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
#### 3.4.4 启动 WebUI
```bash
@@ -175,27 +175,27 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
sh examples/FAQ/run_faq_web.sh
```
-到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验FAQ智能问答系统服务了。
+到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验 FAQ 智能问答系统服务了。
#### 3.4.5 数据更新
-数据更新有两种,第一种是使用界面的文件上传,支持txt,word,必须是Question和Answer两列,用\t进行分隔,另外word格式的数据,数据间用空行分隔开,txt格式按正常回车键分隔即可。第二种是使用前面的 `utils/offline_ann.py`进行数据更新,示例数据如下(demo.txt):
+数据更新有两种,第一种是使用界面的文件上传,支持 txt,word,必须是 Question 和 Answer 两列,用\t 进行分隔,另外 word 格式的数据,数据间用空行分隔开,txt 格式按正常回车键分隔即可。第二种是使用前面的 `utils/offline_ann.py`进行数据更新,示例数据如下(demo.txt):
```
我想买保险,可以买哪些? 人身保障的保险,主要可以分为四大险种——即意外险、重疾险、医疗险和寿险。意外险——像过马路被车撞、被开水烫伤等等意外,意外险皆可赔付。医疗险——花多少钱报销多少钱,一般建议买百万医疗险。重疾险——得了重疾,按比例一次性赔付你约定保额。寿险——身故即赔。
选保险产品时,保险公司很重要吗? 重要,但不是第一重要,也不是最重要。产品应该是优先于公司的,毕竟产品的保障才是最直接和我们的利益挂钩的。在保险产品的保障差不多的情况下,知名度更高的保险公司会更好。
```
-word示例数据:
+word 示例数据:
```
-我想买保险,可以买哪些? 可以买哪些?人身保障的保险,主要可以分为四大险种——即意外险、重疾险、医疗险和寿险。意外险——像过马路被车撞、被开水烫伤等等意外,意外险皆可赔付。医疗险——花多少钱报销多少钱,一般建议买百万医疗险。重疾险——得了重疾,按比例一次性赔付你约定保额。寿险——身故即赔。
+我想买保险,可以买哪些? 可以买哪些?人身保障的保险,主要可以分为四大险种——即意外险、重疾险、医疗险和寿险。意外险——像过马路被车撞、被开水烫伤等等意外,意外险皆可赔付。医疗险——花多少钱报销多少钱,一般建议买百万医疗险。重疾险——得了重疾,按比例一次性赔付你约定保额。寿险——身故即赔。
-选保险产品时,保险公司很重要吗? 重要,但不是第一重要,也不是最重要。产品应该是优先于公司的,毕竟产品的保障才是最直接和我们的利益挂钩的。在保险产品的保障差不多的情况下,知名度更高的保险公司会更好。
+选保险产品时,保险公司很重要吗? 重要,但不是第一重要,也不是最重要。产品应该是优先于公司的,毕竟产品的保障才是最直接和我们的利益挂钩的。在保险产品的保障差不多的情况下,知名度更高的保险公司会更好。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/FAQ/dense_faq_example.py b/slm/pipelines/examples/FAQ/dense_faq_example.py
similarity index 100%
rename from legacy/pipelines/examples/FAQ/dense_faq_example.py
rename to slm/pipelines/examples/FAQ/dense_faq_example.py
diff --git a/legacy/pipelines/examples/FAQ/run_faq_server.sh b/slm/pipelines/examples/FAQ/run_faq_server.sh
similarity index 100%
rename from legacy/pipelines/examples/FAQ/run_faq_server.sh
rename to slm/pipelines/examples/FAQ/run_faq_server.sh
diff --git a/legacy/pipelines/examples/FAQ/run_faq_web.sh b/slm/pipelines/examples/FAQ/run_faq_web.sh
similarity index 100%
rename from legacy/pipelines/examples/FAQ/run_faq_web.sh
rename to slm/pipelines/examples/FAQ/run_faq_web.sh
diff --git a/legacy/pipelines/examples/contrastive_training/README.md b/slm/pipelines/examples/contrastive_training/README.md
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/README.md
rename to slm/pipelines/examples/contrastive_training/README.md
diff --git a/legacy/pipelines/examples/contrastive_training/arguments.py b/slm/pipelines/examples/contrastive_training/arguments.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/arguments.py
rename to slm/pipelines/examples/contrastive_training/arguments.py
diff --git a/legacy/pipelines/examples/contrastive_training/data.py b/slm/pipelines/examples/contrastive_training/data.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/data.py
rename to slm/pipelines/examples/contrastive_training/data.py
diff --git a/legacy/pipelines/examples/contrastive_training/data/toy_finetune_data.jsonl b/slm/pipelines/examples/contrastive_training/data/toy_finetune_data.jsonl
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/data/toy_finetune_data.jsonl
rename to slm/pipelines/examples/contrastive_training/data/toy_finetune_data.jsonl
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/__init__.py b/slm/pipelines/examples/contrastive_training/evaluation/__init__.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/evaluation/__init__.py
rename to slm/pipelines/examples/contrastive_training/evaluation/__init__.py
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/benchmarks.py b/slm/pipelines/examples/contrastive_training/evaluation/benchmarks.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/evaluation/benchmarks.py
rename to slm/pipelines/examples/contrastive_training/evaluation/benchmarks.py
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py b/slm/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py
similarity index 96%
rename from legacy/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py
rename to slm/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py
index e6c08001c012..e667a3cd8d53 100644
--- a/legacy/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py
+++ b/slm/pipelines/examples/contrastive_training/evaluation/mteb/eval_mteb.py
@@ -34,7 +34,7 @@ def get_model(peft_model_name, base_model_name):
k = list(lora_weights.keys())[0]
assert k.startswith(
"llama."
- ), f"You Must Manually Replace 'model' to 'llama'. Please Refer to do_replace_model_llama.py"
+ ), "You Must Manually Replace 'model' to 'llama'. Please Refer to do_replace_model_llama.py"
model = LoRAModel.from_pretrained(base_model, peft_model_name, lora_config=lora_config, dtype="bfloat16")
return model
else:
@@ -87,7 +87,7 @@ def get_args():
passage_prefix = ""
if args.task_name == "QuoraRetrieval":
- assert args.document_instruction != "document: ", f"QuoraRetrieval requires a document instruction"
+ assert args.document_instruction != "document: ", "QuoraRetrieval requires a document instruction"
passage_prefix = "Instruct: " + args.document_instruction + "\nQuery: " # because this is STS task
encode_model = NVEncodeModel.from_pretrained(
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models.py b/slm/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models.py
rename to slm/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models.py
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py b/slm/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py
similarity index 83%
rename from legacy/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py
rename to slm/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py
index 43cc7f6aa134..5378630a87e6 100755
--- a/legacy/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py
+++ b/slm/pipelines/examples/contrastive_training/evaluation/mteb/mteb_models_nv.py
@@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
-from typing import Dict, List, Union, cast
+from typing import Dict, List, Union
import numpy as np
import paddle
@@ -78,33 +77,43 @@ class LatentModel(PretrainedModel):
def __init__(self, config):
super().__init__(config)
- self.cross_attend_blocks_0_fn_to_kv = paddle.nn.Linear(in_features=config.hidden_size, out_features=2*config.max_position_embeddings, bias_attr=False)
- self.cross_attend_blocks_0_fn_to_out = paddle.nn.Linear(in_features=config.max_position_embeddings, out_features=config.hidden_size, bias_attr=False)
- self.cross_attend_blocks_0_fn_to_q = paddle.nn.Linear(in_features=config.hidden_size, out_features=config.max_position_embeddings, bias_attr=False)
+ self.cross_attend_blocks_0_fn_to_kv = paddle.nn.Linear(
+ in_features=config.hidden_size, out_features=2 * config.max_position_embeddings, bias_attr=False
+ )
+ self.cross_attend_blocks_0_fn_to_out = paddle.nn.Linear(
+ in_features=config.max_position_embeddings, out_features=config.hidden_size, bias_attr=False
+ )
+ self.cross_attend_blocks_0_fn_to_q = paddle.nn.Linear(
+ in_features=config.hidden_size, out_features=config.max_position_embeddings, bias_attr=False
+ )
self.cross_attend_blocks_0_norm = paddle.nn.LayerNorm(config.hidden_size)
self.cross_attend_blocks_0_norm_context = paddle.nn.LayerNorm(config.hidden_size)
- self.cross_attend_blocks_1_fn_net_0 = paddle.nn.Linear(in_features=config.hidden_size, out_features=config.max_position_embeddings)
- self.cross_attend_blocks_1_fn_net_2 = paddle.nn.Linear(in_features=config.max_position_embeddings//2, out_features=config.hidden_size)
+ self.cross_attend_blocks_1_fn_net_0 = paddle.nn.Linear(
+ in_features=config.hidden_size, out_features=config.max_position_embeddings
+ )
+ self.cross_attend_blocks_1_fn_net_2 = paddle.nn.Linear(
+ in_features=config.max_position_embeddings // 2, out_features=config.hidden_size
+ )
self.cross_attend_blocks_1_norm = paddle.nn.LayerNorm(config.hidden_size)
self.latents = paddle.nn.Linear(in_features=config.hidden_size, out_features=512, bias_attr=False)
def forward(self, last_hidden_states, pool_mask):
- latents = paddle.stack([self.latents.weight.T for _ in range(last_hidden_states.shape[0])])
+ latents = paddle.stack([self.latents.weight.T for _ in range(last_hidden_states.shape[0])])
+
+ normed_x = self.cross_attend_blocks_0_norm(last_hidden_states)
+ normed_context = self.cross_attend_blocks_0_norm_context(latents)
- normed_x = self.cross_attend_blocks_0_norm(last_hidden_states)
- normed_context = self.cross_attend_blocks_0_norm_context(latents)
+ q = self.cross_attend_blocks_0_fn_to_q(normed_x)
+ kv = self.cross_attend_blocks_0_fn_to_kv(normed_context)
+ k = kv[:, :, : self.config.max_position_embeddings]
+ v = kv[:, :, self.config.max_position_embeddings :]
- q = self.cross_attend_blocks_0_fn_to_q(normed_x)
- kv = self.cross_attend_blocks_0_fn_to_kv(normed_context)
- k = kv[:, :, :self.config.max_position_embeddings]
- v = kv[:, :, self.config.max_position_embeddings:]
+ q, k, v = map(lambda t: rearrange(t, "b n (h d) -> b n h d", h=self.config.num_key_value_heads), (q, k, v))
- q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b n h d', h=self.config.num_key_value_heads), (q, k, v))
-
- out = paddle.nn.functional.scaled_dot_product_attention(q, k, v)
- out = rearrange(out, 'b n h d -> b n (h d)', h=self.config.num_key_value_heads)
+ out = paddle.nn.functional.scaled_dot_product_attention(q, k, v)
+ out = rearrange(out, "b n h d -> b n (h d)", h=self.config.num_key_value_heads)
out_of_layer1 = self.cross_attend_blocks_0_fn_to_out(out) + last_hidden_states
@@ -112,17 +121,17 @@ def forward(self, last_hidden_states, pool_mask):
before_geglu = self.cross_attend_blocks_1_fn_net_0(normed_x)
- x_in_gegle = before_geglu[:, :, :self.config.max_position_embeddings//2]
- gate_in_geglu = before_geglu[:, :, self.config.max_position_embeddings//2:]
+ x_in_gegle = before_geglu[:, :, : self.config.max_position_embeddings // 2]
+ gate_in_geglu = before_geglu[:, :, self.config.max_position_embeddings // 2 :]
x_after_geglu = x_in_gegle * paddle.nn.functional.gelu(gate_in_geglu)
after_geglu = self.cross_attend_blocks_1_fn_net_2(x_after_geglu)
- out_of_layer2 = after_geglu + out_of_layer1
+ out_of_layer2 = after_geglu + out_of_layer1
- s = paddle.sum(out_of_layer2 * pool_mask.unsqueeze(-1), axis=1)
+ s = paddle.sum(out_of_layer2 * pool_mask.unsqueeze(-1), axis=1)
d = paddle.sum(pool_mask, axis=1, keepdim=True)
- hiddens = s / d
+ hiddens = s / d
hiddens = paddle.nn.functional.normalize(hiddens, p=2, axis=-1)
return hiddens
diff --git a/legacy/pipelines/examples/contrastive_training/evaluation/prediction.py b/slm/pipelines/examples/contrastive_training/evaluation/prediction.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/evaluation/prediction.py
rename to slm/pipelines/examples/contrastive_training/evaluation/prediction.py
diff --git a/legacy/pipelines/examples/contrastive_training/models/__init__.py b/slm/pipelines/examples/contrastive_training/models/__init__.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/models/__init__.py
rename to slm/pipelines/examples/contrastive_training/models/__init__.py
diff --git a/legacy/pipelines/examples/contrastive_training/models/modeling.py b/slm/pipelines/examples/contrastive_training/models/modeling.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/models/modeling.py
rename to slm/pipelines/examples/contrastive_training/models/modeling.py
diff --git a/legacy/pipelines/examples/contrastive_training/requirements.txt b/slm/pipelines/examples/contrastive_training/requirements.txt
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/requirements.txt
rename to slm/pipelines/examples/contrastive_training/requirements.txt
diff --git a/legacy/pipelines/examples/contrastive_training/train.py b/slm/pipelines/examples/contrastive_training/train.py
similarity index 100%
rename from legacy/pipelines/examples/contrastive_training/train.py
rename to slm/pipelines/examples/contrastive_training/train.py
diff --git a/legacy/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md b/slm/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md
similarity index 82%
rename from legacy/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md
rename to slm/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md
index 7d86a01b2933..d4841ac40186 100644
--- a/legacy/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md
+++ b/slm/pipelines/examples/image_text_retrieval/IMAGE_TO_TEXT_SEARCH.md
@@ -17,7 +17,7 @@
+ 端到端
+ 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端图搜文跨模态检索系统能力
- + 依托百度领先的NLP技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术,[ERNIE-ViL 2.0](https://arxiv.org/abs/2209.15270)跨模态检索能力
+ + 依托百度领先的 NLP 技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术,[ERNIE-ViL 2.0](https://arxiv.org/abs/2209.15270)跨模态检索能力
+ 预置领先的深度学习模型
## 3. 快速开始: 快速搭建图搜文跨模态检索系统
@@ -41,7 +41,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -59,13 +59,13 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 3.2 数据说明
-图搜文跨模态检索数据库的数据来自于[Noah-Wukong数据集](https://wukong-dataset.github.io/wukong-dataset/index.html),并选取了测试集中3056张图片来搭建图搜文跨模态检索系统。
+图搜文跨模态检索数据库的数据来自于[Noah-Wukong 数据集](https://wukong-dataset.github.io/wukong-dataset/index.html),并选取了测试集中3056张图片来搭建图搜文跨模态检索系统。
### 3.3 一键体验图搜文跨模态检索系统
#### 3.3.1 快速一键启动
-我们预置了基于[Noah-Wukong数据集](https://wukong-dataset.github.io/wukong-dataset/index.html)搭建图搜文跨模态检索系统的代码示例,您可以通过如下命令快速体验图搜文跨模态检索系统的效果
+我们预置了基于[Noah-Wukong 数据集](https://wukong-dataset.github.io/wukong-dataset/index.html)搭建图搜文跨模态检索系统的代码示例,您可以通过如下命令快速体验图搜文跨模态检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -116,11 +116,11 @@ curl http://localhost:9200/wukong_text/_search
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: ANN索引引擎的IP地址
-* `port`: ANN索引引擎的端口号
-* `search_engine`: 选择的近似索引引擎elastic,milvus,默认elastic
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: ANN 索引引擎的 IP 地址
+* `port`: ANN 索引引擎的端口号
+* `search_engine`: 选择的近似索引引擎 elastic,milvus,默认 elastic
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
删除索引也可以使用下面的命令:
@@ -136,7 +136,7 @@ export PIPELINE_YAML_PATH=rest_api/pipeline/image_to_text_retrieval.yaml
python rest_api/application.py 8891
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X 'POST' \
@@ -147,7 +147,7 @@ curl -X 'POST' \
-F 'meta={"Retriever": {"top_k": 2, "query_type":"image"}}'
```
-更多API接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+更多 API 接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
#### 3.4.4 启动 WebUI
```bash
@@ -174,7 +174,7 @@ python utils/offline_ann_mm.py --index_name wukong_text \
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/image_text_retrieval/README.md b/slm/pipelines/examples/image_text_retrieval/README.md
similarity index 79%
rename from legacy/pipelines/examples/image_text_retrieval/README.md
rename to slm/pipelines/examples/image_text_retrieval/README.md
index cc41077478cf..19f02e3f1880 100644
--- a/legacy/pipelines/examples/image_text_retrieval/README.md
+++ b/slm/pipelines/examples/image_text_retrieval/README.md
@@ -2,7 +2,7 @@
## 1. 场景概述
-文图跨模态检索系统目的是通过文字找到最符合描述的图片。传统的方案是用标签和图片的关键字进行匹配,而跨模态检索真正的实现了文本语义和图片语义内容的匹配,这种检索方式更符合人类的逻辑判断,是一种真正意义上的端到端人工智能。文图应用目前可以广泛应用于电商搜索,安防视频,图像检索,抖音等小视频,旅游app应用搜索。有助于提升效率和搜索体验。另外还有一些潜在的领域,比如司法的互联网调查取证,侵权检测,数据增强,文案匹配,各种互联网logo,肖像,风景,海报等图片网站的检索,医药等专业领域的文图搜索等。
+文图跨模态检索系统目的是通过文字找到最符合描述的图片。传统的方案是用标签和图片的关键字进行匹配,而跨模态检索真正的实现了文本语义和图片语义内容的匹配,这种检索方式更符合人类的逻辑判断,是一种真正意义上的端到端人工智能。文图应用目前可以广泛应用于电商搜索,安防视频,图像检索,抖音等小视频,旅游 app 应用搜索。有助于提升效率和搜索体验。另外还有一些潜在的领域,比如司法的互联网调查取证,侵权检测,数据增强,文案匹配,各种互联网 logo,肖像,风景,海报等图片网站的检索,医药等专业领域的文图搜索等。
## 2. 产品功能介绍
@@ -18,7 +18,7 @@
+ 端到端
+ 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端文图跨模态检索系统能力
- + 依托百度领先的NLP技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术,[ERNIE-ViL 2.0](https://arxiv.org/abs/2209.15270)跨模态检索能力
+ + 依托百度领先的 NLP 技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术,[ERNIE-ViL 2.0](https://arxiv.org/abs/2209.15270)跨模态检索能力
+ 预置领先的深度学习模型
## 3. 快速开始: 快速搭建文图跨模态检索系统
@@ -42,7 +42,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -60,13 +60,13 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 3.2 数据说明
-文图跨模态检索数据库的数据来自于[Noah-Wukong数据集](https://wukong-dataset.github.io/wukong-dataset/index.html),并选取了测试集中3056张图片来搭建文图跨模态检索系统。
+文图跨模态检索数据库的数据来自于[Noah-Wukong 数据集](https://wukong-dataset.github.io/wukong-dataset/index.html),并选取了测试集中3056张图片来搭建文图跨模态检索系统。
### 3.3 一键体验文图跨模态检索系统
#### 3.3.1 快速一键启动
-我们预置了基于[Noah-Wukong数据集](https://wukong-dataset.github.io/wukong-dataset/index.html)搭建文图跨模态检索系统的代码示例,您可以通过如下命令快速体验文图跨模态检索系统的效果
+我们预置了基于[Noah-Wukong 数据集](https://wukong-dataset.github.io/wukong-dataset/index.html)搭建文图跨模态检索系统的代码示例,您可以通过如下命令快速体验文图跨模态检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -116,11 +116,11 @@ curl http://localhost:9200/wukong_test/_search
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: ANN索引引擎的IP地址
-* `port`: ANN索引引擎的端口号
-* `search_engine`: 选择的近似索引引擎elastic,milvus,默认elastic
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: ANN 索引引擎的 IP 地址
+* `port`: ANN 索引引擎的端口号
+* `search_engine`: 选择的近似索引引擎 elastic,milvus,默认 elastic
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
删除索引也可以使用下面的命令:
@@ -140,13 +140,13 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
```bash
sh examples/image_text_retrieval/run_search_server.sh
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "云南普者黑现纯白色⒌蒂莲","params": {"Retriever": {"top_k": 5}}}'
```
-更多API接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+更多 API 接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
#### 3.4.4 启动 WebUI
```bash
@@ -177,7 +177,7 @@ python utils/offline_ann_mm.py --index_name wukong_test \
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/image_text_retrieval/image_to_text_retrieval_example.py b/slm/pipelines/examples/image_text_retrieval/image_to_text_retrieval_example.py
similarity index 100%
rename from legacy/pipelines/examples/image_text_retrieval/image_to_text_retrieval_example.py
rename to slm/pipelines/examples/image_text_retrieval/image_to_text_retrieval_example.py
diff --git a/legacy/pipelines/examples/image_text_retrieval/run_search_server.sh b/slm/pipelines/examples/image_text_retrieval/run_search_server.sh
similarity index 100%
rename from legacy/pipelines/examples/image_text_retrieval/run_search_server.sh
rename to slm/pipelines/examples/image_text_retrieval/run_search_server.sh
diff --git a/legacy/pipelines/examples/image_text_retrieval/run_search_web.sh b/slm/pipelines/examples/image_text_retrieval/run_search_web.sh
similarity index 100%
rename from legacy/pipelines/examples/image_text_retrieval/run_search_web.sh
rename to slm/pipelines/examples/image_text_retrieval/run_search_web.sh
diff --git a/legacy/pipelines/examples/image_text_retrieval/text_to_image_retrieval_example.py b/slm/pipelines/examples/image_text_retrieval/text_to_image_retrieval_example.py
similarity index 100%
rename from legacy/pipelines/examples/image_text_retrieval/text_to_image_retrieval_example.py
rename to slm/pipelines/examples/image_text_retrieval/text_to_image_retrieval_example.py
diff --git a/legacy/pipelines/examples/question-answering/Install_windows.md b/slm/pipelines/examples/question-answering/Install_windows.md
similarity index 72%
rename from legacy/pipelines/examples/question-answering/Install_windows.md
rename to slm/pipelines/examples/question-answering/Install_windows.md
index 1e331f169633..51ebd351390c 100644
--- a/legacy/pipelines/examples/question-answering/Install_windows.md
+++ b/slm/pipelines/examples/question-answering/Install_windows.md
@@ -1,13 +1,13 @@
-# WINDOWS环境下搭建端到端智能问答系统
+# WINDOWS 环境下搭建端到端智能问答系统
-以下的流程都是使用的Anaconda的环境进行的搭建,Anaconda安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
+以下的流程都是使用的 Anaconda 的环境进行的搭建,Anaconda 安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
## 1. 快速开始: 城市百科知识问答系统搭建
### 1.1 运行环境和安装说明
a. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
git clone https://github.com/tvst/htbuilder.git
cd htbuilder/
@@ -40,7 +40,7 @@ python examples/question-answering/dense_qa_example.py --device gpu
# 如果只有 CPU 机器,安装CPU版本的Paddle后,可以通过 --device 参数指定 cpu 即可, 运行耗时较长
python examples/question-answering/dense_qa_example.py --device cpu
```
-`dense_qa_example.py`中`DensePassageRetriever`,`ErnieRanker`和`ErnieReader`的模型介绍请参考[API介绍](../../API.md)
+`dense_qa_example.py`中`DensePassageRetriever`,`ErnieRanker`和`ErnieReader`的模型介绍请参考[API 介绍](../../API.md)
### 1.4 构建 Web 可视化问答系统
@@ -49,15 +49,15 @@ python examples/question-answering/dense_qa_example.py --device cpu
#### 1.4.1 启动 ANN 服务
1. 参考官方文档下载安装 [elasticsearch-8.3.2](https://www.elastic.co/cn/downloads/elasticsearch) 并解压。
2. 启动 ES 服务
-把`xpack.security.enabled` 设置成false,如下:
+把`xpack.security.enabled` 设置成 false,如下:
```
xpack.security.enabled: false
```
-然后直接双击bin目录下的elasticsearch.bat即可启动。
+然后直接双击 bin 目录下的 elasticsearch.bat 即可启动。
-3. elasticsearch可视化工具Kibana(可选)
-为了更好的对数据进行管理,可以使用Kibana可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
+3. elasticsearch 可视化工具 Kibana(可选)
+为了更好的对数据进行管理,可以使用 Kibana 可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
#### 1.4.2 文档数据写入 ANN 索引库
```
@@ -66,10 +66,10 @@ python utils/offline_ann.py --index_name baike_cities --doc_dir data/baike --que
```
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
运行成功后会输出如下的日志:
@@ -79,11 +79,11 @@ INFO - pipelines.utils.logger - Logged parameters:
INFO - pipelines.document_stores.elasticsearch - Updating embeddings for all 1318 docs ...
Updating embeddings: 10000 Docs [00:16, 617.76 Docs/s]
```
-运行结束后,可使用Kibana查看数据
+运行结束后,可使用 Kibana 查看数据
#### 1.4.3 启动 RestAPI 模型服务
-**注意** dense_qa.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** dense_qa.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定智能问答系统的Yaml配置文件
@@ -104,7 +104,7 @@ python -m streamlit run ui/webapp_question_answering.py --server.port 8502
#### 1.4.5 数据更新
-数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -116,4 +116,4 @@ python -m streamlit run ui/webapp_question_answering.py --server.port 8502
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
diff --git a/legacy/pipelines/examples/question-answering/README.md b/slm/pipelines/examples/question-answering/README.md
similarity index 83%
rename from legacy/pipelines/examples/question-answering/README.md
rename to slm/pipelines/examples/question-answering/README.md
index 4e46d864fed0..0a73a470c655 100644
--- a/legacy/pipelines/examples/question-answering/README.md
+++ b/slm/pipelines/examples/question-answering/README.md
@@ -12,7 +12,7 @@
## 2. 产品功能介绍
-本项目提供了低成本搭建端到端问答系统的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的问答系统模型(召回模型、排序模型、阅读理解模型)快速搭建一个针对自己业务数据的问答系统,并可以提供基于[Streamlit](https://streamlit.io/) 的 Web 可视化服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,对于召回和排序模型训练可以参考[Neural Search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/neural_search),对于其中的答案抽取模型,训练教程请参考[machine_reading_comprehension](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/machine_reading_comprehension/DuReader-robust),召回和排序模型接入流程参考语义检索的Neural Search接入流程即可,阅读理解模型只需要在加载模型的时候,把模型名称换成您的模型的路径即可。
+本项目提供了低成本搭建端到端问答系统的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的问答系统模型(召回模型、排序模型、阅读理解模型)快速搭建一个针对自己业务数据的问答系统,并可以提供基于[Streamlit](https://streamlit.io/) 的 Web 可视化服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,对于召回和排序模型训练可以参考[Neural Search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/neural_search),对于其中的答案抽取模型,训练教程请参考[machine_reading_comprehension](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/examples/machine_reading_comprehension/DuReader-robust),召回和排序模型接入流程参考语义检索的 Neural Search 接入流程即可,阅读理解模型只需要在加载模型的时候,把模型名称换成您的模型的路径即可。

@@ -24,12 +24,12 @@
+ 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端问答系统能力
+ 多源数据支持: 支持对 Txt、Word、PDF、Image 多源数据进行解析、识别并写入 ANN 数据库
+ 效果好
- + 依托百度领先的NLP技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ + 依托百度领先的 NLP 技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ 预置领先的深度学习模型
## 3. 快速开始: 城市百科知识问答系统搭建
-以下是针对mac和linux的安装流程,windows的安装和使用流程请参考[windows](./Install_windows.md)
+以下是针对 mac 和 linux 的安装流程,windows 的安装和使用流程请参考[windows](./Install_windows.md)
### 3.1 运行环境和安装说明
@@ -49,7 +49,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -82,7 +82,7 @@ python examples/question-answering/dense_qa_example.py --device gpu
unset CUDA_VISIBLE_DEVICES
python examples/question-answering/dense_qa_example.py --device cpu
```
-`dense_qa_example.py`中`DensePassageRetriever`,`ErnieRanker`和`ErnieReader`的模型介绍请参考[API介绍](../../API.md)
+`dense_qa_example.py`中`DensePassageRetriever`,`ErnieRanker`和`ErnieReader`的模型介绍请参考[API 介绍](../../API.md)
### 3.4 构建 Web 可视化问答系统
@@ -118,10 +118,10 @@ python utils/offline_ann.py --index_name baike_cities \
```
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
运行成功后会输出如下的日志:
```
@@ -142,7 +142,7 @@ curl -XGET http://localhost:9200/baike_cities/_count
#### 3.4.3 启动 RestAPI 模型服务
-**注意** dense_qa.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** dense_qa.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定智能问答系统的Yaml配置文件
@@ -155,12 +155,12 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
```bash
sh examples/question-answering/run_qa_server.sh
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "北京市有多少个行政区?","params": {"Retriever": {"top_k": 5}, "Ranker":{"top_k": 5}}}'
```
-更多API接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+更多 API 接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
#### 3.4.4 启动 WebUI
```bash
@@ -180,7 +180,7 @@ sh examples/question-answering/run_qa_web.sh
#### 3.4.5 数据更新
-数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -192,7 +192,7 @@ sh examples/question-answering/run_qa_web.sh
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/question-answering/dense_qa_example.py b/slm/pipelines/examples/question-answering/dense_qa_example.py
similarity index 100%
rename from legacy/pipelines/examples/question-answering/dense_qa_example.py
rename to slm/pipelines/examples/question-answering/dense_qa_example.py
diff --git a/legacy/pipelines/examples/question-answering/run_qa_server.sh b/slm/pipelines/examples/question-answering/run_qa_server.sh
similarity index 100%
rename from legacy/pipelines/examples/question-answering/run_qa_server.sh
rename to slm/pipelines/examples/question-answering/run_qa_server.sh
diff --git a/legacy/pipelines/examples/question-answering/run_qa_web.sh b/slm/pipelines/examples/question-answering/run_qa_web.sh
similarity index 100%
rename from legacy/pipelines/examples/question-answering/run_qa_web.sh
rename to slm/pipelines/examples/question-answering/run_qa_web.sh
diff --git a/legacy/pipelines/examples/semantic-search/Install_windows.md b/slm/pipelines/examples/semantic-search/Install_windows.md
similarity index 63%
rename from legacy/pipelines/examples/semantic-search/Install_windows.md
rename to slm/pipelines/examples/semantic-search/Install_windows.md
index 1d512ec274f8..14237e119eec 100644
--- a/legacy/pipelines/examples/semantic-search/Install_windows.md
+++ b/slm/pipelines/examples/semantic-search/Install_windows.md
@@ -1,12 +1,12 @@
-# WINDOWS环境下搭建端到端语义检索系统
-以下的流程都是使用的Anaconda的环境进行的搭建,Anaconda安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
+# WINDOWS 环境下搭建端到端语义检索系统
+以下的流程都是使用的 Anaconda 的环境进行的搭建,Anaconda 安装好以后,进入 `Anaconda Powershell Prompt`(由于环境变量设置不兼容的原因,暂不支持使用`cmd`执行下面的命令),然后执行下面的流程。
## 1. 快速开始: 快速搭建语义检索系统
### 1.1 运行环境和安装说明
a. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
git clone https://github.com/tvst/htbuilder.git
cd htbuilder/
@@ -27,17 +27,17 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 1.2 数据说明
-语义检索数据库的数据来自于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
+语义检索数据库的数据来自于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
### 1.3 一键体验语义检索系统
-我们预置了基于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
+我们预置了基于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
python examples/semantic-search/semantic_search_example.py --device gpu
# 如果只有 CPU 机器,安装CPU版本的Paddle后,可以通过 --device 参数指定 cpu 即可, 运行耗时较长
python examples/semantic-search/semantic_search_example.py --device cpu
```
-`semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API介绍](../../API.md)
+`semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API 介绍](../../API.md)
### 1.4 构建 Web 可视化语义检索系统
@@ -46,15 +46,15 @@ python examples/semantic-search/semantic_search_example.py --device cpu
#### 1.4.1 启动 ANN 服务
1. 参考官方文档下载安装 [elasticsearch-8.3.2](https://www.elastic.co/cn/downloads/elasticsearch) 并解压。
2. 启动 ES 服务
-把`xpack.security.enabled` 设置成false,如下:
+把`xpack.security.enabled` 设置成 false,如下:
```
xpack.security.enabled: false
```
-然后直接双击bin目录下的elasticsearch.bat即可启动。
+然后直接双击 bin 目录下的 elasticsearch.bat 即可启动。
-3. elasticsearch可视化工具Kibana(可选)
-为了更好的对数据进行管理,可以使用Kibana可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
+3. elasticsearch 可视化工具 Kibana(可选)
+为了更好的对数据进行管理,可以使用 Kibana 可视化工具进行管理和分析,下载链接为[Kibana](https://www.elastic.co/cn/downloads/kibana),下载完后解压,直接双击运行 `bin\kibana.bat`即可。
#### 1.4.2 文档数据写入 ANN 索引库
```
@@ -63,16 +63,16 @@ python utils/offline_ann.py --index_name dureader_robust_query_encoder --doc_dir
```
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
-运行结束后,可使用Kibana查看数据
+运行结束后,可使用 Kibana 查看数据
#### 1.4.3 启动 RestAPI 模型服务
-**注意** semantic_search.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** semantic_search.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定语义检索系统的Yaml配置文件
@@ -94,7 +94,7 @@ python -m streamlit run ui/webapp_semantic_search.py --server.port 8502
#### 1.4.5 数据更新
-数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -106,4 +106,4 @@ python -m streamlit run ui/webapp_semantic_search.py --server.port 8502
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
diff --git a/legacy/pipelines/examples/semantic-search/Multi_Recall.md b/slm/pipelines/examples/semantic-search/Multi_Recall.md
similarity index 72%
rename from legacy/pipelines/examples/semantic-search/Multi_Recall.md
rename to slm/pipelines/examples/semantic-search/Multi_Recall.md
index 5627614090f2..ef398405ba3e 100644
--- a/legacy/pipelines/examples/semantic-search/Multi_Recall.md
+++ b/slm/pipelines/examples/semantic-search/Multi_Recall.md
@@ -2,7 +2,7 @@
## 1. 概述
-多路召回是指采用不同的策略、特征或者简单的模型,分别召回一部分候选集合,然后把这些候选集混合在一起供后续的排序模型进行重排,也可以定制自己的重排序的规则等等。本项目使用关键字和语义检索两路召回的检索系统,系统的架构如下,用户输入的Query会分别通过关键字召回BMRetriever(Okapi BM 25算法,Elasticsearch默认使用的相关度评分算法,是基于词频和文档频率和文档长度相关性来计算相关度),语义向量检索召回DenseRetriever(使用RocketQA抽取向量,然后比较向量之间相似度)后得到候选集,然后通过JoinResults进行结果聚合,最后通过通用的Ranker模块得到重排序的结果返回给用户。
+多路召回是指采用不同的策略、特征或者简单的模型,分别召回一部分候选集合,然后把这些候选集混合在一起供后续的排序模型进行重排,也可以定制自己的重排序的规则等等。本项目使用关键字和语义检索两路召回的检索系统,系统的架构如下,用户输入的 Query 会分别通过关键字召回 BMRetriever(Okapi BM 25算法,Elasticsearch 默认使用的相关度评分算法,是基于词频和文档频率和文档长度相关性来计算相关度),语义向量检索召回 DenseRetriever(使用 RocketQA 抽取向量,然后比较向量之间相似度)后得到候选集,然后通过 JoinResults 进行结果聚合,最后通过通用的 Ranker 模块得到重排序的结果返回给用户。

@@ -36,7 +36,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -54,12 +54,12 @@ cd PaddleNLP/pipelines
【注意】
-- Windows的安装复杂一点,教程请参考:[Windows视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
+- Windows 的安装复杂一点,教程请参考:[Windows 视频安装教程](https://www.bilibili.com/video/BV1DY4y1M7HE)
- 以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 3.2 数据说明
-语义检索数据库的数据来自于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
+语义检索数据库的数据来自于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
### 3.3 一键体验语义检索系统
@@ -82,7 +82,7 @@ curl http://localhost:9200/_aliases?pretty=true
#### 3.3.2 快速一键启动
-我们预置了基于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
+我们预置了基于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -94,28 +94,28 @@ unset CUDA_VISIBLE_DEVICES
python examples/semantic-search/multi_recall_semantic_search_example.py --device cpu \
--search_engine elastic
```
-`multi_recall_semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API介绍](../../API.md)
+`multi_recall_semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API 介绍](../../API.md)
参数含义说明
-* `device`: 设备名称,cpu/gpu,默认为gpu
+* `device`: 设备名称,cpu/gpu,默认为 gpu
* `index_name`: 索引的名称
-* `search_engine`: 选择的近似索引引擎elastic,milvus,默认elastic
-* `max_seq_len_query`: query的最大长度,默认是64
-* `max_seq_len_passage`: passage的最大长度,默认是384
+* `search_engine`: 选择的近似索引引擎 elastic,milvus,默认 elastic
+* `max_seq_len_query`: query 的最大长度,默认是64
+* `max_seq_len_passage`: passage 的最大长度,默认是384
* `retriever_batch_size`: 召回模型一次处理的数据的数量
-* `query_embedding_model`: query模型的名称,默认为rocketqa-zh-nano-query-encoder
-* `passage_embedding_model`: 段落模型的名称,默认为rocketqa-zh-nano-para-encoder
-* `params_path`: Neural Search的召回模型的名称,默认为
-* `embedding_dim`: 模型抽取的向量的维度,默认为312,为rocketqa-zh-nano-query-encoder的向量维度
-* `host`: ANN索引引擎的IP地址
-* `port`: ANN索引引擎的端口号
-* `bm_topk`: 关键字召回节点BM25Retriever的召回数量
-* `dense_topk`: 语义向量召回节点DensePassageRetriever的召回数量
-* `rank_topk`: 排序模型节点ErnieRanker的排序过滤数量
+* `query_embedding_model`: query 模型的名称,默认为 rocketqa-zh-nano-query-encoder
+* `passage_embedding_model`: 段落模型的名称,默认为 rocketqa-zh-nano-para-encoder
+* `params_path`: Neural Search 的召回模型的名称,默认为
+* `embedding_dim`: 模型抽取的向量的维度,默认为312,为 rocketqa-zh-nano-query-encoder 的向量维度
+* `host`: ANN 索引引擎的 IP 地址
+* `port`: ANN 索引引擎的端口号
+* `bm_topk`: 关键字召回节点 BM25Retriever 的召回数量
+* `dense_topk`: 语义向量召回节点 DensePassageRetriever 的召回数量
+* `rank_topk`: 排序模型节点 ErnieRanker 的排序过滤数量
### 3.4 构建 Web 可视化语义检索系统
-整个 Web 可视化语义检索系统主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,搭建ANN服务请参考1.3.1节,接下来我们依次搭建后台和前端两个服务。
+整个 Web 可视化语义检索系统主要包含 3 大组件: 1. 基于 ElasticSearch 的 ANN 服务 2. 基于 RestAPI 构建模型服务 3. 基于 Streamlit 构建 WebUI,搭建 ANN 服务请参考1.3.1节,接下来我们依次搭建后台和前端两个服务。
#### 3.4.1 文档数据写入 ANN 索引库
```
@@ -137,15 +137,15 @@ curl http://localhost:9200/dureader_robust_query_encoder/_search
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: ANN索引引擎的IP地址
-* `port`: ANN索引引擎的端口号
-* `search_engine`: 选择的近似索引引擎elastic,milvus,默认elastic
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: ANN 索引引擎的 IP 地址
+* `port`: ANN 索引引擎的端口号
+* `search_engine`: 选择的近似索引引擎 elastic,milvus,默认 elastic
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
#### 3.4.2 启动 RestAPI 模型服务
-**注意** multi_recall_semantic_search.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** multi_recall_semantic_search.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定语义检索系统的Yaml配置文件
@@ -153,7 +153,7 @@ export PIPELINE_YAML_PATH=rest_api/pipeline/multi_recall_semantic_search.yaml
# 使用端口号 8891 启动模型服务
python rest_api/application.py 8891
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "衡量酒水的价格的因素有哪些?","params": {"BMRetriever": {"top_k": 10}, "DenseRetriever": {"top_k": 10}, "Ranker":{"top_k": 3}}}'
@@ -181,7 +181,7 @@ python utils/offline_ann.py --index_name dureader_robust_query_encoder \
--delete_index
```
-对于第二种使用界面的方式,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+对于第二种使用界面的方式,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -192,7 +192,7 @@ python utils/offline_ann.py --index_name dureader_robust_query_encoder \
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/semantic-search/Neural_Search.md b/slm/pipelines/examples/semantic-search/Neural_Search.md
similarity index 85%
rename from legacy/pipelines/examples/semantic-search/Neural_Search.md
rename to slm/pipelines/examples/semantic-search/Neural_Search.md
index d23988f2ff0b..9a98cbb31338 100644
--- a/legacy/pipelines/examples/semantic-search/Neural_Search.md
+++ b/slm/pipelines/examples/semantic-search/Neural_Search.md
@@ -21,7 +21,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -40,13 +40,13 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 1.2 数据说明
-语义检索数据库的数据来自于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
+语义检索数据库的数据来自于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
### 1.3 一键体验语义检索系统
#### 1.3.1 快速一键启动
-我们预置了基于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
+我们预置了基于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -105,10 +105,10 @@ curl http://localhost:9200/dureader_robust_neural_search/_search
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: Elasticsearch的IP地址
-* `port`: Elasticsearch的端口号
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
+* `doc_dir`: txt 文本数据的路径
+* `host`: Elasticsearch 的 IP 地址
+* `port`: Elasticsearch 的端口号
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
#### 1.4.3 启动 RestAPI 模型服务
```bash
@@ -122,7 +122,7 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
```bash
sh examples/semantic-search/run_neural_search_server.sh
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "衡量酒水的价格的因素有哪些?","params": {"Retriever": {"top_k": 5}, "Ranker":{"top_k": 5}}}'
@@ -146,7 +146,7 @@ sh examples/semantic-search/run_search_web.sh
#### 1.4.5 数据更新
-数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+数据更新的方法有两种,第一种使用前面的 `utils/offline_ann.py`进行数据更新,另一种是使用前端界面的文件上传进行数据更新,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -157,7 +157,7 @@ sh examples/semantic-search/run_search_web.sh
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/semantic-search/README.md b/slm/pipelines/examples/semantic-search/README.md
similarity index 81%
rename from legacy/pipelines/examples/semantic-search/README.md
rename to slm/pipelines/examples/semantic-search/README.md
index d2547ccc23d7..6889e039de31 100644
--- a/legacy/pipelines/examples/semantic-search/README.md
+++ b/slm/pipelines/examples/semantic-search/README.md
@@ -17,7 +17,7 @@
## 2. 产品功能介绍
-本项目提供了低成本搭建端到端语义检索系统的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的语义检索系统模型(召回模型、排序模型)快速搭建一个针对自己业务数据的问答系统,并可以提供 Web 化产品服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,模型训练可以参考[Neural Search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/applications/neural_search),接入流程可以参考[Neural Search的流程](./Neural_Search.md)。
+本项目提供了低成本搭建端到端语义检索系统的能力。用户只需要处理好自己的业务数据,就可以使用本项目预置的语义检索系统模型(召回模型、排序模型)快速搭建一个针对自己业务数据的问答系统,并可以提供 Web 化产品服务。以下是使用预置模型的教程,如果用户想训练并接入自己训练的模型,模型训练可以参考[Neural Search](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/applications/neural_search),接入流程可以参考[Neural Search 的流程](./Neural_Search.md)。

@@ -30,12 +30,12 @@
+ 提供包括数据建库、模型服务部署、WebUI 可视化一整套端到端语义检索系统能力
+ 多源数据支持: 支持对 Txt、Word、PDF、Image 多源数据进行解析、识别并写入 ANN 数据库
+ 效果好
- + 依托百度领先的NLP技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ + 依托百度领先的 NLP 技术,包括[ERNIE](https://github.com/PaddlePaddle/ERNIE)语义理解技术与[RocketQA](https://github.com/PaddlePaddle/RocketQA)开放域问答技术
+ 预置领先的深度学习模型
## 3. 快速开始: 快速搭建语义检索系统
-以下是针对mac和linux的安装流程,windows的安装和使用流程请参考[windows](./Install_windows.md)
+以下是针对 mac 和 linux 的安装流程,windows 的安装和使用流程请参考[windows](./Install_windows.md)
### 3.1 运行环境和安装说明
@@ -55,7 +55,7 @@ b. 硬件环境:
- Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
c. 依赖安装:
-首先需要安装PaddlePaddle,PaddlePaddle的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
+首先需要安装 PaddlePaddle,PaddlePaddle 的安装请参考文档[官方安装文档](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html),然后安装下面的依赖:
```bash
# pip 一键安装
pip install --upgrade paddle-pipelines -i https://pypi.tuna.tsinghua.edu.cn/simple
@@ -73,13 +73,13 @@ cd PaddleNLP/pipelines
【注意】以下的所有的流程都只需要在`pipelines`根目录下进行,不需要跳转目录
### 3.2 数据说明
-语义检索数据库的数据来自于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
+语义检索数据库的数据来自于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust),共包含 46972 个段落文本,并选取了其中验证集1417条段落文本来搭建语义检索系统。
### 3.3 一键体验语义检索系统
#### 3.3.1 快速一键启动
-我们预置了基于[DuReader-Robust数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
+我们预置了基于[DuReader-Robust 数据集](https://github.com/baidu/DuReader/tree/master/DuReader-Robust)搭建语义检索系统的代码示例,您可以通过如下命令快速体验语义检索系统的效果
```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
@@ -91,7 +91,7 @@ unset CUDA_VISIBLE_DEVICES
python examples/semantic-search/semantic_search_example.py --device cpu \
--search_engine faiss
```
-`semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API介绍](../../API.md)
+`semantic_search_example.py`中`DensePassageRetriever`和`ErnieRanker`的模型介绍请参考[API 介绍](../../API.md)
### 3.4 构建 Web 可视化语义检索系统
@@ -136,12 +136,12 @@ curl http://localhost:9200/dureader_robust_query_encoder/_search
参数含义说明
* `index_name`: 索引的名称
-* `doc_dir`: txt文本数据的路径
-* `host`: ANN索引引擎的IP地址
-* `port`: ANN索引引擎的端口号
-* `search_engine`: 选择的近似索引引擎elastic,milvus,默认elastic
-* `delete_index`: 是否删除现有的索引和数据,用于清空es的数据,默认为false
-* `embed_title`: 是否需要对标题建索引,默认为false,标题默认为文件名
+* `doc_dir`: txt 文本数据的路径
+* `host`: ANN 索引引擎的 IP 地址
+* `port`: ANN 索引引擎的端口号
+* `search_engine`: 选择的近似索引引擎 elastic,milvus,默认 elastic
+* `delete_index`: 是否删除现有的索引和数据,用于清空 es 的数据,默认为 false
+* `embed_title`: 是否需要对标题建索引,默认为 false,标题默认为文件名
删除索引也可以使用下面的命令:
@@ -151,7 +151,7 @@ curl -XDELETE http://localhost:9200/dureader_robust_query_encoder
#### 3.4.3 启动 RestAPI 模型服务
-**注意** semantic_search.yaml里面的检索模型需要与前面使用offline_ann.py建库的时候使用的检索模型一致
+**注意** semantic_search.yaml 里面的检索模型需要与前面使用 offline_ann.py 建库的时候使用的检索模型一致
```bash
# 指定语义检索系统的Yaml配置文件
@@ -164,13 +164,13 @@ Linux 用户推荐采用 Shell 脚本来启动服务:
```bash
sh examples/semantic-search/run_search_server.sh
```
-启动后可以使用curl命令验证是否成功运行:
+启动后可以使用 curl 命令验证是否成功运行:
```
curl -X POST -k http://localhost:8891/query -H 'Content-Type: application/json' -d '{"query": "衡量酒水的价格的因素有哪些?","params": {"Retriever": {"top_k": 5}, "Ranker":{"top_k": 5}}}'
```
-更多API接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
+更多 API 接口文档及其调用方式请参考链接[http://127.0.0.1:8891/docs](http://127.0.0.1:8891/docs)
#### 3.4.4 启动 WebUI
@@ -203,7 +203,7 @@ python utils/offline_ann.py --index_name dureader_robust_query_encoder \
--delete_index
```
-对于第二种使用界面的方式,支持txt,pdf,image,word的格式,以txt格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
+对于第二种使用界面的方式,支持 txt,pdf,image,word 的格式,以 txt 格式的文件为例,每段文本需要使用空行隔开,程序会根据空行进行分段建立索引,示例数据如下(demo.txt):
```
兴证策略认为,最恐慌的时候已经过去,未来一个月市场迎来阶段性修复窗口。
@@ -214,7 +214,7 @@ python utils/offline_ann.py --index_name dureader_robust_query_encoder \
长期,继续聚焦科技创新的五大方向。1)新能源(新能源汽车、光伏、风电、特高压等),2)新一代信息通信技术(人工智能、大数据、云计算、5G等),3)高端制造(智能数控机床、机器人、先进轨交装备等),4)生物医药(创新药、CXO、医疗器械和诊断设备等),5)军工(导弹设备、军工电子元器件、空间站、航天飞机等)。
```
-如果安装遇见问题可以查看[FAQ文档](../../FAQ.md)
+如果安装遇见问题可以查看[FAQ 文档](../../FAQ.md)
## Reference
[1]Y. Sun et al., “[ERNIE 3.0: Large-scale Knowledge Enhanced Pre-training for Language Understanding and Generation](https://arxiv.org/pdf/2107.02137.pdf),” arXiv:2107.02137 [cs], Jul. 2021, Accessed: Jan. 17, 2022. [Online]. Available: http://arxiv.org/abs/2107.02137
diff --git a/legacy/pipelines/examples/semantic-search/multi_recall_semantic_search_example.py b/slm/pipelines/examples/semantic-search/multi_recall_semantic_search_example.py
similarity index 100%
rename from legacy/pipelines/examples/semantic-search/multi_recall_semantic_search_example.py
rename to slm/pipelines/examples/semantic-search/multi_recall_semantic_search_example.py
diff --git a/legacy/pipelines/examples/semantic-search/run_neural_search_server.sh b/slm/pipelines/examples/semantic-search/run_neural_search_server.sh
similarity index 100%
rename from legacy/pipelines/examples/semantic-search/run_neural_search_server.sh
rename to slm/pipelines/examples/semantic-search/run_neural_search_server.sh
diff --git a/legacy/pipelines/examples/semantic-search/run_search_server.sh b/slm/pipelines/examples/semantic-search/run_search_server.sh
similarity index 100%
rename from legacy/pipelines/examples/semantic-search/run_search_server.sh
rename to slm/pipelines/examples/semantic-search/run_search_server.sh
diff --git a/legacy/pipelines/examples/semantic-search/run_search_web.sh b/slm/pipelines/examples/semantic-search/run_search_web.sh
similarity index 100%
rename from legacy/pipelines/examples/semantic-search/run_search_web.sh
rename to slm/pipelines/examples/semantic-search/run_search_web.sh
diff --git a/legacy/pipelines/examples/semantic-search/semantic_search_example.py b/slm/pipelines/examples/semantic-search/semantic_search_example.py
similarity index 100%
rename from legacy/pipelines/examples/semantic-search/semantic_search_example.py
rename to slm/pipelines/examples/semantic-search/semantic_search_example.py
diff --git a/legacy/pipelines/examples/tree-of-thought/README.md b/slm/pipelines/examples/tree-of-thought/README.md
similarity index 95%
rename from legacy/pipelines/examples/tree-of-thought/README.md
rename to slm/pipelines/examples/tree-of-thought/README.md
index 7165ba1232e8..12de80dd2b77 100644
--- a/legacy/pipelines/examples/tree-of-thought/README.md
+++ b/slm/pipelines/examples/tree-of-thought/README.md
@@ -16,7 +16,7 @@ pip install -r requirements.txt
2. 请从 https://github.com/ErnestinaQiu/tree-of-thought-llm/tree/master/src/tot/data 获取测试数据,并放置在 pipelines/examples/tree-of-thought/tree/master/src/tot/data
## Quick Start
-以下是脚本,该脚本尝试使用4 5 6 10解决24点游戏(由于使用llama-7b-chat,可能会稍慢一些)
+以下是脚本,该脚本尝试使用4 5 6 10解决24点游戏(由于使用 llama-7b-chat,可能会稍慢一些)
在目录 pipelines/examples/agents/tree-of-thought-llm 下运行
@@ -159,7 +159,7 @@ python run.py \
```
## 测试结果
-本测试采用的是paddlenlp中facebook/llama-2-7b-chat 和 facebook/llama-2-13b-chat.使用的参数为 temperature=0.6, decode_strategy为"greedy_search",max_new_tokens=512,结果如下
+本测试采用的是 paddlenlp 中 facebook/llama-2-7b-chat 和 facebook/llama-2-13b-chat.使用的参数为 temperature=0.6, decode_strategy 为"greedy_search",max_new_tokens=512,结果如下
|model|method|acc|
|----|----|----|
|llama-2-7b-chat|cot|0|
@@ -179,7 +179,7 @@ python run.py \
## 致谢
-我们借鉴了Shunyu Yao ect.出色的框架设计,在此对Tree of Thoughts作者及其开源社区表示感谢。
+我们借鉴了 Shunyu Yao ect.出色的框架设计,在此对 Tree of Thoughts 作者及其开源社区表示感谢。
We learn form the excellent framework design of Shunyu Yao, and we would like to express our thanks to the authors of Tree of Thoughts and their open source community.
diff --git a/legacy/pipelines/examples/tree-of-thought/demo.py b/slm/pipelines/examples/tree-of-thought/demo.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/demo.py
rename to slm/pipelines/examples/tree-of-thought/demo.py
diff --git a/legacy/pipelines/examples/tree-of-thought/requirements.txt b/slm/pipelines/examples/tree-of-thought/requirements.txt
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/requirements.txt
rename to slm/pipelines/examples/tree-of-thought/requirements.txt
diff --git a/legacy/pipelines/examples/tree-of-thought/run.py b/slm/pipelines/examples/tree-of-thought/run.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/run.py
rename to slm/pipelines/examples/tree-of-thought/run.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/llm/__init__.py b/slm/pipelines/examples/tree-of-thought/src/llm/__init__.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/llm/__init__.py
rename to slm/pipelines/examples/tree-of-thought/src/llm/__init__.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/llm/chat_template.json b/slm/pipelines/examples/tree-of-thought/src/llm/chat_template.json
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/llm/chat_template.json
rename to slm/pipelines/examples/tree-of-thought/src/llm/chat_template.json
diff --git a/legacy/pipelines/examples/tree-of-thought/src/llm/ernie_bot.py b/slm/pipelines/examples/tree-of-thought/src/llm/ernie_bot.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/llm/ernie_bot.py
rename to slm/pipelines/examples/tree-of-thought/src/llm/ernie_bot.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/llm/llama.py b/slm/pipelines/examples/tree-of-thought/src/llm/llama.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/llm/llama.py
rename to slm/pipelines/examples/tree-of-thought/src/llm/llama.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/__init__.py b/slm/pipelines/examples/tree-of-thought/src/tot/__init__.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/__init__.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/__init__.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/methods/bfs.py b/slm/pipelines/examples/tree-of-thought/src/tot/methods/bfs.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/methods/bfs.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/methods/bfs.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/models.py b/slm/pipelines/examples/tree-of-thought/src/tot/models.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/models.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/models.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/prompts/crosswords.py b/slm/pipelines/examples/tree-of-thought/src/tot/prompts/crosswords.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/prompts/crosswords.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/prompts/crosswords.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/prompts/game24.py b/slm/pipelines/examples/tree-of-thought/src/tot/prompts/game24.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/prompts/game24.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/prompts/game24.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/prompts/text.py b/slm/pipelines/examples/tree-of-thought/src/tot/prompts/text.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/prompts/text.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/prompts/text.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/tasks/__init__.py b/slm/pipelines/examples/tree-of-thought/src/tot/tasks/__init__.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/tasks/__init__.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/tasks/__init__.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/tasks/base.py b/slm/pipelines/examples/tree-of-thought/src/tot/tasks/base.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/tasks/base.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/tasks/base.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/tasks/crosswords.py b/slm/pipelines/examples/tree-of-thought/src/tot/tasks/crosswords.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/tasks/crosswords.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/tasks/crosswords.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/tasks/game24.py b/slm/pipelines/examples/tree-of-thought/src/tot/tasks/game24.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/tasks/game24.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/tasks/game24.py
diff --git a/legacy/pipelines/examples/tree-of-thought/src/tot/tasks/text.py b/slm/pipelines/examples/tree-of-thought/src/tot/tasks/text.py
similarity index 100%
rename from legacy/pipelines/examples/tree-of-thought/src/tot/tasks/text.py
rename to slm/pipelines/examples/tree-of-thought/src/tot/tasks/text.py
diff --git a/legacy/pipelines/mkdocs.yml b/slm/pipelines/mkdocs.yml
similarity index 99%
rename from legacy/pipelines/mkdocs.yml
rename to slm/pipelines/mkdocs.yml
index 585537d1a5f8..cea1009be299 100644
--- a/legacy/pipelines/mkdocs.yml
+++ b/slm/pipelines/mkdocs.yml
@@ -1,5 +1,5 @@
site_name: PaddleNLP-Pipelines
-repo_url: https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/pipelines
+repo_url: https://github.com/PaddlePaddle/PaddleNLP/tree/develop/slm/pipelines
repo_name: PaddleNLP-Pipelines
site_url: https://paddlenlp-pipelines.readthedocs.io/zh-cn/latest/
site_description: provides an easy-to-use paddlenlp application tool suite.
diff --git a/legacy/pipelines/pipelines/__init__.py b/slm/pipelines/pipelines/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/__init__.py
rename to slm/pipelines/pipelines/__init__.py
diff --git a/legacy/pipelines/pipelines/agents/__init__.py b/slm/pipelines/pipelines/agents/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/__init__.py
rename to slm/pipelines/pipelines/agents/__init__.py
diff --git a/legacy/pipelines/pipelines/agents/agent_step.py b/slm/pipelines/pipelines/agents/agent_step.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/agent_step.py
rename to slm/pipelines/pipelines/agents/agent_step.py
diff --git a/legacy/pipelines/pipelines/agents/base.py b/slm/pipelines/pipelines/agents/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/base.py
rename to slm/pipelines/pipelines/agents/base.py
diff --git a/legacy/pipelines/pipelines/agents/memory/__init__.py b/slm/pipelines/pipelines/agents/memory/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/memory/__init__.py
rename to slm/pipelines/pipelines/agents/memory/__init__.py
diff --git a/legacy/pipelines/pipelines/agents/memory/base.py b/slm/pipelines/pipelines/agents/memory/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/memory/base.py
rename to slm/pipelines/pipelines/agents/memory/base.py
diff --git a/legacy/pipelines/pipelines/agents/memory/conversation_memory.py b/slm/pipelines/pipelines/agents/memory/conversation_memory.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/memory/conversation_memory.py
rename to slm/pipelines/pipelines/agents/memory/conversation_memory.py
diff --git a/legacy/pipelines/pipelines/agents/memory/no_memory.py b/slm/pipelines/pipelines/agents/memory/no_memory.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/memory/no_memory.py
rename to slm/pipelines/pipelines/agents/memory/no_memory.py
diff --git a/legacy/pipelines/pipelines/agents/types.py b/slm/pipelines/pipelines/agents/types.py
similarity index 100%
rename from legacy/pipelines/pipelines/agents/types.py
rename to slm/pipelines/pipelines/agents/types.py
diff --git a/legacy/pipelines/pipelines/data_handler/__init__.py b/slm/pipelines/pipelines/data_handler/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/__init__.py
rename to slm/pipelines/pipelines/data_handler/__init__.py
diff --git a/legacy/pipelines/pipelines/data_handler/dataset.py b/slm/pipelines/pipelines/data_handler/dataset.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/dataset.py
rename to slm/pipelines/pipelines/data_handler/dataset.py
diff --git a/legacy/pipelines/pipelines/data_handler/inputs.py b/slm/pipelines/pipelines/data_handler/inputs.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/inputs.py
rename to slm/pipelines/pipelines/data_handler/inputs.py
diff --git a/legacy/pipelines/pipelines/data_handler/predictions.py b/slm/pipelines/pipelines/data_handler/predictions.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/predictions.py
rename to slm/pipelines/pipelines/data_handler/predictions.py
diff --git a/legacy/pipelines/pipelines/data_handler/processor.py b/slm/pipelines/pipelines/data_handler/processor.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/processor.py
rename to slm/pipelines/pipelines/data_handler/processor.py
diff --git a/legacy/pipelines/pipelines/data_handler/samples.py b/slm/pipelines/pipelines/data_handler/samples.py
similarity index 100%
rename from legacy/pipelines/pipelines/data_handler/samples.py
rename to slm/pipelines/pipelines/data_handler/samples.py
diff --git a/legacy/pipelines/pipelines/document_stores/__init__.py b/slm/pipelines/pipelines/document_stores/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/__init__.py
rename to slm/pipelines/pipelines/document_stores/__init__.py
diff --git a/legacy/pipelines/pipelines/document_stores/base.py b/slm/pipelines/pipelines/document_stores/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/base.py
rename to slm/pipelines/pipelines/document_stores/base.py
diff --git a/legacy/pipelines/pipelines/document_stores/elasticsearch.py b/slm/pipelines/pipelines/document_stores/elasticsearch.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/elasticsearch.py
rename to slm/pipelines/pipelines/document_stores/elasticsearch.py
diff --git a/legacy/pipelines/pipelines/document_stores/faiss.py b/slm/pipelines/pipelines/document_stores/faiss.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/faiss.py
rename to slm/pipelines/pipelines/document_stores/faiss.py
diff --git a/legacy/pipelines/pipelines/document_stores/filter_utils.py b/slm/pipelines/pipelines/document_stores/filter_utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/filter_utils.py
rename to slm/pipelines/pipelines/document_stores/filter_utils.py
diff --git a/legacy/pipelines/pipelines/document_stores/milvus2.py b/slm/pipelines/pipelines/document_stores/milvus2.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/milvus2.py
rename to slm/pipelines/pipelines/document_stores/milvus2.py
diff --git a/legacy/pipelines/pipelines/document_stores/sql.py b/slm/pipelines/pipelines/document_stores/sql.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/sql.py
rename to slm/pipelines/pipelines/document_stores/sql.py
diff --git a/legacy/pipelines/pipelines/document_stores/utils.py b/slm/pipelines/pipelines/document_stores/utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/document_stores/utils.py
rename to slm/pipelines/pipelines/document_stores/utils.py
diff --git a/legacy/pipelines/pipelines/errors.py b/slm/pipelines/pipelines/errors.py
similarity index 100%
rename from legacy/pipelines/pipelines/errors.py
rename to slm/pipelines/pipelines/errors.py
diff --git a/legacy/pipelines/pipelines/nodes/__init__.py b/slm/pipelines/pipelines/nodes/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/__init__.py
rename to slm/pipelines/pipelines/nodes/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/answer_extractor/__init__.py b/slm/pipelines/pipelines/nodes/answer_extractor/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/answer_extractor/__init__.py
rename to slm/pipelines/pipelines/nodes/answer_extractor/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/answer_extractor/answer_extractor.py b/slm/pipelines/pipelines/nodes/answer_extractor/answer_extractor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/answer_extractor/answer_extractor.py
rename to slm/pipelines/pipelines/nodes/answer_extractor/answer_extractor.py
diff --git a/legacy/pipelines/pipelines/nodes/answer_extractor/answer_extractor_preprocessor.py b/slm/pipelines/pipelines/nodes/answer_extractor/answer_extractor_preprocessor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/answer_extractor/answer_extractor_preprocessor.py
rename to slm/pipelines/pipelines/nodes/answer_extractor/answer_extractor_preprocessor.py
diff --git a/legacy/pipelines/pipelines/nodes/answer_extractor/qa_filter.py b/slm/pipelines/pipelines/nodes/answer_extractor/qa_filter.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/answer_extractor/qa_filter.py
rename to slm/pipelines/pipelines/nodes/answer_extractor/qa_filter.py
diff --git a/legacy/pipelines/pipelines/nodes/answer_extractor/qa_filter_postprocessor.py b/slm/pipelines/pipelines/nodes/answer_extractor/qa_filter_postprocessor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/answer_extractor/qa_filter_postprocessor.py
rename to slm/pipelines/pipelines/nodes/answer_extractor/qa_filter_postprocessor.py
diff --git a/legacy/pipelines/pipelines/nodes/base.py b/slm/pipelines/pipelines/nodes/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/base.py
rename to slm/pipelines/pipelines/nodes/base.py
diff --git a/legacy/pipelines/pipelines/nodes/combine_documents/__init__.py b/slm/pipelines/pipelines/nodes/combine_documents/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/combine_documents/__init__.py
rename to slm/pipelines/pipelines/nodes/combine_documents/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/combine_documents/base.py b/slm/pipelines/pipelines/nodes/combine_documents/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/combine_documents/base.py
rename to slm/pipelines/pipelines/nodes/combine_documents/base.py
diff --git a/legacy/pipelines/pipelines/nodes/combine_documents/map_reduce.py b/slm/pipelines/pipelines/nodes/combine_documents/map_reduce.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/combine_documents/map_reduce.py
rename to slm/pipelines/pipelines/nodes/combine_documents/map_reduce.py
diff --git a/legacy/pipelines/pipelines/nodes/combine_documents/reduce.py b/slm/pipelines/pipelines/nodes/combine_documents/reduce.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/combine_documents/reduce.py
rename to slm/pipelines/pipelines/nodes/combine_documents/reduce.py
diff --git a/legacy/pipelines/pipelines/nodes/combine_documents/stuff.py b/slm/pipelines/pipelines/nodes/combine_documents/stuff.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/combine_documents/stuff.py
rename to slm/pipelines/pipelines/nodes/combine_documents/stuff.py
diff --git a/legacy/pipelines/pipelines/nodes/document/__init__.py b/slm/pipelines/pipelines/nodes/document/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/document/__init__.py
rename to slm/pipelines/pipelines/nodes/document/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/document/document_intelligence.py b/slm/pipelines/pipelines/nodes/document/document_intelligence.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/document/document_intelligence.py
rename to slm/pipelines/pipelines/nodes/document/document_intelligence.py
diff --git a/legacy/pipelines/pipelines/nodes/document/document_preprocessor.py b/slm/pipelines/pipelines/nodes/document/document_preprocessor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/document/document_preprocessor.py
rename to slm/pipelines/pipelines/nodes/document/document_preprocessor.py
diff --git a/legacy/pipelines/pipelines/nodes/file_classifier/__init__.py b/slm/pipelines/pipelines/nodes/file_classifier/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_classifier/__init__.py
rename to slm/pipelines/pipelines/nodes/file_classifier/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/file_classifier/file_type.py b/slm/pipelines/pipelines/nodes/file_classifier/file_type.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_classifier/file_type.py
rename to slm/pipelines/pipelines/nodes/file_classifier/file_type.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/__init__.py b/slm/pipelines/pipelines/nodes/file_converter/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/__init__.py
rename to slm/pipelines/pipelines/nodes/file_converter/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/base.py b/slm/pipelines/pipelines/nodes/file_converter/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/base.py
rename to slm/pipelines/pipelines/nodes/file_converter/base.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/docx.py b/slm/pipelines/pipelines/nodes/file_converter/docx.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/docx.py
rename to slm/pipelines/pipelines/nodes/file_converter/docx.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/image.py b/slm/pipelines/pipelines/nodes/file_converter/image.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/image.py
rename to slm/pipelines/pipelines/nodes/file_converter/image.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/markdown.py b/slm/pipelines/pipelines/nodes/file_converter/markdown.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/markdown.py
rename to slm/pipelines/pipelines/nodes/file_converter/markdown.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/pdf.py b/slm/pipelines/pipelines/nodes/file_converter/pdf.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/pdf.py
rename to slm/pipelines/pipelines/nodes/file_converter/pdf.py
diff --git a/legacy/pipelines/pipelines/nodes/file_converter/txt.py b/slm/pipelines/pipelines/nodes/file_converter/txt.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/file_converter/txt.py
rename to slm/pipelines/pipelines/nodes/file_converter/txt.py
diff --git a/legacy/pipelines/pipelines/nodes/llm/__init__.py b/slm/pipelines/pipelines/nodes/llm/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/llm/__init__.py
rename to slm/pipelines/pipelines/nodes/llm/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/llm/chatglm.py b/slm/pipelines/pipelines/nodes/llm/chatglm.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/llm/chatglm.py
rename to slm/pipelines/pipelines/nodes/llm/chatglm.py
diff --git a/legacy/pipelines/pipelines/nodes/llm/ernie_bot.py b/slm/pipelines/pipelines/nodes/llm/ernie_bot.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/llm/ernie_bot.py
rename to slm/pipelines/pipelines/nodes/llm/ernie_bot.py
diff --git a/legacy/pipelines/pipelines/nodes/llm/history.py b/slm/pipelines/pipelines/nodes/llm/history.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/llm/history.py
rename to slm/pipelines/pipelines/nodes/llm/history.py
diff --git a/legacy/pipelines/pipelines/nodes/llm/prompt_template.py b/slm/pipelines/pipelines/nodes/llm/prompt_template.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/llm/prompt_template.py
rename to slm/pipelines/pipelines/nodes/llm/prompt_template.py
diff --git a/legacy/pipelines/pipelines/nodes/models/__init__.py b/slm/pipelines/pipelines/nodes/models/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/models/__init__.py
rename to slm/pipelines/pipelines/nodes/models/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/models/neural_search_model.py b/slm/pipelines/pipelines/nodes/models/neural_search_model.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/models/neural_search_model.py
rename to slm/pipelines/pipelines/nodes/models/neural_search_model.py
diff --git a/legacy/pipelines/pipelines/nodes/other/__init__.py b/slm/pipelines/pipelines/nodes/other/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/other/__init__.py
rename to slm/pipelines/pipelines/nodes/other/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/other/docs2answers.py b/slm/pipelines/pipelines/nodes/other/docs2answers.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/other/docs2answers.py
rename to slm/pipelines/pipelines/nodes/other/docs2answers.py
diff --git a/legacy/pipelines/pipelines/nodes/other/join_answers.py b/slm/pipelines/pipelines/nodes/other/join_answers.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/other/join_answers.py
rename to slm/pipelines/pipelines/nodes/other/join_answers.py
diff --git a/legacy/pipelines/pipelines/nodes/other/join_docs.py b/slm/pipelines/pipelines/nodes/other/join_docs.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/other/join_docs.py
rename to slm/pipelines/pipelines/nodes/other/join_docs.py
diff --git a/legacy/pipelines/pipelines/nodes/other/route_documents.py b/slm/pipelines/pipelines/nodes/other/route_documents.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/other/route_documents.py
rename to slm/pipelines/pipelines/nodes/other/route_documents.py
diff --git a/legacy/pipelines/pipelines/nodes/preprocessor/__init__.py b/slm/pipelines/pipelines/nodes/preprocessor/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/preprocessor/__init__.py
rename to slm/pipelines/pipelines/nodes/preprocessor/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/preprocessor/base.py b/slm/pipelines/pipelines/nodes/preprocessor/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/preprocessor/base.py
rename to slm/pipelines/pipelines/nodes/preprocessor/base.py
diff --git a/legacy/pipelines/pipelines/nodes/preprocessor/preprocessor.py b/slm/pipelines/pipelines/nodes/preprocessor/preprocessor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/preprocessor/preprocessor.py
rename to slm/pipelines/pipelines/nodes/preprocessor/preprocessor.py
diff --git a/legacy/pipelines/pipelines/nodes/preprocessor/text_splitter.py b/slm/pipelines/pipelines/nodes/preprocessor/text_splitter.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/preprocessor/text_splitter.py
rename to slm/pipelines/pipelines/nodes/preprocessor/text_splitter.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/__init__.py b/slm/pipelines/pipelines/nodes/prompt/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/__init__.py
rename to slm/pipelines/pipelines/nodes/prompt/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/__init__.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/__init__.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/base.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/base.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/base.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/chatglm.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/chatglm.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/chatglm.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/chatglm.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/chatgpt.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/chatgpt.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/chatgpt.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/chatgpt.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/ernie_bot.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/ernie_bot.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/ernie_bot.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/ernie_bot.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/handlers.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/handlers.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/handlers.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/handlers.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/invocation_layer/open_ai.py b/slm/pipelines/pipelines/nodes/prompt/invocation_layer/open_ai.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/invocation_layer/open_ai.py
rename to slm/pipelines/pipelines/nodes/prompt/invocation_layer/open_ai.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/prompt_model.py b/slm/pipelines/pipelines/nodes/prompt/prompt_model.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/prompt_model.py
rename to slm/pipelines/pipelines/nodes/prompt/prompt_model.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/prompt_node.py b/slm/pipelines/pipelines/nodes/prompt/prompt_node.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/prompt_node.py
rename to slm/pipelines/pipelines/nodes/prompt/prompt_node.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/prompt_template.py b/slm/pipelines/pipelines/nodes/prompt/prompt_template.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/prompt_template.py
rename to slm/pipelines/pipelines/nodes/prompt/prompt_template.py
diff --git a/legacy/pipelines/pipelines/nodes/prompt/shapers.py b/slm/pipelines/pipelines/nodes/prompt/shapers.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/prompt/shapers.py
rename to slm/pipelines/pipelines/nodes/prompt/shapers.py
diff --git a/legacy/pipelines/pipelines/nodes/question_generator/__init__.py b/slm/pipelines/pipelines/nodes/question_generator/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/question_generator/__init__.py
rename to slm/pipelines/pipelines/nodes/question_generator/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/question_generator/question_generator.py b/slm/pipelines/pipelines/nodes/question_generator/question_generator.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/question_generator/question_generator.py
rename to slm/pipelines/pipelines/nodes/question_generator/question_generator.py
diff --git a/legacy/pipelines/pipelines/nodes/ranker/__init__.py b/slm/pipelines/pipelines/nodes/ranker/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/ranker/__init__.py
rename to slm/pipelines/pipelines/nodes/ranker/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/ranker/base.py b/slm/pipelines/pipelines/nodes/ranker/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/ranker/base.py
rename to slm/pipelines/pipelines/nodes/ranker/base.py
diff --git a/legacy/pipelines/pipelines/nodes/ranker/ernie_ranker.py b/slm/pipelines/pipelines/nodes/ranker/ernie_ranker.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/ranker/ernie_ranker.py
rename to slm/pipelines/pipelines/nodes/ranker/ernie_ranker.py
diff --git a/legacy/pipelines/pipelines/nodes/reader/__init__.py b/slm/pipelines/pipelines/nodes/reader/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/reader/__init__.py
rename to slm/pipelines/pipelines/nodes/reader/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/reader/base.py b/slm/pipelines/pipelines/nodes/reader/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/reader/base.py
rename to slm/pipelines/pipelines/nodes/reader/base.py
diff --git a/legacy/pipelines/pipelines/nodes/reader/ernie_dureader.py b/slm/pipelines/pipelines/nodes/reader/ernie_dureader.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/reader/ernie_dureader.py
rename to slm/pipelines/pipelines/nodes/reader/ernie_dureader.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/__init__.py b/slm/pipelines/pipelines/nodes/retriever/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/__init__.py
rename to slm/pipelines/pipelines/nodes/retriever/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/base.py b/slm/pipelines/pipelines/nodes/retriever/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/base.py
rename to slm/pipelines/pipelines/nodes/retriever/base.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/base_embedding_encoder.py b/slm/pipelines/pipelines/nodes/retriever/base_embedding_encoder.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/base_embedding_encoder.py
rename to slm/pipelines/pipelines/nodes/retriever/base_embedding_encoder.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/dense.py b/slm/pipelines/pipelines/nodes/retriever/dense.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/dense.py
rename to slm/pipelines/pipelines/nodes/retriever/dense.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/embedder.py b/slm/pipelines/pipelines/nodes/retriever/embedder.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/embedder.py
rename to slm/pipelines/pipelines/nodes/retriever/embedder.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/ernie_encoder.py b/slm/pipelines/pipelines/nodes/retriever/ernie_encoder.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/ernie_encoder.py
rename to slm/pipelines/pipelines/nodes/retriever/ernie_encoder.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/multimodal_retriever.py b/slm/pipelines/pipelines/nodes/retriever/multimodal_retriever.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/multimodal_retriever.py
rename to slm/pipelines/pipelines/nodes/retriever/multimodal_retriever.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/parallel_retriever.py b/slm/pipelines/pipelines/nodes/retriever/parallel_retriever.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/parallel_retriever.py
rename to slm/pipelines/pipelines/nodes/retriever/parallel_retriever.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/sparse.py b/slm/pipelines/pipelines/nodes/retriever/sparse.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/sparse.py
rename to slm/pipelines/pipelines/nodes/retriever/sparse.py
diff --git a/legacy/pipelines/pipelines/nodes/retriever/web.py b/slm/pipelines/pipelines/nodes/retriever/web.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/retriever/web.py
rename to slm/pipelines/pipelines/nodes/retriever/web.py
diff --git a/legacy/pipelines/pipelines/nodes/search_engine/__init__.py b/slm/pipelines/pipelines/nodes/search_engine/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/search_engine/__init__.py
rename to slm/pipelines/pipelines/nodes/search_engine/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/search_engine/base.py b/slm/pipelines/pipelines/nodes/search_engine/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/search_engine/base.py
rename to slm/pipelines/pipelines/nodes/search_engine/base.py
diff --git a/legacy/pipelines/pipelines/nodes/search_engine/providers.py b/slm/pipelines/pipelines/nodes/search_engine/providers.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/search_engine/providers.py
rename to slm/pipelines/pipelines/nodes/search_engine/providers.py
diff --git a/legacy/pipelines/pipelines/nodes/search_engine/utils.py b/slm/pipelines/pipelines/nodes/search_engine/utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/search_engine/utils.py
rename to slm/pipelines/pipelines/nodes/search_engine/utils.py
diff --git a/legacy/pipelines/pipelines/nodes/search_engine/web.py b/slm/pipelines/pipelines/nodes/search_engine/web.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/search_engine/web.py
rename to slm/pipelines/pipelines/nodes/search_engine/web.py
diff --git a/legacy/pipelines/pipelines/nodes/sentiment_analysis/__init__.py b/slm/pipelines/pipelines/nodes/sentiment_analysis/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/sentiment_analysis/__init__.py
rename to slm/pipelines/pipelines/nodes/sentiment_analysis/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/sentiment_analysis/senta.py b/slm/pipelines/pipelines/nodes/sentiment_analysis/senta.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/sentiment_analysis/senta.py
rename to slm/pipelines/pipelines/nodes/sentiment_analysis/senta.py
diff --git a/legacy/pipelines/pipelines/nodes/sentiment_analysis/senta_preprocessor.py b/slm/pipelines/pipelines/nodes/sentiment_analysis/senta_preprocessor.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/sentiment_analysis/senta_preprocessor.py
rename to slm/pipelines/pipelines/nodes/sentiment_analysis/senta_preprocessor.py
diff --git a/legacy/pipelines/pipelines/nodes/sentiment_analysis/senta_visualization.py b/slm/pipelines/pipelines/nodes/sentiment_analysis/senta_visualization.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/sentiment_analysis/senta_visualization.py
rename to slm/pipelines/pipelines/nodes/sentiment_analysis/senta_visualization.py
diff --git a/legacy/pipelines/pipelines/nodes/text_to_image_generator/__init__.py b/slm/pipelines/pipelines/nodes/text_to_image_generator/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/text_to_image_generator/__init__.py
rename to slm/pipelines/pipelines/nodes/text_to_image_generator/__init__.py
diff --git a/legacy/pipelines/pipelines/nodes/text_to_image_generator/text_to_image_generator.py b/slm/pipelines/pipelines/nodes/text_to_image_generator/text_to_image_generator.py
similarity index 100%
rename from legacy/pipelines/pipelines/nodes/text_to_image_generator/text_to_image_generator.py
rename to slm/pipelines/pipelines/nodes/text_to_image_generator/text_to_image_generator.py
diff --git a/legacy/pipelines/pipelines/pipelines/__init__.py b/slm/pipelines/pipelines/pipelines/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/pipelines/__init__.py
rename to slm/pipelines/pipelines/pipelines/__init__.py
diff --git a/legacy/pipelines/pipelines/pipelines/base.py b/slm/pipelines/pipelines/pipelines/base.py
similarity index 100%
rename from legacy/pipelines/pipelines/pipelines/base.py
rename to slm/pipelines/pipelines/pipelines/base.py
diff --git a/legacy/pipelines/pipelines/pipelines/config.py b/slm/pipelines/pipelines/pipelines/config.py
similarity index 100%
rename from legacy/pipelines/pipelines/pipelines/config.py
rename to slm/pipelines/pipelines/pipelines/config.py
diff --git a/legacy/pipelines/pipelines/pipelines/standard_pipelines.py b/slm/pipelines/pipelines/pipelines/standard_pipelines.py
similarity index 100%
rename from legacy/pipelines/pipelines/pipelines/standard_pipelines.py
rename to slm/pipelines/pipelines/pipelines/standard_pipelines.py
diff --git a/legacy/pipelines/pipelines/pipelines/utils.py b/slm/pipelines/pipelines/pipelines/utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/pipelines/utils.py
rename to slm/pipelines/pipelines/pipelines/utils.py
diff --git a/legacy/pipelines/pipelines/schema.py b/slm/pipelines/pipelines/schema.py
similarity index 100%
rename from legacy/pipelines/pipelines/schema.py
rename to slm/pipelines/pipelines/schema.py
diff --git a/legacy/pipelines/pipelines/utils/__init__.py b/slm/pipelines/pipelines/utils/__init__.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/__init__.py
rename to slm/pipelines/pipelines/utils/__init__.py
diff --git a/legacy/pipelines/pipelines/utils/cleaning.py b/slm/pipelines/pipelines/utils/cleaning.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/cleaning.py
rename to slm/pipelines/pipelines/utils/cleaning.py
diff --git a/legacy/pipelines/pipelines/utils/common_utils.py b/slm/pipelines/pipelines/utils/common_utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/common_utils.py
rename to slm/pipelines/pipelines/utils/common_utils.py
diff --git a/legacy/pipelines/pipelines/utils/doc_store.py b/slm/pipelines/pipelines/utils/doc_store.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/doc_store.py
rename to slm/pipelines/pipelines/utils/doc_store.py
diff --git a/legacy/pipelines/pipelines/utils/export_utils.py b/slm/pipelines/pipelines/utils/export_utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/export_utils.py
rename to slm/pipelines/pipelines/utils/export_utils.py
diff --git a/legacy/pipelines/pipelines/utils/import_utils.py b/slm/pipelines/pipelines/utils/import_utils.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/import_utils.py
rename to slm/pipelines/pipelines/utils/import_utils.py
diff --git a/legacy/pipelines/pipelines/utils/logger.py b/slm/pipelines/pipelines/utils/logger.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/logger.py
rename to slm/pipelines/pipelines/utils/logger.py
diff --git a/legacy/pipelines/pipelines/utils/preprocessing.py b/slm/pipelines/pipelines/utils/preprocessing.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/preprocessing.py
rename to slm/pipelines/pipelines/utils/preprocessing.py
diff --git a/legacy/pipelines/pipelines/utils/tokenization.py b/slm/pipelines/pipelines/utils/tokenization.py
similarity index 100%
rename from legacy/pipelines/pipelines/utils/tokenization.py
rename to slm/pipelines/pipelines/utils/tokenization.py
diff --git a/legacy/pipelines/pipelines/version.py b/slm/pipelines/pipelines/version.py
similarity index 100%
rename from legacy/pipelines/pipelines/version.py
rename to slm/pipelines/pipelines/version.py
diff --git a/legacy/pipelines/requirements.txt b/slm/pipelines/requirements.txt
similarity index 100%
rename from legacy/pipelines/requirements.txt
rename to slm/pipelines/requirements.txt
diff --git a/legacy/pipelines/rest_api/__init__.py b/slm/pipelines/rest_api/__init__.py
similarity index 100%
rename from legacy/pipelines/rest_api/__init__.py
rename to slm/pipelines/rest_api/__init__.py
diff --git a/legacy/pipelines/rest_api/application.py b/slm/pipelines/rest_api/application.py
similarity index 100%
rename from legacy/pipelines/rest_api/application.py
rename to slm/pipelines/rest_api/application.py
diff --git a/legacy/pipelines/rest_api/config.py b/slm/pipelines/rest_api/config.py
similarity index 100%
rename from legacy/pipelines/rest_api/config.py
rename to slm/pipelines/rest_api/config.py
diff --git a/legacy/pipelines/rest_api/controller/__init__.py b/slm/pipelines/rest_api/controller/__init__.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/__init__.py
rename to slm/pipelines/rest_api/controller/__init__.py
diff --git a/legacy/pipelines/rest_api/controller/document.py b/slm/pipelines/rest_api/controller/document.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/document.py
rename to slm/pipelines/rest_api/controller/document.py
diff --git a/legacy/pipelines/rest_api/controller/errors/__init__.py b/slm/pipelines/rest_api/controller/errors/__init__.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/errors/__init__.py
rename to slm/pipelines/rest_api/controller/errors/__init__.py
diff --git a/legacy/pipelines/rest_api/controller/errors/http_error.py b/slm/pipelines/rest_api/controller/errors/http_error.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/errors/http_error.py
rename to slm/pipelines/rest_api/controller/errors/http_error.py
diff --git a/legacy/pipelines/rest_api/controller/feedback.py b/slm/pipelines/rest_api/controller/feedback.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/feedback.py
rename to slm/pipelines/rest_api/controller/feedback.py
diff --git a/legacy/pipelines/rest_api/controller/file_upload.py b/slm/pipelines/rest_api/controller/file_upload.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/file_upload.py
rename to slm/pipelines/rest_api/controller/file_upload.py
diff --git a/legacy/pipelines/rest_api/controller/router.py b/slm/pipelines/rest_api/controller/router.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/router.py
rename to slm/pipelines/rest_api/controller/router.py
diff --git a/legacy/pipelines/rest_api/controller/search.py b/slm/pipelines/rest_api/controller/search.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/search.py
rename to slm/pipelines/rest_api/controller/search.py
diff --git a/legacy/pipelines/rest_api/controller/utils.py b/slm/pipelines/rest_api/controller/utils.py
similarity index 100%
rename from legacy/pipelines/rest_api/controller/utils.py
rename to slm/pipelines/rest_api/controller/utils.py
diff --git a/legacy/pipelines/rest_api/pipeline/__init__.py b/slm/pipelines/rest_api/pipeline/__init__.py
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/__init__.py
rename to slm/pipelines/rest_api/pipeline/__init__.py
diff --git a/legacy/pipelines/rest_api/pipeline/chatfile.yaml b/slm/pipelines/rest_api/pipeline/chatfile.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/chatfile.yaml
rename to slm/pipelines/rest_api/pipeline/chatfile.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/custom_component.py b/slm/pipelines/rest_api/pipeline/custom_component.py
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/custom_component.py
rename to slm/pipelines/rest_api/pipeline/custom_component.py
diff --git a/legacy/pipelines/rest_api/pipeline/dense_faq.yaml b/slm/pipelines/rest_api/pipeline/dense_faq.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/dense_faq.yaml
rename to slm/pipelines/rest_api/pipeline/dense_faq.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/dense_qa.yaml b/slm/pipelines/rest_api/pipeline/dense_qa.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/dense_qa.yaml
rename to slm/pipelines/rest_api/pipeline/dense_qa.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/docprompt.yaml b/slm/pipelines/rest_api/pipeline/docprompt.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/docprompt.yaml
rename to slm/pipelines/rest_api/pipeline/docprompt.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/image_to_text_retrieval.yaml b/slm/pipelines/rest_api/pipeline/image_to_text_retrieval.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/image_to_text_retrieval.yaml
rename to slm/pipelines/rest_api/pipeline/image_to_text_retrieval.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/multi_recall_semantic_search.yaml b/slm/pipelines/rest_api/pipeline/multi_recall_semantic_search.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/multi_recall_semantic_search.yaml
rename to slm/pipelines/rest_api/pipeline/multi_recall_semantic_search.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/pipelines.yaml b/slm/pipelines/rest_api/pipeline/pipelines.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/pipelines.yaml
rename to slm/pipelines/rest_api/pipeline/pipelines.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/semantic_ernie_search_en.yaml b/slm/pipelines/rest_api/pipeline/semantic_ernie_search_en.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/semantic_ernie_search_en.yaml
rename to slm/pipelines/rest_api/pipeline/semantic_ernie_search_en.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/semantic_search.yaml b/slm/pipelines/rest_api/pipeline/semantic_search.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/semantic_search.yaml
rename to slm/pipelines/rest_api/pipeline/semantic_search.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/semantic_search_custom.yaml b/slm/pipelines/rest_api/pipeline/semantic_search_custom.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/semantic_search_custom.yaml
rename to slm/pipelines/rest_api/pipeline/semantic_search_custom.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/semantic_search_en.yaml b/slm/pipelines/rest_api/pipeline/semantic_search_en.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/semantic_search_en.yaml
rename to slm/pipelines/rest_api/pipeline/semantic_search_en.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/semantic_search_milvus.yaml b/slm/pipelines/rest_api/pipeline/semantic_search_milvus.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/semantic_search_milvus.yaml
rename to slm/pipelines/rest_api/pipeline/semantic_search_milvus.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/senta.yaml b/slm/pipelines/rest_api/pipeline/senta.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/senta.yaml
rename to slm/pipelines/rest_api/pipeline/senta.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/text_to_image.yaml b/slm/pipelines/rest_api/pipeline/text_to_image.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/text_to_image.yaml
rename to slm/pipelines/rest_api/pipeline/text_to_image.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/text_to_image_retrieval.yaml b/slm/pipelines/rest_api/pipeline/text_to_image_retrieval.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/text_to_image_retrieval.yaml
rename to slm/pipelines/rest_api/pipeline/text_to_image_retrieval.yaml
diff --git a/legacy/pipelines/rest_api/pipeline/unsupervised_qa.yaml b/slm/pipelines/rest_api/pipeline/unsupervised_qa.yaml
similarity index 100%
rename from legacy/pipelines/rest_api/pipeline/unsupervised_qa.yaml
rename to slm/pipelines/rest_api/pipeline/unsupervised_qa.yaml
diff --git a/legacy/pipelines/rest_api/schema.py b/slm/pipelines/rest_api/schema.py
similarity index 100%
rename from legacy/pipelines/rest_api/schema.py
rename to slm/pipelines/rest_api/schema.py
diff --git a/legacy/pipelines/rest_api/test/__init__.py b/slm/pipelines/rest_api/test/__init__.py
similarity index 100%
rename from legacy/pipelines/rest_api/test/__init__.py
rename to slm/pipelines/rest_api/test/__init__.py
diff --git a/legacy/pipelines/rest_api/test/test_rest_api.py b/slm/pipelines/rest_api/test/test_rest_api.py
similarity index 100%
rename from legacy/pipelines/rest_api/test/test_rest_api.py
rename to slm/pipelines/rest_api/test/test_rest_api.py
diff --git a/legacy/pipelines/setup.py b/slm/pipelines/setup.py
similarity index 100%
rename from legacy/pipelines/setup.py
rename to slm/pipelines/setup.py
diff --git a/legacy/pipelines/tests/__init__.py b/slm/pipelines/tests/__init__.py
similarity index 100%
rename from legacy/pipelines/tests/__init__.py
rename to slm/pipelines/tests/__init__.py
diff --git a/legacy/pipelines/tests/agents/__init__.py b/slm/pipelines/tests/agents/__init__.py
similarity index 100%
rename from legacy/pipelines/tests/agents/__init__.py
rename to slm/pipelines/tests/agents/__init__.py
diff --git a/legacy/pipelines/tests/agents/test_agent.py b/slm/pipelines/tests/agents/test_agent.py
similarity index 100%
rename from legacy/pipelines/tests/agents/test_agent.py
rename to slm/pipelines/tests/agents/test_agent.py
diff --git a/legacy/pipelines/tests/agents/test_agent_step.py b/slm/pipelines/tests/agents/test_agent_step.py
similarity index 100%
rename from legacy/pipelines/tests/agents/test_agent_step.py
rename to slm/pipelines/tests/agents/test_agent_step.py
diff --git a/legacy/pipelines/tests/agents/test_memory.py b/slm/pipelines/tests/agents/test_memory.py
similarity index 100%
rename from legacy/pipelines/tests/agents/test_memory.py
rename to slm/pipelines/tests/agents/test_memory.py
diff --git a/legacy/pipelines/tests/agents/test_tools_manager.py b/slm/pipelines/tests/agents/test_tools_manager.py
similarity index 100%
rename from legacy/pipelines/tests/agents/test_tools_manager.py
rename to slm/pipelines/tests/agents/test_tools_manager.py
diff --git a/legacy/pipelines/tests/conftest.py b/slm/pipelines/tests/conftest.py
similarity index 100%
rename from legacy/pipelines/tests/conftest.py
rename to slm/pipelines/tests/conftest.py
diff --git a/legacy/pipelines/tests/fixtures/example_docx.docx b/slm/pipelines/tests/fixtures/example_docx.docx
similarity index 100%
rename from legacy/pipelines/tests/fixtures/example_docx.docx
rename to slm/pipelines/tests/fixtures/example_docx.docx
diff --git a/legacy/pipelines/tests/fixtures/example_markdown.md b/slm/pipelines/tests/fixtures/example_markdown.md
similarity index 100%
rename from legacy/pipelines/tests/fixtures/example_markdown.md
rename to slm/pipelines/tests/fixtures/example_markdown.md
diff --git a/legacy/pipelines/tests/fixtures/example_pdf.pdf b/slm/pipelines/tests/fixtures/example_pdf.pdf
similarity index 100%
rename from legacy/pipelines/tests/fixtures/example_pdf.pdf
rename to slm/pipelines/tests/fixtures/example_pdf.pdf
diff --git a/legacy/pipelines/tests/nodes/combine_documents/test_combinedocuments.py b/slm/pipelines/tests/nodes/combine_documents/test_combinedocuments.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/combine_documents/test_combinedocuments.py
rename to slm/pipelines/tests/nodes/combine_documents/test_combinedocuments.py
diff --git a/legacy/pipelines/tests/nodes/file_converter/test_docx.py b/slm/pipelines/tests/nodes/file_converter/test_docx.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/file_converter/test_docx.py
rename to slm/pipelines/tests/nodes/file_converter/test_docx.py
diff --git a/legacy/pipelines/tests/nodes/file_converter/test_markdown.py b/slm/pipelines/tests/nodes/file_converter/test_markdown.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/file_converter/test_markdown.py
rename to slm/pipelines/tests/nodes/file_converter/test_markdown.py
diff --git a/legacy/pipelines/tests/nodes/file_converter/test_pdf.py b/slm/pipelines/tests/nodes/file_converter/test_pdf.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/file_converter/test_pdf.py
rename to slm/pipelines/tests/nodes/file_converter/test_pdf.py
diff --git a/legacy/pipelines/tests/nodes/llm/test_chatglm_bot.py b/slm/pipelines/tests/nodes/llm/test_chatglm_bot.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/llm/test_chatglm_bot.py
rename to slm/pipelines/tests/nodes/llm/test_chatglm_bot.py
diff --git a/legacy/pipelines/tests/nodes/llm/test_ernie_bot.py b/slm/pipelines/tests/nodes/llm/test_ernie_bot.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/llm/test_ernie_bot.py
rename to slm/pipelines/tests/nodes/llm/test_ernie_bot.py
diff --git a/legacy/pipelines/tests/nodes/llm/test_history.py b/slm/pipelines/tests/nodes/llm/test_history.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/llm/test_history.py
rename to slm/pipelines/tests/nodes/llm/test_history.py
diff --git a/legacy/pipelines/tests/nodes/llm/test_prompt_template.py b/slm/pipelines/tests/nodes/llm/test_prompt_template.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/llm/test_prompt_template.py
rename to slm/pipelines/tests/nodes/llm/test_prompt_template.py
diff --git a/legacy/pipelines/tests/nodes/preprocessor/test_preprocessor.py b/slm/pipelines/tests/nodes/preprocessor/test_preprocessor.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/preprocessor/test_preprocessor.py
rename to slm/pipelines/tests/nodes/preprocessor/test_preprocessor.py
diff --git a/legacy/pipelines/tests/nodes/preprocessor/test_text_splitter.py b/slm/pipelines/tests/nodes/preprocessor/test_text_splitter.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/preprocessor/test_text_splitter.py
rename to slm/pipelines/tests/nodes/preprocessor/test_text_splitter.py
diff --git a/legacy/pipelines/tests/nodes/prompt/__init__.py b/slm/pipelines/tests/nodes/prompt/__init__.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/__init__.py
rename to slm/pipelines/tests/nodes/prompt/__init__.py
diff --git a/legacy/pipelines/tests/nodes/prompt/conftest.py b/slm/pipelines/tests/nodes/prompt/conftest.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/conftest.py
rename to slm/pipelines/tests/nodes/prompt/conftest.py
diff --git a/legacy/pipelines/tests/nodes/prompt/invocation_layer/__init__.py b/slm/pipelines/tests/nodes/prompt/invocation_layer/__init__.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/invocation_layer/__init__.py
rename to slm/pipelines/tests/nodes/prompt/invocation_layer/__init__.py
diff --git a/legacy/pipelines/tests/nodes/prompt/invocation_layer/test_chatglm.py b/slm/pipelines/tests/nodes/prompt/invocation_layer/test_chatglm.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/invocation_layer/test_chatglm.py
rename to slm/pipelines/tests/nodes/prompt/invocation_layer/test_chatglm.py
diff --git a/legacy/pipelines/tests/nodes/prompt/invocation_layer/test_chatgpt.py b/slm/pipelines/tests/nodes/prompt/invocation_layer/test_chatgpt.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/invocation_layer/test_chatgpt.py
rename to slm/pipelines/tests/nodes/prompt/invocation_layer/test_chatgpt.py
diff --git a/legacy/pipelines/tests/nodes/prompt/invocation_layer/test_ernie_bot.py b/slm/pipelines/tests/nodes/prompt/invocation_layer/test_ernie_bot.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/invocation_layer/test_ernie_bot.py
rename to slm/pipelines/tests/nodes/prompt/invocation_layer/test_ernie_bot.py
diff --git a/legacy/pipelines/tests/nodes/prompt/invocation_layer/test_openai.py b/slm/pipelines/tests/nodes/prompt/invocation_layer/test_openai.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/invocation_layer/test_openai.py
rename to slm/pipelines/tests/nodes/prompt/invocation_layer/test_openai.py
diff --git a/legacy/pipelines/tests/nodes/prompt/test_handlers.py b/slm/pipelines/tests/nodes/prompt/test_handlers.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/test_handlers.py
rename to slm/pipelines/tests/nodes/prompt/test_handlers.py
diff --git a/legacy/pipelines/tests/nodes/prompt/test_prompt_model.py b/slm/pipelines/tests/nodes/prompt/test_prompt_model.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/test_prompt_model.py
rename to slm/pipelines/tests/nodes/prompt/test_prompt_model.py
diff --git a/legacy/pipelines/tests/nodes/prompt/test_prompt_node.py b/slm/pipelines/tests/nodes/prompt/test_prompt_node.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/test_prompt_node.py
rename to slm/pipelines/tests/nodes/prompt/test_prompt_node.py
diff --git a/legacy/pipelines/tests/nodes/prompt/test_prompt_template.py b/slm/pipelines/tests/nodes/prompt/test_prompt_template.py
similarity index 100%
rename from legacy/pipelines/tests/nodes/prompt/test_prompt_template.py
rename to slm/pipelines/tests/nodes/prompt/test_prompt_template.py
diff --git a/legacy/pipelines/tests/pipelines/test_chatbot_pipeline.py b/slm/pipelines/tests/pipelines/test_chatbot_pipeline.py
similarity index 100%
rename from legacy/pipelines/tests/pipelines/test_chatbot_pipeline.py
rename to slm/pipelines/tests/pipelines/test_chatbot_pipeline.py
diff --git a/legacy/pipelines/tests/requirements.txt b/slm/pipelines/tests/requirements.txt
similarity index 100%
rename from legacy/pipelines/tests/requirements.txt
rename to slm/pipelines/tests/requirements.txt
diff --git a/legacy/pipelines/ui/__init__.py b/slm/pipelines/ui/__init__.py
similarity index 100%
rename from legacy/pipelines/ui/__init__.py
rename to slm/pipelines/ui/__init__.py
diff --git a/legacy/pipelines/ui/baike_qa.csv b/slm/pipelines/ui/baike_qa.csv
similarity index 100%
rename from legacy/pipelines/ui/baike_qa.csv
rename to slm/pipelines/ui/baike_qa.csv
diff --git a/legacy/pipelines/ui/country_search.csv b/slm/pipelines/ui/country_search.csv
similarity index 100%
rename from legacy/pipelines/ui/country_search.csv
rename to slm/pipelines/ui/country_search.csv
diff --git a/legacy/pipelines/ui/dureader_search.csv b/slm/pipelines/ui/dureader_search.csv
similarity index 100%
rename from legacy/pipelines/ui/dureader_search.csv
rename to slm/pipelines/ui/dureader_search.csv
diff --git a/legacy/pipelines/ui/insurance_faq.csv b/slm/pipelines/ui/insurance_faq.csv
similarity index 100%
rename from legacy/pipelines/ui/insurance_faq.csv
rename to slm/pipelines/ui/insurance_faq.csv
diff --git a/legacy/pipelines/ui/utils.py b/slm/pipelines/ui/utils.py
similarity index 100%
rename from legacy/pipelines/ui/utils.py
rename to slm/pipelines/ui/utils.py
diff --git a/legacy/pipelines/ui/webapp_chatfile_gradio.py b/slm/pipelines/ui/webapp_chatfile_gradio.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_chatfile_gradio.py
rename to slm/pipelines/ui/webapp_chatfile_gradio.py
diff --git a/legacy/pipelines/ui/webapp_docprompt_gradio.py b/slm/pipelines/ui/webapp_docprompt_gradio.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_docprompt_gradio.py
rename to slm/pipelines/ui/webapp_docprompt_gradio.py
diff --git a/legacy/pipelines/ui/webapp_faq.py b/slm/pipelines/ui/webapp_faq.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_faq.py
rename to slm/pipelines/ui/webapp_faq.py
diff --git a/legacy/pipelines/ui/webapp_image_to_text_retrieval.py b/slm/pipelines/ui/webapp_image_to_text_retrieval.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_image_to_text_retrieval.py
rename to slm/pipelines/ui/webapp_image_to_text_retrieval.py
diff --git a/legacy/pipelines/ui/webapp_multi_recall_semantic_search.py b/slm/pipelines/ui/webapp_multi_recall_semantic_search.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_multi_recall_semantic_search.py
rename to slm/pipelines/ui/webapp_multi_recall_semantic_search.py
diff --git a/legacy/pipelines/ui/webapp_question_answering.py b/slm/pipelines/ui/webapp_question_answering.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_question_answering.py
rename to slm/pipelines/ui/webapp_question_answering.py
diff --git a/legacy/pipelines/ui/webapp_semantic_search.py b/slm/pipelines/ui/webapp_semantic_search.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_semantic_search.py
rename to slm/pipelines/ui/webapp_semantic_search.py
diff --git a/legacy/pipelines/ui/webapp_senta.py b/slm/pipelines/ui/webapp_senta.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_senta.py
rename to slm/pipelines/ui/webapp_senta.py
diff --git a/legacy/pipelines/ui/webapp_text_to_image.py b/slm/pipelines/ui/webapp_text_to_image.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_text_to_image.py
rename to slm/pipelines/ui/webapp_text_to_image.py
diff --git a/legacy/pipelines/ui/webapp_text_to_image_retrieval.py b/slm/pipelines/ui/webapp_text_to_image_retrieval.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_text_to_image_retrieval.py
rename to slm/pipelines/ui/webapp_text_to_image_retrieval.py
diff --git a/legacy/pipelines/ui/webapp_unsupervised_question_answering.py b/slm/pipelines/ui/webapp_unsupervised_question_answering.py
similarity index 100%
rename from legacy/pipelines/ui/webapp_unsupervised_question_answering.py
rename to slm/pipelines/ui/webapp_unsupervised_question_answering.py
diff --git a/legacy/pipelines/utils/__init__.py b/slm/pipelines/utils/__init__.py
similarity index 100%
rename from legacy/pipelines/utils/__init__.py
rename to slm/pipelines/utils/__init__.py
diff --git a/legacy/pipelines/utils/offline_ann.py b/slm/pipelines/utils/offline_ann.py
similarity index 100%
rename from legacy/pipelines/utils/offline_ann.py
rename to slm/pipelines/utils/offline_ann.py
diff --git a/legacy/pipelines/utils/offline_ann_mm.py b/slm/pipelines/utils/offline_ann_mm.py
similarity index 100%
rename from legacy/pipelines/utils/offline_ann_mm.py
rename to slm/pipelines/utils/offline_ann_mm.py
diff --git a/tests/test_tipc/auto_tuner/llama_pretrain/benchmark_common/prepare.sh b/tests/test_tipc/auto_tuner/llama_pretrain/benchmark_common/prepare.sh
index a7a13a9ae9a2..53e96e055d43 100644
--- a/tests/test_tipc/auto_tuner/llama_pretrain/benchmark_common/prepare.sh
+++ b/tests/test_tipc/auto_tuner/llama_pretrain/benchmark_common/prepare.sh
@@ -16,7 +16,7 @@ python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/benchmark/modules/ernie_tiny.py b/tests/test_tipc/benchmark/modules/ernie_tiny.py
index 7b4904d59b94..502f23e4543c 100644
--- a/tests/test_tipc/benchmark/modules/ernie_tiny.py
+++ b/tests/test_tipc/benchmark/modules/ernie_tiny.py
@@ -31,7 +31,7 @@
0,
os.path.abspath(
os.path.join(
- os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "legacy", "model_zoo", "ernie-3.0"
+ os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "slm", "model_zoo", "ernie-3.0"
)
),
)
diff --git a/tests/test_tipc/configs/bert/base/bert_base_seqlen128_cinn_train_infer_python.txt b/tests/test_tipc/configs/bert/base/bert_base_seqlen128_cinn_train_infer_python.txt
index 3c84dff46228..bd830e2f5fb3 100644
--- a/tests/test_tipc/configs/bert/base/bert_base_seqlen128_cinn_train_infer_python.txt
+++ b/tests/test_tipc/configs/bert/base/bert_base_seqlen128_cinn_train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/model_zoo/bert/run_pretrain.py --preprocessing_num_workers 8 --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-base-uncased --input_dir ./data/wikicorpus_en_seqlen128 --fuse_transformer false --amp_level O2 --cinn True
+norm_train:../slm/model_zoo/bert/run_pretrain.py --preprocessing_num_workers 8 --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-base-uncased --input_dir ./data/wikicorpus_en_seqlen128 --fuse_transformer false --amp_level O2 --cinn True
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/bert/base/train_infer_python.txt b/tests/test_tipc/configs/bert/base/train_infer_python.txt
index 1a29d9487c8b..df3124cf0dee 100644
--- a/tests/test_tipc/configs/bert/base/train_infer_python.txt
+++ b/tests/test_tipc/configs/bert/base/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/model_zoo/bert/run_pretrain.py --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-base-uncased --input_dir ./data/wikicorpus_en_seqlen128 --fuse_transformer true --amp_level O2
+norm_train:../slm/model_zoo/bert/run_pretrain.py --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-base-uncased --input_dir ./data/wikicorpus_en_seqlen128 --fuse_transformer true --amp_level O2
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/bert/large/train_infer_python.txt b/tests/test_tipc/configs/bert/large/train_infer_python.txt
index 888380b10a8f..79055d8adcc8 100644
--- a/tests/test_tipc/configs/bert/large/train_infer_python.txt
+++ b/tests/test_tipc/configs/bert/large/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/model_zoo/bert/run_pretrain.py --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-large-uncased --input_dir ./data/wikicorpus_en_seqlen512
+norm_train:../slm/model_zoo/bert/run_pretrain.py --max_predictions_per_seq 20 --learning_rate 1e-4 --weight_decay 1e-2 --adam_epsilon 1e-6 --warmup_steps 10000 --output_dir ./tmp2/ --logging_steps 10 --save_steps 20000 --model_type bert --model_name_or_path bert-large-uncased --input_dir ./data/wikicorpus_en_seqlen512
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/gpt2/train_infer_python.txt b/tests/test_tipc/configs/gpt2/train_infer_python.txt
index 776322930364..8116409225bc 100644
--- a/tests/test_tipc/configs/gpt2/train_infer_python.txt
+++ b/tests/test_tipc/configs/gpt2/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/model_zoo/gpt/run_pretrain.py --model_type="gpt" --model_name_or_path="gpt2-en" --save_steps 100000 --decay_steps 320000 --weight_decay 0.01 --warmup_rate 0.01 --grad_clip 1.0 --logging_freq 1 --eval_freq 1000 --device "gpu" --min_lr 0.00001 --max_lr 0.00015 --max_seq_len 1024 --output_dir=./output/ --input_dir=./data/
+norm_train:../slm/model_zoo/gpt/run_pretrain.py --model_type="gpt" --model_name_or_path="gpt2-en" --save_steps 100000 --decay_steps 320000 --weight_decay 0.01 --warmup_rate 0.01 --grad_clip 1.0 --logging_freq 1 --eval_freq 1000 --device "gpu" --min_lr 0.00001 --max_lr 0.00015 --max_seq_len 1024 --output_dir=./output/ --input_dir=./data/
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/gpt3/train_infer_python.txt b/tests/test_tipc/configs/gpt3/train_infer_python.txt
index 8b0fb521cfac..d051d0a0d7ea 100644
--- a/tests/test_tipc/configs/gpt3/train_infer_python.txt
+++ b/tests/test_tipc/configs/gpt3/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/model_zoo/gpt-3/dygraph/run_pretrain.py --model_type="gpt" --model_name_or_path="gpt2-en" --save_steps 100000 --decay_steps 320000 --weight_decay 0.01 --warmup_rate 0.01 --grad_clip 1.0 --logging_freq 1 --eval_freq 1000 --device "gpu" --min_lr 0.00001 --max_lr 0.00015 --max_seq_len 1024 --output_dir=./output/ --input_dir=./data/
+norm_train:../slm/model_zoo/gpt-3/dygraph/run_pretrain.py --model_type="gpt" --model_name_or_path="gpt2-en" --save_steps 100000 --decay_steps 320000 --weight_decay 0.01 --warmup_rate 0.01 --grad_clip 1.0 --logging_freq 1 --eval_freq 1000 --device "gpu" --min_lr 0.00001 --max_lr 0.00015 --max_seq_len 1024 --output_dir=./output/ --input_dir=./data/
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/llama/train_infer_python.txt b/tests/test_tipc/configs/llama/train_infer_python.txt
index 8242d0f0f744..fe3ccf74af31 100644
--- a/tests/test_tipc/configs/llama/train_infer_python.txt
+++ b/tests/test_tipc/configs/llama/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/benchmark/llm/llama_single_gpu/benchmark.py --model_name_or_path facebook/llama-7b-2l --do_train --max_steps 500 --recompute False --overwrite_output_dir --output_dir ./checkpoints/ --fp16_opt_level O2 --learning_rate 3e-5 --warmup_steps 0 --seed 23 --logging_steps 1 --dataloader_num_workers 1
+norm_train:../slm/examples/benchmark/llm/llama_single_gpu/benchmark.py --model_name_or_path facebook/llama-7b-2l --do_train --max_steps 500 --recompute False --overwrite_output_dir --output_dir ./checkpoints/ --fp16_opt_level O2 --learning_rate 3e-5 --warmup_steps 0 --seed 23 --logging_steps 1 --dataloader_num_workers 1
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/transformer/base/train_dy2static_python.txt b/tests/test_tipc/configs/transformer/base/train_dy2static_python.txt
index d37d4e685268..0cfef5070a8a 100644
--- a/tests/test_tipc/configs/transformer/base/train_dy2static_python.txt
+++ b/tests/test_tipc/configs/transformer/base/train_dy2static_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/train.py --config ../examples/machine_translation/transformer/configs/transformer.base.yaml --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token " " --bos_token "" --eos_token "" --benchmark
+norm_train:../slm/examples/machine_translation/transformer/train.py --config ../examples/machine_translation/transformer/configs/transformer.base.yaml --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/transformer/base/train_infer_python.txt b/tests/test_tipc/configs/transformer/base/train_infer_python.txt
index fcabaef9915a..f52c6b5d2d40 100644
--- a/tests/test_tipc/configs/transformer/base/train_infer_python.txt
+++ b/tests/test_tipc/configs/transformer/base/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/train.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.base.yaml --train_file ../legacy/examples/machine_translation/transformer/train.en ../legacy/examples/machine_translation/transformer/train.de --dev_file ../legacy/examples/machine_translation/transformer/dev.en ../legacy/examples/machine_translation/transformer/dev.de --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+norm_train:../slm/examples/machine_translation/transformer/train.py --config ../slm/examples/machine_translation/transformer/configs/transformer.base.yaml --train_file ../slm/examples/machine_translation/transformer/train.en ../slm/examples/machine_translation/transformer/train.de --dev_file ../slm/examples/machine_translation/transformer/dev.en ../slm/examples/machine_translation/transformer/dev.de --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
pact_train:null
fpgm_train:null
distill_train:null
@@ -21,13 +21,13 @@ null:null
null:null
##
===========================eval_params===========================
-eval:./legacy/examples/machine_translation/transformer/predict.py --config ./legacy/examples/machine_translation/transformer/configs/transformer.base.yaml --test_file ./legacy/examples/machine_translation/transformer/test.en ./legacy/examples/machine_translation/transformer/test.de --without_ft --vocab_file ./legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+eval:./slm/examples/machine_translation/transformer/predict.py --config ./slm/examples/machine_translation/transformer/configs/transformer.base.yaml --test_file ./slm/examples/machine_translation/transformer/test.en ./slm/examples/machine_translation/transformer/test.de --without_ft --vocab_file ./slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
null:null
##
===========================infer_params===========================
null:null
null:null
-norm_export:./legacy/examples/machine_translation/transformer/export_model.py --config ./legacy/examples/machine_translation/transformer/configs/transformer.base.yaml --vocab_file ./legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --bos_token "" --eos_token "" --benchmark
+norm_export:./slm/examples/machine_translation/transformer/export_model.py --config ./slm/examples/machine_translation/transformer/configs/transformer.base.yaml --vocab_file ./slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --bos_token "" --eos_token "" --benchmark
quant_export:null
fpgm_export:null
distill_export:null
@@ -37,7 +37,7 @@ export2:null
infer_model:null
infer_export:null
infer_quant:null
-inference:../legacy/examples/machine_translation/transformer/deploy/python/inference.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.base.yaml --profile --test_file ../legacy/examples/machine_translation/transformer/test.en ../legacy/examples/machine_translation/transformer/test.de --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+inference:../slm/examples/machine_translation/transformer/deploy/python/inference.py --config ../slm/examples/machine_translation/transformer/configs/transformer.base.yaml --profile --test_file ../slm/examples/machine_translation/transformer/test.en ../slm/examples/machine_translation/transformer/test.de --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
--device:gpu|cpu
--use_mkl:True
--threads:1|6
diff --git a/tests/test_tipc/configs/transformer/base/transformer_base_static_params.txt b/tests/test_tipc/configs/transformer/base/transformer_base_static_params.txt
index 38f706407cab..442d4d5dfe88 100644
--- a/tests/test_tipc/configs/transformer/base/transformer_base_static_params.txt
+++ b/tests/test_tipc/configs/transformer/base/transformer_base_static_params.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/static/train.py --config ../examples/machine_translation/transformer/configs/transformer.base.yaml --distributed --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33708 --unk_token "" --bos_token "" --eos_token ""
+norm_train:../slm/examples/machine_translation/transformer/static/train.py --config ../examples/machine_translation/transformer/configs/transformer.base.yaml --distributed --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33708 --unk_token "" --bos_token "" --eos_token ""
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/transformer/big/train_dy2static_python.txt b/tests/test_tipc/configs/transformer/big/train_dy2static_python.txt
index 614e045c6820..215e9972d5a3 100644
--- a/tests/test_tipc/configs/transformer/big/train_dy2static_python.txt
+++ b/tests/test_tipc/configs/transformer/big/train_dy2static_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/train.py --config ../examples/machine_translation/transformer/configs/transformer.big.yaml --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+norm_train:../slm/examples/machine_translation/transformer/train.py --config ../examples/machine_translation/transformer/configs/transformer.big.yaml --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/configs/transformer/big/train_infer_python.txt b/tests/test_tipc/configs/transformer/big/train_infer_python.txt
index b96000788365..956497a3a9b5 100644
--- a/tests/test_tipc/configs/transformer/big/train_infer_python.txt
+++ b/tests/test_tipc/configs/transformer/big/train_infer_python.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/train.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.big.yaml --train_file ../legacy/examples/machine_translation/transformer/train.en ../legacy/examples/machine_translation/transformer/train.de --dev_file ../legacy/examples/machine_translation/transformer/dev.en ../legacy/examples/machine_translation/transformer/dev.de --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+norm_train:../slm/examples/machine_translation/transformer/train.py --config ../slm/examples/machine_translation/transformer/configs/transformer.big.yaml --train_file ../slm/examples/machine_translation/transformer/train.en ../slm/examples/machine_translation/transformer/train.de --dev_file ../slm/examples/machine_translation/transformer/dev.en ../slm/examples/machine_translation/transformer/dev.de --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
pact_train:null
fpgm_train:null
distill_train:null
@@ -21,13 +21,13 @@ null:null
null:null
##
===========================eval_params===========================
-eval:../legacy/examples/machine_translation/transformer/predict.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.big.yaml --test_file ../legacy/examples/machine_translation/transformer/test.en ../legacy/examples/machine_translation/transformer/test.de --without_ft --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+eval:../slm/examples/machine_translation/transformer/predict.py --config ../slm/examples/machine_translation/transformer/configs/transformer.big.yaml --test_file ../slm/examples/machine_translation/transformer/test.en ../slm/examples/machine_translation/transformer/test.de --without_ft --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
null:null
##
===========================infer_params===========================
null:null
null:null
-norm_export:../legacy/examples/machine_translation/transformer/export_model.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.big.yaml --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --bos_token "" --eos_token "" --benchmark
+norm_export:../slm/examples/machine_translation/transformer/export_model.py --config ../slm/examples/machine_translation/transformer/configs/transformer.big.yaml --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --bos_token "" --eos_token "" --benchmark
quant_export:null
fpgm_export:null
distill_export:null
@@ -37,7 +37,7 @@ export2:null
infer_model:null
infer_export:null
infer_quant:null
-inference:../legacy/examples/machine_translation/transformer/deploy/python/inference.py --config ../legacy/examples/machine_translation/transformer/configs/transformer.big.yaml --profile --test_file ../legacy/examples/machine_translation/transformer/test.en ../legacy/examples/machine_translation/transformer/test.de --vocab_file ../legacy/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
+inference:../slm/examples/machine_translation/transformer/deploy/python/inference.py --config ../slm/examples/machine_translation/transformer/configs/transformer.big.yaml --profile --test_file ../slm/examples/machine_translation/transformer/test.en ../slm/examples/machine_translation/transformer/test.de --vocab_file ../slm/examples/machine_translation/transformer/vocab_all.bpe.33712 --unk_token "" --bos_token "" --eos_token "" --benchmark
--device:gpu|cpu
--use_mkl:True
--threads:1|6
diff --git a/tests/test_tipc/configs/transformer/big/transformer_big_static_params.txt b/tests/test_tipc/configs/transformer/big/transformer_big_static_params.txt
index 49a9908cbc81..48b0d99d89ae 100644
--- a/tests/test_tipc/configs/transformer/big/transformer_big_static_params.txt
+++ b/tests/test_tipc/configs/transformer/big/transformer_big_static_params.txt
@@ -13,7 +13,7 @@ null:null
null:null
##
trainer:norm_train
-norm_train:../legacy/examples/machine_translation/transformer/static/train.py --config ../examples/machine_translation/transformer/configs/transformer.big.yaml --distributed --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33708 --unk_token "" --bos_token "" --eos_token ""
+norm_train:../slm/examples/machine_translation/transformer/static/train.py --config ../examples/machine_translation/transformer/configs/transformer.big.yaml --distributed --train_file ../examples/machine_translation/transformer/train.en ../examples/machine_translation/transformer/train.de --dev_file ../examples/machine_translation/transformer/dev.en ../examples/machine_translation/transformer/dev.de --vocab_file ../examples/machine_translation/transformer/vocab_all.bpe.33708 --unk_token "" --bos_token "" --eos_token ""
pact_train:null
fpgm_train:null
distill_train:null
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/baichun2/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/hybrid_parallelism/baichun2/benchmark_common/prepare.sh
index 7627ad5d8ca0..db8e3d35b5c6 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/baichun2/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/baichun2/benchmark_common/prepare.sh
@@ -16,7 +16,7 @@ python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/prepare.sh
index 7ced964b7480..bacfac2bf7a0 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/prepare.sh
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cd ../legacy/model_zoo/gpt-3/data_tools/
+cd ../slm/model_zoo/gpt-3/data_tools/
sed -i "s/python3/python3.7/g" Makefile
cd -
@@ -23,7 +23,7 @@ python3 -m pip install pybind11 regex sentencepiece tqdm visualdl #-i https://mi
python3 -m pip install --upgrade paddlenlp
python3 -m pip install fast_dataindex -i https://mirror.baidu.com/pypi/simple
# get data
-cd ../legacy/model_zoo/gpt-3/dygraph/
+cd ../slm/model_zoo/gpt-3/dygraph/
rm -rf data
mkdir data && cd data
wget https://bj.bcebos.com/paddlenlp/models/transformers/gpt2/train.data.json_ids.npz
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh b/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
index 66cc7ae713d2..bb8b442133c5 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
@@ -66,7 +66,7 @@ function _train(){
mkdir $OUTPUT_PATH
# if [ ${model_item} = "gpt3_moe" ];then
- # static_scripts="../legacy/model_zoo/gpt-moe/dygraph/"
+ # static_scripts="../slm/model_zoo/gpt-moe/dygraph/"
# else
# echo "not supported model item: ${model_item}"; exit 1;
# fi
@@ -149,7 +149,7 @@ function _train(){
*) echo "choose run_mode "; exit 1;
esac
fi
- cd ../legacy/model_zoo/gpt-3/dygraph/
+ cd ../slm/model_zoo/gpt-3/dygraph/
echo "train_cmd: ${train_cmd} log_file: ${log_file}"
python -c "import paddlenlp"
if [[ ${model_item} =~ "CE" ]];then # CE精度-不限制执行时间
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/llama/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/hybrid_parallelism/llama/benchmark_common/prepare.sh
index c4ef71fda95f..fc2a90c5cfaa 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/llama/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/llama/benchmark_common/prepare.sh
@@ -16,7 +16,7 @@ python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/llama2/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/hybrid_parallelism/llama2/benchmark_common/prepare.sh
index 36ad272531af..3352bbd336af 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/llama2/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/llama2/benchmark_common/prepare.sh
@@ -16,7 +16,7 @@ python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/dygraph/hybrid_parallelism/qwen/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/hybrid_parallelism/qwen/benchmark_common/prepare.sh
index c69d4b4605ca..3b2264915cf5 100644
--- a/tests/test_tipc/dygraph/hybrid_parallelism/qwen/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/hybrid_parallelism/qwen/benchmark_common/prepare.sh
@@ -18,7 +18,7 @@ python -m pip install -r ../requirements-dev.txt
python -m pip install tiktoken
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/dygraph/moe/gpt/benchmark_common/prepare.sh b/tests/test_tipc/dygraph/moe/gpt/benchmark_common/prepare.sh
index ebb7ad65fd47..32d39d5d5a54 100644
--- a/tests/test_tipc/dygraph/moe/gpt/benchmark_common/prepare.sh
+++ b/tests/test_tipc/dygraph/moe/gpt/benchmark_common/prepare.sh
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cd ../legacy/model_zoo/moe/data_tools/
+cd ../slm/model_zoo/moe/data_tools/
sed -i "s/python3/python3.10/g" Makefile
cd -
@@ -22,7 +22,7 @@ python3 -m pip install -r ../requirements.txt #-i https://pypi.tuna.tsinghua.edu
python3 -m pip install pybind11 regex sentencepiece tqdm visualdl #-i https://mirror.baidu.com/pypi/simple
python3 -m pip install --upgrade paddlenlp
# get data
-cd ../legacy/model_zoo/moe/dygraph/
+cd ../slm/model_zoo/moe/dygraph/
rm -rf data
mkdir data && cd data
wget https://bj.bcebos.com/paddlenlp/models/transformers/gpt2/train.data.json_ids.npz
\ No newline at end of file
diff --git a/tests/test_tipc/dygraph/moe/gpt/benchmark_common/run_benchmark.sh b/tests/test_tipc/dygraph/moe/gpt/benchmark_common/run_benchmark.sh
index fe469b08a34c..7282fad26901 100644
--- a/tests/test_tipc/dygraph/moe/gpt/benchmark_common/run_benchmark.sh
+++ b/tests/test_tipc/dygraph/moe/gpt/benchmark_common/run_benchmark.sh
@@ -60,7 +60,7 @@ function _train(){
mkdir $OUTPUT_PATH
# if [ ${model_item} = "gpt3_moe" ];then
- # static_scripts="../legacy/model_zoo/gpt-moe/dygraph/"
+ # static_scripts="../slm/model_zoo/gpt-moe/dygraph/"
# else
# echo "not supported model item: ${model_item}"; exit 1;
# fi
@@ -147,7 +147,7 @@ function _train(){
;;
*) echo "choose run_mode "; exit 1;
esac
- cd ../legacy/model_zoo/moe/dygraph/
+ cd ../slm/model_zoo/moe/dygraph/
echo "train_cmd: ${train_cmd} log_file: ${log_file}"
python -c "import paddlenlp"
if [[ ${model_item} =~ "CE" ]];then # CE精度-不限制执行时间
diff --git a/tests/test_tipc/prepare.sh b/tests/test_tipc/prepare.sh
index 5ee6a378d3df..1062bb37cc94 100644
--- a/tests/test_tipc/prepare.sh
+++ b/tests/test_tipc/prepare.sh
@@ -45,11 +45,11 @@ if [ ${MODE} = "lite_train_lite_infer" ];then
fi
if [ ${model_name} == "ernie_information_extraction" ]; then
- python ../legacy/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
+ python ../slm/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
fi
if [[ ${model_name} =~ transformer* ]]; then
- cd ../legacy/examples/machine_translation/transformer/
+ cd ../slm/examples/machine_translation/transformer/
# The whole procedure of lite_train_infer should be less than 15min.
# Hence, set maximum output length is 16.
@@ -112,11 +112,11 @@ elif [ ${MODE} = "whole_train_whole_infer" ];then
fi
if [ ${model_name} == "ernie_information_extraction" ]; then
- python ../legacy/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
+ python ../slm/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
fi
if [[ ${model_name} =~ transformer* ]]; then
- cd ../legacy/examples/machine_translation/transformer/
+ cd ../slm/examples/machine_translation/transformer/
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml
@@ -176,11 +176,11 @@ elif [ ${MODE} = "lite_train_whole_infer" ];then
fi
if [ ${model_name} == "ernie_information_extraction" ]; then
- python ../legacy/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
+ python ../slm/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
fi
if [[ ${model_name} =~ transformer* ]]; then
- cd ../legacy/examples/machine_translation/transformer/
+ cd ../slm/examples/machine_translation/transformer/
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml
@@ -256,11 +256,11 @@ elif [ ${MODE} = "whole_infer" ];then
fi
if [ ${model_name} == "ernie_information_extraction" ]; then
- python ../legacy/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
+ python ../slm/examples/information_extraction/waybill_ie/download.py --data_dir ./waybill_ie
fi
if [[ ${model_name} =~ transformer* ]]; then
- cd ../legacy/examples/machine_translation/transformer/
+ cd ../slm/examples/machine_translation/transformer/
sed -i "s/^max_out_len.*/max_out_len: 256/g" configs/transformer.base.yaml
sed -i "s/^max_out_len.*/max_out_len: 1024/g" configs/transformer.big.yaml
@@ -340,7 +340,7 @@ elif [ ${MODE} = "benchmark_train" ];then
fi
if [[ ${model_name} =~ transformer* ]]; then
- cd ../legacy/examples/machine_translation/transformer/
+ cd ../slm/examples/machine_translation/transformer/
git checkout .
diff --git a/tests/test_tipc/static/auto_parallel/llama2/benchmark_common/prepare.sh b/tests/test_tipc/static/auto_parallel/llama2/benchmark_common/prepare.sh
index ddd30134f126..1ef408d706bd 100644
--- a/tests/test_tipc/static/auto_parallel/llama2/benchmark_common/prepare.sh
+++ b/tests/test_tipc/static/auto_parallel/llama2/benchmark_common/prepare.sh
@@ -16,7 +16,7 @@ python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt
# install fused_ln custom ops
-cd ../legacy/model_zoo/gpt-3/external_ops/
+cd ../slm/model_zoo/gpt-3/external_ops/
python setup.py install
cd -
diff --git a/tests/test_tipc/static/dp/bert/benchmark_common/run_benchmark.sh b/tests/test_tipc/static/dp/bert/benchmark_common/run_benchmark.sh
index b34e66f9a756..9a28844b23be 100644
--- a/tests/test_tipc/static/dp/bert/benchmark_common/run_benchmark.sh
+++ b/tests/test_tipc/static/dp/bert/benchmark_common/run_benchmark.sh
@@ -45,7 +45,7 @@ function _set_params(){
function _train(){
batch_size=${base_batch_size} # 如果模型跑多卡单进程时,请在_train函数中计算出多卡需要的bs
- static_scripts="../legacy/model_zoo/bert/static/"
+ static_scripts="../slm/model_zoo/bert/static/"
gradient_merge_steps=$(expr 67584 \/ $batch_size \/ 8)
diff --git a/tests/test_tipc/static/dp/gpt/benchmark_common/prepare.sh b/tests/test_tipc/static/dp/gpt/benchmark_common/prepare.sh
index 5874d35c38b6..5ce60f660e61 100644
--- a/tests/test_tipc/static/dp/gpt/benchmark_common/prepare.sh
+++ b/tests/test_tipc/static/dp/gpt/benchmark_common/prepare.sh
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cd ../legacy/model_zoo/gpt/data_tools/
+cd ../slm/model_zoo/gpt/data_tools/
sed -i "s/python3/python/g" Makefile
sed -i "s/python-config/python3.7m-config/g" Makefile
cd -
-cd ../legacy/model_zoo/gpt-3/data_tools/
+cd ../slm/model_zoo/gpt-3/data_tools/
sed -i "s/python3/python/g" Makefile
sed -i "s/python-config/python3.7m-config/g" Makefile
cd -
diff --git a/tests/test_tipc/static/dp/gpt/benchmark_common/run_benchmark.sh b/tests/test_tipc/static/dp/gpt/benchmark_common/run_benchmark.sh
index 1c763adeaa70..fe4d66e78c57 100644
--- a/tests/test_tipc/static/dp/gpt/benchmark_common/run_benchmark.sh
+++ b/tests/test_tipc/static/dp/gpt/benchmark_common/run_benchmark.sh
@@ -54,9 +54,9 @@ function _train(){
fi
if [ ${model_item} = "gpt2" ];then
- static_scripts="../legacy/model_zoo/gpt/"
+ static_scripts="../slm/model_zoo/gpt/"
else
- static_scripts="../legacy/model_zoo/gpt-3/static/"
+ static_scripts="../slm/model_zoo/gpt-3/static/"
fi
echo "current CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}, model_name=${model_name}, device_num=${device_num}, is profiling=${profiling}"
diff --git a/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/prepare.sh b/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/prepare.sh
index 89f64229bea8..80ba1ba8db50 100644
--- a/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/prepare.sh
+++ b/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/prepare.sh
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cd ../legacy/model_zoo/gpt-3/data_tools/
+cd ../slm/model_zoo/gpt-3/data_tools/
sed -i "s/python3/python3.7/g" Makefile
cd -
@@ -22,6 +22,6 @@ python -m pip install pybind11 regex sentencepiece tqdm visualdl -i https://mirr
python -m pip install fast_dataindex -i https://mirror.baidu.com/pypi/simple
# get data
-cd ../legacy/model_zoo/gpt-3/static/
+cd ../slm/model_zoo/gpt-3/static/
mkdir train_data && cd train_data
wget https://bj.bcebos.com/paddlenlp/models/transformers/gpt2/train.data.json_ids.npz
diff --git a/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh b/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
index db2ff639afe6..e3fe8bbf15e8 100644
--- a/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
+++ b/tests/test_tipc/static/hybrid_parallelism/gpt/benchmark_common/run_benchmark.sh
@@ -61,9 +61,9 @@ function _train(){
mkdir $OUTPUT_PATH
if [ ${model_item} = "gpt2" ];then
- static_scripts="../legacy/model_zoo/gpt/"
+ static_scripts="../slm/model_zoo/gpt/"
else
- static_scripts="../legacy/model_zoo/gpt-3/static/"
+ static_scripts="../slm/model_zoo/gpt-3/static/"
fi
echo "current CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}, model_name=${model_name}, device_num=${device_num}, is profiling=${profiling}"
@@ -165,7 +165,7 @@ function _train(){
;;
*) echo "choose run_mode "; exit 1;
esac
- cd ../legacy/model_zoo/gpt-3/static/
+ cd ../slm/model_zoo/gpt-3/static/
echo "train_cmd: ${train_cmd} log_file: ${log_file}"
python -c "import paddlenlp"
timeout 15m ${train_cmd} > ${log_file} 2>&1
|