Spaces:
Runtime error
Runtime error
File size: 791 Bytes
7b09d7a 342478c 7b09d7a 342478c 2fb4300 7b09d7a 2fb4300 7b09d7a 2fb4300 7b09d7a 9a57f18 |
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 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
# بارگذاری مدل فشردهشده Falcon-7B-Instruct-GPTQ
model_name = "4bit/falcon-7b-instruct-GPTQ"
# بارگذاری توکنایزر و مدل
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
# ایجاد pipeline برای متنسازی
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def respond(
message,
history: list[tuple[str, str]],
system_message,
max_tokens,
temperature,
top_p,
):
# ساخت پیامها برای مدل
messages = [{"role": "system", "content": system_message}]
# اضافه |