├── cover_med.jpg ├── README.md ├── GreenLIT.ipynb └── LICENSE.txt /cover_med.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robgon-art/GreenLIT/HEAD/cover_med.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **GreenLIT: Using GPT-J with Multi-Task Learning to Create New Screenplays** 2 | ## How to fine-tune an ML model to create TV shows and movies with new titles, plot summaries, and scripts 3 | 4 | ![ReGEN Cover Image](https://raw.githubusercontent.com/robgon-art/ReGEN/main/cover_med.jpg) 5 | 6 | Photo by [Tech Daily](https://unsplash.com/photos/PGuCnUzsRSM) on [Unsplash](https://unsplash.com/)
7 | 8 | **By Robert. A Gonsalves**
9 | 10 | You can see my article on [Medium](https://towardsdatascience.com/greenlit-using-gpt-j-with-multi-task-learning-to-create-new-screenplays-54a2d04f761c#c07d-fe51a662351d). 11 | 12 | The source code and generated images are released under the [CC BY-SA license](https://creativecommons.org/licenses/by-sa/4.0/).
13 | ![CC BYC-SA](https://licensebuttons.net/l/by-sa/3.0/88x31.png) 14 | 15 | ## Google Colabs 16 | * [GreenLIT Generator](https://colab.research.google.com/github/robgon-art/GreenLIT/blob/main/GreenLIT.ipynb) 17 | 18 | ## Acknowledgements 19 | - GPT-J, Mesh-Transformer-JAX: Model-Parallel Implementation of Transformer Language Model with JAX (2021) 20 | - R. Caruana, Multitask learning (1997) 21 | - E. Hu, et al., LoRA: Low-rank Adaptation of Large Language Models (2021) 22 | - M. Grootendorst, KeyBERT: Minimal keyword extraction with BERT (2020) 23 | 24 | ## Citation 25 | To cite this repository: 26 | 27 | ```bibtex 28 | @software{GreenLIT, 29 | author = {Gonsalves, Robert A.}, 30 | title = {GreenLIT: Using GPT-J with Multi-Task Learning to Create New Screenplays}, 31 | url = {https://github.com/robgon-art/GreenLIT}, 32 | year = 2022, 33 | month = February 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /GreenLIT.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "GreenLIT", 7 | "provenance": [], 8 | "toc_visible": true, 9 | "mount_file_id": "https://github.com/robgon-art/GreenLIT/blob/main/GreenLIT.ipynb", 10 | "authorship_tag": "ABX9TyMOlNtVvMj5moOvOR0vQO7u", 11 | "include_colab_link": true 12 | }, 13 | "kernelspec": { 14 | "name": "python3", 15 | "display_name": "Python 3" 16 | }, 17 | "language_info": { 18 | "name": "python" 19 | }, 20 | "accelerator": "GPU" 21 | }, 22 | "cells": [ 23 | { 24 | "cell_type": "markdown", 25 | "metadata": { 26 | "id": "view-in-github", 27 | "colab_type": "text" 28 | }, 29 | "source": [ 30 | "\"Open" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "source": [ 36 | "# **GreenLIT: Using GPT-J with Multi-Task Learning to Create New Screenplays**\n", 37 | "## How to fine-tune an ML model to create TV shows and movies with new titles, plot summaries, and scripts\n", 38 | "\n", 39 | "![ReGEN Cover Image](https://raw.githubusercontent.com/robgon-art/ReGEN/main/cover_med.jpg)\n", 40 | "\n", 41 | "Photo by [Tech Daily](https://unsplash.com/photos/PGuCnUzsRSM) on [Unsplash](https://unsplash.com/)
\n", 42 | "\n", 43 | "**By Robert. A Gonsalves**
\n", 44 | "You can see my article on [Medium](https://towardsdatascience.com/greenlit-using-gpt-j-with-multi-task-learning-to-create-new-screenplays-54a2d04f761c#c07d-fe51a662351d)." 45 | ], 46 | "metadata": { 47 | "id": "FEWG2iBgiGxK" 48 | } 49 | }, 50 | { 51 | "cell_type": "code", 52 | "source": [ 53 | "#@title Download the Pretrained Model\n", 54 | "!pip install -U --no-cache-dir gdown --pre\n", 55 | "!gdown 103xsaUZlukpbOu-h2AEyAyQHwMHwgRbk" 56 | ], 57 | "metadata": { 58 | "cellView": "form", 59 | "id": "uYmxQl7EdfK6" 60 | }, 61 | "execution_count": null, 62 | "outputs": [] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "source": [ 67 | "#@title Initialize the System\n", 68 | "!nvidia-smi\n", 69 | "# !pip install transformers bitsandbytes-cuda111 wikipedia\n", 70 | "!pip install transformers==4.22.2\n", 71 | "!pip install bitsandbytes==0.34.0\n", 72 | "!pip install wikipedia\n", 73 | "\n", 74 | "from torch import nn\n", 75 | "from bitsandbytes.functional import quantize_blockwise, dequantize_blockwise\n", 76 | "from torch.cuda.amp import custom_fwd, custom_bwd\n", 77 | "import torch.nn.functional as F\n", 78 | "import wikipedia\n", 79 | "import transformers\n", 80 | "import torch\n", 81 | "\n", 82 | "import nltk\n", 83 | "nltk.download('wordnet')\n", 84 | "\n", 85 | "config = transformers.GPTJConfig.from_pretrained(\"EleutherAI/gpt-j-6B\")\n", 86 | "tokenizer = transformers.AutoTokenizer.from_pretrained(\"EleutherAI/gpt-j-6B\")\n", 87 | "\n", 88 | "def check_in_wiki(name):\n", 89 | " name_parts = name.split()\n", 90 | " wiki_results = wikipedia.search(name)\n", 91 | " for w in wiki_results:\n", 92 | " w = w.lower()\n", 93 | " match_all_parts = True\n", 94 | " for n in name_parts:\n", 95 | " n = n.lower()\n", 96 | " if n == \"the\" or n == \"a\":\n", 97 | " continue\n", 98 | " if n not in w:\n", 99 | " match_all_parts = False\n", 100 | " break\n", 101 | " if match_all_parts:\n", 102 | " return True\n", 103 | " return False\n", 104 | "\n", 105 | "class FrozenBNBLinear(nn.Module):\n", 106 | " def __init__(self, weight, absmax, code, bias=None):\n", 107 | " assert isinstance(bias, nn.Parameter) or bias is None\n", 108 | " super().__init__()\n", 109 | " self.out_features, self.in_features = weight.shape\n", 110 | " self.register_buffer(\"weight\", weight.requires_grad_(False))\n", 111 | " self.register_buffer(\"absmax\", absmax.requires_grad_(False))\n", 112 | " self.register_buffer(\"code\", code.requires_grad_(False))\n", 113 | " self.adapter = None\n", 114 | " self.bias = bias\n", 115 | " \n", 116 | " def forward(self, input):\n", 117 | " output = DequantizeAndLinear.apply(input, self.weight, self.absmax, self.code, self.bias)\n", 118 | " if self.adapter:\n", 119 | " output += self.adapter(input)\n", 120 | " return output\n", 121 | " \n", 122 | " @classmethod\n", 123 | " def from_linear(cls, linear: nn.Linear) -> \"FrozenBNBLinear\":\n", 124 | " weights_int8, state = quantize_blockise_lowmemory(linear.weight)\n", 125 | " return cls(weights_int8, *state, linear.bias)\n", 126 | " \n", 127 | " def __repr__(self):\n", 128 | " return f\"{self.__class__.__name__}({self.in_features}, {self.out_features})\"\n", 129 | " \n", 130 | "class DequantizeAndLinear(torch.autograd.Function): \n", 131 | " @staticmethod\n", 132 | " @custom_fwd\n", 133 | " def forward(ctx, input: torch.Tensor, weights_quantized: torch.ByteTensor,\n", 134 | " absmax: torch.FloatTensor, code: torch.FloatTensor, bias: torch.FloatTensor):\n", 135 | " weights_deq = dequantize_blockwise(weights_quantized, absmax=absmax, code=code)\n", 136 | " ctx.save_for_backward(input, weights_quantized, absmax, code)\n", 137 | " ctx._has_bias = bias is not None\n", 138 | " return F.linear(input, weights_deq, bias)\n", 139 | " \n", 140 | " @staticmethod\n", 141 | " @custom_bwd\n", 142 | " def backward(ctx, grad_output: torch.Tensor):\n", 143 | " assert not ctx.needs_input_grad[1] and not ctx.needs_input_grad[2] and not ctx.needs_input_grad[3]\n", 144 | " input, weights_quantized, absmax, code = ctx.saved_tensors\n", 145 | " # grad_output: [*batch, out_features]\n", 146 | " weights_deq = dequantize_blockwise(weights_quantized, absmax=absmax, code=code)\n", 147 | " grad_input = grad_output @ weights_deq\n", 148 | " grad_bias = grad_output.flatten(0, -2).sum(dim=0) if ctx._has_bias else None\n", 149 | " return grad_input, None, None, None, grad_bias\n", 150 | "\n", 151 | "class FrozenBNBEmbedding(nn.Module):\n", 152 | " def __init__(self, weight, absmax, code):\n", 153 | " super().__init__()\n", 154 | " self.num_embeddings, self.embedding_dim = weight.shape\n", 155 | " self.register_buffer(\"weight\", weight.requires_grad_(False))\n", 156 | " self.register_buffer(\"absmax\", absmax.requires_grad_(False))\n", 157 | " self.register_buffer(\"code\", code.requires_grad_(False))\n", 158 | " self.adapter = None\n", 159 | " \n", 160 | " def forward(self, input, **kwargs):\n", 161 | " with torch.no_grad():\n", 162 | " # note: both quantuized weights and input indices are *not* differentiable\n", 163 | " weight_deq = dequantize_blockwise(self.weight, absmax=self.absmax, code=self.code)\n", 164 | " output = F.embedding(input, weight_deq, **kwargs)\n", 165 | " if self.adapter:\n", 166 | " output += self.adapter(input)\n", 167 | " return output \n", 168 | " \n", 169 | " @classmethod\n", 170 | " def from_embedding(cls, embedding: nn.Embedding) -> \"FrozenBNBEmbedding\":\n", 171 | " weights_int8, state = quantize_blockise_lowmemory(embedding.weight)\n", 172 | " return cls(weights_int8, *state)\n", 173 | " \n", 174 | " def __repr__(self):\n", 175 | " return f\"{self.__class__.__name__}({self.num_embeddings}, {self.embedding_dim})\"\n", 176 | " \n", 177 | "def quantize_blockise_lowmemory(matrix: torch.Tensor, chunk_size: int = 2 ** 20):\n", 178 | " assert chunk_size % 4096 == 0\n", 179 | " code = None\n", 180 | " chunks = []\n", 181 | " absmaxes = []\n", 182 | " flat_tensor = matrix.view(-1)\n", 183 | " for i in range((matrix.numel() - 1) // chunk_size + 1):\n", 184 | " input_chunk = flat_tensor[i * chunk_size: (i + 1) * chunk_size].clone()\n", 185 | " quantized_chunk, (absmax_chunk, code) = quantize_blockwise(input_chunk, code=code)\n", 186 | " chunks.append(quantized_chunk)\n", 187 | " absmaxes.append(absmax_chunk)\n", 188 | " \n", 189 | " matrix_i8 = torch.cat(chunks).reshape_as(matrix)\n", 190 | " absmax = torch.cat(absmaxes)\n", 191 | " return matrix_i8, (absmax, code)\n", 192 | " \n", 193 | " \n", 194 | "def convert_to_int8(model):\n", 195 | " \"\"\"Convert linear and embedding modules to 8-bit with optional adapters\"\"\"\n", 196 | " for module in list(model.modules()):\n", 197 | " for name, child in module.named_children():\n", 198 | " if isinstance(child, nn.Linear):\n", 199 | " print(name, child)\n", 200 | " setattr( \n", 201 | " module,\n", 202 | " name,\n", 203 | " FrozenBNBLinear(\n", 204 | " weight=torch.zeros(child.out_features, child.in_features, dtype=torch.uint8),\n", 205 | " absmax=torch.zeros((child.weight.numel() - 1) // 4096 + 1),\n", 206 | " code=torch.zeros(256),\n", 207 | " bias=child.bias,\n", 208 | " ),\n", 209 | " )\n", 210 | " elif isinstance(child, nn.Embedding):\n", 211 | " setattr(\n", 212 | " module,\n", 213 | " name,\n", 214 | " FrozenBNBEmbedding(\n", 215 | " weight=torch.zeros(child.num_embeddings, child.embedding_dim, dtype=torch.uint8),\n", 216 | " absmax=torch.zeros((child.weight.numel() - 1) // 4096 + 1),\n", 217 | " code=torch.zeros(256),\n", 218 | " )\n", 219 | " )\n", 220 | "\n", 221 | "class GPTJBlock(transformers.models.gptj.modeling_gptj.GPTJBlock):\n", 222 | " def __init__(self, config):\n", 223 | " super().__init__(config)\n", 224 | "\n", 225 | " convert_to_int8(self.attn)\n", 226 | " convert_to_int8(self.mlp)\n", 227 | "\n", 228 | "\n", 229 | "class GPTJModel(transformers.models.gptj.modeling_gptj.GPTJModel):\n", 230 | " def __init__(self, config):\n", 231 | " super().__init__(config)\n", 232 | " convert_to_int8(self)\n", 233 | " \n", 234 | "\n", 235 | "class GPTJForCausalLM(transformers.models.gptj.modeling_gptj.GPTJForCausalLM):\n", 236 | " def __init__(self, config):\n", 237 | " super().__init__(config)\n", 238 | " convert_to_int8(self)\n", 239 | "\n", 240 | "\n", 241 | "transformers.models.gptj.modeling_gptj.GPTJBlock = GPTJBlock # monkey-patch GPT-J\n", 242 | "\n", 243 | "gpt = torch.load(\"/content/GreenLIT_new.pt\", map_location=torch.device('cuda'))\n", 244 | "gpt.eval()\n", 245 | "\n", 246 | "import re\n", 247 | "import textwrap\n", 248 | "from nltk.corpus import wordnet as wn" 249 | ], 250 | "metadata": { 251 | "id": "nn2aaM6rwUnR", 252 | "cellView": "form" 253 | }, 254 | "execution_count": null, 255 | "outputs": [] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "source": [ 260 | "#@title Generate Titles and Summaries\n", 261 | "genre = 'crime drama' #@param {type:\"string\"}\n", 262 | "theme = 'cryptocurrency' #@param {type:\"string\"}\n", 263 | "\n", 264 | "prompt = \"GENRE: \" + genre + \" THEME: \" + theme + \"TITLE:\"\n", 265 | "with torch.no_grad():\n", 266 | " prompt_tokens = tokenizer(prompt, return_tensors=\"pt\").input_ids.cuda()\n", 267 | " sample_outputs = gpt.generate(prompt_tokens, max_length=80, do_sample=True, \n", 268 | " temperature=0.8, pad_token_id=tokenizer.eos_token_id, num_return_sequences=40)\n", 269 | "\n", 270 | "titles = []\n", 271 | "summaries = []\n", 272 | "count = 1\n", 273 | "for i, sample_output in enumerate(sample_outputs):\n", 274 | " results = tokenizer.decode(sample_output, skip_special_tokens=True)\n", 275 | " results = results.replace(\"\\n\", \" \")\n", 276 | " genre = re.search('GENRE:(.*)THEME:', results).group(1).strip()\n", 277 | " title = re.search('TITLE:(.*)SUMMARY:', results).group(1).strip()\n", 278 | "\n", 279 | " already_done = check_in_wiki(title)\n", 280 | " alpha = re.sub('[^a-zA-Z]+', '', title)\n", 281 | "\n", 282 | " if len(alpha) < 3 or already_done:\n", 283 | " continue\n", 284 | "\n", 285 | " summary = re.search('SUMMARY:(.*)', results).group(1).strip()\n", 286 | " titles.append(title)\n", 287 | " summaries.append(summary)\n", 288 | "\n", 289 | " out = str(count).zfill(2) + \" \" + title + \" - \" + summary\n", 290 | " wrapped = textwrap.fill(out, width=150, subsequent_indent=\" \")\n", 291 | " print(wrapped)\n", 292 | " count += 1" 293 | ], 294 | "metadata": { 295 | "colab": { 296 | "base_uri": "https://localhost:8080/" 297 | }, 298 | "cellView": "form", 299 | "id": "m3i4jeDMd6Yg", 300 | "outputId": "717c7959-c826-4535-a4d6-a48131d78401" 301 | }, 302 | "execution_count": 6, 303 | "outputs": [ 304 | { 305 | "output_type": "stream", 306 | "name": "stdout", 307 | "text": [ 308 | "01 L'Inconnu de l'Amérique - In this suspenseful mystery about an unknown man found dead in a New York building, the detective and the doctor\n", 309 | " investigate a large number of clues to discover who the man really was and why he died.\n", 310 | "02 The Cryptovalley - In search of financial independence, a young man discovers that cryptocurrency is a way to unlock a world of opportunities. But\n", 311 | " when he buys into the promise of a promising industry, he becomes a target for everyone who wants to take advantage of the newcomers.\n", 312 | "03 The Dark Side of the Internet - In this crime thriller, a young man uses the anonymous currency of Bitcoin to help kidnap his ex-girlfriend.\n", 313 | "04 Unforeseen (4K UHD) - Unforeseen is a darkly comedic drama about an unlikely friendship as five men with nothing in common but a common obsession,\n", 314 | " Bitcoin, go on the run from a pair of armed robbers.\n", 315 | "05 The Private Life of Pippa Lee - A young woman, trapped in a loveless marriage, is drawn into exploring her husband's world of cryptocurrency, and\n", 316 | " discovers a shocking world of sex and drugs.\n" 317 | ] 318 | } 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "source": [ 324 | "#@title Choose a Title and Create a Script\n", 325 | "\n", 326 | "choice = 2 #@param {type:\"slider\", min:1, max:40, step:1}\n", 327 | "choice -= 1\n", 328 | "\n", 329 | "if choice >= len(titles):\n", 330 | " print(\"Choose between 1 and \" + str(len(titles)))\n", 331 | "else:\n", 332 | " title = titles[choice]\n", 333 | " summary = summaries[choice]\n", 334 | " print(choice+1, title)\n", 335 | "\n", 336 | " prompt = \"TITLE: \" + title + \" SUMMARY: \" + summary + \" SCRIPT:\\n[Scene:\"\n", 337 | " \n", 338 | " with torch.no_grad():\n", 339 | " prompt_tokens = tokenizer(prompt, return_tensors=\"pt\").input_ids.cuda()\n", 340 | " sample_outputs = gpt.generate(prompt_tokens, max_length=480, do_sample=True, \n", 341 | " top_k=50, pad_token_id=tokenizer.eos_token_id,\n", 342 | " num_return_sequences=1)\n", 343 | " results = tokenizer.decode(sample_outputs[0], skip_special_tokens=True)\n", 344 | " results = results.strip()\n", 345 | " print(\"\\n[Scene:\" + results[len(prompt):])" 346 | ], 347 | "metadata": { 348 | "id": "tkLOMdD8M2xb", 349 | "colab": { 350 | "base_uri": "https://localhost:8080/" 351 | }, 352 | "cellView": "form", 353 | "outputId": "8b5905d0-e532-488c-90f8-597fdc6cbe9a" 354 | }, 355 | "execution_count": 7, 356 | "outputs": [ 357 | { 358 | "output_type": "stream", 359 | "name": "stdout", 360 | "text": [ 361 | "2 The Cryptovalley\n", 362 | "\n", 363 | "[Scene: Club; the club is packed. Ozzy is in his element.]\n", 364 | "\n", 365 | "OSBORNE - And this is his new friend, the Cryptovalley guy, Timmy.\n", 366 | "TIMMYS - Hi Ozzy. I'm Timmy.\n", 367 | "OSBORNE - Welcome to our humble abode, folks. We're having a special night in honour of our new friend. As you may have heard, the Cryptovalley is now known as the hottest thing since the Aztec empire. A few of our customers got together and put together a deal that really could change the world. Here ya go.\n", 368 | "[He pulls out a velvet bag.\n", 369 | "TIMMYS - That's...\n", 370 | "OSBORNE - Let me handle this, Timothy. As some of you know, I came in on this just before the explosion. And I made a little bit of money. But Timmy was actually thinking of entering the new game.\n", 371 | "TIMMYS - Yeah. Sure.\n", 372 | "OSBORNE - But he didn't need to. Because as you can see Timmy came to us for a certain...\n", 373 | "[Enter Anson. He walks up to Ozzy, looks at Timmy and his expression changes. He gives Ozzy a look of absolute disgust. Ozzy's expression changes to that of complete confusion.]\n", 374 | "\n", 375 | "ANSON - Is there a problem?\n", 376 | "OSBORNE - Oh no. I'm sorry. I didn't mean to disturb everyone. We were just discussing Timmy's future.\n", 377 | "ANSON - Do you know him?\n", 378 | "OSBORNE - Yeah. He's my assistant.\n" 379 | ] 380 | } 381 | ] 382 | } 383 | ] 384 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | 307 | including for purposes of Section 3(b); and 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public 411 | licenses. Notwithstanding, Creative Commons may elect to apply one of 412 | its public licenses to material it publishes and in those instances 413 | will be considered the “Licensor.” The text of the Creative Commons 414 | public licenses is dedicated to the public domain under the CC0 Public 415 | Domain Dedication. Except for the limited purpose of indicating that 416 | material is shared under a Creative Commons public license or as 417 | otherwise permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the 425 | public licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | --------------------------------------------------------------------------------