Code Monkey home page Code Monkey logo

Comments (6)

testmurk avatar testmurk commented on May 14, 2024

我尝试对比了一下 tokenized_datasets 的长度
print(len(tokenized_datasets["train"]))
print(len(tokenized_datasets["valid"]))
我自己的数据集train 只有12 valid 只有1 而我生成了6K问答对。。。

from zero_nlp.

yuanzhoulvpi2017 avatar yuanzhoulvpi2017 commented on May 14, 2024
  1. 不得不说,这东西是玄学,好了,这是开玩笑的。
  2. 说回技术,因为我加载数据,使用的是datasets这个包,你可以看看这个包的使用介绍。

from zero_nlp.

akoukou123 avatar akoukou123 commented on May 14, 2024

`def tokenize(element):
outputs = tokenizer(
element["content"],
truncation=True,
max_length=context_length,
return_overflowing_tokens=True,
return_length=True,
)
input_batch = []
for length, input_ids in zip(outputs["length"], outputs["input_ids"]):
if length == context_length:
input_batch.append(input_ids)
return {"input_ids": input_batch}

tokenized_datasets = raw_datasets.map(
tokenize, batched=True, remove_columns=raw_datasets["train"].column_names
)
tokenized_datasets

data_collator = DataCollatorForLanguageModeling(tokenizer, mlm=False)`

里面的
if length == context_length:
input_batch.append(input_ids)

这个会把小于512的数据排除,可以看看是不是可以改成<=呢?

from zero_nlp.

testmurk avatar testmurk commented on May 14, 2024

我尝试了小于512 以及
tokenizer(
element["content"],
padding=True,
truncation=True,
max_length=context_length,
)
甚至删除了length了判断。。也没有作用。
我打印了作者提供的数据集的相关数据
print(len(raw_datasets["train"])) # 10000
print(len(tokenized_datasets["train"])) # 4753
print(len(tokenized_datasets["valid"])) #489
也存在着输出丢失的问题。不过我自己构建的那个更明显raw_datasets 的train 有4000多,而 tokenized_datasets 的train 只有12个 (手动捂脸)

from zero_nlp.

akoukou123 avatar akoukou123 commented on May 14, 2024

我们是把if length == context_length:改成了if length <= context_length:检查了一下数据集发现ok了,但是不知道为啥调出来的模型没有效果,老哥那边能调出一个有效果的模型吗

from zero_nlp.

zhangtaochn avatar zhangtaochn commented on May 14, 2024

@yuanzhoulvpi2017 请问下,为啥这里要 if length == context_length

    input_batch = []
    for length, input_ids in zip(outputs["length"], outputs["input_ids"]):
        if length == context_length:
            input_batch.append(input_ids)
    return {"input_ids": input_batch}

from zero_nlp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.