Code Monkey home page Code Monkey logo

shakespeare-data's Introduction

Text cleaning

clean.py is the original cleaning code that I used when adding hamlet.txt to tinyshakespeare.txt.

play.py is the newer version, which includes stripping folger prefix in file and dir names and options to format the plays and concatenate them into one text file for training.

sp.txt and sp-prefix.txt are the output files. sp-prefix.txt was the one I eventually used. They only contain the plays, not poems and sonnets. (See shakespeare-works folder).

sp.txt - texts in the files directly related Folger were stripped away, and add <|endoftext|> between each play.

sp-prefix.txt - in addition to sp.txt, removed ACT and SCENE headers and separators, and prefixed each play with a unique number.

Model training

Sites that helped

Things I tried but got tripped up

  • Try to train Huggingface Transformer...
    • Didn't know how to properly make a dataset
    • Didn't know how to use top-k sampling in the Huggingface pipeline, with the pytorch model (Didin't try TF2 model)
      • So I got worse results than my first attempt with TF1 using gpt2-simple
  • Convert TF1 model into PyTorch
    • No "constants" file in pytorch_model.bin (tch-rs couldn't load it)
  • Convert TF1 to mmdn IR (and eventually PyTorch)
    • Didn't know the output node name
  • Save original fine-tuned GPT-2 into Keras
  • Trying to load from sonos/tract
    • Feature incomplete: "stateless evaluation not implemented"

Tips

  • Quickly check if a file is valid UTF-8

iconv -f UTF-8 -t UTF-8 FILE > /dev/nul (valid utf-8 if no error and/or return code is 0)

credit: https://superuser.com/questions/649834/is-there-a-linux-command-to-find-out-if-a-file-is-utf-8

In short: diff -ur dir1 dir2

What I did instead

Train model with aitextgen, and use a proper backend instead of trying to put everying into the browser.

shakespeare-data's People

Contributors

ruoshui-git avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

ahmadvh

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.