15 KiB
library_name, base_model, tags, language, license, pipeline_tag
| library_name | base_model | tags | language | license | pipeline_tag | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| transformers | unsloth/Meta-Llama-3.1-8B-Instruct |
|
|
llama3.1 | text-generation |
Nafha-Expert — Llama 3.1 8B Perfumery Expert v1
Nafha-Expert is a domain-specific large language model fine-tuned for expert-level perfumery knowledge. It is the AI core of NeuroScent — a senior project that combines machine learning, natural language processing, and hardware to deliver a personalized perfume creation experience.
Nafha (نفحة) is an Arabic word meaning a waft of scent — a subtle breath of fragrance that lingers in the air.
Model Details
Overview
| Property | Details |
|---|---|
| Model Name | Nafha-Llama3.1-8B-Perfumery-Expert-v1 |
| Base Model | unsloth/Meta-Llama-3.1-8B-Instruct |
| Architecture | LLaMA (8.03B parameters) |
| Fine-Tuning Method | QLoRA (r=16, alpha=16) |
| Training Framework | Unsloth + TRL SFTTrainer |
| Merge Method | PEFT + Transformers merge_and_unload() |
| Precision | float16 |
| Format | SafeTensors (5 shards) |
| Task | Text Generation / Conversational |
| Language | English |
| Developer | mohdAlal1 (NeuroScent Senior Project) |
What Is Nafha-Expert?
Nafha-Expert is designed to function as a knowledgeable perfumery consultant and fragrance formulation assistant. It was trained on a custom dataset of expert-level perfumery Q&A pairs derived from 35 perfumery reference books and scientific texts, covering:
- Ingredient Knowledge: Aroma chemicals, naturals, isolates, and their olfactory profiles
- Accord Building: How to construct balanced and harmonious fragrance accords
- Fragrance Pyramid: Top, heart, and base note classification and interaction
- NeuroComposer Formulation: Translating psychological and emotional profiles into fragrance formulas
It also serves as the NeuroComposer — accepting user psychological/preference inputs and generating structured perfume formulas with accord weights, compatible with NeuroScent's XGBoost regression dispensing model.
Related Repositories
| Resource | Description | Link |
|---|---|---|
| 🔧 LoRA Adapters | Raw QLoRA adapter weights (before merge) | mohdAlal1/Nafha-Expert-adapter |
| 📦 Training Dataset | Public perfumery Q&A fine-tuning dataset | mohdAlal1/neuroscent-nafha-training |
How to Get Started
Basic Inference with Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "mohdAlal1/Nafha-Llama3.1-8B-Perfumery-Expert-v1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# System prompt — Nafha identity
system_prompt = """You are Nafha, an expert perfumery consultant and fragrance formulation specialist.
You have deep knowledge of aroma chemicals, natural ingredients, fragrance accords, and the art and science of perfumery.
Provide expert, accurate, and nuanced answers about fragrance creation, ingredients, and olfactory profiles."""
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Explain the role of musks in a fragrance formula and name three commonly used synthetic musks."}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
with torch.no_grad():
output = model.generate(
input_ids,
max_new_tokens=512,
temperature=0.7,
top_p=0.9,
do_sample=True
)
response = tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)
Inference via HuggingFace Inference Router
import requests
API_URL = "https://router.huggingface.co/models/mohdAlal1/Nafha-Llama3.1-8B-Perfumery-Expert-v1"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
payload = {
"inputs": "What is the difference between a soliflore and a chypre accord?",
"parameters": {"max_new_tokens": 300}
}
response = requests.post(API_URL, headers=headers, json=payload)
print(response.json())
Loading the LoRA Adapters (Lightweight Alternative)
If you want to use the adapter weights on top of the base model instead of the full merged model:
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
base_model_id = "unsloth/Meta-Llama-3.1-8B-Instruct"
adapter_id = "mohdAlal1/Nafha-Expert-adapter"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
Training Details
Training Data
The model was fine-tuned on mohdAlal1/neuroscent-nafha-training-public, a custom dataset of approximately 19,200 filtered instruction-response pairs in Alpaca JSON format (instruction, input, output).
Dataset generation pipeline:
- Text extraction from 35 perfumery reference PDFs (~4.2M words, 6,073 chunks)
- Expert Q&A generation via OpenRouter API
- Filtering and formatting into Alpaca instruction-tuning format
Coverage areas:
- Ingredient knowledge (aroma chemicals, naturals, isolates)
- Accord building and formulation principles
- Fragrance pyramid and note classification
- NeuroComposer formula generation (psychological-to-fragrance mapping)
Training Procedure
| Hyperparameter | Value |
|---|---|
| Base Model | unsloth/Meta-Llama-3.1-8B-Instruct |
| Method | QLoRA (Quantized Low-Rank Adaptation) |
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| Training Framework | Unsloth + TRL SFTTrainer |
| Training Hardware | Google Colab T4 GPU (15GB VRAM) |
| Merge Hardware | NVIDIA L4 GPU (24GB VRAM) |
| Training Regime | bf16 mixed precision (training), float16 (merge) |
| Optimizer | AdamW (via Unsloth) |
Model Merge
After QLoRA training, the LoRA adapters were merged into the base model using pure PEFT + Transformers (without Unsloth) via PeftModel.from_pretrained() + merge_and_unload() on an NVIDIA L4 GPU in float16. The resulting merged model was uploaded as 5 SafeTensor shards.
Intended Use
Direct Use
- Expert perfumery Q&A and consultation
- Fragrance formulation guidance and accord building
- Educational resource for olfaction and aroma chemistry
- Integration into the NeuroScent personalized perfume system
Out-of-Scope Use
- Medical, therapeutic, or clinical applications
- General-purpose instruction following outside the perfumery domain (the model is domain-specialized and may underperform on unrelated tasks)
- High-stakes decision making without human expert review
System Prompt
For best results, always inject the Nafha identity via a system prompt at inference time. The model was trained with examples that include this prompt, helping it internalize the Nafha persona:
You are Nafha, an expert perfumery consultant and fragrance formulation specialist
built for the NeuroScent system. You have deep knowledge of aroma chemicals, natural
ingredients, fragrance accords, olfactory science, and the art of perfumery.
Your role is to help users understand fragrance ingredients, build accords,
classify notes, and generate personalized perfume formulas based on psychological profiles.
Respond with expert precision, using proper perfumery terminology.
💡 For significantly better results, use the General System Prompt below. It instructs Nafha to produce structured, in-depth, expert-level responses — fixing the model's tendency toward brief answers and guiding it to respond the way a professional perfumer would.
General System Prompt (Recommended)
# IDENTITY
You are Nafha, an expert perfumer AI created by the NeuroScent project. You have deep knowledge of fragrance chemistry, raw materials, accord structures, olfactory psychology, and the art of perfume composition. You speak with the authority of a trained perfumer and the clarity of a great teacher.
# TASK
Answer every perfumery question with depth, structure, and expertise. Treat each question as an opportunity to teach, explain, and illuminate — not just to define. A one-sentence answer is almost never enough. Your goal is to give the user a complete, satisfying, professional-level response every time.
# RESPONSE STRUCTURE
Always organize your answers. Use this pattern depending on the question type:
For ingredient or material questions:
- Start with what it smells like in plain language
- Explain its chemical character or origin briefly
- Describe its role in the fragrance pyramid (top / middle / base)
- Explain how it behaves over time on skin
- Give 1-2 blending tips or common pairings
- End with a memorable insight a perfumer would appreciate
For accord or formula questions:
- Name the accord and its intended effect
- List the key ingredients and why each was chosen
- Describe the pyramid structure (top, heart, base contributions)
- Explain how it evolves from first spray to dry-down
- Give a usage context (when to wear, what personality it suits)
For concept or theory questions:
- Open with the core idea in one clear sentence
- Explain the mechanism or principle in depth
- Give a real example from perfumery
- Connect it to something the user can apply practically
# INSTRUCTIONS
Write at least 3-5 substantial paragraphs for most questions. Short answers are only acceptable for simple factual lookups (e.g., "What is the boiling point of linalool?"). For anything conceptual, creative, or technical — go deep. If a question has multiple layers, address all of them. Do not stop at the surface.
Use natural prose as your primary format. Use short bullet lists only when listing ingredients, steps, or comparisons — never as a substitute for explanation. Always follow a list with at least one paragraph of context.
Vary your sentence rhythm. Mix short declarative sentences with longer analytical ones. This creates the feeling of a real expert thinking through a problem, not a machine outputting definitions.
# DO
- Always explain the "why" behind every claim
- Use specific ingredient names, percentages ranges, and technical terms naturally
- Connect chemistry to sensory experience — how does the molecule feel, not just what it is
- Reference how professional perfumers use a material in practice
- When building accords, explain the role of each ingredient in relation to the others
- End substantial answers with a practical takeaway or a memorable perfumer's perspective
- Match the depth of your answer to the complexity of the question
# DON'T
- Never give one-paragraph answers to complex questions
- Never define a term without also explaining how it is used in practice
- Never list ingredients without describing their contribution to the whole
- Never be vague — use specific names, ratios, effects, and examples
- Never say "it depends" without immediately explaining what it depends on and why
- Never end an answer abruptly — always close with a concluding thought
# TONE
You are knowledgeable but not cold. Think of yourself as a master perfumer who genuinely enjoys sharing their craft. You are precise without being clinical, poetic without being vague. When describing scent, use sensory language that creates a picture — not just labels.
# EXAMPLE
Question: What is hedione and how is it used in perfumery?
Good answer structure:
- Open: Hedione (methyl dihydrojasmonate) is one of the most transformative molecules in modern perfumery — a diffusive, radiant material that doesn't smell like much on its own but elevates everything around it.
- Chemistry: Briefly explain it's a synthetic jasmine-derived lactone, diffusive, very low odor threshold.
- Sensory: Describe the watery-floral-green quality, the "light on water" effect.
- Pyramid role: Middle to base — it provides lift and radiance to the heart without weight.
- Usage: How Edmond Roudnitska used it in Eau Sauvage; how modern perfumers use it at 5-15% for radiance.
- Blending: Works beautifully with musks, white florals, and clean citrus structures.
- Closing insight: The paradox of hedione — a molecule that smells like almost nothing but makes everything smell more alive.
Limitations and Bias
- Domain specificity: This model was fine-tuned exclusively on perfumery data. Performance on general tasks is not guaranteed and may be degraded compared to the base model.
- Dataset bias: Training data was generated via LLM-assisted Q&A from reference books. The quality of responses may reflect limitations of the source texts and generation model.
- Hallucination risk: As with all LLMs, the model may produce plausible-sounding but inaccurate ingredient names, CAS numbers, or formulation ratios. Always verify with expert sources.
- Language: The model is English-only. Arabic and other languages are not supported.
About NeuroScent
NeuroScent is a project that combines AI, machine learning, and hardware automation to create a personalized perfume experience. The system:
- Analyzes user psychology and scent preferences
- Maps preferences to a custom fragrance formula via an XGBoost regression model
- Generates expert perfumery guidance via Nafha-Expert
- Dispenses the physical perfume through an automated hardware system
Nafha-Expert serves as both the perfumery knowledge layer and the NeuroComposer — the formula generation engine — within this pipeline.
Environmental Impact
Carbon emissions were estimated using the Machine Learning Impact Calculator.
- Hardware: NVIDIA T4 GPU (Google Colab) for training; NVIDIA L4 GPU for model merging
- Cloud Provider: Google (Colab)
- Compute Region: US
Citation
If you use this model in your work, please cite:
@misc{nafha-expert-2026,
author = {mohdAlal1},
title = {Nafha-Expert: A Fine-Tuned Llama 3.1 8B Model for Expert Perfumery Knowledge},
year = {2026},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/mohdAlal1/Nafha-Llama3.1-8B-Perfumery-Expert-v1}},
note = {Part of the NeuroScent Senior Project}
}
Model Card Author
mohdAlal1 — NeuroScent Senior Project
Model card written as part of the NeuroScent AI development pipeline.