Skip to content

Instantly share code, notes, and snippets.

View sigridjineth's full-sized avatar
🎯
Lynne Frederick (1954-1994)

Sigrid Jin (ΰΈ‡'Μ€-'́)ΰΈ‡ oO sigridjineth

🎯
Lynne Frederick (1954-1994)
View GitHub Profile
# /// script
# dependencies = [ "transformers", "accelerate" ]
# ///
# run on 2xH200 rented from primeintellect.ai
import gc
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
@toy-crane
toy-crane / toss-frontend-rules.mdc
Last active December 8, 2025 07:53
ν† μŠ€ ν”„λ‘ νŠΈμ—”λ“œ κ°€μ΄λ“œλΌμΈ 기반으둜 λ§Œλ“  Cursor rule
# Frontend Design Guideline
This document summarizes key frontend design principles and rules, showcasing
recommended patterns. Follow these guidelines when writing frontend code.
# Readability
Improving the clarity and ease of understanding code.
@AstraBert
AstraBert / sentrev_practical_showcase.ipynb
Created December 5, 2024 02:23
SenTrEv_Practical_Showcase.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nrbnlulu
nrbnlulu / msgspec_vs_pydanticv2.py
Created June 18, 2024 08:43
Msgspec vs Pydantic v2
from datetime import datetime
import json
import re
import timeit
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Annotated, Any, Callable, Iterator, TypedDict
from pydantic.annotated_handlers import GetJsonSchemaHandler
@tsensei
tsensei / semantic-chunker.ts
Created April 5, 2024 14:33
This TypeScript snippet processes a large corpus of text to output semantic chunks by tokenizing into sentences, combining them for context, generating sentence embeddings with OpenAI's service, calculating cosine similarities to identify semantic shifts, and finally grouping sentences into semantically cohesive chunks based on these shifts.
import "dotenv/config";
import { OpenAIEmbeddings } from "@langchain/openai";
import { TextLoader } from "langchain/document_loaders/fs/text";
import natural from "natural";
import * as math from "mathjs";
import { quantile } from "d3-array";
interface SentenceObject {
sentence: string;
index: number;
@densumesh
densumesh / splade.rs
Created December 14, 2023 19:26
Rust Splade Embeddings generation
pub fn get_splade_vector(
input: String,
model: Model,
tokenizer: &Tokenizer,
) -> Result<Vec<f32>, ServiceError> {
let tokenized_inputs = tokenizer.encode(input, false).unwrap();
let tokens = tokenized_inputs.get_ids().to_vec();
let token_ids = Tensor::new(tokens.as_slice(), &candle_core::Device::Cpu)
.map_err(|e| ServiceError::BadRequest(format!("Could not create tensor: {}", e)))?;
@mlabonne
mlabonne / finetune_llama2.py
Last active January 22, 2025 15:02
Easy Llama 2 fine-tuning script (πŸ“ Article: https://tinyurl.com/finetunellama2)
# Based on younesbelkada/finetune_llama_v2.py
# Install the following libraries:
# pip install accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7 scipy
from dataclasses import dataclass, field
from typing import Optional
import torch
from datasets import load_dataset
from transformers import (
@MihailCosmin
MihailCosmin / cuda_11.8_installation_on_Ubuntu_22.04
Last active November 8, 2025 08:46 — forked from primus852/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/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
# 1) Install dependencies: pip install cohere datasets elasticsearch==8.6.2
# 2) Start a local Elasticsearch server: docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:8.6.2
# 3) Get your Cohere API key and past it below
from elasticsearch import Elasticsearch, helpers
import cohere
from datasets import load_dataset
# Get your cohere API key on: www.cohere.com

μŠ€νƒ ν¬λ“œμ•ŒνŒŒμΉ΄ ν•™μŠ΅ν•˜κΈ°

  • runpod.ioμ—μ„œ μ‹€ν–‰
  • Llama-7B μ‚¬μš©
  • llama λͺ¨λΈμ„ workspace λ°– ν™ˆλ””λ ‰μ—μ„œ λ‹€μš΄λ°›κΈ° λ•Œλ¬Έμ— μ»¨ν…Œμ΄λ„ˆ μš©λŸ‰μ„ 15GB 정도 μž‘μ•„μ€˜μ•Ό ν•œλ‹€
  • Volume μš©λŸ‰μ€ 30G μ΄μƒμœΌλ‘œ μž‘μ•„μ€˜μ•Ό ν•œλ‹€ - νŒŒμΈνŠœλ‹ λλ‚˜κ³  output에 μ €μž₯λ˜λŠ” νŒŒμΌλ“€μ΄ 25GB λ‚¨μ§“λ˜λŠ” 크기가 ν•„μš”ν•˜κΈ° λ•Œλ¬Έ
  • ν—ˆκΉ…νŽ˜μ΄μŠ€ λͺ¨λΈμ€ 별도 λ‹€μš΄ 받을 ν•„μš” μ—†κ³ 
  • A100 80G X 4둜 처음 μ‹œμž‘ 1% μ§€μ μ—μ„œ μ˜ˆμƒμ‹œκ°„ 5:37:57 찍힘

Install vi