Coder Social home page Coder Social logo

beomi / megatronlm_dataset_autotokenizer Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 510 KB

Megatron-LM/GPT-NeoX compatible Text Encoder with 🤗Transformers AutoTokenizer.

License: Apache License 2.0

Python 99.32% Shell 0.68%
megatron-lm gpt-neox tokenizers transformers

megatronlm_dataset_autotokenizer's Introduction

KoAlpaca icon

MegatronLM Dataset with 🤗Transformers AutoTokenizer

What's the difference between GPT-NeoX or Megaton-LM?

  • GPT-NeoX is a fork of Megatron-LM with some additional features.
  • GPT-NeoX supports various tokenizers than Megatron-LM, such as LlamaTokenizer, HFGPT2Tokenizer, or TiktokenTokenizer.

However, both repository does not support Transformers AutoTokenizer out of the box.

That's why I made this repository.

In this repository:

  • You can encode your dataset with any AutoTokenizer-compatible tokenizer.

Prepare the dataset

  • Checkout examples/sample_dataset.jsonl for the format of the dataset.
// examples/sample_dataset.jsonl
{"text": "This is the first sentence."}
{"text": "This is the second sentence."}
// ...

Prepare the Environment

  • Install the dependencies
pip install -r requirements.txt

for more details, please checkout requirements.frozen.txt.

Encode the dataset

  • Encode the dataset with the following command
  • Check sample shell file:run.sh
# Create output directory
mkdir -p data-sample/
# Encode the dataset
python preprocess_data.py \
--input examples/sample_dataset.jsonl \
--tokenizer-type AutoTokenizer \
--vocab-file beomi/llama-2-ko-7b \
--output-prefix data-sample/out \
--dataset-impl mmap \
--workers 10

Notes

  1. Input file name must ends with .jsonl

  2. Your JSONL file must NOT contain any empty lines.

Example(This makes error):

{"text": "This is the first sentence."}
{"text": "This is the second sentence."}
// YOU SHOULD NOT HAVE EMPTY LINE HERE
{"text": "This is the third sentence."}
// YOU SHOULD NOT HAVE EMPTY LINE AT THE END OF THE FILE TOO

JSON above will cause this error:

jsonlines.jsonlines.InvalidLineError: line contains invalid json: Expected object or value (line 3)

This is OK:

{"text": "This is the first sentence."}
{"text": "This is the second sentence."}

Acknowledgement

This repo codes are partially copied/edited from EleutherAI/gpt-neox @ 10bf78.

megatronlm_dataset_autotokenizer's People

Contributors

beomi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.