Skip to content

对NgramSampleEvaluator代码实现的疑问 #396

@DKAMX

Description

@DKAMX

Problem Description / 问题描述

开发者你们好,我对文档
https://opendcai.github.io/DataFlow-Doc/zh/api/operators/general_text/filter/ngramfilter/
中给出的示例输出和结果分析感到困惑,其提到

样本1("今天天气真不错,阳光明媚,万里无云,适合出门散步。")通过过滤(但输出中未显示,可能因为只显示了通过的样本)

我通过调试和阅读源码,发现实际上这个范例只有样本3的英文文本能够通过,其他2个样本因为得分为0所以无法通过过滤。因为ngram_sample_evaluator.py_score_func函数的实现是通过str.split函数来对文本进行切分,这仅对英文有效,对于没有空格或者使用标点的文本无法进行切分,导致gram只有1个,因而无法计分。

我想到的一个解决方法是使用大模型的分词器来对文本进行切分,但是我不清楚这样实现是否有效。以及关于代码架构方面,在Operator类里面调用transformer管线是否合适?

System Info (dataflow env) / 系统信息(dataflow env

  • Dataflow version: 1.0.7
  • Platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39
  • Python version: 3.12.3
  • PyTorch version: 2.9.1+cu128 (GPU)
  • Torchvision version: 2.9.1+cu128
  • GPU type: NVIDIA GeForce RTX 3060
  • GPU number: 1
  • GPU memory: 12.00GB

Minimal Reproducible Example / 最小可复现示例

完全复制文档中的示例用法和输入
https://opendcai.github.io/DataFlow-Doc/zh/api/operators/general_text/filter/ngramfilter/

Additional Information / 其他补充

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions