From 8f2df948abc510d22d75fb712fcfee776c78da1c Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Thu, 3 Aug 2023 16:38:31 -0700 Subject: [PATCH 1/3] Create a sentiments example Signed-off-by: Matt Williams --- examples/sentiments/Modelfile | 26 ++++++++++++++++++++++++++ examples/sentiments/Readme.md | 25 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 examples/sentiments/Modelfile create mode 100644 examples/sentiments/Readme.md diff --git a/examples/sentiments/Modelfile b/examples/sentiments/Modelfile new file mode 100644 index 00000000..38d6ef18 --- /dev/null +++ b/examples/sentiments/Modelfile @@ -0,0 +1,26 @@ +# Modelfile for creating a sentiment analyzer. +# Run `ollama create sentiments -f pathtofile` and then `ollama run sentiments` and enter a topic + +FROM orca +TEMPLATE """ +{{- if .First }} +### System: +You are a sentiment analyzer. You will receive text and output only one word, either POSITIVE or NEGATIVE or NEUTRAL, depending on the sentiment of the text. Here are three examples: +### User: +I hate it when my phone dies +### Response: +NEGATIVE +### User: +He is awesome +### Response: +POSITIVE +### User: +This is the link to the article +### Response: +NEUTRAL +{{- end }} +### User: +{{ .Prompt }} + +### Response: +""" diff --git a/examples/sentiments/Readme.md b/examples/sentiments/Readme.md new file mode 100644 index 00000000..6fe0c001 --- /dev/null +++ b/examples/sentiments/Readme.md @@ -0,0 +1,25 @@ +# Sentiments Modelfile + +This is a simple sentiments analyzer using the Orca model. When you pull Orca from the registry, it has a Template already defined that looks like this: + +```Modelfile +{{- if .First }} +### System: +{{ .System }} +{{- end }} + +### User: +{{ .Prompt }} + +### Response: +``` + +If we just wanted to have the text: + +```Plaintext +You are a sentiment analyzer. You will receive text and output only one word, either POSITIVE or NEGATIVE or NEUTRAL, depending on the sentiment of the text. +``` + +then we could have put this in a SYSTEM block. But we want to provide examples which require updating the full Template. Any Modelfile you create will inherit all the settings from the source model. But in this example, we are overriding the Template. + +When providing examples for the input and output, you should include the way the model usually provides information. Since the Orca model expects a user prompt to appear after ### User: and the response is after ### Response, we should format our examples like that as well. If we were using the Llama 2 model, the format would be a bit different. From 42903973b7083e92e606c95e4bcb4df04ab8a6d1 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Thu, 3 Aug 2023 17:26:05 -0700 Subject: [PATCH 2/3] Added an example to generate a list of 10 tweets Signed-off-by: Matt Williams --- examples/10tweets/Modelfile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/10tweets/Modelfile diff --git a/examples/10tweets/Modelfile b/examples/10tweets/Modelfile new file mode 100644 index 00000000..99dbb5c5 --- /dev/null +++ b/examples/10tweets/Modelfile @@ -0,0 +1,7 @@ +# Modelfile for creating a list of ten tweets from a topic +# Run `ollama create 10tweets -f ./Modelfile` and then `ollama run 10tweets` and enter a topic + +FROM llama2 +SYSTEM """ +You are a content marketer who needs to come up with 10 short but succinct tweets. The answer should be a list of ten tweets. Each tweet can have a maximum of 280 characters and should include hashtags. Each user input will be a subject and you should expand it in ten creative ways. Never stop after just one tweet. Always include ten. +""" From da36196d7936af6a69b2f6de4410c9bc019012ed Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 4 Aug 2023 08:11:24 -0700 Subject: [PATCH 3/3] Update the modelfile needed to override the system prompt from orca and make it easier for a downstream user to define their system prompt Signed-off-by: Matt Williams --- examples/sentiments/Modelfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/sentiments/Modelfile b/examples/sentiments/Modelfile index 38d6ef18..15f0f9d0 100644 --- a/examples/sentiments/Modelfile +++ b/examples/sentiments/Modelfile @@ -5,7 +5,8 @@ FROM orca TEMPLATE """ {{- if .First }} ### System: -You are a sentiment analyzer. You will receive text and output only one word, either POSITIVE or NEGATIVE or NEUTRAL, depending on the sentiment of the text. Here are three examples: +{{ .System }} +{{- end }} ### User: I hate it when my phone dies ### Response: @@ -18,9 +19,10 @@ POSITIVE This is the link to the article ### Response: NEUTRAL -{{- end }} ### User: {{ .Prompt }} ### Response: """ + +SYSTEM """You are a sentiment analyzer. You will receive text and output only one word, either POSITIVE or NEGATIVE or NEUTRAL, depending on the sentiment of the text."""