Skip to content

Instantly share code, notes, and snippets.

View aniketmaurya's full-sized avatar
🔨
Building Intelligent Software with ML

Aniket Maurya aniketmaurya

🔨
Building Intelligent Software with ML
View GitHub Profile
from typing import Generator
from threading import Thread
import torch
from litserve.api import LitAPI
from litserve import LitServer
from pydantic import BaseModel
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
@aniketmaurya
aniketmaurya / gemma_streamlit.py
Created February 23, 2024 01:21
Gemma streamlit app
# Adapted from https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps#build-a-simple-chatbot-gui-with-streaming
import streamlit as st
import gemma
model = "Gemma"
def chat(prompt, model=model, context=None, **kwargs):
"""streaming client with ollama"""
@aniketmaurya
aniketmaurya / gemma_hf.py
Created February 23, 2024 01:20
Gogole gemma inference
import os
model = "google/gemma-7b-it"
os.environ["HF_HOME"] = "/teamspace/studios/this_studio/weights"
os.environ["TRANSFORMERS_OFFLINE"] = "1"
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
MODEL=TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T
# Install
git clone https://github.com/Lightning-AI/lit-gpt.git
cd lit-gpt
pip install -r requirements-all.txt
# Download weights
python scripts/download.py --repo_id $MODEL
@aniketmaurya
aniketmaurya / generate_fake_images.py
Last active October 26, 2023 20:11
Fake image generation
import os
import argparse
import numpy as np
from PIL import Image
from functools import lru_cache
@lru_cache(maxsize=None) # Cache all generated images
def generate_random_image(width, height):
# Create a random RGB image
image_data = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
We can't make this file beautiful and searchable because it's too large.
instruction,category,input,output
When did Virgin Australia start operating?,closed_qa,"Virgin Australia, the trading name of Virgin Australia Airlines Pty Ltd, is an Australian-based airline. It is the largest airline by fleet size to use the Virgin brand. It commenced services on 31 August 2000 as Virgin Blue, with two aircraft on a single route. It suddenly found itself as a major airline in Australia's domestic market after the collapse of Ansett Australia in September 2001. The airline has since grown to directly serve 32 cities in Australia, from hubs in Brisbane, Melbourne and Sydney.","Virgin Australia commenced services on 31 August 2000 as Virgin Blue, with two aircraft on a single route."
Which is a species of fish? Tope or Rope,classification,,Tope
Why can camels survive for long without water?,open_qa,,Camels use the fat in their humps to keep them filled with energy and hydration for long periods of time.
"Alice's parents have three daughters: Amy, Jessy, and what’s the name of the third daughte
@aniketmaurya
aniketmaurya / lit-gpt-llama2.ipynb
Created July 24, 2023 11:30
lit-gpt-llama2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aniketmaurya
aniketmaurya / instruct-tune-lit-llama.ipynb
Last active July 10, 2023 19:14
instruct-tune-lit-llama.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aniketmaurya
aniketmaurya / falcon-lightning.ipynb
Last active July 23, 2023 07:58
falcon-lightning.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.