Giter Club home page Giter Club logo

haha_2019's People

Contributors

bfarzin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mittalshruti

haha_2019's Issues

CustTok returns backward tokens

Update to return backwards tokens with CustomTokenizer with bwd=True flag. Start with xxbos and then return the series of tokens in reverse order [::-1]. Proceed as usual with everything else. Model works "backwards" and should produce slightly different results. Ensemble with forward models and submit scores.

https://raw.githubusercontent.com/bfarzin/wiki103_from_scratch/master/Wiki103_from_scratch_fastai_v1_raw_articles-backward_tokens.ipynb

    "class Tokenizer():\n",
    "    \"Put together rules and a tokenizer function to tokenize text with multiprocessing.\"\n",
    "    def __init__(self, tok_func:Callable=SpacyTokenizer, lang:str='en', pre_rules:ListRules=None,\n",
    "                 post_rules:ListRules=None, special_cases:Collection[str]=None, n_cpus:int=None,bwd_toks=False):\n",
    "        self.tok_func,self.lang,self.special_cases = tok_func,lang,special_cases\n",
    "        self.pre_rules  = ifnone(pre_rules,  defaults.text_pre_rules )\n",
    "        self.post_rules = ifnone(post_rules, defaults.text_post_rules)\n",
    "        self.special_cases = special_cases if special_cases else defaults.text_spec_tok\n",
    "        self.n_cpus = ifnone(n_cpus, defaults.cpus)\n",
    "        self.bwd_toks = bwd_toks\n",
    "        \n",
    "...\n",
    "\n",
    "    def process_text(self, t:str, tok:BaseTokenizer) -> List[str]:\n",
    "        \"Process one text `t` with tokenizer `tok`.\"\n",
    "        for rule in self.pre_rules: t = rule(t)\n",
    "        toks = tok.tokenizer(t)\n",
    "        for rule in self.post_rules: toks = rule(toks)\n",
    "        return listify(toks[0])+toks[1:][::-1] if self.bwd_toks else toks  # <-- Just one line changed!"
   ]
  },

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.