Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.py #17

Open
ghost opened this issue Dec 5, 2021 · 0 comments
Open

app.py #17

ghost opened this issue Dec 5, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 5, 2021

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", )
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants