This document describes how to install nvidia drivers & CUDA in one go on a fresh debian install.
Work in progress
- Start with a fresh Debian install.
import torch | |
import os | |
import argparse | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
import seaborn as sns | |
def get_parser(): |
# coding=utf-8 | |
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')): | |
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering | |
Args: | |
logits: logits distribution shape (vocabulary size) | |
top_k >0: keep only top k tokens with highest probability (top-k filtering). | |
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering). | |
Nucleus filtering is described in Holtzman et al. (http://arxiv.org/abs/1904.09751) | |
""" | |
assert logits.dim() == 1 # batch size 1 for now - could be updated for more but the code would be less clear | |
top_k = min(top_k, logits.size(-1)) # Safety check |
# BASIC TKINTER CHEATSHEET | |
# Build basic GUIs with Python | |
from tkinter import * | |
from tkinter import scrolledtext | |
from tkinter import messagebox | |
from tkinter.ttk import Progressbar | |
from tkinter import filedialog | |
from tkinter import Menu |
#coding: utf-8 | |
#demo of beam search for seq2seq model | |
import numpy as np | |
import random | |
vocab = { | |
0: 'a', | |
1: 'b', | |
2: 'c', | |
3: 'd', |
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py | |
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen): | |
"""for every sample, calculate probability for every possible label | |
you need to supply your RNN model and maxlen - the length of sequences it can handle | |
""" | |
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty) | |
return rnn_model.predict(data, verbose=0) | |
def beamsearch(predict=keras_rnn_predict, |
Hi:
perl -e 'print "hello world!\n"'
A simple filter:
perl -ne 'print if /REGEX/'
Filter out blank lines (in place):
// tokenize(str) | |
// extracts semantically useful tokens from a string containing English-language sentences | |
// @param {String} the string to tokenize | |
// @returns {Array} contains extracted tokens | |
function tokenize(str) { | |
var punct='\\['+ '\\!'+ '\\"'+ '\\#'+ '\\$'+ // since javascript does not | |
'\\%'+ '\\&'+ '\\\''+ '\\('+ '\\)'+ // support POSIX character | |
'\\*'+ '\\+'+ '\\,'+ '\\\\'+ '\\-'+ // classes, we'll need our |