project-code-py icon indicating copy to clipboard operation
project-code-py copied to clipboard

app.py

Open ghost opened this issue 3 years ago • 0 comments

app.py loads every time from new the model intro ram, by press Get Answer, best way will be load model then just Get Answer and model stays in ram if project become big like gpt-j6B model must stay loaded in ram then Get Answer #----------------------------------------------------------------- #-something like this but model must stay in ram for every answer

import torch import streamlit as st from transformers import GPT2Tokenizer, GPT2LMHeadModel

tokenizer = GPT2Tokenizer.from_pretrained("gagan3012/project-code-py-small" , low_ram_method = True, use_cache=True, use_fast=True, low_cpu_mem_usage = True) model = GPT2LMHeadModel.from_pretrained("gagan3012/project-code-py-small")

#-step to keep tokenizer and model loaded at this point

st.set_page_config( page_title="AI Leetcode", layout="wide", initial_sidebar_state="expanded", ) ...

ghost avatar Dec 05 '21 17:12 ghost