Skip to content

Instantly share code, notes, and snippets.

View soroushmehr's full-sized avatar

Soroush Mehri soroushmehr

  • Microsoft Research (prev. Maluuba and MILA-UdeM)
  • Vancouver, BC
View GitHub Profile
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output.
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure.
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS!
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed.
- Conclusion, classifications, or results should ALWAYS appear last.
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements.
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p
@soroushmehr
soroushmehr / neurips_tab.js
Created December 6, 2020 03:45
NeurIPS (nips.cc) Open Link in New Tab
// Tested on Chrome (December 2020) and macOS Catalina
// Install "Run Javascript" Chrome extension
// Go to nips.cc e.g. https://nips.cc/Conferences/2020/Schedule
// Change the `year` variable accordingly
// Select "Run Javascript" icon from top-right
// Paste the following script into it, select "Save & Run" and "Enable on nips.cc"
// In Chrome settings for nips.cc change the pop-up behavior to "Allow"
// Now everytime you visit NeurIPS schedules and a list of "cards,"
// you will see "[open tab!]" next to them that you can select "Open link in new tab"
// from right-click menu
@soroushmehr
soroushmehr / jupyter_gym_render.py
Created July 25, 2019 17:26 — forked from thomelane/jupyter_gym_render.py
OpenAI Gym render in Jupyter
import gym
from IPython import display
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
env = gym.make('Breakout-v0')
env.reset()
img = plt.imshow(env.render(mode='rgb_array')) # only call this once
for _ in range(100):
@soroushmehr
soroushmehr / test_view_5d.py
Created April 24, 2019 19:25
pytorch - will `view` preserve the spatial orientation as in the original tensor? Yes.
'''
See: https://github.com/pytorch/pytorch/issues/2013
Q: Will view preserve the spatial orientation as in the original tensor?
Run: python -u test_view_5d.py
'''
import random
import numpy as np
import torch
@soroushmehr
soroushmehr / pytorch-simple-rnn.py
Created August 10, 2018 21:05 — forked from spro/pytorch-simple-rnn.py
PyTorch RNN training example
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.autograd import Variable
from torch import optim
import numpy as np
import math, random
# Generating a noisy multi-sin wave
@soroushmehr
soroushmehr / msmarco_to_paragraph.py
Created November 10, 2017 18:25
Tokenize (with CoreNLP Make CNN/DailyMail (tokenized) datasets into paragraphs of minimum length 300 words.
"""
Install CoreNLP
Setup a server:
$ cd /home/somehri/corenlp/stanford-corenlp-full-2017-06-09
$ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer
Install PyCoreNLP:
https://github.com/smilli/py-corenlp
import types
import tensorflow as tf
import numpy as np
# Expressions are represented as lists of lists,
# in lisp style -- the symbol name is the head (first element)
# of the list, and the arguments follow.
# add an expression to an expression list, recursively if necessary.
def add_expr_to_list(exprlist, expr):
@soroushmehr
soroushmehr / TestDense&HW.ipynb
Created June 1, 2017 20:10 — forked from mickypaganini/TestDense&HW.ipynb
Test Dense and Highway layers in Keras using the same inputs as in our lwtnn-test-highway.cxx
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@soroushmehr
soroushmehr / latency.txt
Created January 31, 2017 16:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD