Skip to content

Instantly share code, notes, and snippets.

@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:

Reinforcement Learning for Language Models

Yoav Goldberg, April 2023.

Why RL?

With the release of the ChatGPT model and followup large language models (LLMs), there was a lot of discussion of the importance of "RLHF training", that is, "reinforcement learning from human feedback". I was puzzled for a while as to why RL (Reinforcement Learning) is better than learning from demonstrations (a.k.a supervised learning) for training language models. Shouldn't learning from demonstrations (or, in language model terminology "instruction fine tuning", learning to immitate human written answers) be sufficient? I came up with a theoretical argument that was somewhat convincing. But I came to realize there is an additional argumment which not only supports the case of RL training, but also requires it, in particular for models like ChatGPT. This additional argument is spelled out in (the first half of) a talk by John Schulman from OpenAI. This post pretty much

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@rxaviers
rxaviers / gist:7360908
Last active May 20, 2024 06:07
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@ityonemo
ityonemo / test.md
Last active May 20, 2024 06:07
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.dir{display:inline-block;height:22px;vertical-align:middle;background-color:transparent;background-size:contain !important;background-color:#000;color:#FFF;padding-left:0.15em;padding-right:0.15em;border-radius:0.23em;font-family:'Tahoma','Arial', sans-serif;font-weight:bold;/*width:22px;*/}
.btn{display:inline-block;width:22px;height:22px;vertical-align:middle;background-color:transparent;background-size:contain !important;}
#X{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA7CAYAAAAn+enKAAAOtElEQVRo3u1baXSU1RmuW1d7atX2ZyUsIUD2fZ3JvkxmspJtkkxC1sm+70B2SIJsiopLrRXbIorVYzlC5RQpVbTSWhVrW6WUisXKqVYt/fv0fe43M5nB7Iu2Pc45z8nwzb33fZ/7Lve997t86UtffL74LPhTVdXU6O3jh7DwKMTExiMuPhkJicmIT9AQG5eonkdFRSMwKBTrN3jh4JNHPf9nCJ4BbrhthRsihYAh1YT0jGzk5BbAUlKGxuZWbN4ygJHRMYyN78C27RMYHBxBZ1cvqmvqkJtnhtGUriYkOiYOAYHBsFjKhk+cwPX/dUTffx8
@thushan
thushan / ConvertAzureAppSettingsToLocalSettings
Created May 20, 2024 05:53
Azure App Settings to local.settings.json converter
<#
Azure App Settings / Environment Variables to local.settings.json Converter
| v1.0.0 |-----------------------------------------------------------------
This script will take an Azure App Settings JSON file and convert it to a
local.settings.json file for use with Azure Functions.
It also moves some of the Azure specific settings to the top of the file.
@tomhicks
tomhicks / useTaskQueue.ts
Created January 11, 2021 11:41
React Hook for queueing and processing async tasks sequentially
function useTaskQueue(params: {
shouldProcess: boolean
}): {
tasks: ReadonlyArray<Task>
isProcessing: boolean
addTask: (task: Task) => void
} {
const [queue, setQueue] = React.useState<{
isProcessing: boolean
tasks: Array<Task>
@burchill
burchill / zachmagic.py
Last active May 20, 2024 05:55
Custom magic commands for Jupyter notebooks
# Created by Zachary Burchill, 2019-2021
# Feel free to use/modify however you want, but be nice and
# please give me credit/attribution.
#
# Put this file in your jupyter directory and load it in the first cell with:
# %load_ext zachmagic
# After that, you can use %beep, %%beep, %hook, %%hook, %time_beep, %%time_beep, %% %hide_all,
# %show_all, %keep_input and %%keep_input in the cells.
from IPython.core.magic import Magics, magics_class, line_magic, cell_magic, line_cell_magic
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.btn{display:inline-block;width:22px;height:22px;vertical-align:middle;background-color:transparent;background-size:contain !important;}
#X{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA7CAYAAAAn+enKAAAOtElEQVRo3u1baXSU1RmuW1d7atX2ZyUsIUD2fZ3JvkxmspJtkkxC1sm+70B2SIJsiopLrRXbIorVYzlC5RQpVbTSWhVrW6WUisXKqVYt/fv0fe43M5nB7Iu2Pc45z8nwzb33fZ/7Lve997t86UtffL74LPhTVdXU6O3jh7DwKMTExiMuPhkJicmIT9AQG5eonkdFRSMwKBTrN3jh4JNHPf9nCJ4BbrhthRsihYAh1YT0jGzk5BbAUlKGxuZWbN4ygJHRMYyN78C27RMYHBxBZ1cvqmvqkJtnhtGUriYkOiYOAYHBsFjKhk+cwPX/dUTffx83+vr5Iyk5FZlZOaissmJr/xD23rEP++7ej3377sHEjp0YGh4V0v3o6dmM7p4+9PZtkXaDGJVJ2HH7LjUJA4PDqG9okonKF49IRHiEDu5rPXD+PL76uRMFcK2Prz9SDGnIzslHV3cfdu++Ezt37cHg0AhaWtpRVW0VC29CgblIkcjKzkVG5kYFfucz/lZSWoZqay2aW9rURHBiurp75Xm5cv3wiCisXuOO/n5c+7mQjdDFnkxMSlEW7ejswZ69d2FoZJtSeFNZBTZuzENaeiZMpgyY0jJnhVG1y5A+WSoMyi