forked from minimaxir/textgenrnn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# textgenrnn 1.3.1 Text Cycling Demo\n", | ||
"\n", | ||
"by [Max Woolf](http://minimaxir.com)\n", | ||
"\n", | ||
"*Max's open-source projects are supported by his [Patreon](https://www.patreon.com/minimaxir). If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.*" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"Using TensorFlow backend.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from textgenrnn import textgenrnn\n", | ||
"\n", | ||
"textgen = textgenrnn()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The `generate` function generates `n` text documents at a given temperature:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"I was a bit of a stranger and I have a programming thing and I was a good day.\n", | ||
"\n", | ||
"[Spoilers] A streak of the streets of the game of the sidewalk browser of the story of the state of the same series is the best streamer and I was a beauty of the game of the story of the same star in the results of the state of the state of the story of the story of the same seconds of the state \n", | ||
"\n", | ||
"[PS4] [H] 2000 GTX 1080 [W] $150 GG [W] Paypal\n", | ||
"\n", | ||
"[F4M] I want to stop starting to make me to see the state of the state of the most poster is a stranger and he was a company to be a company to be a lot of this subreddit and the company with the story of the most poster in a community was the most poster and I was actually a post and the only one\n", | ||
"\n", | ||
"[Specific] Can someone please remove the story of the protests the one of the state of the state of the state in the computer and the season is the first time that I saw this one of the most possible to make a stranger and all the state of the most poster in the state of the state of the same time\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"textgen.generate(5, temperature=0.2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"You can pass a `list` of temperatures to `temperatures` instead, and the prediction will cycle through the given temperatures when generating new characters/words. Alternating a low temperature with a high temperature allows the model to access \"hidden\" knowledge without becoming a complete trainwreck." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"I wouldn't been two years and a busty adventure of it advertian and there is the compy local questions like this abless\n", | ||
"\n", | ||
"[PS4] [H] 2200 of 2017 Subs [W] PARG in the car two years\n", | ||
"\n", | ||
"In the Filmed Subreddit at the Press Marine Trap 2016!\n", | ||
"\n", | ||
"[but okay) will be a red really come to the performance of Mario Or Sanders accounts (full recent)\n", | ||
"\n", | ||
"[Discussion] Network wanting to start smartphones about the computer and fake with this guy\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"generated_texts = textgen.generate(5, temperature=[0.2, 1.0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"You can specify a temperature multiple times to repeat it for sequential tokens." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[Suggestion] I'm a long time that gamesfee... As a new shown trip by three elephants all the skin up to the striper: \"King and keep their Sony of the FL and the best tree you short to control.\n", | ||
"\n", | ||
"[Pics][Ory/move] Thank your daily container and that he was a laptop for a Trump to the mods but the one is a program ( ͡° ͜ʖ ͡°)\n", | ||
"\n", | ||
"How do we know this is the Marvin Space and the fight men design that makes a week by Xbox\n", | ||
"\n", | ||
"A comment to top of the stage to the safer's ball weapon?\n", | ||
"\n", | ||
"[PS4] Water to the person on the state of reddit in the most player and think you have present?\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"generated_texts = textgen.generate(5, temperature=[0.2, 0.2, 1.0, 1.0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# LICENSE\n", | ||
"\n", | ||
"MIT License\n", | ||
"\n", | ||
"Copyright (c) 2018 Max Woolf\n", | ||
"\n", | ||
"Permission is hereby granted, free of charge, to any person obtaining a copy\n", | ||
"of this software and associated documentation files (the \"Software\"), to deal\n", | ||
"in the Software without restriction, including without limitation the rights\n", | ||
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n", | ||
"copies of the Software, and to permit persons to whom the Software is\n", | ||
"furnished to do so, subject to the following conditions:\n", | ||
"\n", | ||
"The above copyright notice and this permission notice shall be included in all\n", | ||
"copies or substantial portions of the Software.\n", | ||
"\n", | ||
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", | ||
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n", | ||
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n", | ||
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n", | ||
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n", | ||
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n", | ||
"SOFTWARE." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters