Skip to content

Instantly share code, notes, and snippets.

View galacticglum's full-sized avatar

Shon Verch galacticglum

  • University of Toronto
  • Toronto, ON
  • 02:25 (UTC -04:00)
  • LinkedIn in/shon-verch
View GitHub Profile
"""
This examples show how to train a Bi-Encoder for the MS Marco dataset (https://github.com/microsoft/MSMARCO-Passage-Ranking).
The queries and passages are passed independently to the transformer network to produce fixed sized embeddings.
These embeddings can then be compared using cosine-similarity to find matching passages for a given query.
For training, we use MultipleNegativesRankingLoss. There, we pass triplets in the format:
(query, positive_passage, negative_passage)
Negative passage are hard negative examples, that were mined using different dense embedding methods and lexical search methods.
@galacticglum
galacticglum / AutoCrop.jsx
Last active January 4, 2024 20:07
An After Effects CC 2020 script for automatically cropping a composition to its content.
{
// AutoCrop.jsx
//
// This script scales the active comp to the size of the contents.
function AutoCrop(thisObj) {
var scriptName = "AutoCrop";
function onCropClick() {
var activeItem = app.project.activeItem;
@galacticglum
galacticglum / ecoo19_round2_p4.cpp
Last active April 28, 2019 11:52
20/100 (run 1)
#include <bits/stdc++.h>
//#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
int a[5005];
@galacticglum
galacticglum / ecoo19_round2_p3.cpp
Last active April 28, 2019 11:52
60/100 (run 1)
#include <bits/stdc++.h>
//#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
//int a[1000001];
@galacticglum
galacticglum / ecoo19_round2_p2.cpp
Last active April 28, 2019 11:52
100/100 (run 2)
#include <bits/stdc++.h>
//#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
//
int index = (int)pixelScreenCoordinates.y % 3;
if(y == 0)
{
muls *= float4(_ScanColour, _ScanColour, _ScanColour, 1);
}
_Contrast("Contrast", Float) = 0
_Brightness("Brightness", Float) = 0
...
uniform float _Contrast;
uniform float _Brightness;
...
int pixelPosition = (int)pixelScreenCoordinates.x % 3;
float4 output = float4(0, 0, 0, 1);
if (pixelPosition == 1)
{
output.r = color.r;
}
else if (pixelPosition == 2)
{
output.g = color.g;
}
using System;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine;
/// <summary>
/// Custom editor for a <see cref="SokobanPuzzleInstance"/>.
/// </summary>
[CustomEditor(typeof(SokobanPuzzleInstance))]
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine;
/// <inheritdoc />
/// <summary>
/// Room component inspector.
/// </summary>
[CustomEditor(typeof(Room), true)]