Skip to content

Instantly share code, notes, and snippets.

@rain-1
rain-1 / LLM.md
Last active July 18, 2024 22:37
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@sbarratt
sbarratt / scrape_ftx.py
Last active July 10, 2023 03:35
A script to export all FTX history
import pandas as pd
import time
import requests
import time
import hmac
from requests import Request
import sys
import json
import os
## Imports
from typing import Tuple
import torch
from torch import Module, Tensor
from transformers.models.roberta.modeling_roberta import RobertaPreTrainedModel, RobertaConfig, RobertaModel, RobertaEncoder
from torch.nn import CrossEntropyLoss, CosineEmbeddingLoss
## Function
@shi510
shi510 / ohem_generator.py
Last active January 29, 2023 20:29
Tensorflow 2.0 Online Hard Example Mining (OHEM)
class HardExampleMiner(tf.keras.utils.Sequence):
def __init__(self, model, x, y, batch_size, map_fn=None, ratio=0.8):
self.x = np.array(x, dtype=np.float32)
self.y = np.array(y, dtype=np.float32)
self.batch_size = batch_size
self.model = model
self.ratio = ratio
self.num_of_batch = int(math.floor((len(self.x) / self.batch_size)))
self.hard_idxs = np.arange(self.num_of_batch * self.batch_size)
@amqdn
amqdn / amqdn-crl.ipynb
Last active July 26, 2022 14:17
Implementing Class Rectification Loss in fast.ai
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@felipemoraes
felipemoraes / 0.useful.md
Last active March 10, 2024 19:55
Machine Learning Interview Questions
@ejlp12
ejlp12 / aws_glue_boto3_example.md
Last active March 22, 2022 18:29
AWS Glue Create Crawler, Run Crawler and update Table to use "org.apache.hadoop.hive.serde2.OpenCSVSerde"
import boto3

client = boto3.client('glue')

response = client.create_crawler(
    Name='SalesCSVCrawler',
    Role='AWSGlueServiceRoleDefault',
    DatabaseName='sales-cvs',
    Description='Crawler for generated Sales schema',
@yang-zhang
yang-zhang / pytorch-losses-in-plain-python.ipynb
Last active December 21, 2022 07:14
git/yang-zhang.github.io/ds_code/pytorch-losses-in-plain-python.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rickcrawford
rickcrawford / elastic_search_golang.md
Last active July 22, 2020 00:03
Get Elastic Search client working locally with Golang

Create 2 files: main.go and docker-compose.yml. Once both are created use docker-compose up and it will build the necessary files and start Elastic Search.

I found it necessary to add elastic.SetSniff(false) or I could not connect. Also remember the docker containers have security enabled for Elasticsearch with the password set as elastic:changeme. You can test it using curl:

curl http://127.0.0.1:9200/_cat/health -u elastic:changeme

Once it is running you can successfully run the main.go file using go run main.go.

@erogol
erogol / NLL_OHEM.py
Last active January 29, 2023 21:02
Online hard example mining PyTorch
import torch as th
class NLL_OHEM(th.nn.NLLLoss):
""" Online hard example mining.
Needs input from nn.LogSotmax() """
def __init__(self, ratio):
super(NLL_OHEM, self).__init__(None, True)
self.ratio = ratio