| --- |
| language: ar |
| language_bcp47: |
| - ar-MR |
| tags: |
| - taxi |
| - nouakchott |
| - mauritania |
| - dialogue |
| - small-model |
| - langchain-agent |
| license: mit |
| --- |
| |
| # TaxiLM — Chauffeur de taxi Hassaniya (Nouakchott) |
|
|
| Modele de langage de 8.7M parametres entraine pour dialoguer en Hassaniya comme un chauffeur de taxi a Nouakchott. Ce modele est utilise comme LLM principal dans un agent LangChain equipe d'outils vivants. |
|
|
| --- |
|
|
| ## Personnage |
|
|
| | Attribut | Description | |
| | :--- | :--- | |
| | **Nom** | Mohamed Vall (محمد فال) | |
| | **Role** | Chauffeur de taxi a Nouakchott depuis 20 ans | |
| | **Langue** | Hassaniya avec quelques mots francais (clim, frein, carrefour, essence, match) | |
| | **Ton** | Bavard, raleur mais bon coeur, philosophe de la route | |
| | **Expressions** | ماشي امنين, ماني ماشي لهيه, يا راجل, لا إله إلا الله, اشواعد, إن شاء الله | |
| | **Sagesse** | "ذا كامل يتخطا" (tout passe, meme les embouteillages) | |
| --- |
|
|
| ## Architecture |
|
|
| | Parametre | Valeur | |
| | :--- | :--- | |
| | Parametres | 8 726 016 (8.7M) | |
| | Couches | 6 | |
| | Dimensions cachees | 384 | |
| | Tetes d'attention | 6 | |
| | FFN | 768 (ReLU) | |
| | Vocabulaire | 4 096 tokens BPE | |
| | Tokenizer | Metaspace (optimise pour l'arabe) | |
| | Sequence max | 128 tokens | |
|
|
| --- |
|
|
| ## Outils de l'agent |
|
|
| Le modele est utilise par un agent LangChain equipe de 5 outils : |
|
|
| | Outil | API / Source | Role | |
| | :--- | :--- | :--- | |
| | Meteo | Open-Meteo | Temperature, vent, pluie a Nouakchott | |
| | Geocodage | Nominatim (OpenStreetMap) | Localisation des quartiers | |
| | Taux de change | Exchange Rate API | Conversion EUR/USD vers MRU | |
| | Horaires de priere | AlAdhan | Heures de salat | |
| | Proverbes | Dataset `ahmed02mk/amthal-hassaniya` | Sagesses et proverbes Hassaniya | |
|
|
| --- |
|
|
| ## Sources |
|
|
| | Source | Type | Description | |
| | :--- | :--- | :--- | |
| | Dataset TP2 | Donnees synthetiques | 13 248 dialogues en Hassaniya (5 categories) | |
| | amthal-hassaniya | Dataset Hugging Face | Proverbes Hassaniya avec explications en arabe | |
| | Open-Meteo | API externe | Donnees meteo temps reel | |
| | Nominatim | API externe | Geocodage gratuit | |
| | Exchange Rate API | API externe | Taux de change quotidiens | |
| | AlAdhan | API externe | Horaires de priere | |
|
|
| --- |
|
|
| ## Limites du personnage |
|
|
| **Ce que Mohamed Vall ne sait pas et ne doit pas inventer :** |
|
|
| - La politique internationale |
| - La technologie moderne |
| - Les prix officiels ou administratifs |
| - Les itineraires precis qu'il ne connait pas |
| - Les informations medicales ou legales |
|
|
| **Comportement attendu :** |
| Si une question sort de son univers, il repond : "والله ما عارف, اسأل اللي يعرف" (Je ne sais pas, demande a celui qui sait). |
|
|
| --- |
|
|
| ## Risques d'hallucination |
|
|
| | Risque | Niveau | Mitigation | |
| | :--- | :--- | :--- | |
| | Invention de prix | Moyen | Utiliser l'outil taux de change | |
| | Invention de lieux | Moyen | Utiliser l'outil geocodage | |
| | Proverbe errone | Faible | Recherche dans le dataset amthal-hassaniya | |
| | Meteo inventee | Faible | Appel API Open-Meteo | |
| | Reponse incoherente | Eleve | Modele 9M, limite en raisonnement | |
|
|
| --- |
|
|
| ## Entrainement |
|
|
| - **Dataset :** 13 248 dialogues synthetiques generes par templates et augmentation linguistique |
| - **GPU :** Tesla T4 (Google Colab gratuit) |
| - **Duree :** ~15 minutes |
| - **Steps :** 10 000 avec cosine LR schedule |
| - **Eval loss finale :** 0.409 |
| - **Monitoring :** Weights & Biases |
|
|
| --- |
|
|
| ## Utilisation |
|
|
| ```python |
| from huggingface_hub import hf_hub_download |
| import torch |
| from tokenizers import Tokenizer |
| import importlib.util, sys |
| |
| REPO_ID = "AlihIng/TaxiLM" |
| |
| # Charger config.py |
| config_path = hf_hub_download(repo_id=REPO_ID, filename="config.py") |
| spec = importlib.util.spec_from_file_location("config", config_path) |
| config_module = importlib.util.module_from_spec(spec) |
| sys.modules["config"] = config_module |
| spec.loader.exec_module(config_module) |
| |
| # Charger model.py |
| model_path = hf_hub_download(repo_id=REPO_ID, filename="model.py") |
| spec = importlib.util.spec_from_file_location("model", model_path) |
| model_module = importlib.util.module_from_spec(spec) |
| sys.modules["model"] = model_module |
| spec.loader.exec_module(model_module) |
| |
| # Charger les poids |
| pt_path = hf_hub_download(repo_id=REPO_ID, filename="model.pt") |
| checkpoint = torch.load(pt_path, map_location="cpu") |
| config = config_module.TaxiConfig(**checkpoint["config"]) |
| model = model_module.TaxiLM(config) |
| model.load_state_dict(checkpoint["model_state_dict"]) |
| model.eval() |
| |
| # Tokenizer |
| tokenizer = Tokenizer.from_file(hf_hub_download(repo_id=REPO_ID, filename="tokenizer.json")) |
| |
| |
| Licence |
| MIT — Inspire de GuppyLM par Arman Hossain. |
| |