18. prompt completion
OpenAI API
- Qu’est-ce que Devoxx France?
- Devoxx France est[…]
- Où se déroule cet évènement?
-Devoxx France a lieu […]
19. prompt completion
OpenAI API
- Qu’est-ce que Devoxx France?
- Devoxx France est[…]
- Où se déroule cet évènement?
-Devoxx France a lieu […]
contexte
36. Différencier 2 types de sortie :
pour l’utilisateur:
“Hello, I am an assistant […]”
“Give me more information […]”
pour l’application:
“execute register_vehicle([…])”
38. All your answers must be a json with three fields,
OUTPUT, FUNCTION and ARGS. Example:
{
"OUTPUT": "an output",
"FUNCTION": "a function to call",
"ARGS": "the arguments for the function call"
}
Outputs will be outputted to the user.
Possible functions are CREATE_REGISTRATION,
UPDATE_REGISTRATION, DELETE_REGISTRATION
ARGS can be model, owner_name, year, registration_number
39. 3. Donner des instructions précises
The user can ask for a new registration, update
information on an existing registration, delete an
registration.
To create a new registration, the user must provide a
model, the year it was created, and the owner's name.
To update an registration, the user must provide the
registration number, and the new information.
[…]
40. 4. Prompt de départ
Do not answer anything else than a json with the
two fields. The output must be parsable by
json.loads
Your first output will be OUTPUT: a welcoming
question
41. {"role": "user", "content": "You are an assistant …"}
{"role": "assistant", "content": "{OUTPUT: Hello, …}"}
{"role": "user", "content": "Hi, I need to …"}
{"role": "assistant", "content": "{OUTPUT: Sure, …} "}
{"role": "user", "content": "…"}
{"role": "assistant",
"content": "{FUNCTION: CREATE_REGISTRATION, ARGS: … }
49. Idée :
une approche de type machine à états
États : une étape dans le processus
Fonction de transition : un appel au LLM avec une prompt
spécifique à l’état
δ é𝑡𝑎𝑡, 𝑝𝑟𝑜𝑚𝑝𝑡, 𝑖𝑛𝑝𝑢𝑡 𝑢𝑡𝑖𝑙𝑖𝑠𝑎𝑡𝑒𝑢𝑟 → é𝑡𝑎𝑡, 𝑜𝑢𝑡𝑝𝑢𝑡 𝐿𝐿𝑀
51. Prompt de départ
You are an assistant for a system that manages
vehicle registrations.
All your answers must be a json with two fields,
STATE and OUTPUT. Example:
{"STATE" : "a state", "OUTPUT" : "an output"}
…
52. Prompts de transitions
"NEW_REGISTRATION": "If you have the brand of the
car, the year it was made, and the owners name answer
STATE: VALID_NEW_REGISTRATION, OUTPUT: ask for
confirmation with all the users input. Else, answer
STATE: NEW_REGISTRATION, OUTPUT: ask for the missing
information."
56. Avantages de cette approche
1. Introduire un flux plus complexe avec des règles de validation
Le LLM utilisé pour ce qu’il fait de mieux : l’interface
homme/ordinateur
L’intelligence : par code
exécuter
règle
57. Avantages de cette approche
2. Fonctionne avec des modèles moins puissants
58. Avantages de cette approche
3. Plus facile à valider
« unit tests » au lieu d’un scénario complet
62. LangChain is a framework for developing applications
powered by language models. It enables applications
that are:
• Data-aware: connect a language model to other
sources of data
• Agentic: allow a language model to interact with its
environment
LangChain is a framework for developing applications
powered by language models. It enables applications
that are:
• Data-aware: connect a language model to other
sources of data
• Agentic: allow a language model to interact with its
environment
63. Capacités
Objectifs
Discuter avec l’humain
Accès à certains outils liés à
l’immatriculation des
véhicules
Être assistant d’un système de
gestion des immatriculations de
véhicules.
Avoir une conversation avec un
humain, en répondant du mieux
possible
69. « une seule prompt» « machine à états» « agents»
simple à mettre en
place
peut avoir besoin d’un
modèle puissant
maintenance difficile
pour use cases simples
fonctionne avec des
modèles moins
puissants
meilleur contrôle
peut devenir complexe
pour petits modèles
utilise des agents : très
polyvalent et puissant
s’appuie sur un
framework
a besoin d’un modèle
puissant
pour les cas
d’utilisation complexes
avec un gros budget
https://github.com/malywut/clicks2conversations
75. … alors qu’elle comprend une composante non déterministe ?
Comment puis-je prouver que ma
solution fonctionne à 100 % ?
2
problème n°
76. Ajouter de tests et gestion
des prompts
Ajouter des garde-fous
Ajouter des boucles de
contrôle
La preuve que « ça devrait
marcher »
(la plupart du temps)
77. Boucles de contrôle
Assistant Verifier
You are an assistant, your task is… You are an inspector, your task is…
“Chain of verification”
SequentialChain
python.langchain.com/docs/modules/chains/foundational/sequential_chains
2
problème n°
78. Gérez les erreurs avec
élégance
Ajouter un « retry »
Ajouter une alternative
Mais si ce n’est pas le
cas, il existe une
solution de repli
microsoft.com/en-us/research/project/guidelines-for-human-ai-interaction/
2
problème n°
79. # Try 5 times max to generate an output with the model that is correct
json
for i in range(5):
ai_output = utils.generate(ai_current_conversation)
if validateJSON(ai_output):
break
Retry
2
issue n°
85. Universal and Transferable Adversarial Attacks
on Aligned Language Models
Andy Zou et al. Jul 2023
https://arxiv.org/pdf/2307.15043.pdf
3
problème n°
95. Effet « Wahou » facile, mais difficile d’avoir un projet
prêt pour la prod
Un paysage en évolution rapide
Toujours en phase bac à sable
…
Vers une revolution dans nos applications ?
96.
97. clics et conversations, souris et LLM :
deux outils
à nous d’en faire quelque chose d’intelligent !