Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
tutorial
游雁5ebac59f9e76
diff --git a/README.md b/README.mdindex e7ff1b10e..95529c629 100644--- a/README.md+++ b/README.md@@ -67,7 +67,7 @@ pip3 install -U modelscope```## Model Zoo-FunASR has open-sourced a large number of pre-trained models on industrial data. You are free to use, copy, modify, and share FunASR models under the [Model License Agreement](./MODEL_LICENSE). Below are some representative models, for more models please refer to the [Model Zoo]().+FunASR has open-sourced a large number of pre-trained models on industrial data. You are free to use, copy, modify, and share FunASR models under the [Model License Agreement](./MODEL_LICENSE). Below are some representative models, for more models please refer to the [Model Zoo](./model_zoo).(Note: ⭐ represents the ModelScope model zoo, 🤗 represents the Huggingface model zoo, 🍀 represents the OpenAI model zoo)diff --git a/README_zh.md b/README_zh.mdindex 46af926ee..eeedc0495 100644--- a/README_zh.md+++ b/README_zh.md@@ -69,7 +69,7 @@ pip3 install -U modelscope## 模型仓库-FunASR开源了大量在工业数据上预训练模型,您可以在[模型许可协议](./MODEL_LICENSE)下自由使用、复制、修改和分享FunASR模型,下面列举代表性的模型,更多模型请参考[模型仓库]()。+FunASR开源了大量在工业数据上预训练模型,您可以在[模型许可协议](./MODEL_LICENSE)下自由使用、复制、修改和分享FunASR模型,下面列举代表性的模型,更多模型请参考 [模型仓库](./model_zoo)。(注:⭐ 表示ModelScope模型仓库,🤗 表示Huggingface模型仓库,🍀表示OpenAI模型仓库)@@ -208,7 +208,8 @@ text_file = f"{model.model_path}/example/text.txt"res = model.generate(input=(wav_file, text_file), data_type=("sound", "text"))print(res)```-更多详细用法([示例](https://github.com/alibaba-damo-academy/FunASR/tree/main/examples/industrial_data_pretraining))+更详细([用法](docs/tutorial/README_zh.md)),+更多([示例](https://github.com/alibaba-damo-academy/FunASR/tree/main/examples/industrial_data_pretraining))## 导出ONNX### 从命令行导出diff --git a/docs/runtime b/docs/runtimedeleted file mode 120000index 3d1f9906c..000000000--- a/docs/runtime+++ /dev/null@@ -1 +0,0 @@-../runtime\ No newline at end of filediff --git a/docs/tutorial/README_zh.md b/docs/tutorial/README_zh.mdnew file mode 100644index 000000000..97bce7193--- /dev/null+++ b/docs/tutorial/README_zh.md@@ -0,0 +1,186 @@+(简体中文|[English](./README.md))++FunASR开源了大量在工业数据上预训练模型,您可以在[模型许可协议](../../MODEL_LICENSE)下自由使用、复制、修改和分享FunASR模型,下面列举代表性的模型,更多模型请参考 [模型仓库](../../model_zoo)。+++## 推理++### 快速使用+#### [Paraformer 模型](https://www.modelscope.cn/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary)+```python+from funasr import AutoModel++model = AutoModel(model="/Users/zhifu/Downloads/modelscope_models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch")++res = model.generate(input="/Users/zhifu/Downloads/modelscope_models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav")+print(res)+```++### 详细用法介绍+```python+model = AutoModel(model=[str], device=[str], ncpu=[int], output_dir=[str], batch_size=[int], **kwargs)+```+#### AutoModel 定义+- `model`(str): [模型仓库](https://alibaba-damo-academy.github.io/FunASR/en/model_zoo/modelscope_models.html#pretrained-models-on-modelscope) 中的模型名称,或本地磁盘中的模型路径+- `device`(str): `cuda:0`(默认gpu0),使用 GPU 进行推理,指定。如果为`cpu`,则使用 CPU 进行推理+- `ncpu`(int): `4` (默认),设置用于 CPU 内部操作并行性的线程数+- `output_dir`(str): `None` (默认),如果设置,输出结果的输出路径+- `batch_size`(int): `1` (默认),解码时的批处理大小+- `**kwargs`(dict): 所有在`config.yaml`中参数,均可以直接在此处指定,例如,vad模型中最大切割长度 `max_single_segment_time=6000` (毫秒)。+#### AutoModel 推理+```python+res = model.generate(input=[str], output_dir=[str])+```+- `input`: 要解码的输入,可以是:+ - wav文件路径, 例如: asr_example.wav+ - pcm文件路径, 例如: asr_example.pcm,此时需要指定音频采样率fs(默认为16000)+ - 音频字节数流,例如:麦克风的字节数数据+ - wav.scp,kaldi 样式的 wav 列表 (`wav_id \t wav_path`), 例如:+ ```text+ asr_example1 ./audios/asr_example1.wav+ asr_example2 ./audios/asr_example2.wav+ ```+ 在这种输入 `wav.scp` 的情况下,必须设置 `output_dir` 以保存输出结果+ - 音频采样点,例如:`audio, rate = soundfile.read("asr_example_zh.wav")`, 数据类型为 numpy.ndarray。支持batch输入,类型为list:+ ```[audio_sample1, audio_sample2, ..., audio_sampleN]```+ - fbank输入,支持组batch。shape为[batch, frames, dim],类型为torch.Tensor,例如+- `output_dir`: None (默认),如果设置,输出结果的输出路径+- `**kwargs`(dict): 与模型相关的推理参数,例如,`beam_size=10`,`decoding_ctc_weight=0.1`。++### onnx与libtorch导出++```python+res = model.export(type="onnx", quantize=True)+```+- `type`(str):`onnx`(默认),导出onnx格式。`torch`导出libtorch格式。+- `quantize`(bool):`False`(默认),是否做量化。+++## 微调++### 快速开始+```shell+cd examples/industrial_data_pretraining/paraformer+bash finetune.sh+# "log_file: ./outputs/log.txt"+```+详细完整的脚本参考 [finetune.sh](../../examples/industrial_data_pretraining/paraformer/finetune.sh)++### 详细参数介绍++```shell+funasr/bin/train.py \+++model="${model_name_or_model_dir}" \+++model_revision="${model_revision}" \+++train_data_set_list="${train_data}" \+++valid_data_set_list="${val_data}" \+++dataset_conf.batch_size=20000 \+++dataset_conf.batch_type="token" \+++dataset_conf.num_workers=4 \+++train_conf.max_epoch=50 \+++train_conf.log_interval=1 \+++train_conf.resume=false \+++train_conf.validate_interval=2000 \+++train_conf.save_checkpoint_interval=2000 \+++train_conf.keep_nbest_models=20 \+++optim_conf.lr=0.0002 \+++output_dir="${output_dir}" &> ${log_file}+```++- `model`(str):模型名字(模型仓库中的ID),此时脚本会自动下载模型到本读;或者本地已经下载好的模型路径。+- `model_revision`(str):当 `model` 为模型名字时,下载指定版本的模型。+- `train_data_set_list`(str):训练数据路径,默认为jsonl格式,具体参考([例子](../../data/list))。+- `valid_data_set_list`(str):验证数据路径,默认为jsonl格式,具体参考([例子](../../data/list))。+- `dataset_conf.batch_type`(str):`example`(默认),batch的类型。`example`表示按照固定数目batch_size个样本组batch;`length` or `token` 表示动态组batch,batch总长度或者token数为batch_size。+- `dataset_conf.batch_size`(int):与 `batch_type` 搭配使用,当 `batch_type=example` 时,表示样本个数;当 `batch_type=length` 时,表示样本中长度,单位为fbank帧数(1帧10ms)或者文字token个数。+- `train_conf.max_epoch`(int):训练总epoch数。+- `train_conf.log_interval`(int):打印日志间隔step数。+- `train_conf.resume`(int):是否开启断点重训。+- `train_conf.validate_interval`(int):训练中做验证测试的间隔step数。+- `train_conf.save_checkpoint_interval`(int):训练中模型保存间隔step数。+- `train_conf.keep_nbest_models`(int):保留最大多少个模型参数,按照验证集acc排序,从高到底保留。+- `optim_conf.lr`(float):学习率。+- `output_dir`(str):模型保存路径。+- `**kwargs`(dict): 所有在`config.yaml`中参数,均可以直接在此处指定,例如,过滤20s以上长音频:`dataset_conf.max_token_length=2000`,单位为音频fbank帧数(1帧10ms)或者文字token个数。++#### 多gpu训练+##### 单机多gpu训练+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 1 --nproc_per_node ${gpu_num} \+../../../funasr/bin/train.py ${train_args}+```+--nnodes 表示参与的节点总数,--nproc_per_node 表示每个节点上运行的进程数++##### 多机多gpu训练++在主节点上,假设IP为192.168.1.1,端口为12345,使用的是2个GPU,则运行如下命令:+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 2 --nproc_per_node ${gpu_num} --master_addr=192.168.1.1 --master_port=12345 \+../../../funasr/bin/train.py ${train_args}+```+在从节点上(假设IP为192.168.1.2),你需要确保MASTER_ADDR和MASTER_PORT环境变量与主节点设置的一致,并运行同样的命令:+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 2 --nproc_per_node ${gpu_num} --master_addr=192.168.1.1 --master_port=12345 \+../../../funasr/bin/train.py ${train_args}+```++--nnodes 表示参与的节点总数,--nproc_per_node 表示每个节点上运行的进程数++#### 准备数据++`train_text.txt`++左边为数据唯一ID,需与`train_wav.scp`中的`ID`一一对应+右边为音频文件标注文本,格式如下:++```bash+ID0012W0013 当客户风险承受能力评估依据发生变化时+ID0012W0014 所有只要处理 data 不管你是做 machine learning 做 deep learning+ID0012W0015 he tried to think how it could be+```+++`train_wav.scp`++左边为数据唯一ID,需与`train_text.txt`中的`ID`一一对应+右边为音频文件的路径,格式如下++```bash+BAC009S0764W0121 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0764W0121.wav+BAC009S0916W0489 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0916W0489.wav+ID0012W0015 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_cn_en.wav+```+++#### 查看训练日志++##### 查看实验log+```shell+tail log.txt+[2024-03-21 15:55:52,137][root][INFO] - train, rank: 3, epoch: 0/50, step: 6990/1, total step: 6990, (loss_avg_rank: 0.327), (loss_avg_epoch: 0.409), (ppl_avg_epoch: 1.506), (acc_avg_epoch: 0.795), (lr: 1.165e-04), [('loss_att', 0.259), ('acc', 0.825), ('loss_pre', 0.04), ('loss', 0.299), ('batch_size', 40)], {'data_load': '0.000', 'forward_time': '0.315', 'backward_time': '0.555', 'optim_time': '0.076', 'total_time': '0.947'}, GPU, memory: usage: 3.830 GB, peak: 18.357 GB, cache: 20.910 GB, cache_peak: 20.910 GB+[2024-03-21 15:55:52,139][root][INFO] - train, rank: 1, epoch: 0/50, step: 6990/1, total step: 6990, (loss_avg_rank: 0.334), (loss_avg_epoch: 0.409), (ppl_avg_epoch: 1.506), (acc_avg_epoch: 0.795), (lr: 1.165e-04), [('loss_att', 0.285), ('acc', 0.823), ('loss_pre', 0.046), ('loss', 0.331), ('batch_size', 36)], {'data_load': '0.000', 'forward_time': '0.334', 'backward_time': '0.536', 'optim_time': '0.077', 'total_time': '0.948'}, GPU, memory: usage: 3.943 GB, peak: 18.291 GB, cache: 19.619 GB, cache_peak: 19.619 GB+```+指标解释:+- `rank`:表示gpu id。+- `epoch`,`step`,`total step`:表示当前epoch,step,总step。+- `loss_avg_rank`:表示当前step,所有gpu平均loss。+- `loss/ppl/acc_avg_epoch`:表示当前epoch周期,截止当前step数时,总平均loss/ppl/acc。epoch结束时的最后一个step表示epoch总平均loss/ppl/acc,推荐使用acc指标。+- `lr`:当前step的学习率。+- `[('loss_att', 0.259), ('acc', 0.825), ('loss_pre', 0.04), ('loss', 0.299), ('batch_size', 40)]`:表示当前gpu id的具体数据。+- `total_time`:表示单个step总耗时。+- `GPU, memory`:分别表示,模型使用/峰值显存,模型+缓存使用/峰值显存。++##### tensorboard可视化+```bash+tensorboard --logdir /xxxx/FunASR/examples/industrial_data_pretraining/paraformer/outputs/log/tensorboard+```+浏览器中打开:http://localhost:6006/diff --git a/examples/README_zh.md b/examples/README_zh.mdnew file mode 120000index 000000000..a2059ae65--- /dev/null+++ b/examples/README_zh.md@@ -0,0 +1 @@+../docs/tutorial/README_zh.md\ No newline at end of filediff --git a/examples/industrial_data_pretraining/paraformer/README_zh.md b/examples/industrial_data_pretraining/paraformer/README_zh.mdindex 38a445573..97bce7193 100644--- a/examples/industrial_data_pretraining/paraformer/README_zh.md+++ b/examples/industrial_data_pretraining/paraformer/README_zh.md@@ -1,9 +1,7 @@(简体中文|[English](./README.md))-# 语音识别+FunASR开源了大量在工业数据上预训练模型,您可以在[模型许可协议](../../MODEL_LICENSE)下自由使用、复制、修改和分享FunASR模型,下面列举代表性的模型,更多模型请参考 [模型仓库](../../model_zoo)。-> **注意**:-> pipeline 支持 [modelscope模型仓库](https://alibaba-damo-academy.github.io/FunASR/en/model_zoo/modelscope_models.html#pretrained-models-on-modelscope) 中的所有模型进行推理和微调。这里我们以典型模型作为示例来演示使用方法。## 推理@@ -14,18 +12,25 @@ from funasr import AutoModelmodel = AutoModel(model="/Users/zhifu/Downloads/modelscope_models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch")-res = model(input="/Users/zhifu/Downloads/modelscope_models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav")+res = model.generate(input="/Users/zhifu/Downloads/modelscope_models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav")print(res)```-### API接口说明+### 详细用法介绍+```python+model = AutoModel(model=[str], device=[str], ncpu=[int], output_dir=[str], batch_size=[int], **kwargs)+```#### AutoModel 定义-- `model`: [模型仓库](https://alibaba-damo-academy.github.io/FunASR/en/model_zoo/modelscope_models.html#pretrained-models-on-modelscope) 中的模型名称,或本地磁盘中的模型路径-- `device`: `cuda`(默认),使用 GPU 进行推理。如果为`cpu`,则使用 CPU 进行推理-- `ncpu`: `None` (默认),设置用于 CPU 内部操作并行性的线程数-- `output_dir`: `None` (默认),如果设置,输出结果的输出路径-- `batch_size`: `1` (默认),解码时的批处理大小+- `model`(str): [模型仓库](https://alibaba-damo-academy.github.io/FunASR/en/model_zoo/modelscope_models.html#pretrained-models-on-modelscope) 中的模型名称,或本地磁盘中的模型路径+- `device`(str): `cuda:0`(默认gpu0),使用 GPU 进行推理,指定。如果为`cpu`,则使用 CPU 进行推理+- `ncpu`(int): `4` (默认),设置用于 CPU 内部操作并行性的线程数+- `output_dir`(str): `None` (默认),如果设置,输出结果的输出路径+- `batch_size`(int): `1` (默认),解码时的批处理大小+- `**kwargs`(dict): 所有在`config.yaml`中参数,均可以直接在此处指定,例如,vad模型中最大切割长度 `max_single_segment_time=6000` (毫秒)。#### AutoModel 推理+```python+res = model.generate(input=[str], output_dir=[str])+```- `input`: 要解码的输入,可以是:- wav文件路径, 例如: asr_example.wav- pcm文件路径, 例如: asr_example.pcm,此时需要指定音频采样率fs(默认为16000)@@ -40,56 +45,142 @@ print(res)```[audio_sample1, audio_sample2, ..., audio_sampleN]```- fbank输入,支持组batch。shape为[batch, frames, dim],类型为torch.Tensor,例如- `output_dir`: None (默认),如果设置,输出结果的输出路径+- `**kwargs`(dict): 与模型相关的推理参数,例如,`beam_size=10`,`decoding_ctc_weight=0.1`。++### onnx与libtorch导出++```python+res = model.export(type="onnx", quantize=True)+```+- `type`(str):`onnx`(默认),导出onnx格式。`torch`导出libtorch格式。+- `quantize`(bool):`False`(默认),是否做量化。## 微调+### 快速开始+```shell+cd examples/industrial_data_pretraining/paraformer+bash finetune.sh+# "log_file: ./outputs/log.txt"+```+详细完整的脚本参考 [finetune.sh](../../examples/industrial_data_pretraining/paraformer/finetune.sh)++### 详细参数介绍++```shell+funasr/bin/train.py \+++model="${model_name_or_model_dir}" \+++model_revision="${model_revision}" \+++train_data_set_list="${train_data}" \+++valid_data_set_list="${val_data}" \+++dataset_conf.batch_size=20000 \+++dataset_conf.batch_type="token" \+++dataset_conf.num_workers=4 \+++train_conf.max_epoch=50 \+++train_conf.log_interval=1 \+++train_conf.resume=false \+++train_conf.validate_interval=2000 \+++train_conf.save_checkpoint_interval=2000 \+++train_conf.keep_nbest_models=20 \+++optim_conf.lr=0.0002 \+++output_dir="${output_dir}" &> ${log_file}+```++- `model`(str):模型名字(模型仓库中的ID),此时脚本会自动下载模型到本读;或者本地已经下载好的模型路径。+- `model_revision`(str):当 `model` 为模型名字时,下载指定版本的模型。+- `train_data_set_list`(str):训练数据路径,默认为jsonl格式,具体参考([例子](../../data/list))。+- `valid_data_set_list`(str):验证数据路径,默认为jsonl格式,具体参考([例子](../../data/list))。+- `dataset_conf.batch_type`(str):`example`(默认),batch的类型。`example`表示按照固定数目batch_size个样本组batch;`length` or `token` 表示动态组batch,batch总长度或者token数为batch_size。+- `dataset_conf.batch_size`(int):与 `batch_type` 搭配使用,当 `batch_type=example` 时,表示样本个数;当 `batch_type=length` 时,表示样本中长度,单位为fbank帧数(1帧10ms)或者文字token个数。+- `train_conf.max_epoch`(int):训练总epoch数。+- `train_conf.log_interval`(int):打印日志间隔step数。+- `train_conf.resume`(int):是否开启断点重训。+- `train_conf.validate_interval`(int):训练中做验证测试的间隔step数。+- `train_conf.save_checkpoint_interval`(int):训练中模型保存间隔step数。+- `train_conf.keep_nbest_models`(int):保留最大多少个模型参数,按照验证集acc排序,从高到底保留。+- `optim_conf.lr`(float):学习率。+- `output_dir`(str):模型保存路径。+- `**kwargs`(dict): 所有在`config.yaml`中参数,均可以直接在此处指定,例如,过滤20s以上长音频:`dataset_conf.max_token_length=2000`,单位为音频fbank帧数(1帧10ms)或者文字token个数。++#### 多gpu训练+##### 单机多gpu训练+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 1 --nproc_per_node ${gpu_num} \+../../../funasr/bin/train.py ${train_args}+```+--nnodes 表示参与的节点总数,--nproc_per_node 表示每个节点上运行的进程数++##### 多机多gpu训练++在主节点上,假设IP为192.168.1.1,端口为12345,使用的是2个GPU,则运行如下命令:+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 2 --nproc_per_node ${gpu_num} --master_addr=192.168.1.1 --master_port=12345 \+../../../funasr/bin/train.py ${train_args}+```+在从节点上(假设IP为192.168.1.2),你需要确保MASTER_ADDR和MASTER_PORT环境变量与主节点设置的一致,并运行同样的命令:+```shell+export CUDA_VISIBLE_DEVICES="0,1"+gpu_num=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')++torchrun --nnodes 2 --nproc_per_node ${gpu_num} --master_addr=192.168.1.1 --master_port=12345 \+../../../funasr/bin/train.py ${train_args}+```++--nnodes 表示参与的节点总数,--nproc_per_node 表示每个节点上运行的进程数+#### 准备数据`train_text.txt`左边为数据唯一ID,需与`train_wav.scp`中的`ID`一一对应-右边为音频文件标注文本+右边为音频文件标注文本,格式如下:```bashID0012W0013 当客户风险承受能力评估依据发生变化时-ID0012W0014 杨涛不得不将工厂关掉+ID0012W0014 所有只要处理 data 不管你是做 machine learning 做 deep learning+ID0012W0015 he tried to think how it could be````train_wav.scp`左边为数据唯一ID,需与`train_text.txt`中的`ID`一一对应-右边为音频文件的绝对路径+右边为音频文件的路径,格式如下```bash-ID0012W0013 /Users/zhifu/funasr_github/test_local/aishell2_dev_ios/wav/D0012/ID0012W0013.wav-ID0012W0014 /Users/zhifu/funasr_github/test_local/aishell2_dev_ios/wav/D0012/ID0012W0014.wav+BAC009S0764W0121 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0764W0121.wav+BAC009S0916W0489 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0916W0489.wav+ID0012W0015 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_cn_en.wav```-#### 训练-```bash-cd examples/industrial_data_pretraining/paraformer-sh finetune_from_local.sh-```--**查看训练日志**+#### 查看训练日志+##### 查看实验log+```shell+tail log.txt+[2024-03-21 15:55:52,137][root][INFO] - train, rank: 3, epoch: 0/50, step: 6990/1, total step: 6990, (loss_avg_rank: 0.327), (loss_avg_epoch: 0.409), (ppl_avg_epoch: 1.506), (acc_avg_epoch: 0.795), (lr: 1.165e-04), [('loss_att', 0.259), ('acc', 0.825), ('loss_pre', 0.04), ('loss', 0.299), ('batch_size', 40)], {'data_load': '0.000', 'forward_time': '0.315', 'backward_time': '0.555', 'optim_time': '0.076', 'total_time': '0.947'}, GPU, memory: usage: 3.830 GB, peak: 18.357 GB, cache: 20.910 GB, cache_peak: 20.910 GB+[2024-03-21 15:55:52,139][root][INFO] - train, rank: 1, epoch: 0/50, step: 6990/1, total step: 6990, (loss_avg_rank: 0.334), (loss_avg_epoch: 0.409), (ppl_avg_epoch: 1.506), (acc_avg_epoch: 0.795), (lr: 1.165e-04), [('loss_att', 0.285), ('acc', 0.823), ('loss_pre', 0.046), ('loss', 0.331), ('batch_size', 36)], {'data_load': '0.000', 'forward_time': '0.334', 'backward_time': '0.536', 'optim_time': '0.077', 'total_time': '0.948'}, GPU, memory: usage: 3.943 GB, peak: 18.291 GB, cache: 19.619 GB, cache_peak: 19.619 GB+```+指标解释:+- `rank`:表示gpu id。+- `epoch`,`step`,`total step`:表示当前epoch,step,总step。+- `loss_avg_rank`:表示当前step,所有gpu平均loss。+- `loss/ppl/acc_avg_epoch`:表示当前epoch周期,截止当前step数时,总平均loss/ppl/acc。epoch结束时的最后一个step表示epoch总平均loss/ppl/acc,推荐使用acc指标。+- `lr`:当前step的学习率。+- `[('loss_att', 0.259), ('acc', 0.825), ('loss_pre', 0.04), ('loss', 0.299), ('batch_size', 40)]`:表示当前gpu id的具体数据。+- `total_time`:表示单个step总耗时。+- `GPU, memory`:分别表示,模型使用/峰值显存,模型+缓存使用/峰值显存。++##### tensorboard可视化```bashtensorboard --logdir /xxxx/FunASR/examples/industrial_data_pretraining/paraformer/outputs/log/tensorboard```---## 导出onnx--```python-from funasr import AutoModel-wav_file = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/vad_example.wav"--model = AutoModel(model="iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",- model_revision="v2.0.4")--res = model.export(input=wav_file, type="onnx", quantize=False)-print(res)-```\ No newline at end of file+浏览器中打开:http://localhost:6006/