Skip to content

Instantly share code, notes, and snippets.

View iamjanvijay's full-sized avatar

Janvijay Singh iamjanvijay

View GitHub Profile
@iamjanvijay
iamjanvijay / llm_worker.py
Last active July 25, 2023 17:45
Parallelized LLM Calls: Executing GPT and PaLM Requests
import time
from langchain.llms import VertexAI, OpenAI
from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
import threading
from queue import Queue
from threading import Thread, Semaphore, Condition
class LLMWorker:
We can't make this file beautiful and searchable because it's too large.
concepts,fraction_section_concepts,concept_mentions,fraction_section_concept_mentions,words,fraction_section_words,paragraphs,fraction_section_paragraphs,position,subject,num_images
5,12.8205,12,3.6474,75,1.9873,1,1.0989,0.0,M,0
5,12.8205,21,6.383,224,5.9353,2,2.1978,6.6667,M,0
8,20.5128,31,9.4225,240,6.3593,5,5.4945,13.3333,M,3
13,33.3333,46,13.9818,775,20.5352,24,26.3736,20.0,M,1
3,7.6923,5,1.5198,56,1.4838,4,4.3956,26.6667,M,0
7,17.9487,10,3.0395,126,3.3386,3,3.2967,33.3333,M,0
2,5.1282,4,1.2158,153,4.0541,3,3.2967,40.0,M,2
10,25.641,35,10.6383,491,13.0101,6,6.5934,46.6667,M,0
5,12.8205,16,4.8632,232,6.1473,4,4.3956,53.3333,M,1
import smtplib
from email.message import EmailMessage
# set your email and password
# please use App Password
email_address = "janvijay.singh.cse14@gmail.com"
email_password = "xxxxxxxx" # generate the "app password" using the instructions mentioned here: https://support.google.com/accounts/answer/185833
# create email
msg = EmailMessage()
@iamjanvijay
iamjanvijay / run_experiment.py
Last active September 25, 2022 04:19
Script to keep checking if a GPU has enough space; if yes, occupy the GPU as much as possible
# sample command
# python run_experiment.py train --config_args ./train_config/config_1.json
import torch
import numpy as np
3iL École d'ingénieurs | France
A.T. Still University | United States
Aalborg Universitet | Denmark
Aalto-yliopisto | Finland
Aarhus Universitet | Denmark
Aba Teachers University | China
Abasyn University | Pakistan
Abbottabad University of Science and Technology | Pakistan
Abdul Wali Khan University Mardan | Pakistan
Abdullah Gül Üniversitesi | Turkey
# This file is an adapted version of modelling_clip.py taken from transformers==4.21.3
# coding=utf-8
# Copyright 2021 The OpenAI Team Authors and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
// sample launch.json file for python debugging in vscode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "meta-train-samp-1",
@iamjanvijay
iamjanvijay / run_experiment.py
Last active December 29, 2021 15:35
Script to occupy a GPU on server
# sample command
# CUDA_VISIBLE_DEVICES=0; python run_experiment.py train --config_args ./train_config/config_1.json;
import torch
import numpy as np
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"mode",
@iamjanvijay
iamjanvijay / copy_data.py
Created February 4, 2021 07:25
Script to copy data using multiple threads.
import shutil
from concurrent.futures import ThreadPoolExecutor
import os
import sys
from copy import deepcopy
f = open(sys.argv[1])
if not os.path.exists(os.path.dirname(sys.argv[2])):
os.makedirs(os.path.dirname(sys.argv[2]))
@iamjanvijay
iamjanvijay / preprocess.py
Created February 3, 2021 12:17
FinSBD2 - Tokeniser
for f in fnames:
# Read text from json and tokenize
fpath = os.path.join(data_folder, f)
text, sentences, lists, items, items1, items2, items3, items4 = read_json(fpath)
tokenised_text = word_tokenize(text)
# Additional splits to clean the dataset - mannual
add_splits = {"Classe6":["Classe", "6"], "Class.The":["Class", ".", "The"], ".The":[".", "The"], ".Such":[".", "Such"], ".These":[".", "These"]}
temp_tokenised_text = []
for token in tokenised_text: