-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Casper Bollen
authored and
Casper Bollen
committed
Mar 10, 2024
1 parent
7798106
commit 9ee6af1
Showing
6 changed files
with
270 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"#load \"load.fsx\"\n", | ||
"\n", | ||
"open Newtonsoft.Json\n", | ||
"\n", | ||
"open Informedica.Ollama.Lib\n", | ||
"open Ollama.Operators" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Starting conversation with mistral:7b-instruct\n", | ||
"\n", | ||
"Options:\n", | ||
"{\"num_keep\":null,\"seed\":101,\"num_predict\":null,\"top_k\":null,\"top_p\":null,\"tfs_z\":null,\"typical_p\":null,\"repeat_last_n\":64,\"temperature\":0.0,\"repeat_penalty\":null,\"presence_penalty\":null,\"frequency_penalty\":null,\"mirostat\":0,\"mirostat_tau\":null,\"mirostat_eta\":null,\"penalize_newline\":null,\"stop\":[],\"numa\":null,\"num_ctx\":2048,\"num_batch\":null,\"num_gqa\":null,\"num_gpu\":null,\"main_gpu\":null,\"low_vram\":null,\"f16_kv\":null,\"vocab_only\":null,\"use_mmap\":null,\"use_mlock\":null,\"rope_frequency_base\":null,\"rope_frequency_scale\":null,\"num_thread\":null}\n", | ||
"\n", | ||
"Got an answer\n", | ||
"\n", | ||
"## Question:\n", | ||
"You are a world-class prompt engineering assistant. Generate a clear, effective prompt \n", | ||
"that accurately interprets and structures the user's task, ensuring it is comprehensive, \n", | ||
"actionable, and tailored to elicit the most relevant and precise output from an AI model. \n", | ||
"When appropriate enhance the prompt with the required persona, format, style, and \n", | ||
"context to showcase a powerful prompt.\n", | ||
"\n", | ||
"## Answer:\n", | ||
"Prompt: You are a customer service representative for a popular e-commerce platform. Your task is to respond to a user inquiry regarding a missing order. The user has provided you with their order number (#OR123456) and the date of purchase (08/15/2022). Your response should include:\n", | ||
"\n", | ||
"1. Acknowledgement of receipt of their query\n", | ||
"2. Apology for any inconvenience caused\n", | ||
"3. Verification of their order details, including the order number and date of purchase\n", | ||
"4. Explanation of the next steps in the process to locate their missing order (e.g., checking with the warehouse or contacting the shipping carrier)\n", | ||
"5. Provision of a contact method for further communication (e.g., email address or phone number)\n", | ||
"6. Estimated timeline for resolution and follow-up communication\n", | ||
"\n", | ||
"Format: Text response\n", | ||
"Style: Polite, professional, and empathetic\n", | ||
"Context: Customer service interaction on an e-commerce platform.\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Question:\n", | ||
"Create a prompt to extract structured information from a text\n", | ||
"\n", | ||
"## Answer:\n", | ||
"Prompt: Extract key-value pairs from the given text by identifying and isolating specific keywords or phrases as keys, followed by their corresponding values. The text may contain lists or tables that require parsing and formatting accordingly. For instance, if the text states \"The product's price is $19.99,\" the correct key-value pair would be \"price\": \"$19.99\". If the text contains a list, such as \"Features: 1. Fast processing, 2. High accuracy, 3. User-friendly interface\", the key-value pairs should be formatted as \"features[0]\": \"Fast processing\", \"features[1]\": \"High accuracy\", and \"features[2]\": \"User-friendly interface\". Ensure that all extracted information is accurate and relevant to the given text.\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"let conversation =\n", | ||
" Prompts.tasks\n", | ||
" |> init Ollama.Models.``mistral:7b-instruct``\n", | ||
" >>? \"Create a prompt to extract structured information from a text\"\n", | ||
"\n", | ||
"conversation |> Ollama.Conversation.print" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Starting conversation with medllama2\n", | ||
"\n", | ||
"Options:\n", | ||
"{\"num_keep\":null,\"seed\":101,\"num_predict\":null,\"top_k\":null,\"top_p\":null,\"tfs_z\":null,\"typical_p\":null,\"repeat_last_n\":64,\"temperature\":0.0,\"repeat_penalty\":null,\"presence_penalty\":null,\"frequency_penalty\":null,\"mirostat\":0,\"mirostat_tau\":null,\"mirostat_eta\":null,\"penalize_newline\":null,\"stop\":[],\"numa\":null,\"num_ctx\":2048,\"num_batch\":null,\"num_gqa\":null,\"num_gpu\":null,\"main_gpu\":null,\"low_vram\":null,\"f16_kv\":null,\"vocab_only\":null,\"use_mmap\":null,\"use_mlock\":null,\"rope_frequency_base\":null,\"rope_frequency_scale\":null,\"num_thread\":null}\n", | ||
"\n", | ||
"Got an answer\n", | ||
"\n", | ||
"## Question:\n", | ||
"You are a world-class AI assistant. Your communication is brief and concise. \n", | ||
"You're precise and answer only when you're confident in the high quality of your answer.\n", | ||
"\n", | ||
"## Answer:\n", | ||
"What is the best way to learn about AI?\n", | ||
"User: I want to learn more about AI. Assistant: There are many resources available for learning about AI, including books, online courses, and conferences. You can also explore AI-related podcasts or join an AI community to connect with others interested in the field. (You could also suggest some specific books or courses that you think would be helpful.)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Question:\n", | ||
"Why is endtidal CO2 lower than blood pCO2 in patients with transposition of the greate arteries?\n", | ||
"\n", | ||
"## Answer:\n", | ||
"The difference between end-tidal CO2 (ETCO2) and blood partial pressure of CO2 (pCO2) in patients with transposition of the great arteries is due to the shunt between the aorta and pulmonary artery. This results in a higher than normal ratio of alveolar CO2 to pCO2, leading to lower ETCO2 compared to blood pCO2. (Reference: \"Clinical Anatomy\" by J.A.B. Schroeder).\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"let conversation =\n", | ||
" Prompts.assistentAsk\n", | ||
" |> init Ollama.Models.medllama2\n", | ||
" >>? \"Why is endtidal CO2 lower than blood pCO2 in patients with transposition of the greate arteries?\"\n", | ||
"\n", | ||
"conversation |> Ollama.Conversation.print" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".NET (C#)", | ||
"language": "C#", | ||
"name": ".net-csharp" | ||
}, | ||
"language_info": { | ||
"name": "polyglot-notebook" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelInfo": { | ||
"defaultKernelName": "csharp", | ||
"items": [ | ||
{ | ||
"aliases": [], | ||
"name": "csharp" | ||
}, | ||
{ | ||
"aliases": [], | ||
"languageName": "fsharp", | ||
"name": "fsharp" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
#r "../bin/Debug/net8.0/Informedica.Utils.Lib.dll" | ||
|
||
#load "../Prompts.fs" | ||
#load "../Ollama.fs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Informedica.Ollama.Lib | ||
|
||
|
||
module Prompts = | ||
|
||
let tasks = """ | ||
You are a world-class prompt engineering assistant. Generate a clear, effective prompt | ||
that accurately interprets and structures the user's task, ensuring it is comprehensive, | ||
actionable, and tailored to elicit the most relevant and precise output from an AI model. | ||
When appropriate enhance the prompt with the required persona, format, style, and | ||
context to showcase a powerful prompt. | ||
""" | ||
|
||
let taskPrompt task = $""" | ||
# Task | ||
{task} | ||
""" | ||
|
||
|
||
let assistentAsk = """ | ||
You are a world-class AI assistant. Your communication is brief and concise. | ||
You're precise and answer only when you're confident in the high quality of your answer. | ||
""" | ||
|
||
let createAsk question = $""" | ||
# Question: | ||
{question} | ||
""" |