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
!pip install transformers==4.30 | |
!pip install accelerate | |
!pip install trl peft | |
!pip install bitsandbytes | |
!pip install xformers==0.0.22 | |
!pip install autoawq | |
from peft import LoraConfig | |
from peft import get_peft_model, PeftConfig, PeftModel, LoraConfig, prepare_model_for_kbit_training |
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
### Download files from https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0/tree/main | |
import time | |
from transformers import AutoTokenizer | |
import transformers | |
import torch | |
# model = "PY007/TinyLlama-1.1B-step-50K-105b" | |
# model = "yuhanzgithub/tinyllama" | |
model = "./" | |
tokenizer = AutoTokenizer.from_pretrained(model) |
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
speechSynthesis.speak(new SpeechSynthesisUtterance("This is very interesting")); |
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
select from_unixtime(unix_timestamp(DATE_SUB(CURRENT_DATE, 1), 'yyyyMMdd'),'yyyy-MM-dd') |
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
import pyarrow as pa | |
from deltalake.writer import write_deltalake | |
n_legs = pa.array([2, 4, 5, 100]) | |
animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"]) | |
names = ["n_legs", "animals"] | |
table = pa.Table.from_arrays([n_legs, animals], names=names) | |
write_deltalake('/tmp/delta_table', table, mode = 'append') |
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
# Based on https://docs.trychroma.com/usage-guide | |
import chromadb | |
persist_directory = '/tmp/vector_db' | |
client = chromadb.PersistentClient(path=persist_directory) | |
collection2 = client.create_collection( \ | |
name="save_embeddings", \ | |
metadata={"hnsw:space": "cosine"} # l2 is the default \ |
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
# pip3 install torch hanz | |
### Verify your torch support Apple M1 GPU: | |
### >>> torch.backends.mps.is_available() | |
### True | |
## Initialize the device | |
import torch | |
DEVICE = torch.device("mps" if torch.backends.mps.is_available() else "cpu") |
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
# gem install grpc grpc-tools | |
# grpc_tools_ruby_protoc --ruby_out=/tmp/hello --grpc_out=/tmp/grpc ./src/main/proto/helloworld.proto | |
# ... Then, include the generated files | |
require 'gruf' | |
Gruf.configure do |c| | |
c.default_client_host = 'localhost:9001' | |
end |
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
import resource | |
print(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) |
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
ffmpeg -i ../puppy.mp4 -ss 00:02:08 -t 00:00:03 '%04d.png' |
NewerOlder