This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_with_cache(model, model_inputs, max_new_tokens): | |
''' Use past_key_values for a theoretical speedup. ''' | |
generated_tokens = [] | |
past_key_values = None | |
next_token = None | |
input_ids = model_inputs['input_ids'] | |
attention_mask = model_inputs['attention_mask'] | |
for i in range(max_new_tokens): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Metalearning allows SGD within SGD | |
There's an inner loop of optimization/SGD within the Model. | |
Then the normal optimzer, Adam, makes the outer loop. | |
This toy model just does this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Highlight blocks and send to Python interpreter | |
(defun search-unique (marker) | |
"Search for the first and only occurrence of MARKER. | |
Return the position if found, or nil if not found or multiple occurrences exist." | |
(let ((first-pos nil) | |
(count 0)) | |
(save-excursion | |
(goto-char (point-min)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE DeriveTraversable #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module BoundRecursionSchemes where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
module ConstrainedVinylRecords where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TypeOperators #-} | |
module Sand where | |
import Data.Aeson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The MIT License (MIT) | |
Copyright (c) 2016 Josh Freckleton | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(run* [q] | |
(fresh [al finn irv jim | |
p1 p2 p3 p4 | |
y1 y2 y3 y4] | |
;; rule #1 --------- | |
;; Of the item that sold for $175 and the one that sold for $225, | |
;; one featured Irv Ingram and the other came out in 1983. | |
(conde | |
((== irv [:175 (lvar)]) | |
(membero [:225 :1983] [al finn jim])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn rotate | |
"rotate a 2D matrix 90 degrees, it's ok if it's not a perfect square" | |
[mat] | |
(loop [remaining (map reverse mat) | |
result []] | |
(if (every? empty? remaining) | |
result | |
(recur (map rest remaining) | |
(conj result (remove nil? (mapv first remaining))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def search-term (atom "")) | |
(defn input [model on-change] | |
(let [external-model (atom @model) | |
internal-model (atom (or @external-model ""))] | |
(fn [model on-change] | |
;; this is taken from recom - http://bit.ly/1SZ1OXn | |
(when (not= @external-model @model) | |
(.log js/console "changed to " @model) | |
(reset! external-model @model) |
NewerOlder