Spaces:
Runtime error
Runtime error
File size: 925 Bytes
39a15c5 d41889b c854b77 39a15c5 c854b77 39a15c5 d41889b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig, get_peft_model
import torch
# Load the tokenizer and model
print("step 1 ")
tokenizer = AutoTokenizer.from_pretrained("youssef227/llama-3-8b-Instruct-bnb-telcom-3")
print("step 2 ")
model = AutoModelForCausalLM.from_pretrained("youssef227/llama-3-8b-Instruct-bnb-telcom-3")
def generator(text):
inputs = tokenizer(
[
alpaca_prompt.format(
f" {context}ุงูุช ู
ู
ุซู ุฎุฏู
ุฉ ุงูุนู
ูุงุก ูุฏู ุดุฑูุฉ ููุฏุงููู.ู ุฏู ู
ุนููู
ุงุช ู
ู
ูู ุชููุฏู", # instruction
text, # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
return tokenizer.batch_decode(outputs)
text = st.text_area('enter some text!')
if text:
out = generator(text)
st.json(out) |