Skip to content

Instantly share code, notes, and snippets.

View madaan's full-sized avatar

Aman Madaan madaan

View GitHub Profile
@madaan
madaan / safetensors_to_pytorch_ckpt.py
Last active February 19, 2024 06:59
Safetensors to pytorch checkpoint
from safetensors.torch import load_file
from glob import glob
import torch
from tqdm import tqdm
def main(base_path: str):
"""
Convert safetensors files to pytorch checkpoints files.
@madaan
madaan / gemini_api.py
Created January 12, 2024 16:58
MWE for using the Gemini api. The code has been tested with v0.3.2.
# MWE for using the Gemini api. The code has been tested with v0.3.2.
import google.generativeai as genai
import random
import time
assert genai.__version__ == '0.3.2'
genai.configure(api_key="YOUR_KEY_HERE!")
@madaan
madaan / seqlenpatch.diff
Created September 14, 2023 03:16
Patch for VLLM to use seq length of 4096 with LLAMA2
diff --git a/vllm/config.py b/vllm/config.py
index 2e8d584..83395d0 100644
--- a/vllm/config.py
+++ b/vllm/config.py
@@ -134,6 +134,7 @@ class ModelConfig:
max_len_key = getattr(self.hf_config, key, None)
if max_len_key is not None:
max_model_len = min(max_model_len, max_len_key)
+ return 4096
return max_model_len
@madaan
madaan / output.txt
Created April 27, 2023 03:41
MCTS output
Root node: TreeNode(title='Using language models of code for few-shot commonsense', acronym='CODEX', scores={'Ease of pronunciation': 4, 'Ease of spelling': 4, 'Relation to title': 3, 'Positive connotation': 5, 'Well-known': 4, 'Total score': 20}, visits=1, value=0.0, parent_acronym='None' children=None)
Root node after generating initial children: TreeNode(title='Using language models of code for few-shot commonsense', acronym='CODEX', scores={'Ease of pronunciation': 4, 'Ease of spelling': 4, 'Relation to title': 3, 'Positive connotation': 5, 'Well-known': 4, 'Total score': 20}, visits=1, value=0.0, parent_acronym='None' children=COMODEX, COGENT, LMC2C)
Selecting...
Selected node: COGENT for title 'Using language models of code for few-shot commonsense'
Expanding...
Expanded node: LMCFS for title 'Using language models of code for few-shot commonsense'
Simulating...
Simulated value: 0.4
Backpropagating...
Backpropagation complete
@madaan
madaan / fastchat_serve.py
Created April 13, 2023 20:35
An OpenAI like web-api for FastChat
from flask import Flask, request, Response, stream_with_context, jsonify
from fastchat.serve.cli import load_model, generate_stream
import time
import torch
import logging
from datetime import datetime
from logging.handlers import TimedRotatingFileHandler
from transformers import StoppingCriteriaList, MaxLengthCriteria, StoppingCriteria
3 ++ 2
7 END
##
1 ++ 9
19 END
@madaan
madaan / softconf_count.js
Last active September 3, 2022 14:37
A word counter for Softconf (Google Chrome only)
//based on the original checkwords provided by softconf
/*
To use this script:
1. Copy this script (you can select contents of this box + copy. Alternatively, click `Raw` on top-right of this box, then CTRL + A and copy).
2. Go to softconf author response page.
3. Right click anywhere on the page, and click `Inspect`.
@madaan
madaan / md
Last active October 11, 2019 15:10
plts_xfrmed
## ORIGINALLY_NON_POLITE (indexed_politeness.test.scores.0)
records:2021
sum:755.778771780001
avg:0.373962776734291
std:0.141803229134052
med:0.36097676
max:0.96558416
min:0.06964769
@madaan
madaan / Best Defaults
Last active October 8, 2019 14:05
HypE Train Log
Training the HypE model...
Number of training data points: 61911
Starting training...
iteration#: 1, loss: 1128.5969721078873
iteration#: 2, loss: 589.3206909894943
iteration#: 3, loss: 352.0712777376175
iteration#: 4, loss: 246.19432146847248
iteration#: 5, loss: 202.48553057014942
iteration#: 6, loss: 165.68770626187325
iteration#: 7, loss: 145.24890618771315
@madaan
madaan / Ref
Created September 18, 2019 05:17
CompareMT Sentence Level BLEU Comparison Issue
and it can be a very complicated thing , what human health is .
and bringing those two together might seem a very daunting task , but what i 'm going to try to say is that even in that complexity , there 's some simple themes that i think , if we understand , we can really move forward .
and those simple themes aren 't really themes about the complex science of what 's going on , but things that we all pretty well know .
and i 'm going to start with this one : if momma ain 't happy , ain 't nobody happy .
we know that , right ? we 've experienced that .
and if we just take that and we build from there , then we can go to the next step , which is that if the ocean ain 't happy , ain 't nobody happy .