Applications
Applications
Outils, frameworks et mise en pratique de l'IA
Passer de la théorie à la pratique nécessite de maîtriser les bons outils. Cette section couvre les frameworks, APIs et bonnes pratiques pour construire des applications IA.
Écosystème IA
┌─────────────────────────────────────────────────────────────┐
│ STACK IA MODERNE │
├─────────────────────────────────────────────────────────────┤
│ │
│ APPLICATIONS │
│ ├── Chatbots, Assistants │
│ ├── Analyse de documents │
│ ├── Génération de contenu │
│ └── Automatisation │
│ │
│ FRAMEWORKS D'ORCHESTRATION │
│ ├── LangChain, LlamaIndex │
│ ├── Haystack, Semantic Kernel │
│ └── Agents SDK │
│ │
│ MODÈLES │
│ ├── APIs : OpenAI, Anthropic, Mistral, Google │
│ └── Local : Ollama, vLLM, llama.cpp │
│ │
│ INFRASTRUCTURE │
│ ├── Vector DBs : Pinecone, Chroma, Weaviate │
│ ├── Compute : GPU cloud, TPUs │
│ └── MLOps : MLflow, Weights & Biases │
│ │
│ ML CLASSIQUE │
│ ├── scikit-learn, XGBoost │
│ └── PyTorch, TensorFlow │
│ │
└─────────────────────────────────────────────────────────────┘Frameworks ML
scikit-learn
La référence pour le Machine Learning classique.
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# Split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# Entraînement
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
# Prédiction
predictions = model.predict(X_test)
print(f"Accuracy: {accuracy_score(y_test, predictions):.2f}")PyTorch
Le framework Deep Learning le plus populaire en recherche.
import torch
import torch.nn as nn
class Net(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(784, 128)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = torch.relu(self.fc1(x))
return self.fc2(x)
model = Net()
optimizer = torch.optim.Adam(model.parameters())
criterion = nn.CrossEntropyLoss()TensorFlow/Keras
Production-ready, écosystème complet.
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
model.fit(X_train, y_train, epochs=10)APIs LLM
Anthropic (Claude)
from anthropic import Anthropic
client = Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
system="Tu es un assistant utile.",
messages=[
{"role": "user", "content": "Explique le machine learning"}
]
)
print(message.content[0].text)OpenAI (GPT)
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "Tu es un assistant utile."},
{"role": "user", "content": "Explique le machine learning"}
]
)
print(response.choices[0].message.content)Mistral
from mistralai.client import MistralClient
client = MistralClient(api_key="...")
response = client.chat(
model="mistral-large-latest",
messages=[
{"role": "user", "content": "Explique le machine learning"}
]
)
print(response.choices[0].message.content)Exécution locale
Ollama
Le plus simple pour exécuter des LLM localement.
# Installation
curl -fsSL https://ollama.com/install.sh | sh
# Télécharger et lancer un modèle
ollama run llama2
ollama run mistral
ollama run codellama
# API compatible OpenAI
curl http://localhost:11434/api/generate -d '{
"model": "llama2",
"prompt": "Bonjour"
}'LM Studio
Interface graphique pour tester des modèles locaux.
vLLM
Serving haute performance pour la production.
from vllm import LLM, SamplingParams
llm = LLM(model="mistralai/Mistral-7B-v0.1")
sampling_params = SamplingParams(temperature=0.7, max_tokens=100)
outputs = llm.generate(["Bonjour, comment"], sampling_params)Comparaison des outils
| Outil | Usage | Difficulté | Production |
|---|---|---|---|
| scikit-learn | ML classique | Facile | ✓ |
| PyTorch | Deep Learning, Recherche | Moyenne | ✓ |
| TensorFlow | Deep Learning, Production | Moyenne | ✓✓ |
| Hugging Face | NLP, Modèles pré-entraînés | Facile | ✓ |
| LangChain | Applications LLM | Moyenne | ✓ |
| Ollama | LLM local | Très facile | Dev |