Spaces:
Runtime error
Runtime error
File size: 1,409 Bytes
0971956 097b095 0971956 097b095 0971956 097b095 0971956 097b095 e0fee24 0971956 097b095 0971956 097b095 0971956 097b095 0971956 097b095 0971956 |
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
from unsloth import FastLanguageModel
import gradio as gr
import torch
# Charger le modèle base + adapter (LoRA)
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "unsloth/Qwen3-14B", # Base model utilisé pendant l'entraînement
adapter_path = "ilyass31/DH-AI-negotiation-assistant", # Ton repo LoRA
max_seq_length = 2048,
load_in_4bit = True,
)
# Fonction de génération de texte
def generate_response(prompt, temperature=0.7, max_new_tokens=512):
inputs = tokenizer(prompt, return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
outputs = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=temperature,
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Interface
demo = gr.Interface(
fn=generate_response,
inputs=[
gr.Textbox(label="Prompt", placeholder="Enter your negotiation scenario..."),
gr.Slider(0.1, 1.5, value=0.7, step=0.1, label="Temperature"),
gr.Slider(32, 2048, value=512, step=32, label="Max New Tokens")
],
outputs=gr.Textbox(label="Response"),
title="🧠 AI Negotiation Assistant",
description="Enter a scenario and get a negotiation strategy or analysis using a fine-tuned Qwen3-14B model."
)
if __name__ == "__main__":
demo.launch()
|