Spaces:
Runtime error
Runtime error
File size: 895 Bytes
2e31dfc d41889b 8b79802 c854b77 8b79802 c854b77 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 25 |
from ctransformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig, get_peft_model
import torch
# Load the tokenizer and model
model = AutoModelForCausalLM.from_pretrained("youssef227/llama-3-8b-Instruct-bnb-telcom-3",hf=True)
print("step 1 ")
tokenizer = AutoTokenizer.from_pretrained(model)
print("step 2 ")
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) |