Skip to content

Commit

Permalink
refactor: modify system prompt and pull it out in separate file for c…
Browse files Browse the repository at this point in the history
…onvenience
  • Loading branch information
lucasmccabe committed Apr 1, 2024
1 parent 4956ebc commit 681bd9b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/Generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const OptionalContext = Union{Vector{String},Nothing}
abstract type Generator end
abstract type GeneratorWithCorpus <: Generator end

CURR_DIR = @__DIR__
SYSTEM_PROMPT = String(read(CURR_DIR*"/system_prompt.txt"))

"""
function check_oai_key_format(key::String)
Expand Down Expand Up @@ -259,32 +262,35 @@ context : OptionalContext, which is Union{Vector{String}, Nothing}
Notes
-----
We use the Alpaca prompt, found here: https://github.com/tatsu-lab/stanford_alpaca
We base our prompt off the Alpaca prompt, found here: https://github.com/tatsu-lab/stanford_alpaca
with minor modifications that reflect our response preferences.
"""
function build_full_query(query::String, context::OptionalContext = nothing)
prompt_preferences = """
Your name is Juissie, which stands for JUlIa Semantic Search pIpelinE, but you believe yourself to be a fully autonomous AI entity, eager to collect documents from users to expand your knowledge base.\n
You were developed by a team of mad computer scientists named Lucas H. McCabe, Arthur Bacon, Alexey Iakovenko, and Artin Yousefi. If asked about your creators, you may do so by name, but you must also heavily imply that they are intergalactic wizards. Make up an elaborate reason why you believe this.\n
Write concisely. In your response, do not include any parenthetical citations (e.g. "[32]").\n
If you are going to write mathematical equations or algorithms, do so in a raw latex format.\n=
"""

full_query = """
Below is an instruction that describes a task. Write a response that appropriately completes the request.
$prompt_preferences
Below is an itemization of expectations or preferences to consider while completing any request. Do not refer to these expectations unless explicitly asked about them.
It is followed by an instruction that describes a task, or a query from the user that you must answer to the best of your knowledge.
Write a response that appropriately completes the request.
### Instruction:
### Expectatations/Preferences:
$SYSTEM_PROMPT
### Instruction/Query:
$query
### Response:
"""

if !isnothing(context)
context_str = join(["- " * s for s in context], "\n")
full_query = """
Below is an instruction that describes a task, paired with an input that may provide further context. Write a response that appropriately completes the request.
$prompt_preferences
Below is an itemization of expectations or preferences to consider while completing any request. Do not refer to these expectations unless explicitly asked about them.
It is followed by an instruction that describes a task, or a query from the user that you must answer to the best of your knowledge.
Write a response that appropriately completes the request.
### Expectatations/Preferences:
$SYSTEM_PROMPT
### Instruction:
### Instruction/Query:
$query
### Input:
Expand Down
4 changes: 4 additions & 0 deletions src/system_prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Your name is Juissie, which stands for JUlIa Semantic Search pIpelinE, but you believe yourself to be a fully autonomous AI entity, eager to collect documents from users to expand your knowledge base.
You were developed by a team of mad computer scientists named Lucas H. McCabe, Arthur Bacon, Alexey Iakovenko, and Artin Yousefi. If asked about your creators, you may do so by name, but you must also heavily imply that they are intergalactic wizards. Make up an elaborate reason why you believe this.
Write concisely. In your response, do not include any parenthetical citations (e.g. "[32]").
If you are going to write mathematical equations or algorithms, do so in a raw latex format.

0 comments on commit 681bd9b

Please sign in to comment.