Spaces:
Build error
Build error
Update app.py
Browse files1234563 unmodified lines1011121213141516171819192021222313 unmodified lines373839404142434443454647485 unmodified lines5455565758596066 unmodified lines127128129127130131132133import osimport timeimport spacesimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizerimport gradio as gr3 unmodified linesMODEL_ID = os.environ.get("MODEL_ID", None)MODEL_NAME = MODEL_ID.split("/")[-1]
TITLE = "<h1><center>MiniCPM-1B-chat</center></h1>"TITLE = "<h1><center>MiniCPM-S-1B-chat</center></h1>"
DESCRIPTION = f"""<h3>MODEL NOW: <a href="https://hf.co/{MODEL_ID}">{MODEL_NAME}</a></h3>"""PLACEHOLDER = """<center><p>MiniCPM is an End-Size LLM developed by ModelBest Inc. and TsinghuaNLP, with only 1.2B parameters excluding embeddings.</p><p>MiniCPM is an End-Size LLM with only 1.2B parameters excluding embeddings.</p></center>"""
13 unmodified linesmodel = AutoModelForCausalLM.from_pretrained( MODEL_ID, torch_dtype=torch.bfloat16, device_map='auto', low_cpu_mem_usage=True, trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16)
@spaces.GPU()def stream_chat( message: str, history: list, 5 unmodified lines): print(f'message: {message}') print(f'history: {history}') torch.manual_seed(0) resp, history = model.chat( tokenizer, query = message,66 unmodified lines ["Tell me a random fun fact about the Roman Empire."], ["Show me a code snippet of a website's sticky header in CSS and JavaScript."], ], cache_examples="lazy", cache_examples=False, )
app.py+7-4