Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@janlukasschroeder
janlukasschroeder / summarize-sec-filings-with-openai-gpt3.ipynb
Last active October 10, 2023 12:57
Summarize-SEC-Filings-with-OpenAI-GPT3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashleyha
ashleyha / hf_helsinki-nlp_translation.py
Created December 16, 2020 17:57
example using the huggingface transformers library with the Helsinki-NLP/opus-mt-ru-en model
from transformers import MarianTokenizer, AutoModelForSeq2SeqLM
text = 'Рада познакомиться'
mname = 'Helsinki-NLP/opus-mt-ru-en'
tokenizer = MarianTokenizer.from_pretrained(mname)
model = AutoModelForSeq2SeqLM.from_pretrained(mname)
input_ids = tokenizer.encode(text, return_tensors="pt")
outputs = model.generate(input_ids)
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded) #Nice to meet you
@minlaxz
minlaxz / jupyter-lab.service-systemd
Last active November 12, 2023 12:03
Jupyter lab auto start or restart ( crash or server stopped ) on nvidia jetson nano or ubuntu.
# create a file and (name your wish) , then add this content to the file.
# OR
# sudo vim /etc/systemd/system/jupyter-lab.service
# paste code below
# Esc , shift z z
[Unit]
Description=Start Jupyter Lab Server at Boot
[Service]
@seanorama
seanorama / pyspark-on-yarn-self-contained.md
Last active September 8, 2023 07:43
PySpark on YARN in self-contained environments
@stoensin
stoensin / &map
Last active November 14, 2022 12:15
python因为其全局解释器锁GIL而无法通过线程实现真正的平行计算。 IO密集型:读取文件,读取网络套接字频繁。 计算密集型:大量消耗CPU的数学与逻辑运算,也就是我们这里说的平行计算。 而concurrent.futures模块,可以利用multiprocessing实现真正的平行计算。 核心原理是:concurrent.futures会以子进程的形式,平行的运行多个python解释器,从而令python程序可以利用多核CPU来提升执行速度。由于子进程与主解释器相分离,所以他们的全局解释器锁也是相互独立的。每个子进程都能够完整的使用一个CPU内核。
# 求最大公约数
def gcd(pair):
a, b = pair
low = min(a, b)
for i in range(low, 0, -1):
if a % i == 0 and b % i == 0:
return i
numbers = [
(1963309, 2265973), (1879675, 2493670), (2030677, 3814172),
@slowkow
slowkow / remove-emoji.py
Created July 19, 2018 14:10
Remove all traces of emoji from a text file.
#!/usr/bin/env python
"""
Remove emoji from a text file and print it to stdout.
Usage
-----
python remove-emoji.py input.txt > output.txt
"""
@Mahedi-61
Mahedi-61 / cuda_11.8_installation_on_Ubuntu_22.04
Last active April 26, 2024 08:00
Instructions for CUDA v11.8 and cuDNN 8.9.7 installation on Ubuntu 22.04 for PyTorch 2.1.2
#!/bin/bash
### steps ####
# Verify the system has a cuda-capable gpu
# Download and install the nvidia cuda toolkit and cudnn
# Setup environmental variables
# Verify the installation
###
### to verify your gpu is cuda enable check
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.