Skip to content

Instantly share code, notes, and snippets.

View ShawonAshraf's full-sized avatar

Shawon Ashraf ShawonAshraf

View GitHub Profile
@ShawonAshraf
ShawonAshraf / main.py
Created April 12, 2024 15:18
Ollama + Distilabel
import os
import shutil
if os.path.exists(".cache/distilabel"):
shutil.rmtree(".cache/distilabel")
from distilabel.steps.tasks import TextGeneration
from distilabel.steps import LoadHubDataset
from distilabel.pipeline.local import Pipeline
@ShawonAshraf
ShawonAshraf / main.py
Created April 11, 2024 20:11
vllm request
import openai
from pydantic import BaseModel, Field
import json
class ResponseStructure(BaseModel):
bookname: str = Field(..., title="Book Name")
author: str = Field(..., title="Author")
reading_list_name: str = Field(..., title="Reading List Name")
@ShawonAshraf
ShawonAshraf / phase.c
Created October 11, 2023 22:00
STM32 Phase Change
#include "stm32f4xx.h"
#include "stm32f4xx_hal.h"
ADC_HandleTypeDef hadc1;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
int main(void) {
# Import the required libraries
from collections import defaultdict
# Define the Chu-Liu/Edmonds algorithm function
def chu_liu_edmonds(graph):
# Step 1: Contract the graph to a single node
contracted_node = max(graph.keys()) + 1
contracted_graph = defaultdict(list)
for node in graph:
for (weight, child) in graph[node]:
import pynvml
pynvml.nvmlInit()
device_count = pynvml.nvmlDeviceGetCount()
for i in range(device_count):
try:
handle = pynvml.nvmlDeviceGetHandleByIndex(i)
util = pynvml.nvmlDeviceGetUtilizationRates(handle)
import torch.nn as nn
from einops.layers.torch import Rearrange
from transformers import AutoModel
class DummyModel(nn.Module):
def __init__(self, textmodel_weight_name, task_name, batch_size, freeze_text_model=False):
super(DummyModel, self).__init__()
self.task_name = task_name
@ShawonAshraf
ShawonAshraf / gpupowerlimiter.service
Created August 8, 2022 21:33
Nvidia GPU power limit Linux
# /lib/systemd/system/gpupowerlimiter.service
[Unit]
Description="Limit Nvidia GPU power at each reboot using nvidia-smi"
[Service]
User=root
Group=root
ExecStartPre=/usr/bin/nvidia-smi -i 0 -pm ENABLED
ExecStart=/usr/bin/nvidia-smi -pl 280
@ShawonAshraf
ShawonAshraf / .zshrc
Last active August 8, 2022 21:34
My ZSH Config
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$PATH:/home/shawon/.local/bin"
# openbangla settings for kde
# Ibus KDE
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
@ShawonAshraf
ShawonAshraf / marc.sh
Last active May 30, 2022 13:03
Marc!
#!/usr/bin/bash
function echo_green {
echo -e "\\e[32m$*\\e[0m"
}
function echo_orange {
echo -e "\\e[33m$*\\e[0m"
}
absl-py==1.0.0
aiohttp==3.8.1
aiosignal==1.2.0
analytics-python==1.4.0
anyio==3.5.0
asgiref==3.5.0
async-timeout==4.0.2
attrs==21.4.0
autopep8==1.6.0
backoff==1.10.0