Spaces:
Sleeping
Sleeping
File size: 815 Bytes
4091234 bb80c5e 4091234 467532a 4091234 467532a 4091234 fc2d002 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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"])
|