diff --git a/.gitattributes b/.gitattributes index 1ef325f1b111266a6b26e0196871bd78baa8c2f3..f2adc91801740874fee8ba6b677733f4960d5cb9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text # Video files - compressed *.mp4 filter=lfs diff=lfs merge=lfs -text *.webm filter=lfs diff=lfs merge=lfs -text +*.json filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md index 7b95401dc46245ac339fc25059d4a56d90b4cde5..205007843e9385e2392bbb25dd4d6e4df74b4209 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,129 @@ +# SAP²-ASR Dataset + +本数据集用于 **SAP² (Speech-Aware Long Context Pruning and Integration)** 方法的上下文感知自动语音识别(ASR)研究。 + +## 📖 简介 + +SAP² 是一个用于上下文感知自动语音识别的新框架,能够动态剪枝并集成相关的上下文关键词。该方法解决了在特定领域场景(如会议演讲)中利用长上下文信息的挑战,这些场景中大量来自OCR的文本上下文既包含相关信息,也包含大量噪声。 + +### 核心特性 + +- **语音感知上下文剪枝**:动态过滤来自OCR的文本上下文,仅保留与语音内容直接相关的关键词 +- **跨模态上下文压缩**:使用语音驱动注意力池化(Speech-Driven Attention-based Pooling)将大量文本输入压缩为简洁的、与语音相关的上下文嵌入 +- **最先进的性能**:在 SlideSpeech 数据集上达到 7.71% 的词错误率(WER),在 LibriSpeech 数据集上达到 1.12% 的 WER,相比非上下文基线,在偏向关键词识别方面相对提升了 41.1% + +## 📊 数据集结构 + +本数据集包含两个主要子数据集: + +### SlideSpeech + +- **来源**:SlideSpeech 是一个包含幻灯片的大规模音视频语料库,包含 1,705 个视频,超过 1,000 小时的音频,其中包括 473 小时的高质量转录语音 +- **数据格式**:JSON 格式,包含音频路径和带上下文关键词的对话格式 +- **目录结构**: + - `slidespeech_L95/`: 原始数据(对应论文中PC) + - `slidespeech_L95_filter/`: 训练TPI第一阶段 + - `slidespeech_L95_filtered_train`: 训练TPI第二阶段 + - `slidespeech_L95_5slides/`: 5张幻灯片版本 + - `slidespeech_L95_multitask/`: 多任务版本(对应论文中的JPI) + +### LibriSpeech + +- **来源**:LibriSpeech 是一个大规模英语朗读语音语料库,源自 LibriVox 项目的有声读物 +- **数据格式**:JSON 格式,包含训练、验证和测试集的不同配置 +- **目录结构**: + - `train-clean-460_*.json`: 训练集(clean,460小时) + - `train-other-500_*.json`: 训练集(other,500小时) + - `dev-clean_*.json`, `dev-other_*.json`: 验证集 + - `test-clean_*.json`, `test-other_*.json`: 测试集(不同规模:100, 500, 1000, 2000条) + +### 数据格式示例 + +```json +{ + "messages": [ + { + "role": "user", + "content": "Transcribe speech to text according to keywords may appear in the utterance. Possible keywords are: <|startofcontext|>keyword1 keyword2 keyword3<|endofcontext|>" + }, + { + "role": "assistant", + "content": "transcribed text" + } + ], + "audios": "/path/to/audio.wav" +} +``` + +**关键标记**: +- `<|startofcontext|>` 和 `<|endofcontext|>`: 用于标记上下文关键词的特殊标记 +- ``: 音频文件路径标记 + +## 🚀 使用方法 + +### 加载数据集 + +```python +import json + +# 加载 SlideSpeech 数据集 +with open('slidespeech/slidespeech_L95_filter/train.json', 'r') as f: + slidespeech_train = json.load(f) + +# 加载 LibriSpeech 数据集 +with open('librispeech/train-clean-460_filter.json', 'r') as f: + librispeech_train = json.load(f) +``` + +### 与 SAP² 模型一起使用 + +详细的使用说明、训练和推理代码请参考: + +**🔗 [SAP²-ASR GitHub Repository](https://github.com/jymh/SAP2-ASR.git)** + +该仓库包含: +- 完整的模型实现代码 +- 训练和推理脚本 +- 数据预处理工具 +- 评估脚本 +- 详细的使用文档 + +## 📎 引用 + +如果您在研究中使用了本数据集,请引用以下论文: + +```bibtex +@article{rong2025speechaware, + title={Speech-Aware Long Context Pruning and Integration for Contextualized Automatic Speech Recognition}, + author={Rong, Yiming and Zhang, Yixin and Wang, Ziyi and Jiang, Deyang and Zhao, Yunlong and Wu, Haoran and Zhou, Shiyu and Xu, Bo}, + journal={arXiv preprint arXiv:2511.11139}, + year={2025} +} +``` + +**论文链接**:[https://www.arxiv.org/abs/2511.11139](https://www.arxiv.org/abs/2511.11139) + +## 📚 相关资源 + +- **代码仓库**:[https://github.com/jymh/SAP2-ASR.git](https://github.com/jymh/SAP2-ASR.git) +- **论文**:[arXiv:2511.11139](https://www.arxiv.org/abs/2511.11139) +- **SlideSpeech 原始数据集**:[https://slidespeech.github.io/](https://slidespeech.github.io/) +- **LibriSpeech 原始数据集**:[OpenSLR](https://www.openslr.org/12/) + +## 🏛 许可证 + +本数据集的使用请遵循原始数据集的许可证要求。对于 SlideSpeech 和 LibriSpeech,请参考其原始资源页面的许可证说明。 + +## ⚠️ 注意事项 + +1. 音频文件路径可能需要根据实际环境进行调整 +2. 数据集文件较大,请确保有足够的存储空间 +3. 使用前请仔细阅读 [GitHub 仓库](https://github.com/jymh/SAP2-ASR.git) 中的详细文档 + +--- + +**更多信息和使用示例,请访问 [SAP²-ASR GitHub Repository](https://github.com/jymh/SAP2-ASR.git)** + --- license: apache-2.0 --- diff --git a/librispeech/dev-clean_filter.json b/librispeech/dev-clean_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..cb933367a2865b1807af5ca6ce14dea9b707b562 --- /dev/null +++ b/librispeech/dev-clean_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:494079e66f5983e481a2423858292e68b7a271e9ba1a704182a0ab3c078860f0 +size 16995084 diff --git a/librispeech/dev-clean_filtered_asr.json b/librispeech/dev-clean_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..3bb093de2319b40e1c5046f9781c2672ab82d9d6 --- /dev/null +++ b/librispeech/dev-clean_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:214bd3858a522b3411d9ba2a6a8e3492e155239bbb637a74ebc1936a63893e83 +size 1361688 diff --git a/librispeech/dev-clean_pc.json b/librispeech/dev-clean_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..5cb2957a203f24a0b6c8fbb2c6c8e25ba8c97a75 --- /dev/null +++ b/librispeech/dev-clean_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:569c4c5bc96b7a8bc1b3edcc51d7114f38c481e7d1e4d4bc6507e08e4c28af51 +size 17284317 diff --git a/librispeech/dev-other_filter.json b/librispeech/dev-other_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..f21524316a9358609f15a811ae1d6be9092717d3 --- /dev/null +++ b/librispeech/dev-other_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:047450d5d1742788e9600fd1430378a24499c9f9ad51a953f49d1dd1d60c6b46 +size 17947988 diff --git a/librispeech/dev-other_filtered_asr.json b/librispeech/dev-other_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..cef3d7bb32e709f18860dc7a707adddf1801b23c --- /dev/null +++ b/librispeech/dev-other_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67bc165d5ab132c65ae18d9d8ebbe6a5496fb4a3d4084e86bb49a756b80db013 +size 1378646 diff --git a/librispeech/dev-other_pc.json b/librispeech/dev-other_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..15787ac8c9e78d733b8c1d27fed669508f66af0c --- /dev/null +++ b/librispeech/dev-other_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf629643a4d0b12969776917ddc013248c17025d170366c19bdfb0b7f34ac388 +size 18225434 diff --git a/librispeech/test-clean_1000_filter.json b/librispeech/test-clean_1000_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..4c2037631ef4588671446a17b9d02b9500f1ac86 --- /dev/null +++ b/librispeech/test-clean_1000_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dc449ac48a83d8a5db2f435932416b7d99e198114571a249ec9c6986b304239 +size 26661553 diff --git a/librispeech/test-clean_1000_filtered_asr.json b/librispeech/test-clean_1000_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..674bc05df5adf9463274a68e8f26f958fea51093 --- /dev/null +++ b/librispeech/test-clean_1000_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:868eb9e72ca917406659dd93b1fda09acec7b4f063a8e9c711547f8b7680b215 +size 1322871 diff --git a/librispeech/test-clean_1000_pc.json b/librispeech/test-clean_1000_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..fb30db2f2dbaa16adfb2398f27990b508c83746e --- /dev/null +++ b/librispeech/test-clean_1000_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e056ed82f802a8cf61e6714de09caef1a78b68eda6349e6447e7a86aa1849de8 +size 26941872 diff --git a/librispeech/test-clean_100_filter.json b/librispeech/test-clean_100_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..fdede0eab9a5739e6437f112a498ac7b3f89b348 --- /dev/null +++ b/librispeech/test-clean_100_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aefeed8018ffe5fb6f8b40803537524e0bbe1bf444e8f93ecc2dbb9524c71a28 +size 3649107 diff --git a/librispeech/test-clean_100_filtered_asr.json b/librispeech/test-clean_100_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..674bc05df5adf9463274a68e8f26f958fea51093 --- /dev/null +++ b/librispeech/test-clean_100_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:868eb9e72ca917406659dd93b1fda09acec7b4f063a8e9c711547f8b7680b215 +size 1322871 diff --git a/librispeech/test-clean_100_pc.json b/librispeech/test-clean_100_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..57faa9ebe582ff4c17a96a2ca391f92d15d5ac9d --- /dev/null +++ b/librispeech/test-clean_100_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:066d66baf4f5f632f377147ad7c9e9c3c831202b4de1f0f2ff4ce18e1b156859 +size 3929426 diff --git a/librispeech/test-clean_2000_filter.json b/librispeech/test-clean_2000_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..ecb8e35b9bf256be5a749fec63913f45039c8c40 --- /dev/null +++ b/librispeech/test-clean_2000_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ae13a50bd8a21810aa3a5eda7dec09319b87c53b735777c3a5a395fb8e21861 +size 52137181 diff --git a/librispeech/test-clean_2000_filtered_asr.json b/librispeech/test-clean_2000_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..674bc05df5adf9463274a68e8f26f958fea51093 --- /dev/null +++ b/librispeech/test-clean_2000_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:868eb9e72ca917406659dd93b1fda09acec7b4f063a8e9c711547f8b7680b215 +size 1322871 diff --git a/librispeech/test-clean_2000_pc.json b/librispeech/test-clean_2000_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..70d86210530a811b26d620884f4fa7e2d92576ce --- /dev/null +++ b/librispeech/test-clean_2000_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a405223fa0156c25ab722ab10a08d11768c1b103192568ea838a031f67741064 +size 52417500 diff --git a/librispeech/test-clean_500_filter.json b/librispeech/test-clean_500_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..8c8d0056ac9c2e07bc0eedfb8c47487526ef4b4a --- /dev/null +++ b/librispeech/test-clean_500_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05bf5c581551335dcf0f1dfd4eff64f7ddc73c128f9ef9340cf27c78c4fae587 +size 13884322 diff --git a/librispeech/test-clean_500_filtered_asr.json b/librispeech/test-clean_500_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..674bc05df5adf9463274a68e8f26f958fea51093 --- /dev/null +++ b/librispeech/test-clean_500_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:868eb9e72ca917406659dd93b1fda09acec7b4f063a8e9c711547f8b7680b215 +size 1322871 diff --git a/librispeech/test-clean_500_pc.json b/librispeech/test-clean_500_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..300b4f8f484316c64ad4c9aaa739884ea65acc1c --- /dev/null +++ b/librispeech/test-clean_500_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbfaf6cfaec254deecc8e25970430d7a7a070dff5ea57af05fc9aabdd738a59e +size 14164641 diff --git a/librispeech/test-other_1000_filter.json b/librispeech/test-other_1000_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..ccde4ed6cb50b84cf957f05c3fb05ea44ba06f41 --- /dev/null +++ b/librispeech/test-other_1000_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f2fb2bd24bcf99f9fdfd6f43027055df124c2a03299b57493a1f3c3cb6bc5ee +size 29880756 diff --git a/librispeech/test-other_1000_filtered_asr.json b/librispeech/test-other_1000_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..707296673589cfa95b2a0dcb27fe9cdf90e248ed --- /dev/null +++ b/librispeech/test-other_1000_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:186f155270c515fabcfe2a4e2204ac0e80964a000e6de80a39fa2e6cc9e959b3 +size 1424509 diff --git a/librispeech/test-other_1000_pc.json b/librispeech/test-other_1000_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..de678898ba114be8eb3453efe14561e5bf9f44c2 --- /dev/null +++ b/librispeech/test-other_1000_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8796dc23c6cc4b154a265ffbde3061480eaf4ec74f2063852542344a4767edc +size 30164633 diff --git a/librispeech/test-other_100_filter.json b/librispeech/test-other_100_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..9045c04e10dd86e998888f962547e88fdc2594de --- /dev/null +++ b/librispeech/test-other_100_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4719130b77ddbcf44732cf21a536430007d4cfebbb4b484742d5409a639b2f3 +size 4071171 diff --git a/librispeech/test-other_100_filtered_asr.json b/librispeech/test-other_100_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..707296673589cfa95b2a0dcb27fe9cdf90e248ed --- /dev/null +++ b/librispeech/test-other_100_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:186f155270c515fabcfe2a4e2204ac0e80964a000e6de80a39fa2e6cc9e959b3 +size 1424509 diff --git a/librispeech/test-other_100_pc.json b/librispeech/test-other_100_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..09f1b8fc5b8a5252e46b4a22ca58ed6f7b98c2e2 --- /dev/null +++ b/librispeech/test-other_100_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c27aac655cfd574cad309e26cd9f155a1bbb6b01e64cc2d950b9a2cf37d76a5 +size 4355048 diff --git a/librispeech/test-other_2000_filter.json b/librispeech/test-other_2000_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..ee9da71c6041ce3015248f45eb62db957b883226 --- /dev/null +++ b/librispeech/test-other_2000_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72dfb730e0167d794205ebe98077d39cf3969616a819021969192df7a68b5e73 +size 58468062 diff --git a/librispeech/test-other_2000_filtered_asr.json b/librispeech/test-other_2000_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..707296673589cfa95b2a0dcb27fe9cdf90e248ed --- /dev/null +++ b/librispeech/test-other_2000_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:186f155270c515fabcfe2a4e2204ac0e80964a000e6de80a39fa2e6cc9e959b3 +size 1424509 diff --git a/librispeech/test-other_2000_pc.json b/librispeech/test-other_2000_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..134f00469ac7d40012601524d95a7734fe675c81 --- /dev/null +++ b/librispeech/test-other_2000_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40c8545d72c7c00a7b61f1a5509910116113ef62d488468fdc0baf8028ed0a40 +size 58751939 diff --git a/librispeech/test-other_500_filter.json b/librispeech/test-other_500_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..994a10156c17cb5759d4d8fb87140db130548d6b --- /dev/null +++ b/librispeech/test-other_500_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd7547955be409c296402b08666163d2fa32749afc5db9b6e77fc0054d3e251a +size 15552466 diff --git a/librispeech/test-other_500_filtered_asr.json b/librispeech/test-other_500_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..707296673589cfa95b2a0dcb27fe9cdf90e248ed --- /dev/null +++ b/librispeech/test-other_500_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:186f155270c515fabcfe2a4e2204ac0e80964a000e6de80a39fa2e6cc9e959b3 +size 1424509 diff --git a/librispeech/test-other_500_pc.json b/librispeech/test-other_500_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..5a52a52b95e76b886f97e29ec76ab09bc5b94596 --- /dev/null +++ b/librispeech/test-other_500_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bf0b30c6c20a654e6702a8ce96865b174dcb9b6f79c5bab266b7ef41df87644 +size 15836343 diff --git a/librispeech/train-clean-460_filter.json b/librispeech/train-clean-460_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..68d859621019f94310c870719624159d62b5a905 --- /dev/null +++ b/librispeech/train-clean-460_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18f739fa3b818a717d89ae028b4cf13c40ad202e257a4e8e414452ea2bf490d5 +size 836153907 diff --git a/librispeech/train-clean-460_filtered_asr.json b/librispeech/train-clean-460_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..c8aa39a49981530a5f5f7d5e68cf5665fcbad667 --- /dev/null +++ b/librispeech/train-clean-460_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2582b8382240c4c280343b6e87f8b8046935aa3ad5a3a6295a9d865c4d8a2914 +size 81066086 diff --git a/librispeech/train-clean-460_pc.json b/librispeech/train-clean-460_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..f7475e43646e06258c4a56baeb281aa6f35e173a --- /dev/null +++ b/librispeech/train-clean-460_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b535f5e4aedd1a7697c42624e1c4a236796d02caa6c695f29d1e1ff41e584342 +size 858998364 diff --git a/librispeech/train-other-500_filter.json b/librispeech/train-other-500_filter.json new file mode 100644 index 0000000000000000000000000000000000000000..893d13907d6694cbaefb21e099a2a3e69aae91a7 --- /dev/null +++ b/librispeech/train-other-500_filter.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:882a52fa224a9f38c51cdc130877d95a126236e91e22983c8f41e3af87a1a244 +size 936464758 diff --git a/librispeech/train-other-500_filtered_asr.json b/librispeech/train-other-500_filtered_asr.json new file mode 100644 index 0000000000000000000000000000000000000000..e2d5b9564256b47e93ba8048ac8da08db2de4dc7 --- /dev/null +++ b/librispeech/train-other-500_filtered_asr.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed6d94d9cbb825af3ea86253d0b2c2eda618e1444bb9eda411c5954905fd7cd9 +size 88132611 diff --git a/librispeech/train-other-500_pc.json b/librispeech/train-other-500_pc.json new file mode 100644 index 0000000000000000000000000000000000000000..600dc056728c94ab033bf317c69ce0eea4c1472c --- /dev/null +++ b/librispeech/train-other-500_pc.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ddd785c26d91699815157d45b94ba7f4b36d6d49ffb5b57d23286a133004197 +size 960631559 diff --git a/slidespeech/slidespeech_L95/dev.json b/slidespeech/slidespeech_L95/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..c867de12db6bc8e60fe90bb7b468285df8af0951 --- /dev/null +++ b/slidespeech/slidespeech_L95/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a0b71a9c7348bc9c497f933f1b5bd53f8e96231c7225be635c5462e5fb71815 +size 1401937 diff --git a/slidespeech/slidespeech_L95/test.json b/slidespeech/slidespeech_L95/test.json new file mode 100644 index 0000000000000000000000000000000000000000..7c5238c21de3085dcb0189a68b7bd14a8057ee29 --- /dev/null +++ b/slidespeech/slidespeech_L95/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf6ebe808b4877b618cb1c5fd2bd87bb36eec0f0525df80bd8ae234cbd7d558c +size 2487403 diff --git a/slidespeech/slidespeech_L95/train.json b/slidespeech/slidespeech_L95/train.json new file mode 100644 index 0000000000000000000000000000000000000000..e3cc87dfc442f188c4c2faf7b104bd691116e090 --- /dev/null +++ b/slidespeech/slidespeech_L95/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e35ec7372655356a14a2f6ab2b7ab7412169ce8abb1982014c86c371ec6e844b +size 307037255 diff --git a/slidespeech/slidespeech_L95_5slides/dev.json b/slidespeech/slidespeech_L95_5slides/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..3f2514c322893cd2f3b8aa6afa3bad9fcfe9601b --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af2543de7cee371702862f96a143d5206c9fd76aa87e355d9c03ad5c2a560733 +size 2928654 diff --git a/slidespeech/slidespeech_L95_5slides/test.json b/slidespeech/slidespeech_L95_5slides/test.json new file mode 100644 index 0000000000000000000000000000000000000000..cfd65cbe693091f37b319bdf4a067b7cf2921651 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3743038e77227a6a43bd98d14a83e334245094692f9cb7696c7def7a3c28002 +size 5615310 diff --git a/slidespeech/slidespeech_L95_5slides/train.json b/slidespeech/slidespeech_L95_5slides/train.json new file mode 100644 index 0000000000000000000000000000000000000000..9e5c7eb2cba279da0d3d0b4f79d1192d8a7de703 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d9434e2c49116ef76628ae73697b90ef922c45eef44f79cb82162930609ec55 +size 708440282 diff --git a/slidespeech/slidespeech_L95_5slides_filter/S95.json b/slidespeech/slidespeech_L95_5slides_filter/S95.json new file mode 100644 index 0000000000000000000000000000000000000000..455b26b69e0622a96bca865c1526e88b4560adcc --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filter/S95.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bff6bb7a060dcd16af3a574ecbe4814f685efec45c6ef2620acc4da2212fb038 +size 145470666 diff --git a/slidespeech/slidespeech_L95_5slides_filter/dev.json b/slidespeech/slidespeech_L95_5slides_filter/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..a651c6c615b67e615892d2c8a1f5688338aea714 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filter/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c970c517d93cb9922fd6ad117128d43367af2a46f4d05c9da9851717bb72bf7 +size 2676197 diff --git a/slidespeech/slidespeech_L95_5slides_filter/test.json b/slidespeech/slidespeech_L95_5slides_filter/test.json new file mode 100644 index 0000000000000000000000000000000000000000..681422b6161341b21b3be06e375051c836d12d3d --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filter/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a77df39f0da60abae746f8dcfb559ffbcb80af4f8638116600420738208398e +size 5171425 diff --git a/slidespeech/slidespeech_L95_5slides_filter/train.json b/slidespeech/slidespeech_L95_5slides_filter/train.json new file mode 100644 index 0000000000000000000000000000000000000000..976cf8e8d96982477d59ccfa7fc90c280bcd3cc8 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filter/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a8428d6b11b40b4f274008cb89129d1bf65e05fd927ad29191e40b17a5302f9 +size 676787747 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/S95.json b/slidespeech/slidespeech_L95_5slides_filtered_train/S95.json new file mode 100644 index 0000000000000000000000000000000000000000..1d2c76591ba3e08b5210138134c0c2f6ef05fb70 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/S95.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8b9f6435adc29c1a410d580432b9712309600a343861e79326d069045e584e3 +size 41677744 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/count_keywords_after_filter_251011.py b/slidespeech/slidespeech_L95_5slides_filtered_train/count_keywords_after_filter_251011.py new file mode 100644 index 0000000000000000000000000000000000000000..08171128ba0b0e5328293746f66599ce6433fbb3 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/count_keywords_after_filter_251011.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +统计JSON文件中每条样本的<|startofcontext|><|endofcontext|>间的平均词数 +""" + +import json +import re +from typing import List, Dict, Any + + +def count_words_in_context(text: str) -> int: + """ + 统计文本中<|startofcontext|>和<|endofcontext|>之间的词数 + + Args: + text: 输入文本 + + Returns: + context区域内的词数 + """ + # 使用正则表达式匹配<|startofcontext|>和<|endofcontext|>之间的内容 + pattern = r'<\|startofcontext\|>(.*?)<\|endofcontext\|>' + matches = re.findall(pattern, text, re.DOTALL) + + total_words = 0 + for match in matches: + # 去除首尾空白字符,然后按空白字符分割计算词数 + words = match.strip().split(", ") + + words = [] if words == [''] else words + print(words) + total_words += len(words) + + return total_words + + +def analyze_json_file(file_path: str) -> Dict[str, Any]: + """ + 分析JSON文件中的context词数统计 + + Args: + file_path: JSON文件路径 + + Returns: + 包含统计结果的字典 + """ + print(f"正在读取文件: {file_path}") + + with open(file_path, 'r', encoding='utf-8') as f: + data = json.load(f) + + print(f"总样本数: {len(data)}") + + word_counts = [] + samples_with_context = 0 + samples_without_context = 0 + + for i, sample in enumerate(data): + if i % 1000 == 0: + print(f"处理进度: {i}/{len(data)}") + + # 检查每条消息中的content + sample_word_count = 0 + has_context = False + + for message in sample.get('messages', []): + content = message.get('content', '') + word_count = count_words_in_context(content) + sample_word_count += word_count + + if '<|startofcontext|>' in content and '<|endofcontext|>' in content: + has_context = True + + if has_context: + samples_with_context += 1 + word_counts.append(sample_word_count) + else: + samples_without_context += 1 + + # 计算统计信息 + if word_counts: + avg_words = sum(word_counts) / len(word_counts) + max_words = max(word_counts) + min_words = min(word_counts) + + # 计算中位数 + sorted_counts = sorted(word_counts) + n = len(sorted_counts) + median_words = (sorted_counts[n//2 - 1] + sorted_counts[n//2]) / 2 if n % 2 == 0 else sorted_counts[n//2] + else: + avg_words = max_words = min_words = median_words = 0 + + results = { + 'total_samples': len(data), + 'samples_with_context': samples_with_context, + 'samples_without_context': samples_without_context, + 'average_words_per_sample': avg_words, + 'max_words_per_sample': max_words, + 'min_words_per_sample': min_words, + 'median_words_per_sample': median_words, + 'word_counts_distribution': word_counts[:10] if len(word_counts) > 10 else word_counts # 显示前10个样本的词数 + } + + return results + + +def main(): + """主函数""" + file_path = "/data8/rym/Projects/ms-swift/data/add_context_token/slidespeech_L95_5slides_filtered_train/test_from_window_size2_no_param.json" + + try: + results = analyze_json_file(file_path) + + print("\n" + "="*60) + print("统计结果:") + print("="*60) + print(f"总样本数: {results['total_samples']}") + print(f"包含context的样本数: {results['samples_with_context']}") + print(f"不包含context的样本数: {results['samples_without_context']}") + print(f"平均每条样本context区域词数: {results['average_words_per_sample']:.2f}") + print(f"最大词数: {results['max_words_per_sample']}") + print(f"最小词数: {results['min_words_per_sample']}") + print(f"中位数词数: {results['median_words_per_sample']:.2f}") + + if results['word_counts_distribution']: + print(f"\n前10个样本的context词数分布:") + for i, count in enumerate(results['word_counts_distribution']): + print(f" 样本 {i+1}: {count} 词") + + # # 保存详细结果到文件 + # output_file = file_path.replace('.json', '_context_word_stats.json') + # with open(output_file, 'w', encoding='utf-8') as f: + # json.dump(results, f, ensure_ascii=False, indent=2) + + # print(f"\n详细统计结果已保存到: {output_file}") + + except Exception as e: + print(f"处理文件时出错: {e}") + return 1 + + return 0 + + +if __name__ == "__main__": + exit(main()) \ No newline at end of file diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/dev.json b/slidespeech/slidespeech_L95_5slides_filtered_train/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..3433d7f17bb72df267fa973c1d55d5d4c35ef35b --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f1b1f9f0263630850d10f92162a8c0b3b602e02d6c5c6b02c4685f69ca16a71 +size 965474 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/dev_from_window_size2_no_param.json b/slidespeech/slidespeech_L95_5slides_filtered_train/dev_from_window_size2_no_param.json new file mode 100644 index 0000000000000000000000000000000000000000..ec73591dfef23f89c89f2b498fb2057492bb9fda --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/dev_from_window_size2_no_param.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dacdf7dc4e430cc767ad91707ccc09e5d87e419dbc4f08a597a601cc44e65fe0 +size 962350 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/test.json b/slidespeech/slidespeech_L95_5slides_filtered_train/test.json new file mode 100644 index 0000000000000000000000000000000000000000..ef8d8a3efb5de41dd429ee425dd8a5717c28e1b6 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3155b1c2cf6d07d1e035e2990d1dc755c741efbf0c661aae6fa420f4d575711 +size 1711174 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size2_no_param.json b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size2_no_param.json new file mode 100644 index 0000000000000000000000000000000000000000..6f246c59f5de233a3d8ffd3d72d990abf5d2091a --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size2_no_param.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d18a71b32d40c977a7668ab9dab03945d116c81f8f6d1ff83134e875b759e6db +size 1708941 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size4_no_param.json b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size4_no_param.json new file mode 100644 index 0000000000000000000000000000000000000000..1d1b98342d70f384c8d5c2cc307708d08b5afe1e --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size4_no_param.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d73c590812ec2974058c1f7da3e8b58f9198acd685fe7401867729970fbbc402 +size 1703167 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size8_no_param.json b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size8_no_param.json new file mode 100644 index 0000000000000000000000000000000000000000..4033d1d0de2481fcc8aad83ec8180aee91395297 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/test_from_window_size8_no_param.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e8d261972fcd2fad275683e28c597e9c76b4a1454d7feadb46f7091dd13473a +size 1628073 diff --git a/slidespeech/slidespeech_L95_5slides_filtered_train/train.json b/slidespeech/slidespeech_L95_5slides_filtered_train/train.json new file mode 100644 index 0000000000000000000000000000000000000000..0900007e2c51135313960d72dfc7cc290b7ef938 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_filtered_train/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:642587b13eff06548da77a8579b5fdc9177f3d2a77417ff9907c998fd942912d +size 193628968 diff --git a/slidespeech/slidespeech_L95_5slides_multitask/dev.json b/slidespeech/slidespeech_L95_5slides_multitask/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..c21521a2671a735a771ec26a2b5f872979573bf5 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_multitask/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0641d4b3b0e499eab7ed11473e72006e04f8cfc035e0466ce3ef493e0fd0134e +size 3154893 diff --git a/slidespeech/slidespeech_L95_5slides_multitask/test.json b/slidespeech/slidespeech_L95_5slides_multitask/test.json new file mode 100644 index 0000000000000000000000000000000000000000..4f0d6be77341409bbeadaae93bba518ffd9b8d79 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_multitask/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9c872890f763f5d1d38afc213747ea9c7531f32f64a9a24b4f1e9afc47d49fc +size 6013854 diff --git a/slidespeech/slidespeech_L95_5slides_multitask/train.json b/slidespeech/slidespeech_L95_5slides_multitask/train.json new file mode 100644 index 0000000000000000000000000000000000000000..d88cabbf69814248e8fea88084b782ddc4c37e03 --- /dev/null +++ b/slidespeech/slidespeech_L95_5slides_multitask/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8f8081ce41f649bbd7176b7b04c8c72de556b6b085d207b726757b6138f7c65 +size 764433473 diff --git a/slidespeech/slidespeech_L95_filter/dev.json b/slidespeech/slidespeech_L95_filter/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..9a4b2e5433a98dd63724c7bffff26ba3e39ae2a0 --- /dev/null +++ b/slidespeech/slidespeech_L95_filter/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e00d7e33ada458fcfb1f491cd06c4df0a76fdc5dc5b3b48d9368d33ab31c2af7 +size 1120130 diff --git a/slidespeech/slidespeech_L95_filter/test.json b/slidespeech/slidespeech_L95_filter/test.json new file mode 100644 index 0000000000000000000000000000000000000000..42b6097c747dde6ba5bf52c1cf3386fd8ef509de --- /dev/null +++ b/slidespeech/slidespeech_L95_filter/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1939f0eaeb76aae5a02787192e72f6dbcd1d8535f9bd8dac173c388bb7f6df14 +size 1986112 diff --git a/slidespeech/slidespeech_L95_filter/train.json b/slidespeech/slidespeech_L95_filter/train.json new file mode 100644 index 0000000000000000000000000000000000000000..163ad393d662c4c2f600f93ad6e758f0b6edaef0 --- /dev/null +++ b/slidespeech/slidespeech_L95_filter/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ede8e8d764e764f64d3edcec80e1a01c44a0181e429232fbb678c81369da2fc6 +size 264231143 diff --git a/slidespeech/slidespeech_L95_filtered_train/dev.json b/slidespeech/slidespeech_L95_filtered_train/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..2b9774d0353c8e820f4fc2228a552c1dd61122e9 --- /dev/null +++ b/slidespeech/slidespeech_L95_filtered_train/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:433ff9959e547aeb60c4e990d1c1e5fd52057692350c054e10e62b35a99d609d +size 926787 diff --git a/slidespeech/slidespeech_L95_filtered_train/test.json b/slidespeech/slidespeech_L95_filtered_train/test.json new file mode 100644 index 0000000000000000000000000000000000000000..84a61621b9392e6f0ee068678ab2e62507fc3973 --- /dev/null +++ b/slidespeech/slidespeech_L95_filtered_train/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad65b36b01b8a1942b6488ade3a4f68ceb36c3f25cedf89b82a451eab0d544f2 +size 1645068 diff --git a/slidespeech/slidespeech_L95_filtered_train/train.json b/slidespeech/slidespeech_L95_filtered_train/train.json new file mode 100644 index 0000000000000000000000000000000000000000..3649ed8eecef69bfdac5cbe90c0be2e88ca2aa27 --- /dev/null +++ b/slidespeech/slidespeech_L95_filtered_train/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a300f2649abf4967c6c1656c8dabf303622664035f142abe4d0efe6675ef623 +size 188171904 diff --git a/slidespeech/slidespeech_L95_multitask/dev.json b/slidespeech/slidespeech_L95_multitask/dev.json new file mode 100644 index 0000000000000000000000000000000000000000..fbff1ad359589bb7601549ea76af506a6b2fce06 --- /dev/null +++ b/slidespeech/slidespeech_L95_multitask/dev.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31156d32e41f08286760629ea1e84fa91e043d52c4daa3b9cdb5bc2ec32fb677 +size 1595755 diff --git a/slidespeech/slidespeech_L95_multitask/test.json b/slidespeech/slidespeech_L95_multitask/test.json new file mode 100644 index 0000000000000000000000000000000000000000..5d759c04a063a82a41de3b0080026bcd6fdd8dfb --- /dev/null +++ b/slidespeech/slidespeech_L95_multitask/test.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b4ade1bf0855bf254139067bd5d0a415a3c86ee17a8f3bd1e6306c91885fdfe +size 2827344 diff --git a/slidespeech/slidespeech_L95_multitask/train.json b/slidespeech/slidespeech_L95_multitask/train.json new file mode 100644 index 0000000000000000000000000000000000000000..a3c51c9f0bef8574b8fcf4a731d478186ff75581 --- /dev/null +++ b/slidespeech/slidespeech_L95_multitask/train.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5d4cd5e1a8535e0ebeceb496a8886e3a82ab29248cb5af68698819cffc5b32d +size 355813322