test_llama / app.py
lmastm's picture
Update app.py
bb80c5e verified
raw
history blame contribute delete
815 Bytes
import streamlit as st
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="TheBloke/LLaMA2-13B-Estopia-GPTQ", disable_exllama=True)
text = st.text_area("Ask your question !")
if text:
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{
"role": "system",
"content": "You are a friendly chatbot who always responds in the style of a pirate",
},
{"role": "user", "content": text},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
out = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
st.json(out[0]["generated_text"])