| # Llama 3 Domain Name Generator (LoRA fine-tuned) | |
| Ce modèle est une version fine-tunée de [NousResearch/Meta-Llama-3-8B](https://huggingface.co/NousResearch/Meta-Llama-3-8B) pour la génération de noms de domaine disponibles pour des entreprises. | |
| --- | |
| ## 🚀 **Utilisation rapide** | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig | |
| from peft import PeftModel | |
| import torch | |
| # Identifiants du modèle | |
| peft_model_id = "Thehunter99/LLama3" | |
| base_model_id = "NousResearch/Meta-Llama-3-8B" | |
| # Device | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| # Tokenizer | |
| tokenizer = AutoTokenizer.from_pretrained(base_model_id) | |
| tokenizer.pad_token = tokenizer.eos_token | |
| # Config QLoRA (optionnel) | |
| bnb_config = BitsAndBytesConfig( | |
| load_in_4bit=True, | |
| bnb_4bit_quant_type="nf4", | |
| bnb_4bit_compute_dtype=torch.bfloat16 if device == "cuda" else torch.float32, | |
| bnb_4bit_use_double_quant=True, | |
| ) | |
| # Charger le modèle de base | |
| base_model = AutoModelForCausalLM.from_pretrained( | |
| base_model_id, | |
| quantization_config=bnb_config if device == "cuda" else None, | |
| device_map="auto" if device == "cuda" else None, | |
| torch_dtype=torch.bfloat16 if device == "cuda" else torch.float32 | |
| ) | |
| # Charger l'adapter LoRA | |
| model = PeftModel.from_pretrained(base_model, peft_model_id) | |
| model.eval() | |
| if device == "cpu": | |
| model = model.to("cpu") | |
| # Fonction d'inférence | |
| def generate_domains(prompt, max_new_tokens=50, temperature=0.7): | |
| inputs = tokenizer(prompt, return_tensors="pt").to(device) | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=max_new_tokens, | |
| do_sample=True, | |
| temperature=temperature | |
| ) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Exemple de prompt (à respecter strictement) | |
| prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|> | |
| Generate available domain names for businesses. Use only .com, .io, .app, .co TLDs. | |
| Output format: comma-separated domains<|eot_id|> | |
| <|start_header_id|>user<|end_header_id|> | |
| organic bakery in berlin<|eot_id|> | |
| <|start_header_id|>assistant<|end_header_id|>""" | |
| result = generate_domains(prompt, max_new_tokens=30, temperature=0.1) | |
| print(result) | |
| ``` | |
| --- | |
| ## 📝 **Format du prompt d’inférence** | |
| **Respectez exactement ce format :** | |
| ``` | |
| <|begin_of_text|><|start_header_id|>system<|end_header_id|> | |
| Generate available domain names for businesses. Use only .com, .io, .app, .co TLDs. | |
| Output format: comma-separated domains<|eot_id|> | |
| <|start_header_id|>user<|end_header_id|> | |
| [description de l'entreprise]<|eot_id|> | |
| <|start_header_id|>assistant<|end_header_id|> | |
| ``` | |
| **Exemple :** | |
| ``` | |
| <|begin_of_text|><|start_header_id|>system<|end_header_id|> | |
| Generate available domain names for businesses. Use only .com, .io, .app, .co TLDs. | |
| Output format: comma-separated domains<|eot_id|> | |
| <|start_header_id|>user<|end_header_id|> | |
| eco-friendly coffee shop in Paris<|eot_id|> | |
| <|start_header_id|>assistant<|end_header_id|> | |
| ``` | |
| --- | |
| ## 📋 **Conseils** | |
| - Utilisez le même prompt que ci-dessus pour de meilleurs résultats. | |
| - Le modèle retourne une liste de domaines séparés par des virgules. | |
| - Pour des résultats reproductibles, utilisez `temperature=0.1`. | |
| --- | |
| ## 📚 **Dataset d’entraînement** | |
| Le modèle a été fine-tuné sur un dataset synthétique de descriptions d’entreprises et de suggestions de domaines. | |
| --- | |
| ## ❓ **Questions** | |
| Pour toute question ou suggestion, ouvrez une issue sur le repo ou contactez-moi via mon e-mail: achrflassoued17@gmail.com. | |
| --- |