Pretrained Model
Pretrained weights for the Stack Roboflow language model can be downloaded below. If you can chip in a few bucks to help pay for the compute time used generating this and future models that would be much appreciated! Chip in: $
Download Pretrained Model *If you don't want to give me your email and you don't need an email receipt, you may just enter [example@example.com](#) as your email when prompted.* ----- Usage ---- To use the Pretrained model, you will need to install [fast.ai](https://fast.ai). First, load `fastai.text`, point `path` at where you downloaded the pretrained model, and add a couple of special characters (`xxnl` means new line and `xxbody` separates the question subject from its body). ``` from fastai.text import * path = Path("/home/yeldarb/Data/stackoverflow") # change this to where your downloaded model resides defaults.text_spec_tok.append('xxnl') defaults.text_spec_tok.append('xxbody') ``` Next, load the downloaded vocabulary and create an empty pandas DataFrame. ``` vocab = pickle.load(open(path/"vocab.pkl", "rb")) # this vocabulary file should be in {path} empty = pd.DataFrame({"body":["filler", "text"]}) ``` Then, create an empty TextList linked to our empty DataFrame and loaded vocabulary and turn it into a DataBunch we can feed to our model. ``` data_lm = (TextList.from_df(empty, path=path, cols=["body"], vocab=vocab, ignore_empty=True) .split_none() .label_for_lm() .databunch(bs=1) ) ``` Then create our model and load the downloaded weights. ``` learn = language_model_learner(data_lm, AWD_LSTM, drop_mult=0.3) learn.load('stackoverflow-language-model') # this .pth file (the weights) should be in path/'models' ``` Now we're ready to generate questions! ``` prompt = "" # leave blank to generate a random question prompt = "how do i write a recursive sudoku solver? xxbody" # or fill in a prompt to give it a starter (xxbody signifies the end of the subject) output = format(learn.predict(prompt, 500, temperature=0.9)) # (format is defined in the Notebook included with the weights) print(output) ``` Example output:
*Loading...*
License ---- The weights and [the data dump upon which this language model is trained](https://archive.org/details/stackexchange) is released under a [cc-by-sa 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/). Have fun! If you make something cool I'd love to see it! Tweet me [@braddwyer](https://twitter.com/braddwyer)