This commit is contained in:
narawat lamaiin
2024-04-28 08:17:17 +07:00
parent 43f7be1dc7
commit 9641d91594

View File

@@ -120,8 +120,7 @@ end
""" Convert a single chat dictionary into LLM model instruct format. """ Convert a single chat dictionary into LLM model instruct format.
Llama 3 instruct format example\n # Llama 3 instruct format example
-----
<|begin_of_text|> <|begin_of_text|>
<|start_header_id|>system<|end_header_id|> <|start_header_id|>system<|end_header_id|>
You are a helpful assistant. You are a helpful assistant.
@@ -133,19 +132,16 @@ end
Go buy it yourself at 7-11. Go buy it yourself at 7-11.
<|eot_id|> <|eot_id|>
Arguments\n # Arguments
----- - `name::T`
name::T
message owner name e.f. "system", "user" or "assistant" message owner name e.f. "system", "user" or "assistant"
text::T - `text::T`
Return\n # Return
----- - `formattedtext::String`
formattedtext::String
text formatted to model format text formatted to model format
Example\n # Example
-----
```jldoctest ```jldoctest
julia> using Revise julia> using Revise
julia> using YiemAgent julia> using YiemAgent
@@ -154,8 +150,7 @@ end
"<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n" "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n"
``` ```
Signature\n # Signature
-----
""" """
function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString} function formatLLMtext_llama3instruct(name::T, text::T) where {T<:AbstractString}
formattedtext = formattedtext =
@@ -180,20 +175,17 @@ end
""" Convert a chat messages in vector of dictionary into LLM model instruct format. """ Convert a chat messages in vector of dictionary into LLM model instruct format.
Arguments\n # Arguments
----- - `messages::Vector{Dict{Symbol, T}}`
messages::Vector{Dict{Symbol, T}}
message owner name e.f. "system", "user" or "assistant" message owner name e.f. "system", "user" or "assistant"
formatname::T - `formatname::T`
format name to be used format name to be used
Return\n # Return
----- - `formattedtext::String`
formattedtext::String
text formatted to model format text formatted to model format
Example\n # Example
-----
```jldoctest ```jldoctest
julia> using Revise julia> using Revise
julia> using YiemAgent julia> using YiemAgent
@@ -206,8 +198,7 @@ end
"<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n <|start_header_id|>user<|end_header_id|>\n list me all planets in our solar system.\n <|eot_id|>\n <|start_header_id|>assistant<|end_header_id|>\n I'm sorry. I don't know. You tell me.\n <|eot_id|>\n" "<|begin_of_text|>\n <|start_header_id|>system<|end_header_id|>\n You are a helpful, respectful and honest assistant.\n <|eot_id|>\n <|start_header_id|>user<|end_header_id|>\n list me all planets in our solar system.\n <|eot_id|>\n <|start_header_id|>assistant<|end_header_id|>\n I'm sorry. I don't know. You tell me.\n <|eot_id|>\n"
``` ```
Signature\n # Signature
-----
""" """
function formatLLMtext(messages::Vector{Dict{Symbol, T}}, function formatLLMtext(messages::Vector{Dict{Symbol, T}},
formatname::String="llama3instruct") where {T<:Any} formatname::String="llama3instruct") where {T<:Any}