devalender's picture
Ajout du modèle de captioning PaliGemma 2
2e60f04
Raw
History Blame Contribute Delete
1.09 kB
import gradio as gr
from huggingface_hub import hf_hub_download
from ctransformers import AutoModelForCausalLM
# French-Alpaca - modéle français confirmé
MODEL_REPO = "jpacifico/french-alpaca-instruct-Q4-GGUF"
MODEL_FILE = "french-alpaca-instruct-Q4.gguf"
print("📥 Téléchargement du modèle français...")
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
print("⚙️ Chargement...")
llm = AutoModelForCausalLM.from_pretrained(
model_path,
model_type="mistral", # French-Alpaca est basé sur Mistral
threads=2,
context_length=2048,
max_new_tokens=256
)
print("✅ Modèle français chargé !")
def respond(message, history):
# Format du prompt adapté
prompt = f"### Instruction:\n{message}\n\n### Response:\n"
response = llm(prompt, temperature=0.7, max_new_tokens=256)
return response.strip()
demo = gr.ChatInterface(
fn=respond,
title="🤖 Assistant Français (French-Alpaca)",
description="Modèle entraîné spécifiquement pour le français"
)
demo.launch(server_name="0.0.0.0", server_port=7860)