File size: 3,593 Bytes
6bef760
e3811fb
6bef760
e3811fb
6bef760
e3811fb
6bef760
e3811fb
 
6bef760
 
 
 
 
 
 
 
 
 
 
 
 
 
e3811fb
6bef760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3811fb
 
6bef760
e3811fb
6bef760
e3811fb
6bef760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3811fb
6bef760
e3811fb
6bef760
e3811fb
6bef760
 
 
e3811fb
6bef760
 
 
 
 
 
 
e3811fb
6bef760
e3811fb
8d8f72b
e3811fb
6bef760
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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.

---