├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG ├── LICENSE ├── README.md ├── notebooks ├── data │ ├── all_truncated_outputs.json │ ├── code_questions.json │ └── true_facts.json ├── emotion.ipynb ├── experiments.ipynb ├── honesty.ipynb ├── llama-3-70b.ipynb ├── llama-3.3-70b.ipynb ├── sae.ipynb └── vector_ops.ipynb ├── pyproject.toml ├── repeng ├── __init__.py ├── control.py ├── extract.py ├── saes.py └── tests.py └── uv.lock /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | format: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: install uv 16 | uses: astral-sh/setup-uv@v4 17 | with: 18 | version: "0.5.9" 19 | 20 | - name: ruff check 21 | run: uv run ruff check 22 | 23 | - name: ruff format --check 24 | run: uv run ruff format --check 25 | 26 | test: 27 | runs-on: ubuntu-latest 28 | strategy: 29 | matrix: 30 | python-version: ["3.10", "3.11", "3.12", "3.13"] 31 | 32 | steps: 33 | - uses: actions/checkout@v4 34 | 35 | # don't use uv install python because we need a system python for 36 | # numpy wheel builds 37 | - name: install python 38 | uses: actions/setup-python@v4 39 | with: 40 | python-version: ${{ matrix.python-version }} 41 | 42 | - name: install uv 43 | uses: astral-sh/setup-uv@v4 44 | with: 45 | version: "0.5.9" 46 | enable-cache: true 47 | cache-dependency-glob: "uv.lock" 48 | 49 | - run: uv sync --all-extras --dev 50 | 51 | - name: cache huggingface 52 | uses: actions/cache@v4 53 | with: 54 | path: ~/.cache/huggingface 55 | key: ${{ runner.os }}-hf-models-${{ hashFiles('**/lockfiles') }} 56 | restore-keys: | 57 | ${{ runner.os }}-hf-models- 58 | 59 | - run: uv run pytest 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # project 2 | __pycache__/ 3 | .venv/ 4 | 5 | # system 6 | *.pyc 7 | *.pyo 8 | *.pyd 9 | /venv/ 10 | /dist/ 11 | *.egg-info/ 12 | .Python 13 | .idea/ 14 | .vscode/ 15 | *.swp 16 | *~ 17 | .DS_Store 18 | Thumbs.db 19 | .env 20 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.4.0 - 2024-12-13 4 | 5 | * SAE support! See `notebooks/sae.ipynb` for an example. (#49) 6 | * Fixes for models in `bfloat16`. (#49) 7 | * `accelerate` removed from project dependencies, please install it manually with `pip install accelerate` if you need `device_map="auto"` or other `accelerate` features. (#56) 8 | * (for devs) Migrate project to `uv` and `ruff` from `poetry` and `black`. (#56) 9 | 10 | ## 0.3.1 - 2024-07-01 11 | 12 | * Add `method="pca_center"` option for training vectors with a more accurate method. (#29 / #34) 13 | * Thanks to @r3ndd ! :tada: 14 | * (The old method, `"pca_diff"`, remains the default.) 15 | * Also adds the undocumented / experimental `method="umap"`. 16 | * Adds `ControlVector.import_gguf(filename)` as a peer to `export_gguf`. (#34) 17 | * Fixes a bug with training vectors on right-padded models, such as llama-3-*. (#38) 18 | * Thanks to @ohxh ! :tada: 19 | * (0.3.0 was a botched release, has been yanked) 20 | 21 | ## 0.2.2 - 2024-03-09 22 | 23 | * Fix a bug in control.py (#18) 24 | 25 | ## 0.2.1 - 2024-03-04 26 | 27 | * Add GPT-2 support. (#12) 28 | * Officially support Python 3.10 and 3.11. (#13) 29 | 30 | ## 0.2.0 - 2024-03-03 31 | 32 | * Add control vector arithmetic. (#6) 33 | * Add GGUF export. (#5, #9) 34 | * Notebooks: Add code questions dataset. (#4) 35 | * Notebooks: Move `data/` to `notebooks/data/`. (#7) 36 | * Notebooks: Add MPS (Apple Silicon) autodetection. (#8) 37 | 38 | ## 0.1.0 - 2024-01-21 39 | 40 | * Initial release. 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Theia Vogel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # repeng 2 | 3 | [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/vgel/repeng/ci.yml?label=ci)](https://github.com/vgel/repeng/actions) 4 | [![PyPI - Version](https://img.shields.io/pypi/v/repeng)](https://pypi.org/project/repeng/) 5 | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/repeng)](https://pypi.org/project/repeng/) 6 | [![GitHub License](https://img.shields.io/github/license/vgel/repeng)](https://github.com/vgel/repeng/blob/main/LICENSE) 7 | 8 | A Python library for generating control vectors with representation engineering. 9 | Train a vector in less than sixty seconds! 10 | 11 | _For a full example, see the notebooks folder or [the blog post](https://vgel.me/posts/representation-engineering)._ 12 | 13 | ```python 14 | import json 15 | import torch 16 | from transformers import AutoModelForCausalLM, AutoTokenizer 17 | 18 | from repeng import ControlVector, ControlModel, DatasetEntry 19 | 20 | # load and wrap Mistral-7B 21 | model_name = "mistralai/Mistral-7B-Instruct-v0.1" 22 | model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16) 23 | model = ControlModel(model, list(range(-5, -18, -1))) 24 | 25 | def make_dataset(template: str, pos_personas: list[str], neg_personas: list[str], suffixes: list[str]): 26 | # see notebooks/experiments.ipynb for a definition of `make_dataset` 27 | ... 28 | 29 | # generate a dataset with closely-opposite paired statements 30 | trippy_dataset = make_dataset( 31 | "Act as if you're extremely {persona}.", 32 | ["high on psychedelic drugs"], 33 | ["sober from psychedelic drugs"], 34 | truncated_output_suffixes, 35 | ) 36 | 37 | # train the vector—takes less than a minute! 38 | trippy_vector = ControlVector.train(model, tokenizer, trippy_dataset) 39 | 40 | # set the control strength and let inference rip! 41 | for strength in (-2.2, 1, 2.2): 42 | print(f"strength={strength}") 43 | model.set_control(trippy_vector, strength) 44 | out = model.generate( 45 | **tokenizer( 46 | f"[INST] Give me a one-sentence pitch for a TV show. [/INST]", 47 | return_tensors="pt" 48 | ), 49 | do_sample=False, 50 | max_new_tokens=128, 51 | repetition_penalty=1.1, 52 | ) 53 | print(tokenizer.decode(out.squeeze()).strip()) 54 | print() 55 | ``` 56 | 57 | > strength=-2.2 58 | > A young and determined journalist, who is always in the most serious and respectful way, will be able to make sure that the facts are not only accurate but also understandable for the public. 59 | > 60 | > strength=1 61 | > "Our TV show is a wild ride through a world of vibrant colors, mesmerizing patterns, and psychedelic adventures that will transport you to a realm beyond your wildest dreams." 62 | > 63 | > strength=2.2 64 | > "Our show is a kaleidoscope of colors, trippy patterns, and psychedelic music that fills the screen with a world of wonders, where everything is oh-oh-oh, man! ��psy����������oodle����psy��oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 65 | 66 | For a more detailed explanation of how the library works and what it can do, see [the blog post](https://vgel.me/posts/representation-engineering). 67 | 68 | ## Notes 69 | 70 | * For a list of changes by version, see the [CHANGELOG](https://github.com/vgel/repeng/blob/main/CHANGELOG). 71 | * For quantized use, you may be interested in [llama.cpp#5970](https://github.com/ggerganov/llama.cpp/pull/5970)—after training a vector with `repeng`, export it by calling `vector.export_gguf(filename)` and then use it in `llama.cpp` with any quant! 72 | * Vector training *currently does not work* with MoE models (such as Mixtral). (This is theoretically fixable with some work, let me know if you're interested.) 73 | * Some example notebooks require `accelerate`, which must be manually installed with `pip install accelerate`. (This can also be done in the notebook with the IPython magic `%pip install accelerate`.) 74 | 75 | ## Notice 76 | 77 | Some of the code in this repository derives from [andyzoujm/representation-engineering](https://github.com/andyzoujm/representation-engineering) (MIT license). 78 | 79 | ## Citation 80 | 81 | If this repository is useful for academic work, please remember to cite [the representation-engineering paper](https://github.com/andyzoujm/representation-engineering?tab=readme-ov-file#citation) that it's based on, along with this repository: 82 | 83 | ``` 84 | @misc{vogel2024repeng, 85 | title = {repeng}, 86 | author = {Theia Vogel}, 87 | year = {2024}, 88 | url = {https://github.com/vgel/repeng/} 89 | } 90 | ``` 91 | -------------------------------------------------------------------------------- /notebooks/data/all_truncated_outputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | "", 3 | "That game", 4 | "I can see", 5 | "Hmm, this", 6 | "I can relate to", 7 | "Who is", 8 | "I understand the", 9 | "Ugh,", 10 | "What the hell was", 11 | "Hey, did anyone", 12 | "Although", 13 | "Thank you for choosing", 14 | "What are you", 15 | "Oh w", 16 | "How dare you open", 17 | "It was my pleasure", 18 | "I'm hon", 19 | "I appreciate that you", 20 | "Are you k", 21 | "Whoever left this", 22 | "It's always", 23 | "Ew,", 24 | "Hey, I l", 25 | "Hello? Is someone", 26 | "I understand that", 27 | "That poem", 28 | "Aww, poor", 29 | "Hey, it", 30 | "Alright, who", 31 | "I didn't", 32 | "Well, life", 33 | "The document", 34 | "Oh no, this", 35 | "I'm concerned", 36 | "Hello, this is", 37 | "This art", 38 | "Hmm, this drink", 39 | "Hi there!", 40 | "It seems", 41 | "Is", 42 | "Good", 43 | "I can't", 44 | "Ex", 45 | "Who are", 46 | "I can see that", 47 | "Wow,", 48 | "Today is a", 49 | "Hey friend", 50 | "Sometimes friends", 51 | "Oh, this old", 52 | "The weather outside", 53 | "This place is sur", 54 | "I appreciate your input", 55 | "Thank you for the", 56 | "Look at", 57 | "I'm disappoint", 58 | "To my", 59 | "How dare you", 60 | "That's an", 61 | "This piece of art", 62 | "Eww", 63 | "This park is", 64 | "This is incredible", 65 | "Oh no, someone", 66 | "Exc", 67 | "Well, it'", 68 | "I warned", 69 | "Hey, I understand", 70 | "Hey, I saw", 71 | "How dare you go", 72 | "What the he", 73 | "Hey", 74 | "It's", 75 | "Hello? Hello?", 76 | "It", 77 | "Oh no!", 78 | "This is the perfect", 79 | "Good morning,", 80 | "Oh no, there", 81 | "It's so", 82 | "Yeah", 83 | "Uh,", 84 | "Hello everyone", 85 | "Who turned off", 86 | "The weather", 87 | "Who'", 88 | "Hey, this", 89 | "Wait,", 90 | "Eww, gross", 91 | "Excuse", 92 | "It seems like you", 93 | "Thank you so", 94 | "What happened?", 95 | "Oh my g", 96 | "I am deeply sad", 97 | "I war", 98 | "Okay, let'", 99 | "Hey, that", 100 | "That was a beautiful", 101 | "Oh no! That", 102 | "What happened", 103 | "Hey there", 104 | "The artist'", 105 | "What?!", 106 | "Hey, it'", 107 | "I am disappoint", 108 | "It seems like", 109 | "Oh no! The", 110 | "This park is a", 111 | "If you", 112 | "Yes! I did", 113 | "It sounds", 114 | "What", 115 | "Who is it", 116 | "Hmm, that", 117 | "That's strange", 118 | "Yeah, that was", 119 | "That's interesting", 120 | "This park", 121 | "What the hell", 122 | "Who is that", 123 | "I feel like my", 124 | "Oh well", 125 | "What the hell is", 126 | "Hello? Hello", 127 | "To my dearest", 128 | "Bless you!\"", 129 | "Thank you for", 130 | "Oh, looks like", 131 | "Can you please", 132 | "This place is", 133 | "Eww, what", 134 | "Bless you", 135 | "Is everything", 136 | "Hey, I just", 137 | "Whoever left these", 138 | "Well, that'", 139 | "I feel", 140 | "Hey, do you", 141 | "It's sad", 142 | "Oh no, it", 143 | "Hey, that'", 144 | "Oh my god,", 145 | "Thank you,", 146 | "Hello little one,", 147 | "I apolog", 148 | "Hey team, I", 149 | "How dare you read", 150 | "Who is this and", 151 | "Whoever left", 152 | "Hi there! W", 153 | "A", 154 | "If you have", 155 | "I was", 156 | "U", 157 | "Bless", 158 | "Well, this", 159 | "Oh, I'", 160 | "It's a", 161 | "Eww,", 162 | "Is everything okay?", 163 | "Oh, I", 164 | "Hello, can you", 165 | "Al", 166 | "That was a great", 167 | "What are", 168 | "I understand that not", 169 | "Oh no, not", 170 | "Who is it?\"", 171 | "Hey, can we", 172 | "Whoever is taking", 173 | "I would love to", 174 | "Hey, I noticed", 175 | "Hey, could", 176 | "I understand that there", 177 | "Hello?", 178 | "D", 179 | "Oh man, I", 180 | "Thank you so much", 181 | "Oh no, my", 182 | "Dear [Name", 183 | "Uh", 184 | "I remember", 185 | "Hey, who", 186 | "Well, it", 187 | "Are you", 188 | "I understand that it", 189 | "Hey, is", 190 | "I would", 191 | "Who is this", 192 | "Excuse me", 193 | "Alright", 194 | "I am thrilled", 195 | "Sometimes friends have", 196 | "Who the", 197 | "It's interesting", 198 | "I would love", 199 | "E", 200 | "Hello? Is anyone", 201 | "Well, this is", 202 | "This place", 203 | "Well,", 204 | "I warned you", 205 | "Hey, watch where", 206 | "Oh my", 207 | "That'", 208 | "Sometimes friends have different", 209 | "I understand that everyone", 210 | "What?", 211 | "What do these notes", 212 | "I can relate", 213 | "I'm not", 214 | "I understand", 215 | "To my dear", 216 | "Guys", 217 | "Well", 218 | "Hey, I appreciate", 219 | "Wow, what", 220 | "Dear", 221 | "That melody", 222 | "Who the hell", 223 | "Today is", 224 | "Hello little", 225 | "Wow, look", 226 | "That's great", 227 | "Love is never wrong", 228 | "I'm having", 229 | "Whoa, did", 230 | "Ugh", 231 | "Can you please provide", 232 | "I miss you,", 233 | "I feel uncom", 234 | "I know", 235 | "Ugh, this", 236 | "Hey, watch", 237 | "Oh great, a", 238 | "I didn", 239 | "Okay", 240 | "That game of char", 241 | "Oh", 242 | "I appreciate", 243 | "Who's there", 244 | "I am so", 245 | "Oh great, someone", 246 | "Hey, could you", 247 | "I remember wondering", 248 | "Wait, what?", 249 | "What do", 250 | "Hello? Can", 251 | "Hey there,", 252 | "That game of", 253 | "This is incred", 254 | "Oh my gosh", 255 | "Oh great, f", 256 | "I appreciate your", 257 | "It sounds like", 258 | "What the heck", 259 | "Okay, I understand", 260 | "Ew", 261 | "I understand that this", 262 | "Uh, hi", 263 | "Hi everyone!", 264 | "What the hell?", 265 | "Thank you for your", 266 | "Oh no, the", 267 | "Wow, I", 268 | "Who turned", 269 | "Dear [", 270 | "Whoever", 271 | "This is a", 272 | "Whoa, he", 273 | "What in the world", 274 | "Although the physical", 275 | "Hello, who is", 276 | "That's amaz", 277 | "Hey, I know", 278 | "Okay, that", 279 | "Hi everyone", 280 | "Hey, is everything", 281 | "I understand your fr", 282 | "Oh no, poor", 283 | "Oh, look", 284 | "Good morning", 285 | "Ew, gross", 286 | "Oh no, did", 287 | "Look at the family", 288 | "Hey team", 289 | "Yes!", 290 | "Hey, can I", 291 | "Okay, that'", 292 | "It's great", 293 | "Love is", 294 | "Hey, what", 295 | "Good morning, world", 296 | "Who is it?", 297 | "That poem really reson", 298 | "I", 299 | "That's", 300 | "I understand the task", 301 | "Gu", 302 | "Hello? Who'", 303 | "This postcard is", 304 | "Whoa,", 305 | "Oh, that", 306 | "I understand that I", 307 | "Whoever is", 308 | "Hello? Who is", 309 | "I'm really", 310 | "Wow, this", 311 | "Can", 312 | "This artwork really", 313 | "This is a shame", 314 | "I miss you too", 315 | "Who are you?", 316 | "Today is a difficult", 317 | "Hey, just", 318 | "Are you okay", 319 | "I am", 320 | "Hi,", 321 | "Wow, that", 322 | "Hey there! Can", 323 | "Okay, stay", 324 | "Oh great, just", 325 | "Yeah,", 326 | "Hello? Can you", 327 | "Oh, looks", 328 | "Thank you for sharing", 329 | "I'm glad", 330 | "Hey, is that", 331 | "Hmm", 332 | "It was my", 333 | "It sounds like you", 334 | "Wow, your", 335 | "I was promised certain", 336 | "That was such a", 337 | "Thank", 338 | "Excuse you", 339 | "That was", 340 | "Hey team,", 341 | "I feel un", 342 | "It was", 343 | "What'", 344 | "Hey friend, I", 345 | "How", 346 | "Saying goodbye", 347 | "That", 348 | "It's heart", 349 | "How dare", 350 | "Oh,", 351 | "Hello, may", 352 | "What's this", 353 | "Thank you for recogn", 354 | "Aww, that", 355 | "Oh, I remember", 356 | "Hmm, that'", 357 | "I miss", 358 | "I know this", 359 | "Wait", 360 | "Is everything okay", 361 | "Who is that person", 362 | "Wow, you", 363 | "Oh great", 364 | "I'm sad", 365 | "Wow, the", 366 | "I am very disappoint", 367 | "Who turned off the", 368 | "I understand that things", 369 | "I'm very", 370 | "Hi", 371 | "That's very", 372 | "Okay, I", 373 | "Oh no,", 374 | "Wow, there", 375 | "What's wrong", 376 | "I apologize for", 377 | "Hey, I", 378 | "Can I help you", 379 | "Oh, I didn", 380 | "Alright,", 381 | "Oh wow,", 382 | "Oh my goodness", 383 | "I know this event", 384 | "What in the", 385 | "Saying", 386 | "Yeah, that", 387 | "Guys, I", 388 | "Hey, this v", 389 | "This post", 390 | "Are", 391 | "Hey, can", 392 | "Hello? Is", 393 | "I can only imagine", 394 | "Oh, that sounds", 395 | "Hey, is anyone", 396 | "I am disappointed", 397 | "Hello,", 398 | "Hey everyone, I", 399 | "That was such", 400 | "It's okay", 401 | "The artist", 402 | "Whoa", 403 | "I understand that mistakes", 404 | "Can I help", 405 | "Who", 406 | "Hi everyone! I", 407 | "Hey, can you", 408 | "Wow, how", 409 | "Today", 410 | "Oh no, I", 411 | "Oh well, I", 412 | "Well, that", 413 | "This is the", 414 | "Yes! I finally", 415 | "Hey there little", 416 | "Hello everyone!", 417 | "Love is never", 418 | "Look at the", 419 | "This postcard", 420 | "Oh great,", 421 | "Can I", 422 | "Hmm, this is", 423 | "I understand your", 424 | "Oh, look at", 425 | "B", 426 | "I'm so", 427 | "Whoa, this", 428 | "W", 429 | "Oh, this", 430 | "Sometimes", 431 | "This piece of", 432 | "What the", 433 | "That was a", 434 | "Hey, do", 435 | "Oh no", 436 | "Whoa, what", 437 | "I feel like I", 438 | "The documentary", 439 | "Hello", 440 | "Hello little one", 441 | "I understand that my", 442 | "Eww, that", 443 | "Wow, an", 444 | "Yes! Finally,", 445 | "Although the physical location", 446 | "Whoever is watching", 447 | "That movie", 448 | "I remember wondering about", 449 | "Hey there, little", 450 | "Who's", 451 | "Hello, who", 452 | "Hello everyone! Thank", 453 | "Hello, can", 454 | "That's too", 455 | "Hey, just wanted", 456 | "Hey there, I", 457 | "Saying good", 458 | "Hey there!", 459 | "Who is there?", 460 | "Oh my good", 461 | "I am very", 462 | "Oh no, what", 463 | "Wow, thank", 464 | "I was promised", 465 | "Hi, is", 466 | "Hey, I'", 467 | "Guys, the", 468 | "Oh no, that", 469 | "Who is there", 470 | "Hello, this", 471 | "That movie really touched", 472 | "If you have something", 473 | "The documentary was", 474 | "I'm starting", 475 | "Are you kidd", 476 | "That movie really", 477 | "Hey everyone,", 478 | "Thank you for considering", 479 | "I didn'", 480 | "Yes! I", 481 | "Can you", 482 | "Oh my god", 483 | "Hey, whoever", 484 | "That melody really", 485 | "Thank you, little", 486 | "Hello, may I", 487 | "Look", 488 | "Wow, we", 489 | "It looks", 490 | "What do these", 491 | "Oh wow", 492 | "I apologize", 493 | "What are you all", 494 | "It's such", 495 | "It's clear", 496 | "Hey, I was", 497 | "Hey friend,", 498 | "I can only", 499 | "The weather outside is", 500 | "Eww, this", 501 | "I miss you", 502 | "Wow", 503 | "Aww,", 504 | "Hi, is there", 505 | "This artwork", 506 | "Okay,", 507 | "Oh well,", 508 | "This", 509 | "I'", 510 | "Say", 511 | "Hey there little gu", 512 | "Hmm,", 513 | "Whoa, who", 514 | "I am thr", 515 | "Oh man", 516 | "Okay, stay calm", 517 | "I'm happy", 518 | "Oh, this cur", 519 | "Oh man,", 520 | "I'm sorry", 521 | "Hello? Who", 522 | "What?! That", 523 | "This piece", 524 | "Hey everyone", 525 | "That's so", 526 | "Are you okay?", 527 | "What happened? Where", 528 | "Hi there", 529 | "The", 530 | "Who the hell entered", 531 | "I can", 532 | "Guys,", 533 | "What's", 534 | "What in", 535 | "It's important", 536 | "I'm", 537 | "I'm coming", 538 | "It'", 539 | "Yes! Finally", 540 | "Wait, what", 541 | "Wow, reading", 542 | "I'm surprised", 543 | "Hey, did", 544 | "Hey,", 545 | "Okay, let", 546 | "I understand that you", 547 | "Who the hell threw", 548 | "Eww, who", 549 | "Thank you for thinking", 550 | "Who is this?\"", 551 | "I am deeply", 552 | "Thank you for including", 553 | "Oh no, an", 554 | "It looks like you", 555 | "Aww", 556 | "I'm confused", 557 | "Wow, it", 558 | "That poem really", 559 | "Yes", 560 | "Hey there, is", 561 | "Hey, what'", 562 | "Thank you for remember", 563 | "To", 564 | "This is", 565 | "Thank you for making", 566 | "I can'", 567 | "That mel", 568 | "Wow, they", 569 | "I feel like", 570 | "Although the", 571 | "Who are you", 572 | "Love", 573 | "If", 574 | "What the hell are", 575 | "I am so sad", 576 | "Oh, I found", 577 | "Thank you", 578 | "It looks like", 579 | "Well, life is", 580 | "I appreciate that", 581 | "The artist's", 582 | "Whoa, that", 583 | "It's never" 584 | ] -------------------------------------------------------------------------------- /notebooks/data/code_questions.json: -------------------------------------------------------------------------------- 1 | [ 2 | "[INST] How to reverse a string in Python? [/INST] You can use", 3 | "[INST] create a REST API with Flask [/INST] Start by installing", 4 | "[INST] What is polymorphism in OOP? [/INST] Polymorphism allows", 5 | "[INST] best practices for git commit messages [/INST] It's recommended to", 6 | "[INST] install numpy in a virtualenv [/INST] First, activate your", 7 | "[INST] difference between list and tuple in Python [/INST] The main difference", 8 | "[INST] generate random numbers in JavaScript [/INST] Use Math.random() to", 9 | "[INST] using async/await in Node.js [/INST] Async functions enable", 10 | "[INST] CSS selector for an ID [/INST] Use the hash symbol", 11 | "[INST] SQL query to find duplicates [/INST] You can use GROUP BY", 12 | "[INST] prevent SQL injection in PHP [/INST] Always use prepared statements", 13 | "[INST] What is a deadlock in operating systems? [/INST] A deadlock occurs when", 14 | "[INST] setting up environment variables in Linux [/INST] Export the variables using", 15 | "[INST] merge two dictionaries in Python [/INST] Use the {**dict1, **dict2} syntax", 16 | "[INST] center a div with CSS [/INST] Apply display: flex and justify-content", 17 | "[INST] What is machine learning? [/INST] Machine learning is a type of", 18 | "[INST] making a GET request with axios [/INST] Axios.get('url') allows", 19 | "[INST] What are websockets? [/INST] Websockets provide a bidirectional", 20 | "[INST] update a record in MongoDB [/INST] Use the db.collection.updateOne method", 21 | "[INST] convert string to int in Java [/INST] Use Integer.parseInt() for", 22 | "[INST] read a file line by line in Python [/INST] Open the file and iterate", 23 | "[INST] What is Docker? [/INST] Docker is a platform for", 24 | "[INST] How to use hooks in React? [/INST] Hooks allow you to", 25 | "[INST] send an email with Python [/INST] Use the smtplib module to", 26 | "[INST] What is a JWT? [/INST] JWT stands for JSON Web Token,", 27 | "[INST] create a virtual environment in Python [/INST] Use the command python -m venv", 28 | "[INST] How to declare a variable in JavaScript? [/INST] Use let, const, or var", 29 | "[INST] sorting an array in Java [/INST] Arrays.sort() method can", 30 | "[INST] What is the purpose of CORS? [/INST] CORS, or Cross-Origin Resource Sharing,", 31 | "[INST] add an element to an array in PHP [/INST] Use the array_push() function or", 32 | "[INST] How to create a thread in Java? [/INST] Implement the Runnable interface or", 33 | "[INST] make a div full screen [/INST] Set width and height to 100%", 34 | "[INST] What is the Singleton pattern? [/INST] The Singleton pattern ensures a class", 35 | "[INST] remove an element from a list in Python [/INST] Use the list.remove() method or", 36 | "[INST] deploy a React app to GitHub Pages [/INST] Use the gh-pages package to", 37 | "[INST] What is the difference between == and === in JavaScript? [/INST] == checks for", 38 | "[INST] concatenate strings in JavaScript [/INST] Use the + operator or template literals", 39 | "[INST] What is an API? [/INST] An API, or Application Programming Interface,", 40 | "[INST] execute a shell command from Python [/INST] Use the subprocess.run() function", 41 | "[INST] CSS to make text responsive [/INST] Use viewport units like vw", 42 | "[INST] What is the use of the map function in Python? [/INST] The map function applies", 43 | "[INST] How to check if a key exists in a dictionary in Python? [/INST] Use the in keyword", 44 | "[INST] create a responsive navbar [/INST] Use CSS media queries and flexbox", 45 | "[INST] What is the Big O notation? [/INST] Big O notation describes the", 46 | "[INST] update state in React [/INST] Use the useState hook or this.setState in class", 47 | "[INST] How to find the length of a list in Python? [/INST] Use the len() function", 48 | "[INST] generate a QR code in Python [/INST] Use the qrcode library and", 49 | "[INST] What is a promise in JavaScript? [/INST] A promise represents the", 50 | "[INST] vertically center text in a div [/INST] Use display: flex and align-items", 51 | "[INST] How to use Git rebase? [/INST] Git rebase is used for", 52 | "[INST] set a background image in CSS [/INST] Use the background-image property", 53 | "[INST] What is Kubernetes? [/INST] Kubernetes is an open-source platform for", 54 | "[INST] fetch data with React Hooks [/INST] Use the useEffect hook and fetch API", 55 | "[INST] remove duplicates from an array in JavaScript [/INST] Create a new Set() and", 56 | "[INST] What is the purpose of Redux in React? [/INST] Redux provides a predictable", 57 | "[INST] How to create a modal in HTML and CSS? [/INST] Structure your HTML with a", 58 | "[INST] serialize an object to JSON in JavaScript [/INST] Use JSON.stringify() to", 59 | "[INST] What is Agile software development? [/INST] Agile is a methodology that", 60 | "[INST] validate an email address in JavaScript [/INST] Use a regular expression to", 61 | "[INST] create a dropdown menu in HTML [/INST] Use the element along with multiple", 139 | "[INST] What is the use of the await keyword in JavaScript? [/INST] The await keyword is used with", 140 | "[INST] How to optimize website performance? [/INST] Minimize HTTP requests, optimize images, use CDN, enable", 141 | "[INST] What is the Model-View-Controller (MVC) pattern? [/INST] The MVC pattern is a software design pattern", 142 | "[INST] How to read from a file in Java? [/INST] Use the java.io.FileReader class or java.nio.file.Files", 143 | "[INST] How to use the reduce method in JavaScript? [/INST] The reduce method reduces an array to", 144 | "[INST] What is a Docker image? [/INST] A Docker image is a lightweight, standalone, executable package", 145 | "[INST] How to center text in HTML? [/INST] Use the text-align property in CSS with the", 146 | "[INST] How to create a virtual machine? [/INST] Use virtualization software like VMware, VirtualBox, or Hyper-V", 147 | "[INST] What is an ORM? [/INST] ORM stands for Object-Relational Mapping, a technique for", 148 | "[INST] How to make a form in HTML? [/INST] Use the
element with ,