Skip to content

Commit 54a7003

Browse files
author
Chris Warren-Smith
committed
LLAMA: implement nitro agent (work in progress)
1 parent f42e9b4 commit 54a7003

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

llama/llama-sb.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ LlamaIter::LlamaIter() :
2121
_has_next(false) {
2222
}
2323

24+
LlamaIter::LlamaIter(LlamaIter &&other) noexcept
25+
: _llama(std::exchange(other._llama, nullptr))
26+
, _last_word(std::move(other._last_word))
27+
, _t_start(std::move(other._t_start))
28+
, _repetition_count(other._repetition_count)
29+
, _tokens_generated(other._tokens_generated)
30+
, _has_next(other._has_next) {
31+
}
32+
2433
Llama::Llama() :
2534
_model(nullptr),
2635
_ctx(nullptr),

llama/llama-sb.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ struct LlamaIter {
2020
explicit LlamaIter();
2121
~LlamaIter() {}
2222

23+
// move constructor
24+
LlamaIter(LlamaIter &&other) noexcept;
25+
26+
// delete the copy
27+
LlamaIter(const LlamaIter &) = delete;
28+
LlamaIter &operator=(const LlamaIter &) = delete;
29+
2330
Llama *_llama;
2431
string _last_word;
2532
chrono::high_resolution_clock::time_point _t_start;
@@ -32,7 +39,7 @@ struct Llama {
3239
explicit Llama();
3340

3441
// move constructor
35-
Llama(Llama &&otherLlama) noexcept;
42+
Llama(Llama &&other) noexcept;
3643

3744
// delete the copy
3845
Llama(const Llama &) = delete;

llama/samples/nitro_cli.bas

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ func process_input()
197197
return "<|turn|>user\n" + user_input + "\n<|turn|>\n<|turn|>model"
198198
end
199199

200+
'
201+
' creates the llama instance
202+
'
200203
func create_llama()
201204
local llama = llm.llama(model, n_ctx, n_batch, 50)
202205
llama.add_stop("<|turn|>")
@@ -214,18 +217,8 @@ end
214217
' Main process
215218
'
216219
sub main()
217-
' note: this construct requires sbasic fixes
218-
' local llama = create_llama()
219-
local llama = llm.llama(model, n_ctx, n_batch, 50)
220-
llama.add_stop("<|turn|>")
221-
llama.set_max_tokens(n_max_tokens)
222-
llama.set_temperature(n_temperature)
223-
llama.set_top_k(n_top_k)
224-
llama.set_top_p(n_top_p)
225-
llama.set_min_p(n_min_p)
226-
llama.set_penalty_repeat(n_penalty_repeat)
227-
llama.set_penalty_last_n(n_penalty_last_n)
228-
220+
' note: this construct requires recent sbasic fixes
221+
local llama = create_llama()
229222
local iter = llama.generate(initialize_agent())
230223

231224
while 1

0 commit comments

Comments
 (0)