update
This commit is contained in:
39
src/util.jl
39
src/util.jl
@@ -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}
|
||||||
|
|||||||
Reference in New Issue
Block a user