import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
# Mock dataset
def create_mock_dataset(vocab_size, seq_len, num_pairs):
preferred = torch.randint(0, vocab_size, (num_pairs, seq_len))
non_preferred = torch.randint(0, vocab_size, (num_pairs, seq_len))- Deep Q Learning (DQN) (Mnih et al. 2013)
- DQN with Fixed Q Targets (Mnih et al. 2013)
- Double DQN (DDQN) (Hado van Hasselt et al. 2015)
- DDQN with Prioritised Experience Replay (Schaul et al. 2016)
- Dueling DDQN (Wang et al. 2016)
- REINFORCE (Williams et al. 1992)
- Deep Deterministic Policy Gradients (DDPG) (Lillicrap et al. 2016 )
- Twin Delayed Deep Deterministic Policy Gradients (TD3) (Fujimoto et al. 2018)
- Soft Actor-Critic (SAC)
The reward model equation represents the negative log-likelihood loss for training the reward model
-
$r_{\phi}(x, y)$ is the reward model with parameters$\phi$ . -
$(x, y_w, y_l)$ is a tuple from the dataset$\mathcal{D}$ , where:-
$x$ is the input -
$y_w$ is the preferred output -
$y_l$ is the less preferred output
-
-
$\sigma(z) = \frac{1}{1+e^{-z}}$ is the logistic function.
In Emacs, the minibuffer is typically used for single-line input, so pressing RET (Enter) usually submits the input. However, if you need to input a line break (newline) in the minibuffer, you can do so by using the following methods: Method 1: Use C-q C-j
Press C-q (quoted-insert), followed by C-j (newline).
This inserts a literal newline character into the minibuffer.
Method 2: Use C-o
Press C-o (open-line), which inserts a newline and moves the cursor to the new line.
found the source code of many AI papers hard to read, partially because the authors are not in the mindset of software engineers, therefore the code is not aligned to software engineering best practices. How to solve this problem? I want to understand the code so that I can master the concetps in the papers more thourougly through code reading
Reading and fully understanding research code can be challenging, especially when code bases don’t follow traditional software engineering (SE) best practices. Here are some suggestions for getting more out of (often messy) AI research code:
- Organize the Context Before Diving In • Read the paper thoroughly. Make note of the key steps in the algorithm, the architectural components, and the logic flow. Then map these steps to the filenames, modules, and functions you see in the code.
| # -*- coding: utf-8 -*- | |
| """toy-word2vec.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1Lk3Td9MXzndT0ld1iaCF6FbggKCzBa2Z | |
| """ | |
| import jax |
| set nocompatible | |
| syntax on | |
| set number | |
| set relativenumber | |
| set tabstop=4 | |
| set shiftwidth=4 | |
| set expandtab | |
| set autoindent | |
| set hlsearch | |
| set incsearch |
| (defun insert-json-entries (json-str) | |
| (let ((json-object-type 'hash-table)) | |
| (cl-loop for entry across (json-read-from-string json-str) do | |
| (maphash (lambda (key value) | |
| (insert (format (if (string= key "role") "## %s:\n\n" "%s\n\n") | |
| (string-trim value "[ \t\n\r.]+")))) | |
| entry)))) | |
| (defun ask-for-input () | |
| "Prompt the user for input using the minibuffer." |
The route definition
post "/sandhi/analyze", to: "sandhi_analyses#analyze"
automatically includes an optional :format segment, so both
/sandhi/analyze # no explicit format
/sandhi/analyze.json # JSON extension
match the same sandhi_analyses#analyze action.
Throwaway verification that IgnoreSet (pure matcher, src/ignore.rs) behaves correctly against the real [ignore].patterns used by the Ekuro vault (~/.config/vaultsync/config.toml), run against the ignoreset-matcher-pure-pattern-language worktree via a temporary integration test.
Run: cargo test --offline --test smoke_real_config -> 1 test, 25 cases, all PASS.